Advertisement
NewDenverCity

spikes_rewrite.s

May 3rd, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.10 KB | None | 0 0
  1. .thumb
  2. .global spikes_rewrite
  3.  
  4. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  5.  
  6. .equ rom, 0x08000000
  7. .equ offset, 0xF00000
  8.  
  9. .equ Normal, 0
  10. .equ Fighting, 1
  11. .equ Flying, 2
  12. .equ Poison, 3
  13. .equ Ground, 4
  14. .equ Rock, 5
  15. .equ Bug, 6
  16. .equ Ghost, 7
  17. .equ Steel, 8
  18. .equ Fire, 0xA
  19. .equ Water, 0xB
  20. .equ Grass, 0xC
  21. .equ Electric, 0xD
  22. .equ Psychic, 0xE
  23. .equ Ice, 0xF
  24. .equ Dragon, 0x10
  25. .equ Dark, 0x11
  26. .equ Fairy, 23
  27.  
  28. .equ Spikes, 0xBF
  29. .equ Stealth_Rock, 0x1D4
  30. .equ Toxic_Spikes, 0x1D5
  31. .equ Sticky_Web, 0x1E1
  32.  
  33. .equ Immunity, 0x11
  34. .equ Levitate, 0x1A
  35. .equ Magic_Guard, 0xAB
  36.  
  37. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  38.  
  39. .org 0x9063FB
  40. .word main + rom + 1
  41.  
  42. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  43.  
  44. .org offset
  45. .align 1
  46. main:
  47. push {r4-r7, lr}
  48. mov r0, #0
  49. bl get_battle_side_something @get defender
  50. mov r4, r0 @r4 is the bank we're using
  51. mov r1, #0x58 @size_of(battle_struct)
  52. mul r0, r1
  53. ldr r1, battle_struct
  54. add r6, r0, r1 @r6 is the battle_struct
  55. mov r1, #0xC
  56. mul r0, r1
  57. ldr r1, timers
  58. add r0, r1
  59. ldrb r0, [r0, #0xA] @spike bits
  60. mov r1, #0x3F @00WRTTSS
  61. and r0, r1
  62. mov r5, r0
  63.  
  64. type_checks_start:
  65. mov r0, r6
  66. add r0, #0x21
  67. ldrb r0, [r0]
  68. mov r1, #0xC @toxic_spikes bits
  69. mov r2, #0x2F @everything but stealth rock
  70. mov r3, #0
  71. type_check_loop_thing:
  72. cmp r0, #Flying
  73. bne poison_type_check
  74. bic r5, r2
  75. poison_type_check:
  76. cmp r0, #Poison
  77. bne steel_type_check
  78. bic r5, r1
  79. steel_type_check:
  80. cmp r0, #Steel
  81. bne loop_check
  82. bic r5, r1
  83. loop_check:
  84. cmp r3, #1
  85. beq ability_check
  86. add r3, #1
  87. mov r0, r6
  88. add r0, #0x22
  89. ldrb r0, [r0]
  90. b type_check_loop
  91.  
  92. ability_check:
  93. mov r3, #0xFF
  94. mov r0, r6
  95. add r0, #0x20
  96. ldrb r0, [r0]
  97. cmp r0, #Magic_Guard
  98. bne levitate_check
  99. bic r5, r3
  100. levitate_check:
  101. cmp r0, #Levitate
  102. bne immunity_check
  103. bic r5, r2
  104. immunity_check:
  105. cmp r0, #Immunity
  106. bne sticky_web_check
  107. bic r5, r1
  108.  
  109. sticky_web_check:
  110. mov r0, r5
  111. mov r1, #0x20
  112. and r0, r1
  113. cmp r0, #0
  114. beq toxic_spikes_check
  115. ldr r0, sticky_web_battle_script_pointer
  116. bl battle_script_push
  117.  
  118. toxic_spikes_check:
  119. mov r0, r5
  120. mov r1, #0xC
  121. and r0, r1
  122. cmp r0, #0
  123. beq stealth_rock_check
  124. cmp r0, #8 @badly poisoned
  125. bne normal_poison
  126. mov r0, #6 @toxic
  127. b store_effect
  128. normal_poison:
  129. mov r0, #2 @poison
  130. store_effect:
  131. ldr r1, effect
  132. strb r0, [r1]
  133. ldr r0, toxic_spikes_battle_script_pointer
  134. bl battle_script_push
  135. b stealth_rock_check
  136.  
  137. get_badly_poisoned_battle_script:
  138. mov r0, #6 @toxic
  139. b store_effect
  140.  
  141. stealth_rock_check:
  142. mov r0, r5
  143. mov r1, #0x10
  144. and r0, r1
  145. cmp r0, #0
  146. beq spikes_check
  147. mov r2, r6
  148. mov r0, #0 @used for the loop
  149. add r3, #0x21
  150. ldrb r2, [r3, #1] @r2 is one of the types
  151. ldrb r3, [r3] @and there's the other
  152. mov r1, #8 @normal damage
  153. check_type_resistance:
  154. cmp r2, #Fighting
  155. beq reduce_stealth_rock_damage
  156. cmp r2, #Flying
  157. beq increase_stealth_rock_damage
  158. cmp r2, #Ground
  159. beq reduce_stealth_rock_damage
  160. cmp r2, #Bug
  161. beq increase_stealth_rock_damage
  162. cmp r2, #Fire
  163. beq increase_stealth_rock_damage
  164. cmp r2, #Ice
  165. beq increase_stealth_rock_damage
  166. b stealth_rock_loop
  167.  
  168. reduce_stealth_rock_damage:
  169. lsl r1, #1 @makes the denominator bigger, therefore the result will be small (20/10)
  170. b stealth_rock_loop
  171.  
  172. increase_stealth_rock_damage:
  173. lsr r1, #1 @makes the denominator smaller, making a big result (20/2)
  174.  
  175. stealth_rock_loop:
  176. add r0, #1
  177. mov r2, r3
  178. cmp r1, #2
  179. bne check_type_resistance
  180. ldrh r0, [r6, #0x2C] @hp
  181. bl div
  182. ldr r1, damage
  183. cmp r0, #0
  184. bne store_stealth_damage
  185. mov r0, #1
  186. store_stealth_damage:
  187. str r0, [r1]
  188. ldr r0, stealth_rock_battle_script_pointer
  189. bl battle_script_push
  190.  
  191. spikes_check:
  192. mov r0, r5
  193. mov r1, #3
  194. and r0, r1
  195. cmp r0, #0
  196. beq assembly_end
  197. cmp r0, #1
  198. bne spikes_2
  199. mov r1, #8
  200. spikes_2:
  201. cmp r0, #2
  202. bne spikes_3
  203. mov r1, #6
  204. spikes_3:
  205. cmp r0, #3
  206. bne spikes_div
  207. mov r1, #4
  208. spikes_div:
  209. ldrh r0, [r6, #0x2C]
  210. bl div
  211. cmp r0, #0
  212. bne store_spikes_damage
  213. mov r0, #1
  214. store_spikes_damage:
  215. ldr r1, damage
  216. str r0, [r1]
  217. ldr r0, spikes_battle_script_pointer
  218. bl battle_script_push
  219.  
  220. assembly_end:
  221. ldr r0, return_pointer
  222. bl battle_script_push
  223. pop {r4-r7, pc}
  224.  
  225. .align 2
  226. timers: .word 0x02023DE4
  227. battle_struct: .word 0x02023BE4
  228. movescr_cursor: .word 0x02023D74
  229. damage: .word 0x02023D50
  230. effect: .word 0x02023E85
  231. sticky_web_battle_script_pointer: .word sticky_web_battle_script + rom
  232. toxic_spikes_battle_script_pointer: .word toxic_spikes_battle_script + rom
  233. stealth_rock_battle_script_pointer: .word stealth_rock_battle_script + rom
  234. spikes_battle_script_pointer: .word spikes_battle_script + rom
  235. return_pointer: .word return + rom
  236.  
  237. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  238.  
  239. .align 2
  240. battle_script_push:
  241. ldr r1, bs_push
  242. bx r1
  243.  
  244. .align 2
  245. bs_push: .word 0x08017520
  246.  
  247. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  248.  
  249. .align 2
  250. get_battle_side_something:
  251. ldr r1, battle_side_something
  252. bx r1
  253.  
  254. .align 2
  255. battle_side_something: .word 0x08016E24
  256.  
  257. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  258.  
  259. spikes_battle_script: @text at 0x083FC0C6
  260. .byte 0xFA
  261. .word 0x0203C020, 0x083FC036 @text
  262. .byte 0x28 @goto
  263. .word damage_and_msg + rom
  264.  
  265. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  266.  
  267. stealth_rock_battle_script:
  268. @stuff here, the pointer to the text is 08257be5 i think
  269. .byte 0xFA
  270. .word 0x0203C020, 0x08257BE5 @text
  271. .byte 0x28 @goto
  272. .word damage_and_msg + rom
  273.  
  274. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  275.  
  276. toxic_spikes_battle_script:
  277. .byte 0x16, 0xF, 0x12 @seteffecttarget, resultmessage, waitmessage
  278. .hword 0x0040
  279. .byte 0x3C @return
  280.  
  281. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  282.  
  283. sticky_web_battle_script: @text at 08257C02
  284. @text first
  285. .byte 0xFA
  286. .word 0x0203C020, 0x08257C02
  287. .byte 0x10
  288. .hword 0x0184
  289. .byte 0x12
  290. .hword 0x0040
  291. .byte 0x2E @setbyte
  292. .word 0x02023E85
  293. .byte 0x18, 0xF, 0x12
  294. .hword 0x0040
  295. .byte 0x3C
  296.  
  297. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  298.  
  299. damage_and_msg:
  300. .byte 0x5C, 0, 0x3A, 0xB, 0, 0xC, 0 @hp stuff
  301. .byte 0x10
  302. .hword 0x0184
  303. .byte 0x12 @waitmessage
  304. .hword 0x0040
  305. .byte 0x3C @return
  306.  
  307. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  308.  
  309. return:
  310. .byte 0x3C
  311.  
  312. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement