Advertisement
NewDenverCity

incomplete relic song .s file. needs battle script

Jan 5th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.04 KB | None | 0 0
  1. .thumb
  2. @in this example, pirouette form is 0xF1, and aria is 0xF0
  3.  
  4. .equ asm_offset, 0x08800000
  5. .equ battle_script, 0x08810000
  6. .equ end_battle_hook_offset, 0x08820000
  7. .equ faint_hook_offset, 0x08830000
  8. .equ nopalfade_offset, 0x08840000
  9. .equ revert_offset, 0x08850000
  10.  
  11. .align 2
  12. .org 0x080159DC
  13. end_battle:
  14. ldr r0, hooky_thing
  15. bx r0
  16. .align 2
  17. hooky_thing: .word end_battle_hook_offset + 1
  18.  
  19. .align 2
  20. .org 0x080326C4
  21. fainting:
  22. ldr r3, faint_thingy
  23. bx r3
  24. .align 2
  25. faint_thingy: .word faint_hook_offset + 1
  26.  
  27. .align 2
  28. .org 0x08034FFC
  29. nopalfade_hook:
  30. ldr r0, nopalfade
  31. bx r0
  32. .align 2
  33. nopalfade: .word nopalfade_offset + 1
  34.  
  35. @@@@@@@@@@@@@@@@asm called in battle script
  36. .align 2
  37. .org asm_offset
  38. check_pkmn_id:
  39. push {lr}
  40. ldr r0, attacking_bank
  41. ldrb r1, [r0] @which mon did the attack
  42. ldr r0, ram_pointer
  43. ldr r0, [r0]
  44. add r0, r0, #0x60
  45. cmp r1, #0x0
  46. beq set_player_singles
  47. cmp r1, #0x1
  48. beq set_enemy_singles
  49. cmp r1, #0x2
  50. beq set_player_doubles
  51. cmp r1, #0x3
  52. beq set_enemy_doubles
  53. get_battle_struct:
  54. ldr r0, attacking_bank
  55. ldrb r1, [r0] @which mon did the attack
  56. mov r0, #0x58 @length of battle structs
  57. mul r1, r0, r1 @multiplies length of battle structs with which mon did the attack to get the the battle structure i'm working with
  58. ldr r0, battle_struct
  59. add r0, r1, r0 @r0 is the battle struct i'm working with
  60. check_if_aria:
  61. add r2, r2, #0x20
  62. ldrh r1, [r2]
  63. cmp r1, #0xF0
  64. bne end
  65. set_pirouette_forme:
  66. mov r1, #0xF1
  67. strh r1, [r0] @species in battle struct is now the correct thing
  68. strh r1, [r2] @species in party is now pirouette's
  69. sub r2, r2, #0x20 @makes r2 go to the beginning of the party again
  70. push {r0}
  71. mov r0, r2
  72. mov r1, r2
  73. push {r2}
  74. ldr r3, calc_stats0
  75. bl jump @stats should be calculated
  76. pop {r2}
  77. pop {r0} @r2 is the beginning of the party slot, r0 is the beginning of the battle struct
  78. update_type:
  79. add r0, #0x22
  80. mov r1, #0x1
  81. strb r1, [r0] @second type in battle struct is now fighting
  82. update_battle_struct:
  83. sub r0, r0, #0x20
  84. add r2, r2, #0x5A @r0 is at the attack stat, r2 is at the party attack stat
  85. mov r3, #0x0
  86. stat_loop:
  87. ldrh r1, [r2]
  88. strh r1, [r0]
  89. add r0, r0, #0x2
  90. add r2, r2, #0x2
  91. add r3, r3, #0x1
  92. cmp r3, #0x4
  93. bne stat_loop
  94. end:
  95. pop {pc}
  96. jump:
  97. mov pc, r3
  98. set_player_singles:
  99. ldrb r0, [r0]
  100. lsr r0, #0x4 @only one digit is left
  101. mov r1, #0x64 @length of party entry
  102. ldr r2, player_party0
  103. mul r0, r0, r1
  104. add r2, r0, r2 @gets r2 to the correct slot
  105. b get_battle_struct
  106. set_enemy_singles:
  107. add r0, r0, #0x3 @gets to party order for enemy
  108. ldrb r0, [r0]
  109. lsr r0, #0x4
  110. mov r1, #0x64
  111. ldr r2, enemy_party0
  112. mul r0, r0, r1
  113. add r2, r0, r2
  114. b get_battle_struct
  115. set_player_doubles:
  116. ldrb r0, [r0]
  117. lsl r0, #0x1C
  118. lsr r0, #0x1C @gets the second pokemon's location
  119. mov r1, #0x64
  120. ldr r2, player_party0
  121. mul r0, r0, r1
  122. add r2, r0, r2
  123. b get_battle_struct
  124. set_enemy_doubles:
  125. add r0, r0, #0x3
  126. ldrb r0, [r0]
  127. lsl r0, #0x1C
  128. lsr r0, #0x1C
  129. mov r1, #0x64
  130. ldr r2, enemy_party0
  131. mul r0, r0, r1
  132. add r2, r0, r2
  133. b get_battle_struct
  134.  
  135. .align 2
  136. battle_struct: .word 0x02023BE4
  137. player_party0: .word 0x02024284
  138. enemy_party0: .word 0x0202402C
  139. order_pointer: .word 0x02023FE8
  140. attacking_bank: .word 0x02023D6B
  141. calc_stats0: .word 0x0803E47C
  142. ram_pointer: .word 0x02023FE8
  143.  
  144. @@@@@@@@@@@@@@@@end battle hook
  145. .align 2
  146. .org end_battle_hook_offset
  147. start_end_battle:
  148. push {r0-r4}
  149. ldr r0, player_party1
  150. ldr r1, revert_to_aria_forme
  151. bl jump_with_r1
  152. ldr r0, ram_loc0
  153. mov r1, #0x0
  154. strh r1, [r0]
  155. pop {r0-r4}
  156. ldr r1, wut1
  157. ldr r0, wut2
  158. str r0, [r1]
  159. ldr r1, wut3
  160. ldr r0, continuing
  161. bx r0
  162. jump_with_r1:
  163. mov pc, r1
  164.  
  165. .align 2
  166. revert_to_aria_forme: .word revert_offset
  167. ram_loc0: .word 0x020370D4
  168. player_party1: .word 0x02024284
  169. wut1: .word 0x03004F84
  170. wut2: .word 0x08015A31
  171. wut3: .word 0x0300537C
  172. continuing: .word 0x080159E5
  173.  
  174. @@@@@@@@@@@@@@@@faint hook
  175. .align 2
  176. .org faint_hook_offset
  177. faint_hook:
  178. add r0, r2
  179. push {r0-r3}
  180. ldr r0, player_party
  181. ldr r3, revert_to_aria
  182. bl call_via_r3
  183. ldr r0, ram_loc1
  184. mov r1, #0x0
  185. strh r1, [r0]
  186. pop {r0-r3}
  187. continue_with_faint:
  188. ldr r3, fainting_call
  189. bl call_via_r3
  190. mov r1, #0x40
  191. ldr r3, return_fainting
  192. call_via_r3:
  193. bx r3
  194.  
  195. .align 2
  196. revert_to_aria: .word revert_offset + 1
  197. player_party: .word 0x02024284
  198. ram_loc1: .word 0x020370D4
  199. fainting_call: .word 0x08035244 + 1
  200. return_fainting: .word 0x080326CC + 1
  201.  
  202. @@@@@@@@@@@@@@@@
  203. .align 2
  204. .org nopalfade_offset
  205. start_nopalfade:
  206. ldr r0, current_move
  207. ldrh r0, [r0]
  208. cmp r0, #0x90 @compares move to Tranform
  209. bne skip
  210. continue_with_fade:
  211. ldr r3, thing
  212. mov r0, r10
  213. mov r1, #0x10
  214. mov r2, #0x6
  215. ldr r4, palfade
  216. bl jump_with_r4
  217. ldr r1, return
  218. mov pc, r1
  219. skip:
  220. ldr r0, return2
  221. mov pc, r0
  222. jump_with_r4:
  223. mov pc, r4
  224.  
  225. .align 2
  226. current_move: .word 0x02023D4A
  227. thing: .word 0x7FFF
  228. palfade: .word 0x08045274
  229. return: .word 0x08035008
  230. return2: .word 0x08035028
  231.  
  232. @@@@@@@@@@@@@@@@
  233. .align 2
  234. .org revert_offset
  235. .thumb @the hooks decide whether or not to use the enemy's party table or
  236. .align 2 @the player's, that's why they're not here.
  237.  
  238. start:
  239. push {r0-r3, lr}
  240. add r0, r0, #0x20
  241. loop:
  242. ldrh r1, [r0]
  243. cmp r1, #0xF1 @compares the species to pirouette forme
  244. beq push_hp @if the pokemon is pirouette forme, reverts the pokemon
  245. add r0, r0, #0x64 @goes to the next slot
  246. add r2, r2, #0x1 @sets counter to one more
  247. cmp r2, #0x5 @checks if whole party has been scanned
  248. bne loop @if it hasn't happened 6 times it'll loop again
  249. end_if_no_pirouette:
  250. pop {r0-r3, pc} @ends if nothing in the party is pirouette forme
  251. push_hp:
  252. add r0, r0, #0x36
  253. ldrh r3, [r0]
  254. mov r4, r0
  255. push {r3}
  256. push {r4}
  257. revert:
  258. mov r1, #0x84
  259. strh r1, [r0] @makes species aria forme
  260. sub r0, r0, #0x56 @makes r0 the beginning of the party
  261. mov r1, r0 @r0 and r1 should be the same
  262. ldr r2, calc_stats
  263. bl jump_with_r2
  264. fix_hp:
  265. pop {r4}
  266. pop {r3} @r3 is the current hp, r4 is the offset of that
  267. strh r3, [r4]
  268. end_revert:
  269. pop {r0-r3, pc} @ends
  270. jump_with_r2:
  271. mov pc, r2 @executes calc_stats
  272.  
  273. .align 2
  274. calc_stats: .word 0x0803E47C
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement