• 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

I'm practicing ASM and made a fun little routine for Firered (with some help from Spherical Ice) that counts the amount of Rare Candies the player has used.
If you want to punish your players for cheating by hacking in candies, then this might be of use to you.

Spoiler:


After inserting this in a word-aligned offset, go to 0x1263F6 and place:
Code:
01 49 08 47 C0 46 XX XX XX 08
Where XX is the pointer to the routine, +1.

This routine will automatically add 1 to the variable you chose each time the player uses a rare candy.
How you handle the variable in a script is all up to you!
 
Last edited:
There is a way to call a script with ASM? I want to make something like this:
If a flag is set do something, if not set show a message.

What's the command I use on a routine to make it work?
 
There is a way to call a script with ASM? I want to make something like this:
If a flag is set do something, if not set show a message.

What's the command I use on a routine to make it work?

Well, you could manage that by simply using scripts, but if you insist on using ASM:

Code:
[PLAIN]
.text
.align 2
.thumb
.thumb_func

main:
	push {r0-r1, lr}
	ldr r0, .SCRIPT_ADDRESS
	ldr r1, =(0x8069AE4 +1)
	bl linkerTwo
	pop {r0-r1, pc}

linkerTwo:
	bx r1
	
	
.align 2

.SCRIPT_ADDRESS:
	.word 0x8[script_location +1]
[/PLAIN]

FBI made this routine as a reply to something I asked some time ago on the ASM Help Thread. You just have to compile it, modifying the code to add your script location, insert the code on an aligned offset (is it said that way? xDD) and then callasm the routine offset + 1 as usual.

Hope this helps :D
 
Well, you could manage that by simply using scripts, but if you insist on using ASM:

Code:
[PLAIN]
.text
.align 2
.thumb
.thumb_func

main:
	push {r0-r1, lr}
	ldr r0, .SCRIPT_ADDRESS
	ldr r1, =(0x8069AE4 +1)
	bl linkerTwo
	pop {r0-r1, pc}

linkerTwo:
	bx r1
	
	
.align 2

.SCRIPT_ADDRESS:
	.word 0x8[script_location +1]
[/PLAIN]

FBI made this routine as a reply to something I asked some time ago on the ASM Help Thread. You just have to compile it, modifying the code to add your script location, insert the code on an aligned offset (is it said that way? xDD) and then callasm the routine offset + 1 as usual.

Hope this helps :D

I know it can be done only with scripts, but it's needed to edit another routine I have, then it looks better than I wanted, thanks for the reply, I will test it soon as possible and I tell if it worked. ^^

EDIT: Haven't worked, I tested running it by another routine, I tested it by running from the START menu, but haven't worked.
 
Last edited:
Pok?mon Ruby and Sapphire introduced a feature where if you bought 10 or more Pok? Balls in the Mart, you would get a free Premier Ball.
Sadly, this feature was removed in FRLG, and so I tried to port it the best I could.

First, insert this text somewhere using XSE or something and write down the offset of where you inserted it:
Code:
I'll throw in a Premier Ball, too.
After that, assemble this routine in a word-aligned offset (ends in 0, 4, 8 or C)
(But first, replace the XXXXXX with the offset of where you inserted the Premier Ball message):

Spoiler:


After inserting the routine, navigate to 0x3DF0B4 and put the pointer to it, +1. (If I inserted the routine at 0x725030 I would put 31 50 72 08)

And that's it!

Hi. The routine works well but The hereyouare message doesn't seem to appear if I do receive the PREMIER BALL. Instead it goes straight to the 'I'll throw in a PREMIER BALL, too.' I would like to see both messages appear, just as it does in R/S/E. Thanks for the routine!
 
Pok?mon Ruby and Sapphire introduced a feature where if you bought 10 or more Pok? Balls in the Mart, you would get a free Premier Ball.
Sadly, this feature was removed in FRLG, and so I tried to port it the best I could.

First, insert this text somewhere using XSE or something and write down the offset of where you inserted it:
Code:
Here you are!\nI'll throw in a Premier Ball, too.

Not what I meant but whatever.
 
Last edited:
Sorry then.
I'm still learning.

What I meant was, I would like to see the 'I'll throw in...' message following the hereyouare message. Instead of combining the text, I would like to see two separate messages. (without using \p from XSE either)

Something like this.... (I have no knowledge of ASM)
Code:
tryadding:
mov r0, #0xC @premier ball ID
mov r1, #0x1 @amount of premier balls
ldr r7, bag_add_item
bl linkr7
lsl r0, r0, #0x18
lsr r0, r0, #0x18
cmp r0, #1
bne next @if no room for premier ball, skip to next
ldr r1, hereyouare
ldr r2, sub_809BF0C
mov r0, r5
bl displaymsg
[B]ldr r1, message
ldr r2, sub_809BF0C
mov r0, r5
bl displaymsg[/B]
b next
 
REUSABLE BALLS IN EMERALD
gracias a familiawerneck
routine with byte changes
Spoiler:
if y'all want to see specific equivalent addresses:
Spoiler:
have a nice day~

I fixed this so it doesn't delete the fishing rod in the safari zone, among other glitches. It'll now verify that the item is a ball of some kind before it deletes it.

The code looks strange. I'm guessing it could be improved somehow, but it works:
Code:
.text
.align 2
.thumb

@ FE3AA - 00 21
@ 56818 - 00 48 00 47 XX+1 XX XX XX

main:
	bl delete_item_if_pokeball
	b finish

deleteball:
	@ r0 already contains last_used_item.
	mov r1, #1
	ldr r2, .bag_remove_item
	bx r2

delete_item_if_pokeball:
	ldr r0, .last_used_item
	ldrh r0, [r0]
	@ checks that the item id is premier ball or lower
	cmp r0, #0xC
	bls deleteball
	@ support for custom pokeballs can be added like so:
	@ cmp r0, #CUSTOM_BALL_ID
	@ beq deleteball

finish:
	mov r9, r4
	mov r10, r5
	pop {r4-r7}
	pop {r0}
	bx r0

.align 2
.last_used_item:
	.word 0x0203CE7C
.bag_remove_item:
	.word 0x080D6AA4|1

EDIT: See here for a version that also makes safari balls reusable.
 
Last edited:
I fixed this so it doesn't delete the fishing rod in the safari zone, among other glitches. It'll now verify that the item is a ball of some kind before it deletes it.

The code looks strange. I'm guessing it could be improved somehow, but it works:
Code:
.text
.align 2
.thumb

@ FE3AA - 00 21
@ 56818 - 00 48 00 47 XX+1 XX XX XX

main:
	bl delete_item_if_pokeball
	bl finish

deleteball:
	@ r0 already contains last_used_item.
	mov r1, #1
	ldr r2, .bag_remove_item
	bx r2

delete_item_if_pokeball:
	ldr r0, .last_used_item
	ldrh r0, [r0]
	@ checks that the item id is premier ball or lower
	cmp r0, #0xC
	bls deleteball
	@ support for custom pokeballs can be added like so:
	@ cmp r0, #CUSTOM_BALL_ID
	@ beq deleteball

finish:
	mov r9, r4
	mov r10, r5
	pop {r4-r7}
	pop {r0}
	bx r0

.align 2
.last_used_item:
	.word 0x0203CE7C
.bag_remove_item:
	.word 0x080D6AA4|1
oh xD
i guess i forgot to edit my post with what i had posted here and here
muchas gracias amigo~
i'll edit my old post and direct to your method as well x3
 
I hope this is the right place to ask, but I was wondering if anyone knows how to edit the following routines so that they don't end the script after completion? For example, use callasm 0x8XXXXXX and then continue with a msgbox, etc..

Naming the player from the overworld: callasm 0x809FC91


And Jambo's rival naming script:
Code:
.text
.align 2
.thumb
.thumb_func
.global rivalnamingingame

main:
	push {r0-r4,lr}
	ldr r0, place
	str r0, [sp, #0x4]
	ldr r1, ramlocation
	ldr r1, [r1, #0x0]
	ldr r0, standard
	add r1, r1, r0
	mov r0, #0x4
	mov r2, #0x0
	mov r3, #0x0
	bl place2
	ldr r1, ramlocation
	ldr r1, [r1, #0x0]
	ldr r0, standard
	add r1, r1, r0
	ldrb r0, [r1, #0x0]
	cmp r0, #0xFF
	beq failsafe
	cmp r0, #0x0
	beq failsafe
	
return: 
	pop {r0-r4}
	pop {pc}
	
place2: 
	ldr r4, actualroutine
	bx r4
	
failsafe: 
	ldr r0, rivalname

loop: 
	ldrb r2, [r0, #0x0]
	strb r2, [r1, #0x0]
	cmp r2, #0xFF
	beq return
	add r0, #0x1
	add r1, #0x1
	b loop
	
.align 2
place: .word 0x080568E1
ramlocation: .word 0x03005008
standard: .word 0x00003A4C
actualroutine: .word 0x0809D955
rivalname: .word 0x08FFFFFF                    @default name if left blank
 
Back
Top