• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • 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

You want a routine which will end/restart a mission if your given time is over?
Not sure if this will help you but you can try this routine.
Timer in FR
Spoiler:

info:
1.This routine uses safe var 4011, 4012,8002 and flag 248 and 24c
2. Flag 248 is used to start the timer
3. 8002 is used to know how many minutes mission will continue
How to use:
1.insert this hook at 0x054894
00480047 xx+1 yy zz (xx yy zz is where u inserted the routine)
2.In The script which will start the timer based event you have to write this three line
setvar 0x8002 0xXX (XX = the minutes you want event to run )
setvar 0x4012 0xYY {YY = flag you want to set be if event is not finished in time )
setflag 0x248 (start the timer)
-------------------------------------
Now that you have started the timer this routine will run every second and when your given time in var 8002 is over it will set a flag (which is also given in var 4012). Depending on that flag in var 4012 you can determine mission is over / restart the mission / time over can't redo the mission etc.
Note: If player finishes the task in the mission you will obviously wouldn't want the timer to continue.So, clearflag 248 and 24C in that script
.

incredible!thankyou so much!
 
Wow, no one's ever ported Emerald's tag battle with Steven to Fire Red? Well this is a surprise... it would be pretty cool though. I think Andrea, the maker of Pokémon Giratina's Legend, has ported it to Ruby. If that's possible in Ruby, it has to be possible in Fire Red too, right?
 
Wow, no one's ever ported Emerald's tag battle with Steven to Fire Red? Well this is a surprise... it would be pretty cool though. I think Andrea, the maker of Pokémon Giratina's Legend, has ported it to Ruby. If that's possible in Ruby, it has to be possible in Fire Red too, right?
wow, people still ask questions passive-implicatively without actually asking anything?
i mean people have done it but it's not separate from the community hack atm and touched doesn't suggest using it
 
Wow, no one's ever ported Emerald's tag battle with Steven to Fire Red? Well this is a surprise... it would be pretty cool though. I think Andrea, the maker of Pokémon Giratina's Legend, has ported it to Ruby. If that's possible in Ruby, it has to be possible in Fire Red too, right?

It's trickier than you think. And I honestly don't believe someone was able to port it to Ruby.
 
Hello Sirs. I have a question regarding this code:
Spoiler:


So my question is, where should I put the index of Dawn Stone? 'Cuz I'm new to asm and I think I have to (somewhat) point that out or something.

Also, please correct me if this is wrong.

cmp r0, #0x7
beq StandardStone
cmp r0, #0x14 #UPDATE THIS
<----This is Kirlia
beq MaleStone
cmp r0, #0x15 #UPDATE THIS
<----and this would be Snorunt, right?
beq FemaleStone
b NoEvo


Thanks in advance.
 
Hello Sirs. I have a question regarding this code:
Spoiler:


So my question is, where should I put the index of Dawn Stone? 'Cuz I'm new to asm and I think I have to (somewhat) point that out or something.

Also, please correct me if this is wrong.

cmp r0, #0x7
beq StandardStone
cmp r0, #0x14 #UPDATE THIS
<----This is Kirlia
beq MaleStone
cmp r0, #0x15 #UPDATE THIS
<----and this would be Snorunt, right?
beq FemaleStone
b NoEvo


Thanks in advance.

Nop those are not pokemon index...

Rather they are the evolution method index...
As evolution by level, trade, and so on.
Look at PGE ini file to know which index you can use for evolution type...
 
So currently the blank slots between Celebi and Treeko always use the Unown's cry. I fixed that.
Code:
.thumb

.equ rom, 0x08000000
.equ offset, 0xXXXXXX @six digits
.equ table, 0x08XXXXXX

.org 0x0720C4
hook:
	ldr r1, hook_thing
	bx r1

.align 2
hook_thing: .word main + rom + 1

.org offset
main:
	cmp r0, #250
	bls continue_normal
	ldr r1, species_cap
	cmp r0, r1
	bls is_slot
continue_normal:
	ldr r2, species_id_thing
	bl jump_with_r2
	mov r7, r0
	mov r1, #0x7F
	ldr r2, return1
	
jump_with_r2:
	bx r2

is_slot:
	sub r0, #0xFB @the lowest slot
	mov r1, #0xC @the length of a cry entry
	mul r0, r1
	ldr r1, table_pointer
	ldr r2, return2
	bx r2

.align 2
species_cap: .word 275
return2: .word 0x0807217C + 1
table_pointer: .word table
species_id_thing: .word 0x08043304 + 1
return1: .word 0x080720CC + 1
The new table you use for those mons should be the same format as the current cry table. If you find any bugs, please tell me so I can patch it.
 
wanted to make a small request here.
Spoiler:

I wanted this feature to be ported to emerald as well..
I think it would be only a short task of finding the proper pointers,
so if anyone would do it..
then not only me but other emerald hackers would also enjoy it :)
so it my request :)
Since I want the Re-Useable PokéBall feature in Emerald too, I decided to give it a shot but it is still incomplete. Someone else can find the missing parts if they would like to, that would be great. Here is what I have figured out so far through testing:

Found:
Location of bytes "01 21" to change to "00 21": 0x0FE3AA
Var_800E location for Emerald: 0x0203CE7C (which I couldn't find anywhere on the internet for some reason)

Missing:
Emerald's equivalent to FireRed's 0x02D924
What to put instead of "0x809A1D9" in the ASM

Hopefully someone can post the missing parts to complete this.
 
Last edited:
Since I want the Re-Useable PokéBall feature in Emerald too, I decided to give it a shot but it is still incomplete. Someone else can find the missing parts if they would like to, that would be great. Here is what I have figured out so far through testing:

Found:
Location of bytes "01 21" to change to "00 21": 0x0FE3AA
Var_800E location for Emerald: 0x0203CE7C (which I couldn't find anywhere on the internet for some reason)

Missing:
Emerald's equivalent to FireRed's 0x02D924
What to put instead of "0x809A1D9" in the ASM

Hopefully someone can post the missing parts to complete this.

Well its great you are working on it,

BluRose is also working on it (Not working at the moment but he said he will when he completes his current work) and might be you can talk to him about the missing part ;)
 
Use special 0x9F to select the Pokemon then callasm.


EV Reducing berries


Spoiler:

I would like to request to update this routine to include increasing happiness by 10/5/2 depending on the user's happiness amount upon consumption. This link shows the happiness increase amount.

edit:

Getting IVs and EVs


Spoiler:


Another request for the Get EV/IV routine to store highest value EV/IV var in 0x800B and sum of total EV/IV in var 0x800C, please!
 
Last edited:
So I don't know where else to put this because it incorporates abilities, items, and other gen 6 stuff. Oh well. It's Safety Goggles, part of Magic Guard, part of Overcoat, part of Bulletproof, and the Gen 6+ Grass type immunity to spore moves. Knock yourselves out.
Code:
.thumb

.equ rom, 0x08000000
.equ offset, 0xXXXXXX @six digits
.equ powder_table_offset, 0xXXXXXXXX @8 digits
		@table is hwords of move ids repeating, ends with FFFF
.equ Grass_Type, 0xC
.equ Overcoat, 0xXX
.equ Bulletproof, 0xXX
.equ Magic_Guard, 0xXX
.equ Safety_Goggles, 0xXX @held item effect

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

.org 0x01AB32
effect_spore_hook:
	ldr r0, pointer1
	bx r0
.align 2
pointer1: .word effect_spore_things + rom + 1

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

.org 0x01D7D8
powder_moves_hook:
	ldr r1, pointer2
	bx r1
.align 2
pointer2: .word grass_immune_start + rom + 1

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

.org 0x028D4A
jump:
	bx r0

.org 0x028DC4
pointer_to_things:
.word weather_checks + rom + 1

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

.org offset
.align 2
effect_spore_things:
	mov r0, #0x58
	mul r0, r2
	add r1, r0, r1
	ldrh r0, [r1, #0x28]
	cmp r0, #0x0
	beq NoEffectSpore
SafetyGogglesCheck:
	ldrh r0, [r1, #0x2E]
	mov r4, r1
	bl get_held_item_attr
	mov r1, r4
	cmp r0, #Safety_Goggles
	beq NoEffectSpore
OvercoatCheck:
	add r1, #0x20
	ldrb r0, [r1]
	cmp r0, #0x8F
	beq NoEffectSpore
CheckGrassType:
	mov r1, r4
	bl check_grass_type
	cmp r0, #1
	bne Return
NoEffectSpore:
	ldr r4, Return0
	bx r4
Return:
	ldr r0, Return1
	bx r0

bx_with_r1:
	bx r1

.align 2
Return0: .word 0x0801AB3E + 1
Return1: .word 0x0801AB42 + 1

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

.align 2
grass_immune_start:
	ldrb r4, [r0]
	mov r0, #0x58
	mul r0, r4
	ldr r1, battle_struct
	add r1, r0
	bl check_grass_type
	cmp r0, #1
	beq check_powder_set_up
	ldrh r0, [r1, #0x2E] @held item
	bl get_held_item_attr
	cmp r0, #Safety_Goggles
	bne return_to_attack_canceler
check_powder_set_up:
	ldr r1, powder_table
	ldr r2, cur_attack
	ldrh r2, [r2]
	ldr r3, ending_hword
check_powder:
	ldrh r0, [r1]
	cmp r0, r3
	beq return_to_attack_canceler
	add r1, #2
	cmp r0, r2
	bne check_powder
fail:
	mov r0, #8
	ldr r1, effectivity
	strb r0, [r1]
	ldr r3, immune_return
	b jump_with_r3
return_to_attack_canceler:
	mov r0, #2
	mov r1, r4
	mov r2, #0
	str r2, [sp]
	ldr r3, return_not_immune
jump_with_r3:
	bx r3

.align 2
powder_table: .word powder_table_offset
return_not_immune: .word 0x0801D7E0 + 1
battle_struct: .word 0x02023BE4
ending_hword: .word 0x0000FFFF
cur_attack: .word 0x02023D4A
effectivity: .word 0x02023DCC
immune_return: .word 0x0801DAF4 + 1

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

.align 2
weather_checks:
	ldr r0, attacker
	ldr r0, [r0]
	mov r1, #0x58
	mul r0, r1
	ldr r1, battle_struct0
	add r1, r0 @ correct battle struct
	add r1, #0x20 @ability
	ldrb r0, [r1]
	cmp r0, #Overcoat
	beq no_damage
	cmp r0, #Magic_Guard
	ldrh r0, [r1, #0xE] @held item
	bl get_held_item_attr
	cmp r0, #Safety_Goggles
	beq no_damage
	ldr r1, normal_return
	bx r1
no_damage:
	ldr r1, return_addr
jump_with_r1:
	bx r1

.align 2
attacker: .word 0x02023D6B
battle_struct0: .word 0x02023BE4
normal_return: .word 0x08028D4C
weather: .word 0x02023F1C
return_addr: .word 0x08028E3C + 1

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

.align 2
check_grass_type: @r1 is the pointer to the battle_struct
	mov r2, r1
	add r1, #0x20
	ldrb r0, [r1, #1]
	cmp r0, #Grass_Type
	beq yes_grass
	ldrb r0, [r1, #2]
	cmp r0, #Grass_Type
	bne no_grass
yes_grass:
	mov r0, #1
	b return_from_grass_check
no_grass:
	mov r0, #0
return_from_grass_check:
	mov r1, r2
	bx lr

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

.align 2
get_held_item_attr:
	ldr r1, item_get_x12
	bx r1

.align 2
item_get_x12: .word 0x0809A924 + 1

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
Since I want the Re-Useable PokéBall feature in Emerald too, I decided to give it a shot but it is still incomplete. Someone else can find the missing parts if they would like to, that would be great. Here is what I have figured out so far through testing:

Found:
Location of bytes "01 21" to change to "00 21": 0x0FE3AA
Var_800E location for Emerald: 0x0203CE7C (which I couldn't find anywhere on the internet for some reason)

Missing:
Emerald's equivalent to FireRed's 0x02D924
What to put instead of "0x809A1D9" in the ASM

Hopefully someone can post the missing parts to complete this.


Not sure if this is any help but in FR at 0x02D924 I found:
Code:
ROM:0802D924                 MOV     R9, R4

which is right near the end of the function for catching Pokemon at 0x02D800.





The equivalent to FireReds 0x02D924 in Emerald is:
Code:
ROM:0805681A                 MOV     R10, R5
The equivalent function to FireReds 0x02D800 in Emerald is 0x0566A8 from what I can tell...

Not sure if that helps any but good luck
 
Code:
regional_dex_order:
.short 0x0000
.short CHIKORITA
.short BAYLEEF
.short MEGANIUM

What should I put here: the true index slot of a Pokemon? Or, the Pokedex Number (in hex) of a Pokemon?

And, can you also please enhance the routine into "Compiler/THUMB Editor and Assembler"-wise routine? Not all users use ASMAGIX.
 
Last edited:
Not sure if this is any help but in FR at 0x02D924 I found:
[...]
The equivalent function to FireReds 0x02D800 in Emerald is 0x0566A8 from what I can tell...

Not sure if that helps any but good luck

Cool, it does help a bit, thank you. I tested 0x05681A (in place of 0x2D924) and realized that that routine is called right after giving a nickname to the caught Pokémon, or declining to. I did some more searching and found 0x04ACB6, which is similar (in bytes) but is called upon pressing 'A' once the game says "X has been caught!".

Unfortunately, editing either of these with the pointer code to the new ASM routine causes the game to reset as soon as it gets called, even though I +1'ed the pointer properly and did the procedure as it was described. It may have something to do with whatever "0x809A1D9" is supposed to be in Emerald, because I have no clue what to replace that with. I'm not sure if that is what is causing the resets though.

We may have to find out how the person who originally put together the FireRed routine found that offset exactly (unless you are able to find it), as I am not currently well-versed in ASM.

EDIT: Well, looks like we have the answers now. Thanks @BluRose. BTW, how did you originally find the right offsets? Was it through looking at the game's ASM as it ran in a debugger, or by searching through hex data (or something else)? Just curious as to how to do this on my own in the future.
REUSABLE BALLS IN EMERALD
[...]
 
Last edited:
REUSABLE BALLS IN FIRE RED / EMERALD

gracias a familiawerneck (for routine) and mwisbest (for reminding me to update my shit with his perfectly fine method)
he also has one to make safari balls reusable

original: buggy, don't use pls
Spoiler:


BPRE:
Spoiler:

BPEE:
Spoiler:
 
Last edited:
Spoiler:
EDIT: Well, looks like we have the answers now. Thanks @BluRose. BTW, how did you originally find the right offsets? Was it through looking at the game's ASM as it ran in a debugger, or by searching through hex data (or something else)? Just curious as to how to do this on my own in the future.
well i knew A1E30's rough equivalent because A1E1C is the pokeball's held item effect; that one was easy
also found the equivalent of 203AD30 (var_800E) from the pokeball routine; same routine with same function will access equivalent offsets
so, yes i did those two in vba's debugger
now, the other two were found using knizz's/touched's .idb files in ida; comparison of routines, basically :P
a large majority of circumstaces will show either a.) the exact same routine or b.) same values being loaded/adjusted/etc.
in a's case it is simply a matter of branching at the right place; b's requires a small rewrite to replace registers~
 
Berry System

Hello...it' me! xD
An user sayd me that this toturial https://www.pokecommunity.com/posts/8515307/ doesn't work...and than I created a new method via script.
It's not a perfect port of the r/s/e berry system, because the script is for only one tree (if you want more you compile other scripts with other vars).

We need to...

JPAN's hacked engine
ShinyQuagsire's berry bag hack: https://www.pokecommunity.com/threads/295749
FBI's Minutes Played routine https://www.pokecommunity.com/posts/8534141/

The script:

Code:
#dynamic 0x900000
#org @start
lock
compare 0x4050 0x0
if 0x1 goto @nonePlanted
compare 0x4050 0x1
if 0x1 goto @fresh
compare 0x4050 0x2
if 0x1 goto @sprouted
compare 0x4050 0x3
if 0x1 goto @growing
compare 0x4050 0x4
if 0x1 goto @blooming
random 0x4
compare 0x800D 0x0
if 0x1 call @5
compare 0x800D 0x1
if 0x1 call @8
compare 0x800D 0x2
if 0x1 call @10
compare 0x800D 0x3
if 0x1 call @13
bufferitem 0x0 0x404f
buffernumber 0x1 0x5005
msgbox @recieved 0x2
msgbox @returned 0x2
setvar 0x4050 0x0
setvar 0x4051 0x0
release
end

#org @nonePlanted
msgbox @none 0x5
compare LASTRESULT 0x0
if 0x1 goto @end
fadescreen 0x1
setvar 0x8000 0x7E
setvar 0x800E 0x0
callasm 0x0A1881
waitmsg
setvar 0x8000 0x0
compare 0x800E 0x0
if 0x1 goto @end
bufferitem 0x0 0x800e
copyvar 0x404f 0x800e
msgbox @addedBerry 0x2
setvar 0x4050 0x1
removeitem 0x800e 0x1
callasm 0x 'offset+1 Minutes Played routine
copyvar 0x4052 0x800d
release
end

#org @fresh
bufferitem 0x0 0x404f
msgbox @newplant 0x2
callasm 0x 'offset+1 Minutes Played routine
copyvar 0x4053 0x800d
compare 0x4051 0x1
if 0x0 goto @water
msgbox @wateredAlready 0x2
writebytetooffset 0x53 0x0203f4d8
writebytetooffset 0x40 0x0203f4d9
writebytetooffset 0x52 0x0203f4da
writebytetooffset 0x40 0x0203f4db
special 0x3f
compare 0x4053 0x14
if 0x4 goto @germoglia
release
end

#org @germoglia
setvar 0x4051 0x0
setvar 0x4050 0x2
callasm 0x9600061
copyvar 0x4052 0x800d
bufferitem 0x0 0x404f
msgbox @sprouting 0x2
goto @sprouted
end

#org @sprouted
callasm 0x 'offset+1 Minutes Played routine
copyvar 0x4053 0x800d
compare 0x4051 0x1
if 0x0 goto @water
msgbox @wateredAlready 0x2
writebytetooffset 0x53 0x0203f4d8
writebytetooffset 0x40 0x0203f4d9
writebytetooffset 0x52 0x0203f4da
writebytetooffset 0x40 0x0203f4db
special 0x3f
compare 0x4053 0x14
if 0x4 goto @cresci
release
end

#org @cresci
setvar 0x4051 0x0
setvar 0x4050 0x3
callasm 0x 'offset+1 Minutes Played routine
copyvar 0x4052 0x800d
bufferitem 0x0 0x404f
msgbox @tall 0x2
goto @growing
end

#org @growing
callasm 0x 'offset+1 Minutes Played routine
copyvar 0x4053 0x800d
compare 0x4051 0x1
if 0x0 goto @water
msgbox @wateredAlready 0x2
writebytetooffset 0x53 0x0203f4d8
writebytetooffset 0x40 0x0203f4d9
writebytetooffset 0x52 0x0203f4da
writebytetooffset 0x40 0x0203f4db
special 0x3f
compare 0x4053 0x14
if 0x4 goto @fiorisci
release
end

#org @fiorisci
setvar 0x4051 0x0
setvar 0x4050 0x4
callasm 0x 'offset+1 Minutes Played routine
copyvar 0x4052 0x800d
msgbox @bloom 0x2
goto @blooming
end

#org @blooming
callasm 0x 'offset+1 Minutes Played routine
copyvar 0x4053 0x800d
compare 0x4051 0x1
if 0x0 goto @water
msgbox @wateredAlready 0x2
writebytetooffset 0x53 0x0203f4d8
writebytetooffset 0x40 0x0203f4d9
writebytetooffset 0x52 0x0203f4da
writebytetooffset 0x40 0x0203f4db
special 0x3f
compare 0x4053 0x14
if 0x4 goto @raccogli
release
end

#org @raccogli
setvar 0x4051 0x0
setvar 0x4050 0x5
msgbox @raccolta 0x2
goto @start
end

#org @water
checkitem 0xe2 0x1
compare LASTRESULT 0x1
if 0x0 goto @end
msgbox @wantWater 0x5
compare LASTRESULT 0x0
if 0x1 goto @end
msgbox @finishedWatering 0x2
setvar 0x4051 0x1
release
end

#org @5
setvar 0x5005 0x5
additem 0x404f 0x5
return

#org @8
setvar 0x5005 0x8
additem 0x404f 0x8
return

#org @10
setvar 0x5005 0xa
additem 0x404f 0xa
return

#org @13
setvar 0x5005 0xd
additem 0x404f 0xd
return

#org @end
release
end

#org @addedBerry
= Hai piantato una [buffer1] qui. \hF9\hF9

#org @returned
= Il terreno è tornato al suo\nstato originario.

#org @newplant
= Qui è coltivata una [buffer1].

#org @none
= Il terreno sembra fertile.\nVuoi piantare una bacca?

#org @bloom
= Tra poco potrò raccogliere \ni frutti. \hF9\hF9

#org @tall
= La [buffer1] sta\ncrescendo forte e rigogliosa. \hF9\hF9

#org @sprouting
= La [buffer1] ha germogliato! \hF9\hF9

#org @wantWater
= Il terreno ha bisogno di acqua.\nVuoi annaffiarlo?

#org @wateredAlready
= Bisogna aspettare ancora un po'...

#org @recieved
= [player] raccoglie [buffer2] [buffer1]!

#org @finishedWatering
= Il terreno adesso è umido.\nLa bacca sembra beneficiarne!

#org @raccolta
= Dopo tanta fatica sembra che\nla pianta sia pronta! \hF9\hF9

How it works?

1) vars used

var 404F - berry planted
var 4050 - current stage
var 4051 - was watered
var 4052 - time of before stage
var 4053 - time of current stage

2) time
I copy and modify the FBI berry script - 5 phases, each phase lasts 20 minutes playtime. You must always water the berry to acces to the next step.
To calculated the time I used the vars operation of JPAN's hacked engine (var 4053 - var 4052).

3) at the end the script give you a random number of berries (5, 8 ,10 ,13).

How I can create a new berry tree?

You must change the vars with new ones and MORE importante you must change

Code:
writebytetooffset 0x53 0x0203f4d8
writebytetooffset 0x40 0x0203f4d9
writebytetooffset 0x52 0x0203f4da
writebytetooffset 0x40 0x0203f4db

with the 2 new vars of time.



If you find a bug...call me! xD

[sorry for my bad english]
 
Last edited:
Alright, I have a request.
Is it possible to run a Pokemon storage script via an item??
This is implemented in Pokemon NKP but doesn't seem to work...
Basically it can store upto 6 Pokemon and we can carry it in key items..
It would be such a nice feature.
Please look forward to it..
Just a request..
All other asm are great..
make it so that your item runs a script using the item runner from like jpan's hacked engine or something
and then make your script use special 0x9F to choose a pokémon to store with a callasm to like the pokémon storage system linked on the first page
naturally your script will have to do various things, i.e. count the number of pokémon and others, but it shouldn't be too difficult
 
Hello. I'm interested in an edit that makes Emerald generate all IVs of all encountered Pokemon at 31. What's the best way to go about this?
 
Back
Top