Thread: Research: "Background" Scripts
View Single Post
  #11    
Old October 19th, 2012 (11:02 PM).
tajaros's Avatar
tajaros tajaros is offline
Hi I'm dawg
 
Join Date: Apr 2012
Location: Philippines
Age: 16
Gender: Male
Nature: Timid
Posts: 857
Send a message via Windows Live Messenger to tajaros
Quote originally posted by Darthatron:
Sure thang.

Keypresses are handled as so:
Spoiler:
03003118 in the RAM contains a halfword value if buttons are being held.
0300311A in the RAM contains a halfword value if buttons are being pressed this frame.
0300311C and 0300311E are then clones of this.
0300311E is the one used by the game mostly.
Code:
  Bit   Button
  0     A                (0 = Released, 1 = Pressed)
  1     B
  2     Select
  3     Start
  4     Right
  5     Left
  6     Up
  7     Down
  8     R
  9     L
  10-15 Not used
So, say you want to check if the button Start is being pressed this frame:
Code:
<enter code here>
ldr r2, .KeyStates
ldrh r0, [r2, #2]
mov r1, #3
and r0, r1
cmp r0, #0
bne StartIsPressed
<enter code here>

.align 2
.KeyStates:
	.word 0x03003118


Calling scripts from ASM is also fairly simple:
You can run any script by calling 0x08069B48 with the script offset in the r0 register. This is how the game calls most scripts, such as level scripts and the flag setting script when you start a new game.

I hope this helps.

All offsets are for FireRed US (1.0) and may not work with other games or versions. Also, no code was tested. I just wrote it with the post.
Cool, I'll be sure to try this out when I'm on my free time...
__________________
Reply With Quote