route22.asm 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. Route22Script:
  2. call EnableAutoTextBoxDrawing
  3. ld hl, Route22ScriptPointers
  4. ld a, [wRoute22CurScript]
  5. jp CallFunctionInTable
  6. Route22ScriptPointers:
  7. dw Route22Script0
  8. dw Route22Script1
  9. dw Route22Script2
  10. dw Route22Script3
  11. dw Route22Script4
  12. dw Route22Script5
  13. dw Route22Script6
  14. dw Route22Script7
  15. Route22Script_50ece:
  16. xor a
  17. ld [wJoyIgnore], a
  18. ld [wRoute22CurScript], a
  19. Route22Script7:
  20. ret
  21. Route22Script_50ed6:
  22. ld a, [wRivalStarter]
  23. ld b, a
  24. .asm_50eda
  25. ld a, [hli]
  26. cp b
  27. jr z, .asm_50ee1
  28. inc hl
  29. jr .asm_50eda
  30. .asm_50ee1
  31. ld a, [hl]
  32. ld [wTrainerNo], a
  33. ret
  34. Route22MoveRivalSprite:
  35. ld de, Route22RivalMovementData
  36. ld a, [wcf0d]
  37. cp $1
  38. jr z, .asm_50ef1
  39. inc de
  40. .asm_50ef1
  41. call MoveSprite
  42. ld a, SPRITE_FACING_RIGHT
  43. ld [hSpriteFacingDirection], a
  44. jp SetSpriteFacingDirectionAndDelay
  45. Route22RivalMovementData:
  46. db NPC_MOVEMENT_RIGHT
  47. db NPC_MOVEMENT_RIGHT
  48. db NPC_MOVEMENT_RIGHT
  49. db NPC_MOVEMENT_RIGHT
  50. db $FF
  51. Route22Script0:
  52. CheckEvent EVENT_ROUTE22_RIVAL_WANTS_BATTLE
  53. ret z
  54. ld hl, .Route22RivalBattleCoords
  55. call ArePlayerCoordsInArray
  56. ret nc
  57. ld a, [wCoordIndex]
  58. ld [wcf0d], a
  59. xor a
  60. ld [hJoyHeld], a
  61. ld a, $f0
  62. ld [wJoyIgnore], a
  63. ld a, PLAYER_DIR_LEFT
  64. ld [wPlayerMovingDirection], a
  65. CheckEvent EVENT_1ST_ROUTE22_RIVAL_BATTLE
  66. jr nz, .firstRivalBattle
  67. CheckEventReuseA EVENT_2ND_ROUTE22_RIVAL_BATTLE ; is this the rival at the end of the game?
  68. jp nz, Route22Script_5104e
  69. ret
  70. .Route22RivalBattleCoords
  71. db $04, $1D
  72. db $05, $1D
  73. db $FF
  74. .firstRivalBattle
  75. ld a, $1
  76. ld [wEmotionBubbleSpriteIndex], a
  77. xor a ; EXCLAMATION_BUBBLE
  78. ld [wWhichEmotionBubble], a
  79. predef EmotionBubble
  80. ld a, [wWalkBikeSurfState]
  81. and a
  82. jr z, .asm_50f4e
  83. ld a, $ff
  84. ld [wNewSoundID], a
  85. call PlaySound
  86. .asm_50f4e
  87. ld c, BANK(Music_MeetRival)
  88. ld a, MUSIC_MEET_RIVAL
  89. call PlayMusic
  90. ld a, $1
  91. ld [H_SPRITEINDEX], a
  92. call Route22MoveRivalSprite
  93. ld a, $1
  94. ld [wRoute22CurScript], a
  95. ret
  96. Route22Script1:
  97. ld a, [wd730]
  98. bit 0, a
  99. ret nz
  100. ld a, [wcf0d]
  101. cp $1
  102. jr nz, .asm_50f78
  103. ld a, PLAYER_DIR_DOWN
  104. ld [wPlayerMovingDirection], a
  105. ld a, SPRITE_FACING_UP
  106. jr .asm_50f7a
  107. .asm_50f78
  108. ld a, SPRITE_FACING_RIGHT
  109. .asm_50f7a
  110. ld [hSpriteFacingDirection], a
  111. ld a, $1
  112. ld [H_SPRITEINDEX], a
  113. call SetSpriteFacingDirectionAndDelay
  114. xor a
  115. ld [wJoyIgnore], a
  116. ld a, $1
  117. ld [hSpriteIndexOrTextID], a
  118. call DisplayTextID
  119. ld hl, wd72d
  120. set 6, [hl]
  121. set 7, [hl]
  122. ld hl, Route22RivalDefeatedText1
  123. ld de, Route22Text_511bc
  124. call SaveEndBattleTextPointers
  125. ld a, OPP_SONY1
  126. ld [wCurOpponent], a
  127. ld hl, StarterMons_50faf
  128. call Route22Script_50ed6
  129. ld a, $2
  130. ld [wRoute22CurScript], a
  131. ret
  132. StarterMons_50faf:
  133. ; starter the rival picked, rival trainer number
  134. db STARTER2,$04
  135. db STARTER3,$05
  136. db STARTER1,$06
  137. Route22Script2:
  138. ld a, [wIsInBattle]
  139. cp $ff
  140. jp z, Route22Script_50ece
  141. ld a, [wSpriteStateData1 + 9]
  142. and a ; cp SPRITE_FACING_DOWN
  143. jr nz, .notDown
  144. ld a, SPRITE_FACING_UP
  145. jr .done
  146. .notDown
  147. ld a, SPRITE_FACING_RIGHT
  148. .done
  149. ld [hSpriteFacingDirection], a
  150. ld a, $1
  151. ld [H_SPRITEINDEX], a
  152. call SetSpriteFacingDirectionAndDelay
  153. ld a, $f0
  154. ld [wJoyIgnore], a
  155. SetEvent EVENT_BEAT_ROUTE22_RIVAL_1ST_BATTLE
  156. ld a, $1
  157. ld [hSpriteIndexOrTextID], a
  158. call DisplayTextID
  159. ld a, $ff
  160. ld [wNewSoundID], a
  161. call PlaySound
  162. callba Music_RivalAlternateStart
  163. ld a, [wcf0d]
  164. cp $1
  165. jr nz, .asm_50fff
  166. call Route22Script_51008
  167. jr .asm_51002
  168. .asm_50fff
  169. call Route22Script_5100d
  170. .asm_51002
  171. ld a, $3
  172. ld [wRoute22CurScript], a
  173. ret
  174. Route22Script_51008:
  175. ld de, Route22RivalExitMovementData1
  176. jr Route22MoveRival1
  177. Route22Script_5100d:
  178. ld de, Route22RivalExitMovementData2
  179. Route22MoveRival1:
  180. ld a, $1
  181. ld [H_SPRITEINDEX], a
  182. jp MoveSprite
  183. Route22RivalExitMovementData1:
  184. db NPC_MOVEMENT_RIGHT
  185. db NPC_MOVEMENT_RIGHT
  186. db NPC_MOVEMENT_DOWN
  187. db NPC_MOVEMENT_DOWN
  188. db NPC_MOVEMENT_DOWN
  189. db NPC_MOVEMENT_DOWN
  190. db NPC_MOVEMENT_DOWN
  191. db $FF
  192. Route22RivalExitMovementData2:
  193. db NPC_MOVEMENT_UP
  194. db NPC_MOVEMENT_RIGHT
  195. db NPC_MOVEMENT_RIGHT
  196. db NPC_MOVEMENT_RIGHT
  197. db NPC_MOVEMENT_DOWN
  198. db NPC_MOVEMENT_DOWN
  199. db NPC_MOVEMENT_DOWN
  200. db NPC_MOVEMENT_DOWN
  201. db NPC_MOVEMENT_DOWN
  202. db NPC_MOVEMENT_DOWN
  203. db $FF
  204. Route22Script3:
  205. ld a, [wd730]
  206. bit 0, a
  207. ret nz
  208. xor a
  209. ld [wJoyIgnore], a
  210. ld a, HS_ROUTE_22_RIVAL_1
  211. ld [wMissableObjectIndex], a
  212. predef HideObject
  213. call PlayDefaultMusic
  214. ResetEvents EVENT_1ST_ROUTE22_RIVAL_BATTLE, EVENT_ROUTE22_RIVAL_WANTS_BATTLE
  215. ld a, $0
  216. ld [wRoute22CurScript], a
  217. ret
  218. Route22Script_5104e:
  219. ld a, $2
  220. ld [wEmotionBubbleSpriteIndex], a
  221. xor a ; EXCLAMATION_BUBBLE
  222. ld [wWhichEmotionBubble], a
  223. predef EmotionBubble
  224. ld a, [wWalkBikeSurfState]
  225. and a
  226. jr z, .skipYVisibilityTesta
  227. ld a, $ff
  228. ld [wNewSoundID], a
  229. call PlaySound
  230. .skipYVisibilityTesta
  231. ld a, $ff
  232. ld [wNewSoundID], a
  233. call PlaySound
  234. callba Music_RivalAlternateTempo
  235. ld a, $2
  236. ld [H_SPRITEINDEX], a
  237. call Route22MoveRivalSprite
  238. ld a, $4
  239. ld [wRoute22CurScript], a
  240. ret
  241. Route22Script4:
  242. ld a, [wd730]
  243. bit 0, a
  244. ret nz
  245. ld a, $2
  246. ld [H_SPRITEINDEX], a
  247. ld a, [wcf0d]
  248. cp $1
  249. jr nz, .asm_510a1
  250. ld a, PLAYER_DIR_DOWN
  251. ld [wPlayerMovingDirection], a
  252. ld a, SPRITE_FACING_UP
  253. jr .asm_510a8
  254. .asm_510a1
  255. ld a, PLAYER_DIR_LEFT
  256. ld [wPlayerMovingDirection], a
  257. ld a, SPRITE_FACING_RIGHT
  258. .asm_510a8
  259. ld [hSpriteFacingDirection], a
  260. call SetSpriteFacingDirectionAndDelay
  261. xor a
  262. ld [wJoyIgnore], a
  263. ld a, $2
  264. ld [hSpriteIndexOrTextID], a
  265. call DisplayTextID
  266. ld hl, wd72d
  267. set 6, [hl]
  268. set 7, [hl]
  269. ld hl, Route22RivalDefeatedText2
  270. ld de, Route22Text_511d0
  271. call SaveEndBattleTextPointers
  272. ld a, OPP_SONY2
  273. ld [wCurOpponent], a
  274. ld hl, StarterMons_510d9
  275. call Route22Script_50ed6
  276. ld a, $5
  277. ld [wRoute22CurScript], a
  278. ret
  279. StarterMons_510d9:
  280. db STARTER2,$0a
  281. db STARTER3,$0b
  282. db STARTER1,$0c
  283. Route22Script5:
  284. ld a, [wIsInBattle]
  285. cp $ff
  286. jp z, Route22Script_50ece
  287. ld a, $2
  288. ld [H_SPRITEINDEX], a
  289. ld a, [wcf0d]
  290. cp $1
  291. jr nz, .asm_510fb
  292. ld a, PLAYER_DIR_DOWN
  293. ld [wPlayerMovingDirection], a
  294. ld a, SPRITE_FACING_UP
  295. jr .asm_51102
  296. .asm_510fb
  297. ld a, PLAYER_DIR_LEFT
  298. ld [wPlayerMovingDirection], a
  299. ld a, SPRITE_FACING_RIGHT
  300. .asm_51102
  301. ld [hSpriteFacingDirection], a
  302. call SetSpriteFacingDirectionAndDelay
  303. ld a, $f0
  304. ld [wJoyIgnore], a
  305. SetEvent EVENT_BEAT_ROUTE22_RIVAL_2ND_BATTLE
  306. ld a, $2
  307. ld [hSpriteIndexOrTextID], a
  308. call DisplayTextID
  309. ld a, $ff
  310. ld [wNewSoundID], a
  311. call PlaySound
  312. callba Music_RivalAlternateStartAndTempo
  313. ld a, [wcf0d]
  314. cp $1
  315. jr nz, .asm_51134
  316. call Route22Script_5113d
  317. jr .asm_51137
  318. .asm_51134
  319. call Route22Script_51142
  320. .asm_51137
  321. ld a, $6
  322. ld [wRoute22CurScript], a
  323. ret
  324. Route22Script_5113d:
  325. ld de, MovementData_5114c
  326. jr Route22MoveRival2
  327. Route22Script_51142:
  328. ld de, MovementData_5114d
  329. Route22MoveRival2:
  330. ld a, $2
  331. ld [H_SPRITEINDEX], a
  332. jp MoveSprite
  333. MovementData_5114c:
  334. db NPC_MOVEMENT_LEFT
  335. MovementData_5114d:
  336. db NPC_MOVEMENT_LEFT
  337. db NPC_MOVEMENT_LEFT
  338. db NPC_MOVEMENT_LEFT
  339. db $FF
  340. Route22Script6:
  341. ld a, [wd730]
  342. bit 0, a
  343. ret nz
  344. xor a
  345. ld [wJoyIgnore], a
  346. ld a, HS_ROUTE_22_RIVAL_2
  347. ld [wMissableObjectIndex], a
  348. predef HideObject
  349. call PlayDefaultMusic
  350. ResetEvents EVENT_2ND_ROUTE22_RIVAL_BATTLE, EVENT_ROUTE22_RIVAL_WANTS_BATTLE
  351. ld a, $7
  352. ld [wRoute22CurScript], a
  353. ret
  354. Route22TextPointers:
  355. dw Route22Text1
  356. dw Route22Text2
  357. dw Route22FrontGateText
  358. Route22Text1:
  359. TX_ASM
  360. CheckEvent EVENT_BEAT_ROUTE22_RIVAL_1ST_BATTLE
  361. jr z, .asm_5118b
  362. ld hl, Route22RivalAfterBattleText1
  363. call PrintText
  364. jr .asm_51191
  365. .asm_5118b
  366. ld hl, Route22RivalBeforeBattleText1
  367. call PrintText
  368. .asm_51191
  369. jp TextScriptEnd
  370. Route22Text2:
  371. TX_ASM
  372. CheckEvent EVENT_BEAT_ROUTE22_RIVAL_2ND_BATTLE
  373. jr z, .asm_511a4
  374. ld hl, Route22RivalAfterBattleText2
  375. call PrintText
  376. jr .asm_511aa
  377. .asm_511a4
  378. ld hl, Route22RivalBeforeBattleText2
  379. call PrintText
  380. .asm_511aa
  381. jp TextScriptEnd
  382. Route22RivalBeforeBattleText1:
  383. TX_FAR _Route22RivalBeforeBattleText1
  384. db "@"
  385. Route22RivalAfterBattleText1:
  386. TX_FAR _Route22RivalAfterBattleText1
  387. db "@"
  388. Route22RivalDefeatedText1:
  389. TX_FAR _Route22RivalDefeatedText1
  390. db "@"
  391. Route22Text_511bc:
  392. TX_FAR _Route22Text_511bc
  393. db "@"
  394. Route22RivalBeforeBattleText2:
  395. TX_FAR _Route22RivalBeforeBattleText2
  396. db "@"
  397. Route22RivalAfterBattleText2:
  398. TX_FAR _Route22RivalAfterBattleText2
  399. db "@"
  400. Route22RivalDefeatedText2:
  401. TX_FAR _Route22RivalDefeatedText2
  402. db "@"
  403. Route22Text_511d0:
  404. TX_FAR _Route22Text_511d0
  405. db "@"
  406. Route22FrontGateText:
  407. TX_FAR _Route22FrontGateText
  408. db "@"