Welcome to Data Crystal's new home! Data Crystal is now part of the TCRF family (sort of).
The wiki has recently moved; please report any issues in Discord. Pardon the dust.

Pokémon Mystery Dungeon: Red Rescue Team/Script Command Parsing Code

From Data Crystal
< Pokémon Mystery Dungeon: Red Rescue Team
Revision as of 20:32, 9 October 2016 by BRNMan (talk | contribs) (Added comments and dissasembly of method.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This is a sub-page of Pokémon Mystery Dungeon: Red Rescue Team.

So very stubbly.
This page is rather stubbly and could use some expansion.
Are you a bad enough dude to rescue this article?
Script Command Parsing Code
Game Pokémon Mystery Dungeon: Red Rescue Team
Start Address 0x0809EACC
End Address 0x0809EB16
# of Entries 38 (0x26)
Entry Length 2 bytes (0x02)
Total Length 74 bytes (0x4A)
Back to the ROM map

This code is where most commands are read from scripts and redirected to their specific methods.

0809EACC B5F0     push    r4-r7,r14                               
0809EACE 4657     mov     r7,r10                                  
0809EAD0 464E     mov     r6,r9                                   
0809EAD2 4645     mov     r5,r8                                   
0809EAD4 B4E0     push    r5-r7                                   
0809EAD6 B0EF     add     sp,-1BCh           ;Method Initialization
0809EAD8 4681     mov     r9,r0              ;r9 is where the RAM structure starts
0809EADA 2024     mov     r0,24h             ;
0809EADC 4448     add     r0,r9              ;
0809EADE 4682     mov     r10,r0             ;
0809EAE0 4651     mov     r1,r10             ;loop start, r10 is the RAM location for command pointers
0809EAE2 684A     ldr     r2,[r1,4h]         ;retrieves next command in ROM pointer from ram
0809EAE4 61CA     str     r2,[r1,1Ch]        ;next pointer = current pointer
0809EAE6 A902     add     r1,sp,8h           ;r1 = Location of arguments on stack
0809EAE8 1C10     mov     r0,r2              ;r0 = next command pointer
0809EAEA C838     ldmia   [r0]!,r3-r5        ;Loads first three arguments of command 4 bytes at a time.
0809EAEC C138     stmia   [r1]!,r3-r5        ;Sends them to the stack.
0809EAEE 6800     ldr     r0,[r0]            ;Loads last (pointer) argument of command into r0.
0809EAF0 6008     str     r0,[r1]            ;Puts pointer argument in stack just above the other arguments.
0809EAF2 3210     add     r2,10h             ;Increments script index (r2 points to next command in the script)
0809EAF4 4650     mov     r0,r10                                  
0809EAF6 6042     str     r2,[r0,4h]         ;Stores new script index in RAM
0809EAF8 A802     add     r0,sp,8h           ;r0 = command byte index
0809EAFA 7800     ldrb    r0,[r0]            ;Load command byte into r0 (1 byte)
0809EAFC 4651     mov     r1,r10                                  
0809EAFE 3120     add     r1,20h                                  
0809EB00 7008     strb    r0,[r1]            ;Stores command byte in RAM
0809EB02 0600     lsl     r0,r0,18h          
0809EB04 0E00     lsr     r0,r0,18h          ;Can't think of a use for these.
0809EB06 3801     sub     r0,1h              
0809EB08 1C0A     mov     r2,r1              
0809EB0A 28F5     cmp     r0,0F5h            ;If the command byte is F6 or greater,
0809EB0C D8E8     bhi     809EAE0h           ;Then move on to the next command
0809EB0E 0080     lsl     r0,r0,2h           ;else multiply command byte by 4
0809EB10 4901     ldr     r1,=809EB1Ch       ;r1=jump table start
0809EB12 1840     add     r0,r0,r1           ;r0 = location of pointer in jump table
0809EB14 6800     ldr     r0,[r0]            ;Loads command pointer into r0.
0809EB16 4687     mov     r15,r0             ;Changes Instruction Pointer to jump to the pointer to the command's method.