saffrongym.asm 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. SaffronGymScript:
  2. ld hl, wCurrentMapScriptFlags
  3. bit 6, [hl]
  4. res 6, [hl]
  5. call nz, .extra
  6. call EnableAutoTextBoxDrawing
  7. ld hl, SaffronGymTrainerHeader0
  8. ld de, SaffronGymScriptPointers
  9. ld a, [wSaffronGymCurScript]
  10. call ExecuteCurMapScriptInTable
  11. ld [wSaffronGymCurScript], a
  12. ret
  13. .extra
  14. ld hl, Gym6CityName
  15. ld de, Gym6LeaderName
  16. jp LoadGymLeaderAndCityName
  17. Gym6CityName:
  18. db "SAFFRON CITY@"
  19. Gym6LeaderName:
  20. db "SABRINA@"
  21. SaffronGymText_5d048:
  22. xor a
  23. ld [wJoyIgnore], a
  24. ld [wSaffronGymCurScript], a
  25. ld [wCurMapScript], a
  26. ret
  27. SaffronGymScriptPointers:
  28. dw CheckFightingMapTrainers
  29. dw DisplayEnemyTrainerTextAndStartBattle
  30. dw EndTrainerBattle
  31. dw SaffronGymScript3
  32. SaffronGymScript3:
  33. ld a, [wIsInBattle]
  34. cp $ff
  35. jp z, SaffronGymText_5d048
  36. ld a, $f0
  37. ld [wJoyIgnore], a
  38. SaffronGymText_5d068:
  39. ld a, $a
  40. ld [hSpriteIndexOrTextID], a
  41. call DisplayTextID
  42. SetEvent EVENT_BEAT_SABRINA
  43. lb bc, TM_46, 1
  44. call GiveItem
  45. jr nc, .BagFull
  46. ld a, $b
  47. ld [hSpriteIndexOrTextID], a
  48. call DisplayTextID
  49. SetEvent EVENT_GOT_TM46
  50. jr .asm_5d091
  51. .BagFull
  52. ld a, $c
  53. ld [hSpriteIndexOrTextID], a
  54. call DisplayTextID
  55. .asm_5d091
  56. ld hl, wObtainedBadges
  57. set 5, [hl]
  58. ld hl, wBeatGymFlags
  59. set 5, [hl]
  60. ; deactivate gym trainers
  61. SetEventRange EVENT_BEAT_SAFFRON_GYM_TRAINER_0, EVENT_BEAT_SAFFRON_GYM_TRAINER_6
  62. jp SaffronGymText_5d048
  63. SaffronGymTextPointers:
  64. dw SaffronGymText1
  65. dw SaffronGymText2
  66. dw SaffronGymText3
  67. dw SaffronGymText4
  68. dw SaffronGymText5
  69. dw SaffronGymText6
  70. dw SaffronGymText7
  71. dw SaffronGymText8
  72. dw SaffronGymText9
  73. dw SaffronGymText10
  74. dw SaffronGymText11
  75. dw SaffronGymText12
  76. SaffronGymTrainerHeader0:
  77. dbEventFlagBit EVENT_BEAT_SAFFRON_GYM_TRAINER_0
  78. db ($3 << 4) ; trainer's view range
  79. dwEventFlagAddress EVENT_BEAT_SAFFRON_GYM_TRAINER_0
  80. dw SaffronGymBattleText1 ; TextBeforeBattle
  81. dw SaffronGymAfterBattleText1 ; TextAfterBattle
  82. dw SaffronGymEndBattleText1 ; TextEndBattle
  83. dw SaffronGymEndBattleText1 ; TextEndBattle
  84. SaffronGymTrainerHeader1:
  85. dbEventFlagBit EVENT_BEAT_SAFFRON_GYM_TRAINER_1
  86. db ($3 << 4) ; trainer's view range
  87. dwEventFlagAddress EVENT_BEAT_SAFFRON_GYM_TRAINER_1
  88. dw SaffronGymBattleText2 ; TextBeforeBattle
  89. dw SaffronGymAfterBattleText2 ; TextAfterBattle
  90. dw SaffronGymEndBattleText2 ; TextEndBattle
  91. dw SaffronGymEndBattleText2 ; TextEndBattle
  92. SaffronGymTrainerHeader2:
  93. dbEventFlagBit EVENT_BEAT_SAFFRON_GYM_TRAINER_2
  94. db ($3 << 4) ; trainer's view range
  95. dwEventFlagAddress EVENT_BEAT_SAFFRON_GYM_TRAINER_2
  96. dw SaffronGymBattleText3 ; TextBeforeBattle
  97. dw SaffronGymAfterBattleText3 ; TextAfterBattle
  98. dw SaffronGymEndBattleText3 ; TextEndBattle
  99. dw SaffronGymEndBattleText3 ; TextEndBattle
  100. SaffronGymTrainerHeader3:
  101. dbEventFlagBit EVENT_BEAT_SAFFRON_GYM_TRAINER_3
  102. db ($3 << 4) ; trainer's view range
  103. dwEventFlagAddress EVENT_BEAT_SAFFRON_GYM_TRAINER_3
  104. dw SaffronGymBattleText4 ; TextBeforeBattle
  105. dw SaffronGymAfterBattleText4 ; TextAfterBattle
  106. dw SaffronGymEndBattleText4 ; TextEndBattle
  107. dw SaffronGymEndBattleText4 ; TextEndBattle
  108. SaffronGymTrainerHeader4:
  109. dbEventFlagBit EVENT_BEAT_SAFFRON_GYM_TRAINER_4
  110. db ($3 << 4) ; trainer's view range
  111. dwEventFlagAddress EVENT_BEAT_SAFFRON_GYM_TRAINER_4
  112. dw SaffronGymBattleText5 ; TextBeforeBattle
  113. dw SaffronGymAfterBattleText5 ; TextAfterBattle
  114. dw SaffronGymEndBattleText5 ; TextEndBattle
  115. dw SaffronGymEndBattleText5 ; TextEndBattle
  116. SaffronGymTrainerHeader5:
  117. dbEventFlagBit EVENT_BEAT_SAFFRON_GYM_TRAINER_5
  118. db ($3 << 4) ; trainer's view range
  119. dwEventFlagAddress EVENT_BEAT_SAFFRON_GYM_TRAINER_5
  120. dw SaffronGymBattleText6 ; TextBeforeBattle
  121. dw SaffronGymAfterBattleText6 ; TextAfterBattle
  122. dw SaffronGymEndBattleText6 ; TextEndBattle
  123. dw SaffronGymEndBattleText6 ; TextEndBattle
  124. SaffronGymTrainerHeader6:
  125. dbEventFlagBit EVENT_BEAT_SAFFRON_GYM_TRAINER_6, 1
  126. db ($3 << 4) ; trainer's view range
  127. dwEventFlagAddress EVENT_BEAT_SAFFRON_GYM_TRAINER_6, 1
  128. dw SaffronGymBattleText7 ; TextBeforeBattle
  129. dw SaffronGymAfterBattleText7 ; TextAfterBattle
  130. dw SaffronGymEndBattleText7 ; TextEndBattle
  131. dw SaffronGymEndBattleText7 ; TextEndBattle
  132. db $ff
  133. SaffronGymText1:
  134. TX_ASM
  135. CheckEvent EVENT_BEAT_SABRINA
  136. jr z, .asm_5d134
  137. CheckEventReuseA EVENT_GOT_TM46
  138. jr nz, .asm_5d12c
  139. call z, SaffronGymText_5d068
  140. call DisableWaitingAfterTextDisplay
  141. jr .asm_5d15f
  142. .asm_5d12c
  143. ld hl, SaffronGymText_5d16e
  144. call PrintText
  145. jr .asm_5d15f
  146. .asm_5d134
  147. ld hl, SaffronGymText_5d162
  148. call PrintText
  149. ld hl, wd72d
  150. set 6, [hl]
  151. set 7, [hl]
  152. ld hl, SaffronGymText_5d167
  153. ld de, SaffronGymText_5d167
  154. call SaveEndBattleTextPointers
  155. ld a, [H_SPRITEINDEX]
  156. ld [wSpriteIndex], a
  157. call EngageMapTrainer
  158. call InitBattleEnemyParameters
  159. ld a, $6
  160. ld [wGymLeaderNo], a
  161. ld a, $3
  162. ld [wSaffronGymCurScript], a
  163. .asm_5d15f
  164. jp TextScriptEnd
  165. SaffronGymText_5d162:
  166. TX_FAR _SaffronGymText_5d162
  167. db "@"
  168. SaffronGymText_5d167:
  169. TX_FAR _SaffronGymText_5d167
  170. TX_SFX_KEY_ITEM ; actually plays the second channel of SFX_BALL_POOF due to the wrong music bank being loaded
  171. TX_BLINK
  172. db "@"
  173. SaffronGymText_5d16e:
  174. TX_FAR _SaffronGymText_5d16e
  175. db "@"
  176. SaffronGymText10:
  177. TX_FAR _SaffronGymText_5d173
  178. db "@"
  179. SaffronGymText11:
  180. TX_FAR ReceivedTM46Text
  181. TX_SFX_ITEM_1
  182. TX_FAR _TM46ExplanationText
  183. db "@"
  184. SaffronGymText12:
  185. TX_FAR _TM46NoRoomText
  186. db "@"
  187. SaffronGymText2:
  188. TX_ASM
  189. ld hl, SaffronGymTrainerHeader0
  190. call TalkToTrainer
  191. jp TextScriptEnd
  192. SaffronGymText3:
  193. TX_ASM
  194. ld hl, SaffronGymTrainerHeader1
  195. call TalkToTrainer
  196. jp TextScriptEnd
  197. SaffronGymText4:
  198. TX_ASM
  199. ld hl, SaffronGymTrainerHeader2
  200. call TalkToTrainer
  201. jp TextScriptEnd
  202. SaffronGymText5:
  203. TX_ASM
  204. ld hl, SaffronGymTrainerHeader3
  205. call TalkToTrainer
  206. jp TextScriptEnd
  207. SaffronGymText6:
  208. TX_ASM
  209. ld hl, SaffronGymTrainerHeader4
  210. call TalkToTrainer
  211. jp TextScriptEnd
  212. SaffronGymText7:
  213. TX_ASM
  214. ld hl, SaffronGymTrainerHeader5
  215. call TalkToTrainer
  216. jp TextScriptEnd
  217. SaffronGymText8:
  218. TX_ASM
  219. ld hl, SaffronGymTrainerHeader6
  220. call TalkToTrainer
  221. jp TextScriptEnd
  222. SaffronGymText9:
  223. TX_ASM
  224. CheckEvent EVENT_BEAT_SABRINA
  225. jr nz, .asm_5d1dd
  226. ld hl, SaffronGymText_5d1e6
  227. call PrintText
  228. jr .asm_5d1e3
  229. .asm_5d1dd
  230. ld hl, SaffronGymText_5d1eb
  231. call PrintText
  232. .asm_5d1e3
  233. jp TextScriptEnd
  234. SaffronGymText_5d1e6:
  235. TX_FAR _SaffronGymText_5d1e6
  236. db "@"
  237. SaffronGymText_5d1eb:
  238. TX_FAR _SaffronGymText_5d1eb
  239. db "@"
  240. SaffronGymBattleText1:
  241. TX_FAR _SaffronGymBattleText1
  242. db "@"
  243. SaffronGymEndBattleText1:
  244. TX_FAR _SaffronGymEndBattleText1
  245. db "@"
  246. SaffronGymAfterBattleText1:
  247. TX_FAR _SaffronGymAfterBattleText1
  248. db "@"
  249. SaffronGymBattleText2:
  250. TX_FAR _SaffronGymBattleText2
  251. db "@"
  252. SaffronGymEndBattleText2:
  253. TX_FAR _SaffronGymEndBattleText2
  254. db "@"
  255. SaffronGymAfterBattleText2:
  256. TX_FAR _SaffronGymAfterBattleText2
  257. db "@"
  258. SaffronGymBattleText3:
  259. TX_FAR _SaffronGymBattleText3
  260. db "@"
  261. SaffronGymEndBattleText3:
  262. TX_FAR _SaffronGymEndBattleText3
  263. db "@"
  264. SaffronGymAfterBattleText3:
  265. TX_FAR _SaffronGymAfterBattleText3
  266. db "@"
  267. SaffronGymBattleText4:
  268. TX_FAR _SaffronGymBattleText4
  269. db "@"
  270. SaffronGymEndBattleText4:
  271. TX_FAR _SaffronGymEndBattleText4
  272. db "@"
  273. SaffronGymAfterBattleText4:
  274. TX_FAR _SaffronGymAfterBattleText4
  275. db "@"
  276. SaffronGymBattleText5:
  277. TX_FAR _SaffronGymBattleText5
  278. db "@"
  279. SaffronGymEndBattleText5:
  280. TX_FAR _SaffronGymEndBattleText5
  281. db "@"
  282. SaffronGymAfterBattleText5:
  283. TX_FAR _SaffronGymAfterBattleText5
  284. db "@"
  285. SaffronGymBattleText6:
  286. TX_FAR _SaffronGymBattleText6
  287. db "@"
  288. SaffronGymEndBattleText6:
  289. TX_FAR _SaffronGymEndBattleText6
  290. db "@"
  291. SaffronGymAfterBattleText6:
  292. TX_FAR _SaffronGymAfterBattleText6
  293. db "@"
  294. SaffronGymBattleText7:
  295. TX_FAR _SaffronGymBattleText7
  296. db "@"
  297. SaffronGymEndBattleText7:
  298. TX_FAR _SaffronGymEndBattleText7
  299. db "@"
  300. SaffronGymAfterBattleText7:
  301. TX_FAR _SaffronGymAfterBattleText7
  302. db "@"