viridiangym.asm 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. ViridianGymScript:
  2. ld hl, Gym8CityName
  3. ld de, Gym8LeaderName
  4. call LoadGymLeaderAndCityName
  5. call EnableAutoTextBoxDrawing
  6. ld hl, ViridianGymTrainerHeader0
  7. ld de, ViridianGymScriptPointers
  8. ld a, [wViridianGymCurScript]
  9. call ExecuteCurMapScriptInTable
  10. ld [wViridianGymCurScript], a
  11. ret
  12. Gym8CityName:
  13. db "VIRIDIAN CITY@"
  14. Gym8LeaderName:
  15. db "GIOVANNI@"
  16. ViridianGymScript_748d6:
  17. xor a
  18. ld [wJoyIgnore], a
  19. ld [wViridianGymCurScript], a
  20. ld [wCurMapScript], a
  21. ret
  22. ViridianGymScriptPointers:
  23. dw ViridianGymScript0
  24. dw DisplayEnemyTrainerTextAndStartBattle
  25. dw EndTrainerBattle
  26. dw ViridianGymScript3
  27. dw ViridianGymScript4
  28. ViridianGymScript0:
  29. ld a, [wYCoord]
  30. ld b, a
  31. ld a, [wXCoord]
  32. ld c, a
  33. ld hl, ViridianGymArrowTilePlayerMovement
  34. call DecodeArrowMovementRLE
  35. cp $ff
  36. jp z, CheckFightingMapTrainers
  37. call StartSimulatingJoypadStates
  38. ld hl, wd736
  39. set 7, [hl]
  40. ld a, SFX_ARROW_TILES
  41. call PlaySound
  42. ld a, $ff
  43. ld [wJoyIgnore], a
  44. ld a, $4
  45. ld [wCurMapScript], a
  46. ret
  47. ;format:
  48. ;db y,x
  49. ;dw pointer to movement
  50. ViridianGymArrowTilePlayerMovement:
  51. db $b,$13
  52. dw ViridianGymArrowMovement1
  53. db $1,$13
  54. dw ViridianGymArrowMovement2
  55. db $2,$12
  56. dw ViridianGymArrowMovement3
  57. db $2,$b
  58. dw ViridianGymArrowMovement4
  59. db $a,$10
  60. dw ViridianGymArrowMovement5
  61. db $6,$4
  62. dw ViridianGymArrowMovement6
  63. db $d,$5
  64. dw ViridianGymArrowMovement7
  65. db $e,$4
  66. dw ViridianGymArrowMovement8
  67. db $f,$0
  68. dw ViridianGymArrowMovement9
  69. db $f,$1
  70. dw ViridianGymArrowMovement10
  71. db $10,$d
  72. dw ViridianGymArrowMovement11
  73. db $11,$d
  74. dw ViridianGymArrowMovement12
  75. db $FF
  76. ;format: direction, count
  77. ViridianGymArrowMovement1:
  78. db D_UP,$09,$FF
  79. ViridianGymArrowMovement2:
  80. db D_LEFT,$08,$FF
  81. ViridianGymArrowMovement3:
  82. db D_DOWN,$09,$FF
  83. ViridianGymArrowMovement4:
  84. db D_RIGHT,$06,$FF
  85. ViridianGymArrowMovement5:
  86. db D_DOWN,$02,$FF
  87. ViridianGymArrowMovement6:
  88. db D_DOWN,$07,$FF
  89. ViridianGymArrowMovement7:
  90. db D_RIGHT,$08,$FF
  91. ViridianGymArrowMovement8:
  92. db D_RIGHT,$09,$FF
  93. ViridianGymArrowMovement9:
  94. db D_UP,$08,$FF
  95. ViridianGymArrowMovement10:
  96. db D_UP,$06,$FF
  97. ViridianGymArrowMovement11:
  98. db D_LEFT,$06,$FF
  99. ViridianGymArrowMovement12:
  100. db D_LEFT,$0C,$FF
  101. ViridianGymScript4:
  102. ld a, [wSimulatedJoypadStatesIndex]
  103. and a
  104. jr nz, .asm_74980
  105. xor a
  106. ld [wJoyIgnore], a
  107. ld hl, wd736
  108. res 7, [hl]
  109. ld a, $0
  110. ld [wCurMapScript], a
  111. ret
  112. .asm_74980
  113. jpba LoadSpinnerArrowTiles
  114. ViridianGymScript3:
  115. ld a, [wIsInBattle]
  116. cp $ff
  117. jp z, ViridianGymScript_748d6
  118. ld a, $f0
  119. ld [wJoyIgnore], a
  120. ViridianGymScript3_74995:
  121. ld a, $c
  122. ld [hSpriteIndexOrTextID], a
  123. call DisplayTextID
  124. SetEvent EVENT_BEAT_VIRIDIAN_GYM_GIOVANNI
  125. lb bc, TM_27, 1
  126. call GiveItem
  127. jr nc, .BagFull
  128. ld a, $d
  129. ld [hSpriteIndexOrTextID], a
  130. call DisplayTextID
  131. SetEvent EVENT_GOT_TM27
  132. jr .asm_749be
  133. .BagFull
  134. ld a, $e
  135. ld [hSpriteIndexOrTextID], a
  136. call DisplayTextID
  137. .asm_749be
  138. ld hl, wObtainedBadges
  139. set 7, [hl]
  140. ld hl, wBeatGymFlags
  141. set 7, [hl]
  142. ; deactivate gym trainers
  143. SetEventRange EVENT_BEAT_VIRIDIAN_GYM_TRAINER_0, EVENT_BEAT_VIRIDIAN_GYM_TRAINER_7
  144. ld a, HS_ROUTE_22_RIVAL_2
  145. ld [wMissableObjectIndex], a
  146. predef ShowObject
  147. SetEvents EVENT_2ND_ROUTE22_RIVAL_BATTLE, EVENT_ROUTE22_RIVAL_WANTS_BATTLE
  148. jp ViridianGymScript_748d6
  149. ViridianGymTextPointers:
  150. dw ViridianGymText1
  151. dw ViridianGymText2
  152. dw ViridianGymText3
  153. dw ViridianGymText4
  154. dw ViridianGymText5
  155. dw ViridianGymText6
  156. dw ViridianGymText7
  157. dw ViridianGymText8
  158. dw ViridianGymText9
  159. dw ViridianGymText10
  160. dw PickUpItemText
  161. dw ViridianGymText12
  162. dw ViridianGymText13
  163. dw ViridianGymText14
  164. ViridianGymTrainerHeader0:
  165. dbEventFlagBit EVENT_BEAT_VIRIDIAN_GYM_TRAINER_0
  166. db ($4 << 4) ; trainer's view range
  167. dwEventFlagAddress EVENT_BEAT_VIRIDIAN_GYM_TRAINER_0
  168. dw ViridianGymBattleText1 ; TextBeforeBattle
  169. dw ViridianGymAfterBattleText1 ; TextAfterBattle
  170. dw ViridianGymEndBattleText1 ; TextEndBattle
  171. dw ViridianGymEndBattleText1 ; TextEndBattle
  172. ViridianGymTrainerHeader1:
  173. dbEventFlagBit EVENT_BEAT_VIRIDIAN_GYM_TRAINER_1
  174. db ($4 << 4) ; trainer's view range
  175. dwEventFlagAddress EVENT_BEAT_VIRIDIAN_GYM_TRAINER_1
  176. dw ViridianGymBattleText2 ; TextBeforeBattle
  177. dw ViridianGymAfterBattleText2 ; TextAfterBattle
  178. dw ViridianGymEndBattleText2 ; TextEndBattle
  179. dw ViridianGymEndBattleText2 ; TextEndBattle
  180. ViridianGymTrainerHeader2:
  181. dbEventFlagBit EVENT_BEAT_VIRIDIAN_GYM_TRAINER_2
  182. db ($4 << 4) ; trainer's view range
  183. dwEventFlagAddress EVENT_BEAT_VIRIDIAN_GYM_TRAINER_2
  184. dw ViridianGymBattleText3 ; TextBeforeBattle
  185. dw ViridianGymAfterBattleText3 ; TextAfterBattle
  186. dw ViridianGymEndBattleText3 ; TextEndBattle
  187. dw ViridianGymEndBattleText3 ; TextEndBattle
  188. ViridianGymTrainerHeader3:
  189. dbEventFlagBit EVENT_BEAT_VIRIDIAN_GYM_TRAINER_3
  190. db ($2 << 4) ; trainer's view range
  191. dwEventFlagAddress EVENT_BEAT_VIRIDIAN_GYM_TRAINER_3
  192. dw ViridianGymBattleText4 ; TextBeforeBattle
  193. dw ViridianGymAfterBattleText4 ; TextAfterBattle
  194. dw ViridianGymEndBattleText4 ; TextEndBattle
  195. dw ViridianGymEndBattleText4 ; TextEndBattle
  196. ViridianGymTrainerHeader4:
  197. dbEventFlagBit EVENT_BEAT_VIRIDIAN_GYM_TRAINER_4
  198. db ($3 << 4) ; trainer's view range
  199. dwEventFlagAddress EVENT_BEAT_VIRIDIAN_GYM_TRAINER_4
  200. dw ViridianGymBattleText5 ; TextBeforeBattle
  201. dw ViridianGymAfterBattleText5 ; TextAfterBattle
  202. dw ViridianGymEndBattleText5 ; TextEndBattle
  203. dw ViridianGymEndBattleText5 ; TextEndBattle
  204. ViridianGymTrainerHeader5:
  205. dbEventFlagBit EVENT_BEAT_VIRIDIAN_GYM_TRAINER_5
  206. db ($4 << 4) ; trainer's view range
  207. dwEventFlagAddress EVENT_BEAT_VIRIDIAN_GYM_TRAINER_5
  208. dw ViridianGymBattleText6 ; TextBeforeBattle
  209. dw ViridianGymAfterBattleText6 ; TextAfterBattle
  210. dw ViridianGymEndBattleText6 ; TextEndBattle
  211. dw ViridianGymEndBattleText6 ; TextEndBattle
  212. ViridianGymTrainerHeader6:
  213. dbEventFlagBit EVENT_BEAT_VIRIDIAN_GYM_TRAINER_6, 1
  214. db ($3 << 4) ; trainer's view range
  215. dwEventFlagAddress EVENT_BEAT_VIRIDIAN_GYM_TRAINER_6, 1
  216. dw ViridianGymBattleText7 ; TextBeforeBattle
  217. dw ViridianGymAfterBattleText7 ; TextAfterBattle
  218. dw ViridianGymEndBattleText7 ; TextEndBattle
  219. dw ViridianGymEndBattleText7 ; TextEndBattle
  220. ViridianGymTrainerHeader7:
  221. dbEventFlagBit EVENT_BEAT_VIRIDIAN_GYM_TRAINER_7, 1
  222. db ($4 << 4) ; trainer's view range
  223. dwEventFlagAddress EVENT_BEAT_VIRIDIAN_GYM_TRAINER_7, 1
  224. dw ViridianGymBattleText8 ; TextBeforeBattle
  225. dw ViridianGymAfterBattleText8 ; TextAfterBattle
  226. dw ViridianGymEndBattleText8 ; TextEndBattle
  227. dw ViridianGymEndBattleText8 ; TextEndBattle
  228. db $ff
  229. ViridianGymText1:
  230. TX_ASM
  231. CheckEvent EVENT_BEAT_VIRIDIAN_GYM_GIOVANNI
  232. jr z, .asm_6de66
  233. CheckEventReuseA EVENT_GOT_TM27
  234. jr nz, .asm_9fc95
  235. call z, ViridianGymScript3_74995
  236. call DisableWaitingAfterTextDisplay
  237. jr .asm_6dff7
  238. .asm_9fc95
  239. ld a, $1
  240. ld [wDoNotWaitForButtonPressAfterDisplayingText], a
  241. ld hl, ViridianGymText_74ad9
  242. call PrintText
  243. call GBFadeOutToBlack
  244. ld a, HS_VIRIDIAN_GYM_GIOVANNI
  245. ld [wMissableObjectIndex], a
  246. predef HideObject
  247. call UpdateSprites
  248. call Delay3
  249. call GBFadeInFromBlack
  250. jr .asm_6dff7
  251. .asm_6de66
  252. ld hl, ViridianGymText_74ace
  253. call PrintText
  254. ld hl, wd72d
  255. set 6, [hl]
  256. set 7, [hl]
  257. ld hl, ViridianGymText_74ad3
  258. ld de, ViridianGymText_74ad3
  259. call SaveEndBattleTextPointers
  260. ld a, [H_SPRITEINDEX]
  261. ld [wSpriteIndex], a
  262. call EngageMapTrainer
  263. call InitBattleEnemyParameters
  264. ld a, $8
  265. ld [wGymLeaderNo], a
  266. ld a, $3
  267. ld [wViridianGymCurScript], a
  268. .asm_6dff7
  269. jp TextScriptEnd
  270. ViridianGymText_74ace:
  271. TX_FAR _ViridianGymText_74ace
  272. db "@"
  273. ViridianGymText_74ad3:
  274. TX_FAR _ViridianGymText_74ad3
  275. TX_SFX_LEVEL_UP ; probably supposed to play SFX_GET_ITEM_1 but the wrong music bank is loaded
  276. db "@"
  277. ViridianGymText_74ad9:
  278. TX_FAR _ViridianGymText_74ad9
  279. TX_WAIT
  280. db "@"
  281. ViridianGymText12:
  282. TX_FAR _ViridianGymText12
  283. db "@"
  284. ViridianGymText13:
  285. TX_FAR _ReceivedTM27Text
  286. TX_SFX_ITEM_1
  287. TM27ExplanationText:
  288. TX_FAR _TM27ExplanationText
  289. db "@"
  290. ViridianGymText14:
  291. TX_FAR _TM27NoRoomText
  292. db "@"
  293. ViridianGymText2:
  294. TX_ASM
  295. ld hl, ViridianGymTrainerHeader0
  296. call TalkToTrainer
  297. jp TextScriptEnd
  298. ViridianGymBattleText1:
  299. TX_FAR _ViridianGymBattleText1
  300. db "@"
  301. ViridianGymEndBattleText1:
  302. TX_FAR _ViridianGymEndBattleText1
  303. db "@"
  304. ViridianGymAfterBattleText1:
  305. TX_FAR _ViridianGymAfterBattleText1
  306. db "@"
  307. ViridianGymText3:
  308. TX_ASM
  309. ld hl, ViridianGymTrainerHeader1
  310. call TalkToTrainer
  311. jp TextScriptEnd
  312. ViridianGymBattleText2:
  313. TX_FAR _ViridianGymBattleText2
  314. db "@"
  315. ViridianGymEndBattleText2:
  316. TX_FAR _ViridianGymEndBattleText2
  317. db "@"
  318. ViridianGymAfterBattleText2:
  319. TX_FAR _ViridianGymAfterBattleText2
  320. db "@"
  321. ViridianGymText4:
  322. TX_ASM
  323. ld hl, ViridianGymTrainerHeader2
  324. call TalkToTrainer
  325. jp TextScriptEnd
  326. ViridianGymBattleText3:
  327. TX_FAR _ViridianGymBattleText3
  328. db "@"
  329. ViridianGymEndBattleText3:
  330. TX_FAR _ViridianGymEndBattleText3
  331. db "@"
  332. ViridianGymAfterBattleText3:
  333. TX_FAR _ViridianGymAfterBattleText3
  334. db "@"
  335. ViridianGymText5:
  336. TX_ASM
  337. ld hl, ViridianGymTrainerHeader3
  338. call TalkToTrainer
  339. jp TextScriptEnd
  340. ViridianGymBattleText4:
  341. TX_FAR _ViridianGymBattleText4
  342. db "@"
  343. ViridianGymEndBattleText4:
  344. TX_FAR _ViridianGymEndBattleText4
  345. db "@"
  346. ViridianGymAfterBattleText4:
  347. TX_FAR _ViridianGymAfterBattleText4
  348. db "@"
  349. ViridianGymText6:
  350. TX_ASM
  351. ld hl, ViridianGymTrainerHeader4
  352. call TalkToTrainer
  353. jp TextScriptEnd
  354. ViridianGymBattleText5:
  355. TX_FAR _ViridianGymBattleText5
  356. db "@"
  357. ViridianGymEndBattleText5:
  358. TX_FAR _ViridianGymEndBattleText5
  359. db "@"
  360. ViridianGymAfterBattleText5:
  361. TX_FAR _ViridianGymAfterBattleText5
  362. db "@"
  363. ViridianGymText7:
  364. TX_ASM
  365. ld hl, ViridianGymTrainerHeader5
  366. call TalkToTrainer
  367. jp TextScriptEnd
  368. ViridianGymBattleText6:
  369. TX_FAR _ViridianGymBattleText6
  370. db "@"
  371. ViridianGymEndBattleText6:
  372. TX_FAR _ViridianGymEndBattleText6
  373. db "@"
  374. ViridianGymAfterBattleText6:
  375. TX_FAR _ViridianGymAfterBattleText6
  376. db "@"
  377. ViridianGymText8:
  378. TX_ASM
  379. ld hl, ViridianGymTrainerHeader6
  380. call TalkToTrainer
  381. jp TextScriptEnd
  382. ViridianGymBattleText7:
  383. TX_FAR _ViridianGymBattleText7
  384. db "@"
  385. ViridianGymEndBattleText7:
  386. TX_FAR _ViridianGymEndBattleText7
  387. db "@"
  388. ViridianGymAfterBattleText7:
  389. TX_FAR _ViridianGymAfterBattleText7
  390. db "@"
  391. ViridianGymText9:
  392. TX_ASM
  393. ld hl, ViridianGymTrainerHeader7
  394. call TalkToTrainer
  395. jp TextScriptEnd
  396. ViridianGymBattleText8:
  397. TX_FAR _ViridianGymBattleText8
  398. db "@"
  399. ViridianGymEndBattleText8:
  400. TX_FAR _ViridianGymEndBattleText8
  401. db "@"
  402. ViridianGymAfterBattleText8:
  403. TX_FAR _ViridianGymAfterBattleText8
  404. db "@"
  405. ViridianGymText10:
  406. TX_ASM
  407. CheckEvent EVENT_BEAT_VIRIDIAN_GYM_GIOVANNI
  408. jr nz, .asm_1abd1
  409. ld hl, ViridianGymText_74bd4
  410. call PrintText
  411. jr .asm_6064d
  412. .asm_1abd1
  413. ld hl, ViridianGymText_74bd9
  414. call PrintText
  415. .asm_6064d
  416. jp TextScriptEnd
  417. ViridianGymText_74bd4:
  418. TX_FAR _ViridianGymText_74bd4
  419. db "@"
  420. ViridianGymText_74bd9:
  421. TX_FAR _ViridianGymText_74bd9
  422. db "@"