• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Forum moderator applications are now open! Click here for details.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Code: ASM Resource Thread

16
Posts
9
Years
I'm working on stat reducing berries atm.
Weather effects is being worked on by HidoranBlaze. Weather effects adding is already done. As for the Bike one, I haven't decided yet :P

In addition to the EV berries, it would be awesome if you could make berries that can call new asm or something to create the new berries like custap and roseli :D
 

Blah

Free supporter
1,924
Posts
11
Years

Berry System in FireRed!


First of all, before you implement my system you need to insert:
JPAN's save block hack: http://www.pokecommunity.com/showpost.php?p=6993092&postcount=206
ShinyQuagsire's berry bag hack: http://www.pokecommunity.com/showthread.php?t=295749
My code assumes that you've got all of this already implemented.


How to insert:

There's a lot of work to do before you can get this running. Trust me it was more work to create.
Compile each of the following routines and insert them into free space (KEEP TRACK OF WHERE YOU INSERT):

GetTreeData:
Spoiler:


getYeild
Spoiler:


setTime:
Spoiler:


setTreeData:
Spoiler:


Now, once you've compiled those routines into free space you will need to insert their pointers (not in reverse hex) into this script. Remember to add 1 to the pointer.
You'll notice that I've added comments, which in PKSV, are signified by the apostrophe. I.e
Code:
 'This is a comment

I've made sure to add comments everywhere there is a callasm command to one of my routines. You'll also notice that the names I call these routines are identical to the names I gave the spoilers. You need to match the call to the pointer to the name of the routine!

The PKSV script (sorry no XSE version, convert it yourself :P):

Spoiler:


Usage:
After you've compiled the script, write down the offset of it as well. You will need to remember it.
Here is how you'll be using the script:
Code:
#dyn 0x740000
#org @start
setvar 0x8000 0x[max berry yield]
setvar 0x8001 0x[min berry yield]
setvar LASTRESULT 0x[Tree ID]
jump 0x8[Offset where you compiled the above script]

Every tree should have a unique Tree ID. So if you want two trees, one can be 0x0, and the other can be 0x1. Set the tree ID to lastresult and then jump the script that handles the complicated stuff.


System Mechanics:
The beauty of the system is that it uses only temporary variables and derives their values from the RAM. Meaning you can go ahead and use those variables for anything, without having to save them for just the tree. Incase you are interested here's how the data is stored and the variable's significance:

Code:
General variables:
var 0x8000: Max berry yield for tree
var 0x8001: Minimum berry yield for tree
var 0x8005: Current stage
var 0x8006: Time planted
var 0x8007: Was watered
var 0x8008: Times watered
var 0x8009: ID of berry

RAM Data storage:
[Current Stage: 1 byte]
[Time planted: 2 bytes]
[Watered: 1 byte]
[times watered: 1 byte]
[ID of plant: 1 bytes]


System Algorithm:
The system works identical to that of DPPT. The only complication is that FR does not have an RTC. So I used play time to obtain as clock. The current system has 5 phases, each phase lasts 20 minutes playtime. You can Increase or decrease this time by going to the "getTreeData" routine, finding my comment in all caps and changing the constant 0x14 (20) to some other hex number you'd want.
Link to DPPT berry system: http://bulbapedia.bulbagarden.net/wiki/Berry#Formula
 
Last edited:

Lance32497

LanceKoijer of Pokemon_Addicts
792
Posts
9
Years
Another suggestion about your Silent evolution hack, you can improve it by letting a certain pokemon holing specific item evolve in your method than a pokemon in an specific slot.

JPAN save block is 404 page not found
 
Last edited by a moderator:

Blah

Free supporter
1,924
Posts
11
Years
Another suggestion about your Silent evolution hack, you can improve it by letting a certain pokemon holing specific item evolve in your method than a pokemon in an specific slot.

I made an item checker already. So you can do
callasm itemchecker
copyvar 0x8000 0x800D
compare 0x8000 0x[Item you want]
if != jump @end
setvar 0x8000 0x800D
callasm silentEvolve

May I suggest? Will you make a compile version for your hacks, I lost my effective and super cool THUMB compiler and I forgot where todownload that kinda awesome tool...
I'll do that from future. I'm too lazy to do it for these :P

In addition to the EV berries, it would be awesome if you could make berries that can call new asm or something to create the new berries like custap and roseli :D

That's possible already with Davidjcobb's tutorial on item adding!
 

Blah

Free supporter
1,924
Posts
11
Years
How about an specific pokemn rather than Pokemon party slot..

by the way what is the name of your THUMB compiler?

Use special 0x9F to select the Pokemon then callasm.


EV Reducing berries


Speaking of special 0x9F, I finished EV reducing berries which was rather easy.
First of all, follow this tutorial: http://www.pokecommunity.com/showthread.php?t=258426
until you get to the part where you have to give the item an effect via script.

Compile and insert into free space the following routine:
Spoiler:


For the part of inserting a script to give your item functionality, you need to insert this script.
Code:
#dyn 0x740000
#org @start
special 0x9f
waitspecial
storepartypokemon 0x0 0x8004 'bufferpokemon2 in xse
setvar LASTRESULT 0x[EV to modify]
setvar 0x8000 0x[amount to decrease EV by]
callasm 0x[routine +1]
compare LASTRESULT 0xFF
if == jump @failed
storevar 0x1 0x800F 'buffervar in xse
msgbox @gain
callstd MSG_NORMAL
removeitem 0x[ID] 0x1
release
end

#org @failed
msgbox @noEffect
callstd MSG_NORMAL
release
end

#org @noEffect
= It would have no effect!

#org @gain
= \v\h02 gained \v\h03\nInsert the EV your berry gives

In variable 0x8000 put the amount the EV is to decrease by.
In variable 0x800D put which EV you want to modify, in this format:
0x1A - HP EV
0x1B - Attack EV
0x1C - Defence EV
0x1D - Speed EV
0x1E - Sp. Attack EV
0x1F - Sp. Defence EV
 
Last edited:

Joexv

ManMadeOfGouda joexv.github.io
1,037
Posts
11
Years
Ok I have a request. Could you make an asm routine that searches your party for a specific pokemon and then stores its party slot in a variable?
And could you possibly do it for emerald cause I know thats a thing for fire red all ready.
 
252
Posts
10
Years
  • Age 27
  • Seen Jul 6, 2019
Ok I have a request. Could you make an asm routine that searches your party for a specific pokemon and then stores its party slot in a variable?
And could you possibly do it for emerald cause I know thats a thing for fire red all ready.
There's a routine made by itari that returns the number of specified Pokemon you have. It'd be easy to modify that to return the party slot of a specific pokemon.

And, here you go! Credits to itari for the original ASM routine, which I modified a tad. The original routine can be found here: http://www.pokecommunity.com/showpost.php?p=8388671&postcount=547

If you want this to work for EM, just use the same offsets she posted.

Code:
.text
.align 2
.thumb
.thumb_func
.global CountPartyPokemonSpecies

main:
	push {r0-r7, lr}
	ldr r6, var
	ldr r7, party_amount
	ldrb r4, [r7] @ Get Pokemon count from r7
	cmp r4, #0x0
	beq exit
	ldrh r3, [r6] @ Get the species to check
	cmp r3, #0x0
	beq exit @ Don't allow Missingno. This doesn't limit the species from going up, though.
	mov r7, #0x0
loop:
	ldr r0, first_pokemon @ Offset of first Pokemon
	mov r1, #0x64 @ Length of Pokemon RAM data
	mul r1, r1, r7 @ r7 holds current index
	add r0, r0, r1
	bl decrypt_poke_species @ Get this specific species.
	mov r9, r0
	pop {r0-r7}
	cmp r9, r3
	beq exit
next:
	add r7, r7, #0x1 @ Increase party index
	cmp r7, r4 @ And compare against the number in the party
	blo loop @ I could use a bls here?
        mov r7, #0xFF
exit:
	str r7, [r6, #0x10] @ Store the index (r7) in r6 (the var -- 0x800D)
	pop {r0-r7, pc} @ Return

decrypt_poke_species:
	push {r0-r7}
	mov r1, #0xB @ This is the index for the Pokemon species.
	ldr r2, decrypt_poke @ Call the Pokemon decryption code
	bx r2
	
.align 2
party_amount:
	.word 0x02024029
first_pokemon:
	.word 0x02024284
var: @ Got this beauty from HackMew.
	.word 0x020270B8 + (0x8004 * 2)
decrypt_poke:
	.word 0x0803FBE9

This should store the party slot (which would be from 0-5) in 0x800D. Haven't tested it, but I'm fairly confident it should work.

EDIT: Ok, realized there was an oversight, so I modified it a bit. This should return 0xFF if the specified Pokemon doesn't exist in your party. I shouldn't be modifying routines at 2 am lol.

Make sure you set the var 0x8004 to the species you want. The routine should return a value between 0-5 if the Pokemon exists, or 0xFF if it doesn't exist, in var 0x800D. Check for those in a script.
 
Last edited:

Lance32497

LanceKoijer of Pokemon_Addicts
792
Posts
9
Years
Use special 0x9F to select the Pokemon then callasm.
Can you give a full script on how it works?

EV Reducing berries


Speaking of special 0x9F, I finished EV reducing berries which was rather easy.
First of all, follow this tutorial: http://www.pokecommunity.com/showthread.php?t=258426
until you get to the part where you have to give the item an effect via script.

Compile and insert into free space the following routine:
Spoiler:


For the part of inserting a script to give your item functionality, you need to insert this script.
Code:
#dyn 0x740000
#org @start
special 0x9f
storepokemonvar 0x0 0x8004 'bufferpartypokemon2 in xse
setvar LASTRESULT 0x[EV to modify]
setvar 0x800F 0x[amount to decrease EV by]
callasm 0x[routine +1]
storevar 0x1 0x800F 'buffervar in xse
msgbox @gain
callstd MSG_NORMAL
release
end

#org @gain
= \v\h02 gained \v\h03\nInsert the EV your berry gives

In variable 0x800F put the amount the EV is to decrease by.
In variable 0x800D put which EV you want to modify, in this format:
0x1A - HP EV
0x1B - Attack EV
0x1C - Defence EV
0x1D - Speed EV
0x1E - Sp. Attack EV
0x1F - Sp. Defence EV

This is great! man! Just a request or anyone here who can give me a THUMB compiler.
 

BLAx501!

Pokemon Flux
80
Posts
10
Years
I've came up with another idea, I hope it is not very complicated xD.

The main thing is being able to have two separated teams. I know havingo two different Storage Sistems would be really difficult, but I thougth it might be easier this way. For example you are playing with a character, and then you want to change the perspective and take control of another one; you don't want to have the same team for both, so you need to store the first team and give the second character it's own team that is stored in other place...

Is this possible??
 
3,044
Posts
9
Years
If this is hard, ignore this post:

You can have more than 4 moves.

If this is hard, ignore this post:

You can have more than 4 moves.
 

Lance32497

LanceKoijer of Pokemon_Addicts
792
Posts
9
Years
I will give you some ideas and suggestions:

A routine for Mega Evolution, we dont need a Mega Ring because it is very hard, I think:

1.Routine of Item effect(Held item) that checks an specific specie of pokemon then go to Evolution routine(You can use silent evolution so it is not time consuming)

TIP: You can compare how Berries affect in battle so that, instead of eating it, it will go to silent evolution routine. Also, you can use your method in Ev reducing berries to call a script so that you are now able to search certain species

2.Routine of "Return Specie" after the battle it will goto Silent evolution method

With these routines, Advance rom will now be Mega Advance rom XD
 

Blah

Free supporter
1,924
Posts
11
Years
Ok I have a request. Could you make an asm routine that searches your party for a specific pokemon and then stores its party slot in a variable?
And could you possibly do it for emerald cause I know thats a thing for fire red all ready.

Sorry, Fire Red is my love :(
Plus Hidoran already did it, so there's that.

There's a routine made by itari that returns the number of specified Pokemon you have. It'd be easy to modify that to return the party slot of a specific pokemon.

And, here you go! Credits to itari for the original ASM routine, which I modified a tad. The original routine can be found here: http://www.pokecommunity.com/showpost.php?p=8388671&postcount=547

If you want this to work for EM, just use the same offsets she posted.

Code:
.text
.align 2
.thumb
.thumb_func
.global CountPartyPokemonSpecies

main:
	push {r0-r7, lr}
	ldr r6, var
	ldr r7, party_amount
	ldrb r4, [r7] @ Get Pokemon count from r7
	cmp r4, #0x0
	beq exit
	ldrh r3, [r6] @ Get the species to check
	cmp r3, #0x0
	beq exit @ Don't allow Missingno. This doesn't limit the species from going up, though.
	mov r7, #0x0
loop:
	ldr r0, first_pokemon @ Offset of first Pokemon
	mov r1, #0x64 @ Length of Pokemon RAM data
	mul r1, r1, r7 @ r7 holds current index
	add r0, r0, r1
	bl decrypt_poke_species @ Get this specific species.
	mov r9, r0
	pop {r0-r7}
	cmp r9, r3
	beq exit
next:
	add r7, r7, #0x1 @ Increase party index
	cmp r7, r4 @ And compare against the number in the party
	blo loop @ I could use a bls here?
        mov r7, #0xFF
exit:
	str r7, [r6, #0x10] @ Store the index (r7) in r6 (the var -- 0x800D)
	pop {r0-r7, pc} @ Return

decrypt_poke_species:
	push {r0-r7}
	mov r1, #0xB @ This is the index for the Pokemon species.
	ldr r2, decrypt_poke @ Call the Pokemon decryption code
	bx r2
	
.align 2
party_amount:
	.word 0x02024029
first_pokemon:
	.word 0x02024284
var: @ Got this beauty from HackMew.
	.word 0x020270B8 + (0x8004 * 2)
decrypt_poke:
	.word 0x0803FBE9

This should store the party slot (which would be from 0-5) in 0x800D. Haven't tested it, but I'm fairly confident it should work.

EDIT: Ok, realized there was an oversight, so I modified it a bit. This should return 0xFF if the specified Pokemon doesn't exist in your party. I shouldn't be modifying routines at 2 am lol.

Make sure you set the var 0x8004 to the species you want. The routine should return a value between 0-5 if the Pokemon exists, or 0xFF if it doesn't exist, in var 0x800D. Check for those in a script.
Thanks :P

Can you give a full script on how it works?

This is great! man! Just a request or anyone here who can give me a THUMB compiler.

ehh, this isn't really a script thread, but the main parts of it will be like this:
special 0x9f
copyvar 0x8000 0x8004
callasm 0xevolution

For your thumb compiler use HackMew's one. http://www.pokecommunity.com/showpost.php?p=8515334&postcount=3

I've came up with another idea, I hope it is not very complicated xD.

The main thing is being able to have two separated teams. I know havingo two different Storage Sistems would be really difficult, but I thougth it might be easier this way. For example you are playing with a character, and then you want to change the perspective and take control of another one; you don't want to have the same team for both, so you need to store the first team and give the second character it's own team that is stored in other place...

Is this possible??
While it is possible, you would have to put these Pokemon into a save block. Each Pokemon take 100 bytes of space (but if it's just for storage this value is a little less). Needless to say, even with JPAN's save block hack you would only be able to have about 37 Pokemon in this storage. It would be fine for a small team of 5 I suppose. This is an idea I thought up of some time ago as well, however, back then I didn't have the expertise to implement it. Hopefully now I can try for a smaller team size (no promises :P).

edit: I also kinda need this for 2vs2 battles.

If this is hard, ignore this post:

You can have more than 4 moves.
It's not just hard, it requires a complete rework of the current system. The system assumes you have only four moves when:
- you're trying to learn a move
- you're trying to delete moves
- displaying moves
- in battle for AI and yourself
- biggest of all is the Pkmn data structure is written to be exactly 100 bytes, having even one extra move (2 bytes) would overflow onto the next Pokemon.
I probably missed some, but I know after evolution this is checked as well. The biggest hurdle is storage, and then displaying. Sadly, it's a hurdle I'm not going to try to conquer because I think it ruins the current PKMN main game's gameplay and it's too hard :D
 
Last edited:
35
Posts
10
Years
  • Age 37
  • Seen Jul 27, 2016
This "Inheriting IVs from parents (via Destiny Knot, in the daycare)" is amazing but something is missing is "everstone" since in emerald and later games give 50-100% to inherit the natu of the poke holding the item, could you do that??
 

Blah

Free supporter
1,924
Posts
11
Years
I will give you some ideas and suggestions:

A routine for Mega Evolution, we dont need a Mega Ring because it is very hard, I think:

1.Routine of Item effect(Held item) that checks an specific specie of pokemon then go to Evolution routine(You can use silent evolution so it is not time consuming)

TIP: You can compare how Berries affect in battle so that, instead of eating it, it will go to silent evolution routine. Also, you can use your method in Ev reducing berries to call a script so that you are now able to search certain species

2.Routine of "Return Specie" after the battle it will goto Silent evolution method

With these routines, Advance rom will now be Mega Advance rom XD

daniilS requested that I let him do mega evolutions. It seems like he's already started and is eager to do it (so I'm going to let him handle it :P).

This "Inheriting IVs from parents (via Destiny Knot, in the daycare)" is amazing but something is missing is "everstone" since in emerald and later games give 50-100% to inherit the natu of the poke holding the item, could you do that??

I'll add that to my "todo" list.

Thanks dude, are you working in Weather effects when a certain pokemon enters a battle?

HidoranBlaze is doing that.

Kinda...mini mini update:

Basically for the TMs, you can still sell them to vendors. To change this, you need to modify each TM individually. It's unfortunate, but the game checks if an item can be sold my comparing it's market price to zero. If it's strictly greater than zero, then you can sell it to a vendor, seems to be the rule. So to make TMs unsellable you need to set their market prices individually to zero.
I can't use my own checks to disguise the TMs as unique because the sell routine in shops are used for ALL items including potions, berries, TMs, and other items like nuggets.
 

Lance32497

LanceKoijer of Pokemon_Addicts
792
Posts
9
Years
Ohhh ok!
Ahhmm...
Thinking of my new request
. .
Manaphy and Phione Breeding strategy
... ...Can you make it that Even though Phione wont evolve into Manaphy, if bread in Ditto, it produces Phione.

Change Sprite without changing its dex number
... ...I do mean Rotom's forms, An Item effect(For Arceus forme) and/or script (for rotom forme)

Beauty Port from RSE to FR
... ...So Can you port RSE's Beauty feature into FR?
 
Last edited:

Blah

Free supporter
1,924
Posts
11
Years
Ohhh ok!
Ahhmm...
Thinking of my new request
. .
Manaphy and Phione Breeding strategy
... ...Can you make it that Even though Phione wont evolve into Manaphy, if bread in Ditto, it produces Phione.

Change Sprite without changing its dex number
... ...I do mean Rotom's forms, An Item effect(For Arceus forme) and/or script (for rotom forme)

Beauty Port from RSE to FR
... ...So Can you port RSE's Beauty feature into FR?

Controling what breeds with what and what hatches from the result can be done with a Pokemon editor iirc.

Changing sprite without changing dex number? Umm, for form changes like Rotom and Arceus I would just do a silent evolution. It's an index change really. Technically it's a new Pokemon with a new type and same base stats. You can modify your Pokedex not to display it. This is also something that requires an expanded Pokedex/Pokemon inserted which is something I don't have readily available. So because it can be achieved by clever manipulation, I won't be doing this.

The beauty system is used by contests only? So that makes it very pointless standalone. You would have to implement Pokemon contests, which btw would be hell to do. So I'm not doing this either.

Keep the suggestions comming though, maybe you'll get a brilliant idea soon :P


Status update:
Today I've been working on breeding stat passing, particularly nature. I found that a Pokemon's nature in the gen iii games are determined rather randomly. It's done by PID % 25, = nature. In later games, you'll notice that nature is determined in otherways than PID. It's quite bad that FR uses this system because that means that the Pokemon's nature is going to be randomized quite well. I can't really modify the PID to match a certain nature because the PID is used to determine Pokemon IVs and all that good stuff, not to mention the checksum which turns a Pokemon into a badegg. What this means is that I would have to keep generating a new Pokemon UNTIL the PID generated from the game matches qualities of the PID I want. The process is rather complicated and I'm frankly debating whether or not it's worth the work. Honestly, does anyone actually breed farm in ROM hacks?
 
Back
Top