Thread: Research: "Background" Scripts
View Single Post
  #10    
Old October 19th, 2012 (09:54 PM).
Darthatron's Avatar
Darthatron Darthatron is offline
巨大なトロール。
Silver Tier
 
Join Date: Jan 2006
Location: Melbourne, Australia
Age: 23
Gender: Male
Nature: Modest
Posts: 1,152
Quote originally posted by tajaros:
Woah, you already know how to do this? Can you please share it to us? Please...
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.
__________________
あなた は しきしゃ です
わたし は ばか です
Reply With Quote