- 13
- Posts
- 7
- Years
- Seen Sep 12, 2019
Hi folks,
I'm writing a simple ASM routine that will call the functions in Fire Red. So far, my code looks like this...
As you can see, it performs a variety of checks before loading the pointers to the palette loading routines into r5 and calling them in sequence. However, whenever I try to run the code, the game will freeze or the palettes will get messed up. If anyone could point out where I've went wrong here and help me get this code working that would be greatly appreciated. Thank you!
I'm writing a simple ASM routine that will call the functions in Fire Red. So far, my code looks like this...
Code:
.text
.align 2
.thumb
.thumb_func
main:
push {r0-r7, lr}
ldr r4, battleCheck
ldrh r4, [r4]
cmp r4, #0x0
bne end
ldr r3, callback
ldr r3, [r3]
ldr r4, mainloop
cmp r3, r4
bne end
ldr r4, map
ldr r4, [r4]
cmp r4, #0x0
beq end
ldr r5, updatePal
bl bx_r5
ldr r5, updateNPCPal
bl bx_r5
end:
pop {r0-r7, pc}
bx_r5:
bx r5
.align 2
updatePal:
.word 0x08059AD8+1
updateNPCPal:
.word 0x0805FECC+1
battleCheck:
.word 0x02024018
callback:
.word 0x03005090
mainloop:
.word 0x08079E0D
map:
.word 0x02036DFC
As you can see, it performs a variety of checks before loading the pointers to the palette loading routines into r5 and calling them in sequence. However, whenever I try to run the code, the game will freeze or the palettes will get messed up. If anyone could point out where I've went wrong here and help me get this code working that would be greatly appreciated. Thank you!