Bond697

Core Scripting

Jun 1st, 2013
232
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. RAM_ARM9:0201587C             ; =============== S U B R O U T I N E =======================================
  2. RAM_ARM9:0201587C
  3. RAM_ARM9:0201587C
  4. RAM_ARM9:0201587C             ; void __fastcall initScriptEnvironment(ScriptEnvironment *vm)
  5. RAM_ARM9:0201587C             initScriptEnvironment                   ; CODE XREF: initEnvironment+6p
  6. RAM_ARM9:0201587C                                                     ; intializeScriptEnvironment+6p
  7. RAM_ARM9:0201587C 38 B5                       PUSH    {R3-R5,LR}
  8. RAM_ARM9:0201587E 05 1C                       MOVS    R5, R0
  9. RAM_ARM9:02015880 2A 88                       LDRH    R2, [R5]
  10. RAM_ARM9:02015882 00 24                       MOVS    R4, #0
  11. RAM_ARM9:02015884 68 6A                       LDR     R0, [R5,#ScriptEnvironment.script_stack_ptr] ; dest
  12. RAM_ARM9:02015886 00 21                       MOVS    R1, #0          ; data
  13. RAM_ARM9:02015888 92 00                       LSLS    R2, R2, #2
  14. RAM_ARM9:0201588A 2C 62                       STR     R4, [R5,#ScriptEnvironment.script_pos_ptr]
  15. RAM_ARM9:0201588C AC 76                       STRB    R4, [R5,#ScriptEnvironment.scriptCmpResult]
  16. RAM_ARM9:0201588E 6C 76                       STRB    R4, [R5,#ScriptEnvironment.executionState]
  17. RAM_ARM9:02015890 EC 61                       STR     R4, [R5,#ScriptEnvironment.funcptr]
  18. RAM_ARM9:02015892 2C 76                       STRB    R4, [R5,#ScriptEnvironment.stackPointer]
  19. RAM_ARM9:02015894 62 F0 9E EF                 BLX     MI_CpuFill8     ; this zeroes out the entire script stack
  20. RAM_ARM9:02015898 6A 88                       LDRH    R2, [R5,#2]
  21. RAM_ARM9:0201589A A8 6A                       LDR     R0, [R5,#ScriptEnvironment.vars] ; dest
  22. RAM_ARM9:0201589C 00 21                       MOVS    R1, #0          ; data
  23. RAM_ARM9:0201589E 92 00                       LSLS    R2, R2, #2
  24. RAM_ARM9:020158A0 62 F0 98 EF                 BLX     MI_CpuFill8     ; this zeroes out the environment var area
  25. RAM_ARM9:020158A4 2C 63                       STR     R4, [R5,#ScriptEnvironment.script_callback_verifier]
  26. RAM_ARM9:020158A6 6C 63                       STR     R4, [R5,#ScriptEnvironment.sys_info]
  27. RAM_ARM9:020158A8 38 BD                       POP     {R3-R5,PC}
  28. RAM_ARM9:020158A8             ; End of function initScriptEnvironment
  29. RAM_ARM9:020158A8
  30. RAM_ARM9:020158A8             ; ---------------------------------------------------------------------------
  31. RAM_ARM9:020158AA 00 00                       DCW 0
  32. RAM_ARM9:020158AC
  33. RAM_ARM9:020158AC             ; =============== S U B R O U T I N E =======================================
  34. RAM_ARM9:020158AC
  35. RAM_ARM9:020158AC
  36. RAM_ARM9:020158AC             ; void *__fastcall startScriptingVirtualMachine(s16 blkGroupID, ScriptEnvironment *vm)
  37. RAM_ARM9:020158AC             startScriptingVirtualMachine            ; CODE XREF: setupScriptingEnvironment+68p
  38. RAM_ARM9:020158AC
  39. RAM_ARM9:020158AC             marker          = -0x18
  40. RAM_ARM9:020158AC
  41. RAM_ARM9:020158AC F8 B5                       PUSH    {R3-R7,LR}      ; marker
  42. RAM_ARM9:020158AE 0D 1C                       MOVS    R5, R1          ; the &vm being passed in here is a local copy on the stack meant for copying to 1 of 4 globally accesible virtual machines
  43. RAM_ARM9:020158B0 69 88                       LDRH    R1, [R5,#2]     ; virtual machine- script interpreter
  44. RAM_ARM9:020158B2 10 4B                       LDR     R3, =aVm_c      ; "vm.c"
  45. RAM_ARM9:020158B4 00 22                       MOVS    R2, #0          ; clearBlock
  46. RAM_ARM9:020158B6 8C 00                       LSLS    R4, R1, #2
  47. RAM_ARM9:020158B8 29 88                       LDRH    R1, [R5]
  48. RAM_ARM9:020158BA 3C 34                       ADDS    R4, #0x3C ; '<'
  49. RAM_ARM9:020158BC 8E 00                       LSLS    R6, R1, #2
  50. RAM_ARM9:020158BE 60 21                       MOVS    R1, #0x60 ; '`'
  51. RAM_ARM9:020158C0 00 91                       STR     R1, [SP,#0x18+marker] ; marker
  52. RAM_ARM9:020158C2 A1 19                       ADDS    R1, R4, R6      ; blockLength
  53. RAM_ARM9:020158C4 24 F0 B0 FC                 BL      allocateBlockFromExpHeap
  54. RAM_ARM9:020158C8 07 1C                       MOVS    R7, R0
  55. RAM_ARM9:020158CA 00 21                       MOVS    R1, #0          ; data
  56. RAM_ARM9:020158CC A2 19                       ADDS    R2, R4, R6      ; size
  57. RAM_ARM9:020158CE 62 F0 82 EF                 BLX     MI_CpuFill8
  58. RAM_ARM9:020158D2 2B 1C                       MOVS    R3, R5
  59. RAM_ARM9:020158D4 3A 1C                       MOVS    R2, R7
  60. RAM_ARM9:020158D6 03 CB                       LDMIA   R3!, {R0,R1}    ; block copy of prepared script environment
  61. RAM_ARM9:020158D8 03 C2                       STMIA   R2!, {R0,R1}
  62. RAM_ARM9:020158DA 03 CB                       LDMIA   R3!, {R0,R1}
  63. RAM_ARM9:020158DC 03 C2                       STMIA   R2!, {R0,R1}
  64. RAM_ARM9:020158DE 03 CB                       LDMIA   R3!, {R0,R1}
  65. RAM_ARM9:020158E0 03 C2                       STMIA   R2!, {R0,R1}
  66. RAM_ARM9:020158E2 68 88                       LDRH    R0, [R5,#2]     ; global var max
  67. RAM_ARM9:020158E4 39 1C                       MOVS    R1, R7
  68. RAM_ARM9:020158E6 3C 31                       ADDS    R1, #0x3C ; '<'
  69. RAM_ARM9:020158E8 80 00                       LSLS    R0, R0, #2      ; stack max * 4 for alignment(number * size)(stack is 32-bit)
  70. RAM_ARM9:020158EA B9 62                       STR     R1, [R7,#0x28]  ; store ptr to global var store
  71. RAM_ARM9:020158EC 08 18                       ADDS    R0, R1, R0
  72. RAM_ARM9:020158EE 78 62                       STR     R0, [R7,#0x24]  ; stack ptr
  73. RAM_ARM9:020158F0 38 1C                       MOVS    R0, R7
  74. RAM_ARM9:020158F2 F8 BD                       POP     {R3-R7,PC}
  75. RAM_ARM9:020158F2             ; End of function startScriptingVirtualMachine
  76. RAM_ARM9:020158F2
  77. RAM_ARM9:020158F2             ; ---------------------------------------------------------------------------
  78. RAM_ARM9:020158F4             ; void *off_20158F4
  79. RAM_ARM9:020158F4 38 A3 09 02 off_20158F4     DCD aVm_c               ; DATA XREF: startScriptingVirtualMachine+6r
  80. RAM_ARM9:020158F4                                                     ; "vm.c"
  81. RAM_ARM9:020158F8
  82. RAM_ARM9:020158F8             ; =============== S U B R O U T I N E =======================================
  83. RAM_ARM9:020158F8
  84. RAM_ARM9:020158F8
  85. RAM_ARM9:020158F8             ; void __fastcall freeScriptingEnvironment(ScriptEnvironment *vm)
  86. RAM_ARM9:020158F8             freeScriptingEnvironment                ; CODE XREF: freeScriptingAllocations+14p
  87. RAM_ARM9:020158F8 00 4B                       LDR     R3, =(freeBlock+1)
  88. RAM_ARM9:020158FA 18 47                       BX      R3 ; freeBlock
  89. RAM_ARM9:020158FA             ; End of function freeScriptingEnvironment
  90. RAM_ARM9:020158FA
  91. RAM_ARM9:020158FA             ; ---------------------------------------------------------------------------
  92. RAM_ARM9:020158FC 79 A2 03 02 off_20158FC     DCD freeBlock+1         ; DATA XREF: freeScriptingEnvironmentr
  93. RAM_ARM9:02015900
  94. RAM_ARM9:02015900             ; =============== S U B R O U T I N E =======================================
  95. RAM_ARM9:02015900
  96. RAM_ARM9:02015900
  97. RAM_ARM9:02015900             ; void __fastcall initEnvironment(ScriptEnvironment *vm, ScrcmdEnvironment *work)
  98. RAM_ARM9:02015900             initEnvironment                         ; CODE XREF: setupScriptingEnvironment+70p
  99. RAM_ARM9:02015900 38 B5                       PUSH    {R3-R5,LR}
  100. RAM_ARM9:02015902 05 1C                       MOVS    R5, R0
  101. RAM_ARM9:02015904 0C 1C                       MOVS    R4, R1
  102. RAM_ARM9:02015906 FF F7 B9 FF                 BL      initScriptEnvironment
  103. RAM_ARM9:0201590A EC 62                       STR     R4, [R5,#ScriptEnvironment.scrcmd_ptr]
  104. RAM_ARM9:0201590C 38 BD                       POP     {R3-R5,PC}
  105. RAM_ARM9:0201590C             ; End of function initEnvironment
  106. RAM_ARM9:0201590C
  107. RAM_ARM9:0201590C             ; ---------------------------------------------------------------------------
  108. RAM_ARM9:0201590E 00                          DCB    0
  109. RAM_ARM9:0201590F 00                          DCB    0
  110. RAM_ARM9:02015910
  111. RAM_ARM9:02015910             ; =============== S U B R O U T I N E =======================================
  112. RAM_ARM9:02015910
  113. RAM_ARM9:02015910
  114. RAM_ARM9:02015910             ; void __fastcall intializeScriptEnvironment(ScriptEnvironment *vm, u8 *initial_script_ptr_pos)
  115. RAM_ARM9:02015910             intializeScriptEnvironment              ; CODE XREF: setupScriptingEnvironment+AAp
  116. RAM_ARM9:02015910 38 B5                       PUSH    {R3-R5,LR}
  117. RAM_ARM9:02015912 04 1C                       MOVS    R4, R0
  118. RAM_ARM9:02015914 0D 1C                       MOVS    R5, R1
  119. RAM_ARM9:02015916 FF F7 B1 FF                 BL      initScriptEnvironment
  120. RAM_ARM9:0201591A 01 20                       MOVS    R0, #1
  121. RAM_ARM9:0201591C 25 62                       STR     R5, [R4,#ScriptEnvironment.script_pos_ptr]
  122. RAM_ARM9:0201591E 60 76                       STRB    R0, [R4,#ScriptEnvironment.executionState]
  123. RAM_ARM9:02015920 38 BD                       POP     {R3-R5,PC}
  124. RAM_ARM9:02015920             ; End of function intializeScriptEnvironment
  125. RAM_ARM9:02015920
  126. RAM_ARM9:02015920             ; ---------------------------------------------------------------------------
  127. RAM_ARM9:02015922 00                          DCB    0
  128. RAM_ARM9:02015923 00                          DCB    0
  129. RAM_ARM9:02015924
  130. RAM_ARM9:02015924             ; =============== S U B R O U T I N E =======================================
  131. RAM_ARM9:02015924
  132. RAM_ARM9:02015924
  133. RAM_ARM9:02015924             ; void __fastcall setScriptState_End(ScriptEnvironment *vm)
  134. RAM_ARM9:02015924             setScriptState_End                      ; CODE XREF: s0002_endScript+2p
  135. RAM_ARM9:02015924                                                     ; s001D_endScriptExecution+Cp ...
  136. RAM_ARM9:02015924 00 21                       MOVS    R1, #0
  137. RAM_ARM9:02015926 41 76                       STRB    R1, [R0,#ScriptEnvironment.executionState]
  138. RAM_ARM9:02015928 01 62                       STR     R1, [R0,#ScriptEnvironment.script_pos_ptr]
  139. RAM_ARM9:0201592A 70 47                       BX      LR
  140. RAM_ARM9:0201592A             ; End of function setScriptState_End
  141. RAM_ARM9:0201592A
  142. RAM_ARM9:0201592C
  143. RAM_ARM9:0201592C             ; =============== S U B R O U T I N E =======================================
  144. RAM_ARM9:0201592C
  145. RAM_ARM9:0201592C
  146. RAM_ARM9:0201592C             ; bool __fastcall scriptHandler_main(ScriptEnvironment *vm)
  147. RAM_ARM9:0201592C             scriptHandler_main                      ; CODE XREF: runAllVirtualMachines+12p
  148. RAM_ARM9:0201592C                                                     ; execute_script+3Ep
  149. RAM_ARM9:0201592C 70 B5                       PUSH    {R4-R6,LR}
  150. RAM_ARM9:0201592E 05 1C                       MOVS    R5, R0
  151. RAM_ARM9:02015930 69 7E                       LDRB    R1, [R5,#ScriptEnvironment.executionState]
  152. RAM_ARM9:02015932 00 29                       CMP     R1, #0
  153. RAM_ARM9:02015934 04 D0                       BEQ     script_over
  154. RAM_ARM9:02015936 01 29                       CMP     R1, #1
  155. RAM_ARM9:02015938 13 D0                       BEQ     script_run
  156. RAM_ARM9:0201593A 02 29                       CMP     R1, #2
  157. RAM_ARM9:0201593C 02 D0                       BEQ     run_assembly
  158. RAM_ARM9:0201593E 49 E0                       B       pause_script_interpreter
  159. RAM_ARM9:02015940             ; ---------------------------------------------------------------------------
  160. RAM_ARM9:02015940
  161. RAM_ARM9:02015940             script_over                             ; CODE XREF: scriptHandler_main+8j
  162. RAM_ARM9:02015940 00 20                       MOVS    R0, #0
  163. RAM_ARM9:02015942 70 BD                       POP     {R4-R6,PC}
  164. RAM_ARM9:02015944             ; ---------------------------------------------------------------------------
  165. RAM_ARM9:02015944
  166. RAM_ARM9:02015944             run_assembly                            ; CODE XREF: scriptHandler_main+10j
  167. RAM_ARM9:02015944 EA 69                       LDR     R2, [R5,#ScriptEnvironment.funcptr] ; get assembly routine to run
  168. RAM_ARM9:02015946 00 2A                       CMP     R2, #0          ; is there a routine?
  169. RAM_ARM9:02015948 09 D0                       BEQ     swap_asm_to_script ; if not, there may have been a mistake.  jump back to script execution
  170. RAM_ARM9:0201594A E9 6A                       LDR     R1, [R5,#ScriptEnvironment.scrcmd_ptr] ; load script command info struct ptr
  171. RAM_ARM9:0201594C 90 47                       BLX     R2
  172. RAM_ARM9:0201594E 01 28                       CMP     R0, #1
  173. RAM_ARM9:02015950 03 D1                       BNE     exit_success
  174. RAM_ARM9:02015952 00 20                       MOVS    R0, #0
  175. RAM_ARM9:02015954 E8 61                       STR     R0, [R5,#ScriptEnvironment.funcptr] ; set asm routine ptr to 0 after it runs
  176. RAM_ARM9:02015956 01 20                       MOVS    R0, #1
  177. RAM_ARM9:02015958 68 76                       STRB    R0, [R5,#ScriptEnvironment.executionState] ; set script handler status back to executing scripts instead of asm
  178. RAM_ARM9:0201595A
  179. RAM_ARM9:0201595A             exit_success                            ; CODE XREF: scriptHandler_main+24j
  180. RAM_ARM9:0201595A 01 20                       MOVS    R0, #1          ; always exit after running assembly
  181. RAM_ARM9:0201595C 70 BD                       POP     {R4-R6,PC}
  182. RAM_ARM9:0201595E             ; ---------------------------------------------------------------------------
  183. RAM_ARM9:0201595E
  184. RAM_ARM9:0201595E             swap_asm_to_script                      ; CODE XREF: scriptHandler_main+1Cj
  185. RAM_ARM9:0201595E 01 20                       MOVS    R0, #1          ; change from r5 + 0x19 = 2 to r5 + 0x19 = 1, so switch to script execution, not assembly execution
  186. RAM_ARM9:02015960 68 76                       STRB    R0, [R5,#ScriptEnvironment.executionState]
  187. RAM_ARM9:02015962
  188. RAM_ARM9:02015962             script_run                              ; CODE XREF: scriptHandler_main+Cj
  189. RAM_ARM9:02015962                                                     ; scriptHandler_main+7Aj ...
  190. RAM_ARM9:02015962 28 6A                       LDR     R0, [R5,#ScriptEnvironment.script_pos_ptr] ; load ptr to next script command to be read
  191. RAM_ARM9:02015964 00 28                       CMP     R0, #0
  192. RAM_ARM9:02015966 02 D1                       BNE     script_continue
  193. RAM_ARM9:02015968 00 20                       MOVS    R0, #0
  194. RAM_ARM9:0201596A 68 76                       STRB    R0, [R5,#ScriptEnvironment.executionState] ; if the next command is 0, set the continuance byte to 0 and exit
  195. RAM_ARM9:0201596C 70 BD                       POP     {R4-R6,PC}
  196. RAM_ARM9:0201596E             ; ---------------------------------------------------------------------------
  197. RAM_ARM9:0201596E
  198. RAM_ARM9:0201596E             script_continue                         ; CODE XREF: scriptHandler_main+3Aj
  199. RAM_ARM9:0201596E 28 1C                       MOVS    R0, R5          ; vm
  200. RAM_ARM9:02015970 00 F0 3A F8                 BL      scriptRead16
  201. RAM_ARM9:02015974 04 1C                       MOVS    R4, R0
  202. RAM_ARM9:02015976 A8 68                       LDR     R0, [R5,#ScriptEnvironment.cmdMax] ; get total scrcmd count(0x2F3)
  203. RAM_ARM9:02015978 84 42                       CMP     R4, R0          ; is this command valid?(is it 2F2 or less)
  204. RAM_ARM9:0201597A 15 D3                       BCC     verify_scrcmd
  205. RAM_ARM9:0201597C 6B 69                       LDR     R3, [R5,#0x14]
  206. RAM_ARM9:0201597E 9C 42                       CMP     R4, R3
  207. RAM_ARM9:02015980 06 D3                       BCC     loc_2015990
  208. RAM_ARM9:02015982 28 69                       LDR     R0, [R5,#0x10]
  209. RAM_ARM9:02015984 C0 18                       ADDS    R0, R0, R3
  210. RAM_ARM9:02015986 84 42                       CMP     R4, R0
  211. RAM_ARM9:02015988 02 D2                       BCS     loc_2015990
  212. RAM_ARM9:0201598A EA 68                       LDR     R2, [R5,#0xC]
  213. RAM_ARM9:0201598C 00 2A                       CMP     R2, #0
  214. RAM_ARM9:0201598E 02 D1                       BNE     loc_2015996
  215. RAM_ARM9:02015990
  216. RAM_ARM9:02015990             loc_2015990                             ; CODE XREF: scriptHandler_main+54j
  217. RAM_ARM9:02015990                                                     ; scriptHandler_main+5Cj
  218. RAM_ARM9:02015990 00 20                       MOVS    R0, #0
  219. RAM_ARM9:02015992 68 76                       STRB    R0, [R5,#0x19]
  220. RAM_ARM9:02015994 70 BD                       POP     {R4-R6,PC}
  221. RAM_ARM9:02015996             ; ---------------------------------------------------------------------------
  222. RAM_ARM9:02015996
  223. RAM_ARM9:02015996             loc_2015996                             ; CODE XREF: scriptHandler_main+62j
  224. RAM_ARM9:02015996 E3 1A                       SUBS    R3, R4, R3
  225. RAM_ARM9:02015998 9B 00                       LSLS    R3, R3, #2
  226. RAM_ARM9:0201599A E9 6A                       LDR     R1, [R5,#ScriptEnvironment.scrcmd_ptr]
  227. RAM_ARM9:0201599C D2 58                       LDR     R2, [R2,R3]
  228. RAM_ARM9:0201599E 28 1C                       MOVS    R0, R5
  229. RAM_ARM9:020159A0 90 47                       BLX     R2
  230. RAM_ARM9:020159A2 01 28                       CMP     R0, #1
  231. RAM_ARM9:020159A4 18 D0                       BEQ     script_done_success
  232. RAM_ARM9:020159A6 DC E7                       B       script_run
  233. RAM_ARM9:020159A8             ; ---------------------------------------------------------------------------
  234. RAM_ARM9:020159A8
  235. RAM_ARM9:020159A8             verify_scrcmd                           ; CODE XREF: scriptHandler_main+4Ej
  236. RAM_ARM9:020159A8 2E 6B                       LDR     R6, [R5,#ScriptEnvironment.script_callback_verifier]
  237. RAM_ARM9:020159AA 00 2E                       CMP     R6, #0
  238. RAM_ARM9:020159AC 09 D0                       BEQ     execute_scr_cmd
  239. RAM_ARM9:020159AE E9 6A                       LDR     R1, [R5,#ScriptEnvironment.scrcmd_ptr]
  240. RAM_ARM9:020159B0 6A 6B                       LDR     R2, [R5,#ScriptEnvironment.sys_info]
  241. RAM_ARM9:020159B2 28 1C                       MOVS    R0, R5
  242. RAM_ARM9:020159B4 23 1C                       MOVS    R3, R4
  243. RAM_ARM9:020159B6 B0 47                       BLX     R6
  244. RAM_ARM9:020159B8 00 28                       CMP     R0, #0
  245. RAM_ARM9:020159BA 02 D1                       BNE     execute_scr_cmd
  246. RAM_ARM9:020159BC 00 20                       MOVS    R0, #0
  247. RAM_ARM9:020159BE 68 76                       STRB    R0, [R5,#ScriptEnvironment.executionState]
  248. RAM_ARM9:020159C0 70 BD                       POP     {R4-R6,PC}
  249. RAM_ARM9:020159C2             ; ---------------------------------------------------------------------------
  250. RAM_ARM9:020159C2
  251. RAM_ARM9:020159C2             execute_scr_cmd                         ; CODE XREF: scriptHandler_main+80j
  252. RAM_ARM9:020159C2                                                     ; scriptHandler_main+8Ej
  253. RAM_ARM9:020159C2 6B 68                       LDR     R3, [R5,#ScriptEnvironment.cmdArray] ; load address of script command function array
  254. RAM_ARM9:020159C4 A2 00                       LSLS    R2, R4, #2      ; 4-byte alignment
  255. RAM_ARM9:020159C6 E9 6A                       LDR     R1, [R5,#ScriptEnvironment.scrcmd_ptr] ; load script command info pointer
  256. RAM_ARM9:020159C8 9A 58                       LDR     R2, [R3,R2]
  257. RAM_ARM9:020159CA 28 1C                       MOVS    R0, R5
  258. RAM_ARM9:020159CC 90 47                       BLX     R2
  259. RAM_ARM9:020159CE 01 28                       CMP     R0, #1          ; did we hit the end of the script? (1 = yes)
  260. RAM_ARM9:020159D0 02 D0                       BEQ     script_done_success
  261. RAM_ARM9:020159D2 C6 E7                       B       script_run
  262. RAM_ARM9:020159D4             ; ---------------------------------------------------------------------------
  263. RAM_ARM9:020159D4
  264. RAM_ARM9:020159D4             pause_script_interpreter                ; CODE XREF: scriptHandler_main+12j
  265. RAM_ARM9:020159D4 00 20                       MOVS    R0, #0
  266. RAM_ARM9:020159D6 68 76                       STRB    R0, [R5,#ScriptEnvironment.executionState]
  267. RAM_ARM9:020159D8
  268. RAM_ARM9:020159D8             script_done_success                     ; CODE XREF: scriptHandler_main+78j
  269. RAM_ARM9:020159D8                                                     ; scriptHandler_main+A4j
  270. RAM_ARM9:020159D8 01 20                       MOVS    R0, #1
  271. RAM_ARM9:020159DA 70 BD                       POP     {R4-R6,PC}
  272. RAM_ARM9:020159DA             ; End of function scriptHandler_main
  273. RAM_ARM9:020159DA
  274. RAM_ARM9:020159DC
  275. RAM_ARM9:020159DC             ; =============== S U B R O U T I N E =======================================
  276. RAM_ARM9:020159DC
  277. RAM_ARM9:020159DC
  278. RAM_ARM9:020159DC             ; ScrcmdEnvironment *__fastcall getScrcmdEnvironment(ScriptEnvironment *vm)
  279. RAM_ARM9:020159DC             getScrcmdEnvironment                    ; CODE XREF: freeScriptingAllocations+4p
  280. RAM_ARM9:020159DC                                                     ; setScriptCallbackVerifier+4p
  281. RAM_ARM9:020159DC C0 6A                       LDR     R0, [R0,#ScriptEnvironment.scrcmd_ptr]
  282. RAM_ARM9:020159DE 70 47                       BX      LR
  283. RAM_ARM9:020159DE             ; End of function getScrcmdEnvironment
  284. RAM_ARM9:020159DE
  285. RAM_ARM9:020159E0
  286. RAM_ARM9:020159E0             ; =============== S U B R O U T I N E =======================================
  287. RAM_ARM9:020159E0
  288. RAM_ARM9:020159E0
  289. RAM_ARM9:020159E0             saveScriptCallbackSysinfo               ; CODE XREF: setScriptCallbackVerifier+12p
  290. RAM_ARM9:020159E0 01 63                       STR     R1, [R0,#ScriptEnvironment.script_callback_verifier]
  291. RAM_ARM9:020159E2 42 63                       STR     R2, [R0,#ScriptEnvironment.sys_info]
  292. RAM_ARM9:020159E4 70 47                       BX      LR
  293. RAM_ARM9:020159E4             ; End of function saveScriptCallbackSysinfo
  294. RAM_ARM9:020159E4
  295. RAM_ARM9:020159E4             ; ---------------------------------------------------------------------------
  296. RAM_ARM9:020159E6 00                          DCB    0
  297. RAM_ARM9:020159E7 00                          DCB    0
  298. RAM_ARM9:020159E8
  299. RAM_ARM9:020159E8             ; =============== S U B R O U T I N E =======================================
  300. RAM_ARM9:020159E8
  301. RAM_ARM9:020159E8
  302. RAM_ARM9:020159E8             ; u16 __fastcall scriptRead16(ScriptEnvironment *vm)
  303. RAM_ARM9:020159E8             scriptRead16                            ; CODE XREF: scriptHandler_main+44p
  304. RAM_ARM9:020159E8                                                     ; s0003_pauseScriptSysForXTurns+6p ...
  305. RAM_ARM9:020159E8 02 6A                       LDR     R2, [R0,#ScriptEnvironment.script_pos_ptr] ; load offset of next script command
  306. RAM_ARM9:020159EA 13 78                       LDRB    R3, [R2]        ; load next byte of script
  307. RAM_ARM9:020159EC 51 1C                       ADDS    R1, R2, #1      ; add 1 to current script command offset ptr
  308. RAM_ARM9:020159EE 01 62                       STR     R1, [R0,#ScriptEnvironment.script_pos_ptr] ; store that pointer back to script info base
  309. RAM_ARM9:020159F0 52 78                       LDRB    R2, [R2,#1]     ; load next byte of current script command
  310. RAM_ARM9:020159F2 49 1C                       ADDS    R1, R1, #1      ; add 1 to current script command offset ptr
  311. RAM_ARM9:020159F4 01 62                       STR     R1, [R0,#ScriptEnvironment.script_pos_ptr] ; store that pointer back to script info base
  312. RAM_ARM9:020159F6 10 06                       LSLS    R0, R2, #0x18
  313. RAM_ARM9:020159F8 00 0C                       LSRS    R0, R0, #0x10
  314. RAM_ARM9:020159FA 18 18                       ADDS    R0, R3, R0
  315. RAM_ARM9:020159FC 00 04                       LSLS    R0, R0, #0x10
  316. RAM_ARM9:020159FE 00 0C                       LSRS    R0, R0, #0x10
  317. RAM_ARM9:02015A00 70 47                       BX      LR
  318. RAM_ARM9:02015A00             ; End of function scriptRead16
  319. RAM_ARM9:02015A00
  320. RAM_ARM9:02015A00             ; ---------------------------------------------------------------------------
  321. RAM_ARM9:02015A02 00                          DCB    0
  322. RAM_ARM9:02015A03 00                          DCB    0
  323. RAM_ARM9:02015A04
  324. RAM_ARM9:02015A04             ; =============== S U B R O U T I N E =======================================
  325. RAM_ARM9:02015A04
  326. RAM_ARM9:02015A04
  327. RAM_ARM9:02015A04             ; u32 __fastcall scriptRead32(ScriptEnvironment *vm)
  328. RAM_ARM9:02015A04             scriptRead32                            ; CODE XREF: setupScriptingEnvironment+BAp
  329. RAM_ARM9:02015A04                                                     ; s0004_pushPCAndJumpToLeafScript+4p ...
  330. RAM_ARM9:02015A04 30 B4                       PUSH    {R4,R5}
  331. RAM_ARM9:02015A06 02 6A                       LDR     R2, [R0,#ScriptEnvironment.script_pos_ptr]
  332. RAM_ARM9:02015A08 13 78                       LDRB    R3, [R2]
  333. RAM_ARM9:02015A0A 51 1C                       ADDS    R1, R2, #1
  334. RAM_ARM9:02015A0C 4D 1C                       ADDS    R5, R1, #1
  335. RAM_ARM9:02015A0E 01 62                       STR     R1, [R0,#ScriptEnvironment.script_pos_ptr]
  336. RAM_ARM9:02015A10 52 78                       LDRB    R2, [R2,#1]
  337. RAM_ARM9:02015A12 6C 1C                       ADDS    R4, R5, #1
  338. RAM_ARM9:02015A14 05 62                       STR     R5, [R0,#ScriptEnvironment.script_pos_ptr]
  339. RAM_ARM9:02015A16 49 78                       LDRB    R1, [R1,#1]
  340. RAM_ARM9:02015A18 04 62                       STR     R4, [R0,#ScriptEnvironment.script_pos_ptr]
  341. RAM_ARM9:02015A1A 6D 78                       LDRB    R5, [R5,#1]
  342. RAM_ARM9:02015A1C 64 1C                       ADDS    R4, R4, #1
  343. RAM_ARM9:02015A1E 04 62                       STR     R4, [R0,#ScriptEnvironment.script_pos_ptr]
  344. RAM_ARM9:02015A20 00 20                       MOVS    R0, #0
  345. RAM_ARM9:02015A22 40 19                       ADDS    R0, R0, R5
  346. RAM_ARM9:02015A24 00 02                       LSLS    R0, R0, #8
  347. RAM_ARM9:02015A26 40 18                       ADDS    R0, R0, R1
  348. RAM_ARM9:02015A28 00 02                       LSLS    R0, R0, #8
  349. RAM_ARM9:02015A2A 80 18                       ADDS    R0, R0, R2
  350. RAM_ARM9:02015A2C 00 02                       LSLS    R0, R0, #8
  351. RAM_ARM9:02015A2E C0 18                       ADDS    R0, R0, R3
  352. RAM_ARM9:02015A30 30 BC                       POP     {R4,R5}
  353. RAM_ARM9:02015A32 70 47                       BX      LR
  354. RAM_ARM9:02015A32             ; End of function scriptRead32
  355. RAM_ARM9:02015A32
  356. RAM_ARM9:02015A34
  357. RAM_ARM9:02015A34             ; =============== S U B R O U T I N E =======================================
  358. RAM_ARM9:02015A34
  359. RAM_ARM9:02015A34
  360. RAM_ARM9:02015A34             ; void __fastcall pushScriptStack(ScriptEnvironment *vm, u32 val)
  361. RAM_ARM9:02015A34             pushScriptStack                         ; CODE XREF: pushProgramCounterAndSetNew+8p
  362. RAM_ARM9:02015A34                                                     ; s0008_pushParamVarToScriptStack+Cp ...
  363. RAM_ARM9:02015A34 18 B4                       PUSH    {R3,R4}
  364. RAM_ARM9:02015A36 04 7E                       LDRB    R4, [R0,#0x18]
  365. RAM_ARM9:02015A38 02 88                       LDRH    R2, [R0]
  366. RAM_ARM9:02015A3A 63 1C                       ADDS    R3, R4, #1
  367. RAM_ARM9:02015A3C 93 42                       CMP     R3, R2
  368. RAM_ARM9:02015A3E 05 DA                       BGE     loc_2015A4C
  369. RAM_ARM9:02015A40 43 6A                       LDR     R3, [R0,#0x24]
  370. RAM_ARM9:02015A42 A2 00                       LSLS    R2, R4, #2
  371. RAM_ARM9:02015A44 99 50                       STR     R1, [R3,R2]
  372. RAM_ARM9:02015A46 01 7E                       LDRB    R1, [R0,#0x18]
  373. RAM_ARM9:02015A48 49 1C                       ADDS    R1, R1, #1
  374. RAM_ARM9:02015A4A 01 76                       STRB    R1, [R0,#0x18]
  375. RAM_ARM9:02015A4C
  376. RAM_ARM9:02015A4C             loc_2015A4C                             ; CODE XREF: pushScriptStack+Aj
  377. RAM_ARM9:02015A4C 18 BC                       POP     {R3,R4}
  378. RAM_ARM9:02015A4E 70 47                       BX      LR
  379. RAM_ARM9:02015A4E             ; End of function pushScriptStack
  380. RAM_ARM9:02015A4E
  381. RAM_ARM9:02015A50
  382. RAM_ARM9:02015A50             ; =============== S U B R O U T I N E =======================================
  383. RAM_ARM9:02015A50
  384. RAM_ARM9:02015A50
  385. RAM_ARM9:02015A50             ; u32 __fastcall popScriptStack(ScriptEnvironment *vm)
  386. RAM_ARM9:02015A50             popScriptStack                          ; CODE XREF: popStackProgramCounter+4p
  387. RAM_ARM9:02015A50                                                     ; s0007_popScriptStackDerefParamVar+6p ...
  388. RAM_ARM9:02015A50 01 7E                       LDRB    R1, [R0,#0x18]
  389. RAM_ARM9:02015A52 00 29                       CMP     R1, #0
  390. RAM_ARM9:02015A54 01 D1                       BNE     loc_2015A5A
  391. RAM_ARM9:02015A56 00 20                       MOVS    R0, #0
  392. RAM_ARM9:02015A58 70 47                       BX      LR
  393. RAM_ARM9:02015A5A             ; ---------------------------------------------------------------------------
  394. RAM_ARM9:02015A5A
  395. RAM_ARM9:02015A5A             loc_2015A5A                             ; CODE XREF: popScriptStack+4j
  396. RAM_ARM9:02015A5A 49 1E                       SUBS    R1, R1, #1
  397. RAM_ARM9:02015A5C 01 76                       STRB    R1, [R0,#0x18]
  398. RAM_ARM9:02015A5E 41 6A                       LDR     R1, [R0,#0x24]
  399. RAM_ARM9:02015A60 00 7E                       LDRB    R0, [R0,#0x18]
  400. RAM_ARM9:02015A62 80 00                       LSLS    R0, R0, #2
  401. RAM_ARM9:02015A64 08 58                       LDR     R0, [R1,R0]
  402. RAM_ARM9:02015A66 70 47                       BX      LR
  403. RAM_ARM9:02015A66             ; End of function popScriptStack
  404. RAM_ARM9:02015A66
  405. RAM_ARM9:02015A68
  406. RAM_ARM9:02015A68             ; =============== S U B R O U T I N E =======================================
  407. RAM_ARM9:02015A68
  408. RAM_ARM9:02015A68
  409. RAM_ARM9:02015A68             ; void __fastcall jumpScrPos(ScriptEnvironment *vm, u32 address)
  410. RAM_ARM9:02015A68             jumpScrPos                              ; CODE XREF: s001E_unconditionalJump+10p
  411. RAM_ARM9:02015A68                                                     ; s001F_conditionalJump+38p
  412. RAM_ARM9:02015A68 01 62                       STR     R1, [R0,#0x20]
  413. RAM_ARM9:02015A6A 70 47                       BX      LR
  414. RAM_ARM9:02015A6A             ; End of function jumpScrPos
  415. RAM_ARM9:02015A6A
  416. RAM_ARM9:02015A6C
  417. RAM_ARM9:02015A6C             ; =============== S U B R O U T I N E =======================================
  418. RAM_ARM9:02015A6C
  419. RAM_ARM9:02015A6C
  420. RAM_ARM9:02015A6C             ; void __fastcall pushProgramCounterAndSetNew(ScriptEnvironment *vm, void *pJumpScript)
  421. RAM_ARM9:02015A6C             pushProgramCounterAndSetNew             ; CODE XREF: s0004_pushPCAndJumpToLeafScript+10p
  422. RAM_ARM9:02015A6C                                                     ; s0020_conditionalCall+28p
  423. RAM_ARM9:02015A6C 38 B5                       PUSH    {R3-R5,LR}
  424. RAM_ARM9:02015A6E 05 1C                       MOVS    R5, R0
  425. RAM_ARM9:02015A70 0C 1C                       MOVS    R4, R1
  426. RAM_ARM9:02015A72 29 6A                       LDR     R1, [R5,#0x20]  ; val
  427. RAM_ARM9:02015A74 FF F7 DE FF                 BL      pushScriptStack
  428. RAM_ARM9:02015A78 2C 62                       STR     R4, [R5,#0x20]
  429. RAM_ARM9:02015A7A 38 BD                       POP     {R3-R5,PC}
  430. RAM_ARM9:02015A7A             ; End of function pushProgramCounterAndSetNew
  431. RAM_ARM9:02015A7A
  432. RAM_ARM9:02015A7C
  433. RAM_ARM9:02015A7C             ; =============== S U B R O U T I N E =======================================
  434. RAM_ARM9:02015A7C
  435. RAM_ARM9:02015A7C
  436. RAM_ARM9:02015A7C             ; void __fastcall popStackProgramCounter(ScriptEnvironment *vm)
  437. RAM_ARM9:02015A7C             popStackProgramCounter                  ; CODE XREF: s0005_setStackToProgramCounter+2p
  438. RAM_ARM9:02015A7C 10 B5                       PUSH    {R4,LR}
  439. RAM_ARM9:02015A7E 04 1C                       MOVS    R4, R0
  440. RAM_ARM9:02015A80 FF F7 E6 FF                 BL      popScriptStack
  441. RAM_ARM9:02015A84 20 62                       STR     R0, [R4,#0x20]
  442. RAM_ARM9:02015A86 10 BD                       POP     {R4,PC}
  443. RAM_ARM9:02015A86             ; End of function popStackProgramCounter
  444. RAM_ARM9:02015A86
  445. RAM_ARM9:02015A88
  446. RAM_ARM9:02015A88             ; =============== S U B R O U T I N E =======================================
  447. RAM_ARM9:02015A88
  448. RAM_ARM9:02015A88
  449. RAM_ARM9:02015A88             ; void __fastcall setScriptState_Asm(ScriptEnvironment *vm, AsmCall *func_ptr)
  450. RAM_ARM9:02015A88             setScriptState_Asm                      ; CODE XREF: s0003_pauseScriptSysForXTurns+16p
  451. RAM_ARM9:02015A88                                                     ; s001C_callScriptLib+4Ap ...
  452. RAM_ARM9:02015A88 02 22                       MOVS    R2, #2
  453. RAM_ARM9:02015A8A 42 76                       STRB    R2, [R0,#0x19]
  454. RAM_ARM9:02015A8C C1 61                       STR     R1, [R0,#0x1C]
  455. RAM_ARM9:02015A8E 70 47                       BX      LR
  456. RAM_ARM9:02015A8E             ; End of function setScriptState_Asm
RAW Paste Data