The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Fan Games > Binary ROM Hacking
Reload this Page ASM & Hex Need help with reloading map + NPC palettes with ASM in Fire Red

Notices
For all updates, view the main page.

Binary ROM Hacking Need a helping hand or just want to talk about binary ROM hacks? Get comments and answers to any ROM Hacking-related problems, questions or thoughts you have here.

Ad Content
Reply
 
Thread Tools
  #1   Link to this post, but load the entire thread.  
Old February 10th, 2017 (11:51 AM).
kobold kobold is offline
 
Join Date: Jan 2017
Gender: Male
Posts: 13
Hi folks,

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!
Reply With Quote
  #2   Link to this post, but load the entire thread.  
Old February 10th, 2017 (8:37 PM). Edited February 11th, 2017 by Phantom Phoenix.
Phantom Phoenix's Avatar
Phantom Phoenix Phantom Phoenix is offline
Lost on the road of life
 
Join Date: Oct 2015
Location: ???
Age: 26
Gender: Male
Nature: Calm
Posts: 167
hmm ...
you are calling functions without giving parameters which takes parameters
Here is what FBI said in his asm tut:
Code:
Remember when I was talking about paramaters to ASM functions? I said that paramaters, by ASM standards, are defined to be the first four low registers. If there are more than four paramaters, that's a different story (the extra paramaters are writting to the stack pointer). Similarly to paramaters, the output from a function is also like this. Generally, if a function outputs values or pointers for other functions to use (these are often called helper functions in other programming languages), the outputs are stored into r0-r3. They are always filled in consecutive order. So if some function outputted one value, that value would be in r0. Never will you see the value in r1, r2, or r3 and not in r0. Hopefully that makes sense to you, as it's important.
So.....
* before calling update_pal function you have to put current_mapheader in r0
.
like this:
Code:
 ldr 0, map
ldr r0, [r0]
ldr r5, updatePal
bl bx_r5
* And updateNPCPal also takes a parameter.
You don't need to push that many register. You just did some check in this routine so r0-r2 is enough for the task.
__________________
Pokemon XYZ Version
Reply With Quote
Reply

Quick Reply

Join the conversation!

Create an account to post a reply in this thread, participate in other discussions, and more!

Create a PokéCommunity Account
Ad Content

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 9:23 AM.