Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RAM_ARM9:02029E38 ; =============== S U B R O U T I N E =======================================
- RAM_ARM9:02029E38
- RAM_ARM9:02029E38
- RAM_ARM9:02029E38 ; u16 __fastcall getNPCBattleMusic__(u16 npcID)
- RAM_ARM9:02029E38 getNPCBattleMusic__
- RAM_ARM9:02029E38 18 B4 PUSH {R3,R4}
- RAM_ARM9:02029E3A 0A 4A LDR R2, =word_20A75C8 ; LUT pointer
- RAM_ARM9:02029E3C 00 24 MOVS R4, #0 ; int i = 0
- RAM_ARM9:02029E3E 11 88 LDRH R1, [R2] ; load first LUT entry, see if we even need to loop
- RAM_ARM9:02029E40 69 29 CMP R1, #0x69 ; 'i' ; this should pretty much never be equal
- RAM_ARM9:02029E42 0C D0 BEQ loc_2029E5E
- RAM_ARM9:02029E44
- RAM_ARM9:02029E44 loc_2029E44 ; CODE XREF: getNPCBattleMusic__+24j
- RAM_ARM9:02029E44 A3 00 LSLS R3, R4, #2 ; each entry is 4 bytes (u16 npcID and u16 songVal), so loop counter *4 to hit each entry in a row
- RAM_ARM9:02029E46 D1 5A LDRH R1, [R2,R3] ; LUT_base + loop_counter * 4 to run through each entry, fetching the npcID to test against the passed arg
- RAM_ARM9:02029E48 88 42 CMP R0, R1 ; npcID == LUTnpcID
- RAM_ARM9:02029E4A 03 D1 BNE loc_2029E54 ; if not, jump past the return statement
- RAM_ARM9:02029E4C 06 48 LDR R0, =0x20A75CA ; if they are equal, LUT_base + 2(to align for the songVal)
- RAM_ARM9:02029E4E C0 5A LDRH R0, [R0,R3] ; (LUT_base + 2) + (loop_counter * 4) to adjust for alignment + 2nd half of each entry- return songVal
- RAM_ARM9:02029E50 18 BC POP {R3,R4}
- RAM_ARM9:02029E52 70 47 BX LR
- RAM_ARM9:02029E54 ; ---------------------------------------------------------------------------
- RAM_ARM9:02029E54
- RAM_ARM9:02029E54 loc_2029E54 ; CODE XREF: getNPCBattleMusic__+12j
- RAM_ARM9:02029E54 64 1C ADDS R4, R4, #1 ; i++ if the npcID didn't pan out on the previous run
- RAM_ARM9:02029E56 A1 00 LSLS R1, R4, #2 ; loop_counter * 4 for alignment
- RAM_ARM9:02029E58 51 5A LDRH R1, [R2,R1] ; (loop_counter * 4) + LUT_base, jump into LUT to next entry
- RAM_ARM9:02029E5A 69 29 CMP R1, #0x69 ; 'i' ; is the npcID the max?
- RAM_ARM9:02029E5C F2 D1 BNE loc_2029E44 ; if not, run the loop again and jump into the LUT at the next entry
- RAM_ARM9:02029E5E
- RAM_ARM9:02029E5E loc_2029E5E ; CODE XREF: getNPCBattleMusic__+Aj
- RAM_ARM9:02029E5E 03 48 LDR R0, =0x45A ; if it is the max value, return the default battle music
- RAM_ARM9:02029E60 18 BC POP {R3,R4}
- RAM_ARM9:02029E62 70 47 BX LR
- RAM_ARM9:02029E62 ; End of function getNPCBattleMusic__
- RAM_ARM9:02029E62
- RAM_ARM9:02029E62 ; ---------------------------------------------------------------------------
- RAM_ARM9:02029E64 C8 75 0A 02 off_2029E64 DCD word_20A75C8 ; DATA XREF: getNPCBattleMusic__+2r
- RAM_ARM9:02029E68 CA 75 0A 02 dword_2029E68 DCD 0x20A75CA ; DATA XREF: getNPCBattleMusic__+14r
- RAM_ARM9:02029E6C 5A 04 00 00 dword_2029E6C DCD 0x45A ; DATA XREF: getNPCBattleMusic__:loc_2029E5Er
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement