Advertisement
Bond697

u16 __fastcall getNPCBattleMusic__(u16 npcID)

Jun 4th, 2012
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 3.57 KB | None | 0 0
  1. RAM_ARM9:02029E38             ; =============== S U B R O U T I N E =======================================
  2. RAM_ARM9:02029E38
  3. RAM_ARM9:02029E38
  4. RAM_ARM9:02029E38             ; u16 __fastcall getNPCBattleMusic__(u16 npcID)
  5. RAM_ARM9:02029E38             getNPCBattleMusic__
  6. RAM_ARM9:02029E38 18 B4                       PUSH    {R3,R4}
  7. RAM_ARM9:02029E3A 0A 4A                       LDR     R2, =word_20A75C8 ; LUT pointer
  8. RAM_ARM9:02029E3C 00 24                       MOVS    R4, #0          ; int i = 0
  9. RAM_ARM9:02029E3E 11 88                       LDRH    R1, [R2]        ; load first LUT entry, see if we even need to loop
  10. RAM_ARM9:02029E40 69 29                       CMP     R1, #0x69 ; 'i' ; this should pretty much never be equal
  11. RAM_ARM9:02029E42 0C D0                       BEQ     loc_2029E5E
  12. RAM_ARM9:02029E44
  13. RAM_ARM9:02029E44             loc_2029E44                             ; CODE XREF: getNPCBattleMusic__+24j
  14. 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
  15. 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
  16. RAM_ARM9:02029E48 88 42                       CMP     R0, R1          ; npcID == LUTnpcID
  17. RAM_ARM9:02029E4A 03 D1                       BNE     loc_2029E54     ; if not, jump past the return statement
  18. RAM_ARM9:02029E4C 06 48                       LDR     R0, =0x20A75CA  ; if they are equal, LUT_base + 2(to align for the songVal)
  19. 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
  20. RAM_ARM9:02029E50 18 BC                       POP     {R3,R4}
  21. RAM_ARM9:02029E52 70 47                       BX      LR
  22. RAM_ARM9:02029E54             ; ---------------------------------------------------------------------------
  23. RAM_ARM9:02029E54
  24. RAM_ARM9:02029E54             loc_2029E54                             ; CODE XREF: getNPCBattleMusic__+12j
  25. RAM_ARM9:02029E54 64 1C                       ADDS    R4, R4, #1      ; i++ if the npcID didn't pan out on the previous run
  26. RAM_ARM9:02029E56 A1 00                       LSLS    R1, R4, #2      ; loop_counter * 4 for alignment
  27. RAM_ARM9:02029E58 51 5A                       LDRH    R1, [R2,R1]     ; (loop_counter * 4) + LUT_base, jump into LUT to next entry
  28. RAM_ARM9:02029E5A 69 29                       CMP     R1, #0x69 ; 'i' ; is the npcID the max?
  29. RAM_ARM9:02029E5C F2 D1                       BNE     loc_2029E44     ; if not, run the loop again and jump into the LUT at the next entry
  30. RAM_ARM9:02029E5E
  31. RAM_ARM9:02029E5E             loc_2029E5E                             ; CODE XREF: getNPCBattleMusic__+Aj
  32. RAM_ARM9:02029E5E 03 48                       LDR     R0, =0x45A      ; if it is the max value, return the default battle music
  33. RAM_ARM9:02029E60 18 BC                       POP     {R3,R4}
  34. RAM_ARM9:02029E62 70 47                       BX      LR
  35. RAM_ARM9:02029E62             ; End of function getNPCBattleMusic__
  36. RAM_ARM9:02029E62
  37. RAM_ARM9:02029E62             ; ---------------------------------------------------------------------------
  38. RAM_ARM9:02029E64 C8 75 0A 02 off_2029E64     DCD word_20A75C8        ; DATA XREF: getNPCBattleMusic__+2r
  39. RAM_ARM9:02029E68 CA 75 0A 02 dword_2029E68   DCD 0x20A75CA           ; DATA XREF: getNPCBattleMusic__+14r
  40. 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