intro.asm 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. MOVE_GENGAR_RIGHT EQU $00
  2. MOVE_GENGAR_LEFT EQU $01
  3. MOVE_NIDORINO_RIGHT EQU $ff
  4. PlayIntro:
  5. xor a
  6. ld [hJoyHeld], a
  7. inc a
  8. ld [H_AUTOBGTRANSFERENABLED], a
  9. call PlayShootingStar
  10. call PlayIntroScene
  11. call GBFadeOutToWhite
  12. xor a
  13. ld [hSCX], a
  14. ld [H_AUTOBGTRANSFERENABLED], a
  15. call ClearSprites
  16. call DelayFrame
  17. ret
  18. PlayIntroScene:
  19. ld b, SET_PAL_NIDORINO_INTRO
  20. call RunPaletteCommand
  21. ld a, %11100100
  22. ld [rBGP], a
  23. ld [rOBP0], a
  24. ld [rOBP1], a
  25. xor a
  26. ld [hSCX], a
  27. ld b, $3 ; Gengar tiles
  28. call IntroCopyTiles
  29. ld a, 0
  30. ld [wBaseCoordX], a
  31. ld a, 80
  32. ld [wBaseCoordY], a
  33. lb bc, 6, 6
  34. call InitIntroNidorinoOAM
  35. lb de, 80 / 2, MOVE_NIDORINO_RIGHT
  36. call IntroMoveMon
  37. ret c
  38. ; hip
  39. ld a, SFX_INTRO_HIP
  40. call PlaySound
  41. xor a
  42. ld [wIntroNidorinoBaseTile], a
  43. ld de, IntroNidorinoAnimation1
  44. call AnimateIntroNidorino
  45. ; hop
  46. ld a, SFX_INTRO_HOP
  47. call PlaySound
  48. ld de, IntroNidorinoAnimation2
  49. call AnimateIntroNidorino
  50. ld c, $a
  51. call CheckForUserInterruption
  52. ret c
  53. ; hip
  54. ld a, SFX_INTRO_HIP
  55. call PlaySound
  56. ld de, IntroNidorinoAnimation1
  57. call AnimateIntroNidorino
  58. ; hop
  59. ld a, SFX_INTRO_HOP
  60. call PlaySound
  61. ld de, IntroNidorinoAnimation2
  62. call AnimateIntroNidorino
  63. ld c, $1e
  64. call CheckForUserInterruption
  65. ret c
  66. ; raise
  67. ld b, $4
  68. call IntroCopyTiles
  69. ld a, SFX_INTRO_RAISE
  70. call PlaySound
  71. lb de, 8 / 2, MOVE_GENGAR_LEFT
  72. call IntroMoveMon
  73. ld c, $1e
  74. call CheckForUserInterruption
  75. ret c
  76. ; slash
  77. ld b, $5
  78. call IntroCopyTiles
  79. ld a, SFX_INTRO_CRASH
  80. call PlaySound
  81. lb de, 16 / 2, MOVE_GENGAR_RIGHT
  82. call IntroMoveMon
  83. ; hip
  84. ld a, SFX_INTRO_HIP
  85. call PlaySound
  86. ld a, $24
  87. ld [wIntroNidorinoBaseTile], a
  88. ld de, IntroNidorinoAnimation3
  89. call AnimateIntroNidorino
  90. ld c, $1e
  91. call CheckForUserInterruption
  92. ret c
  93. lb de, 8 / 2, MOVE_GENGAR_LEFT
  94. call IntroMoveMon
  95. ld b, $3
  96. call IntroCopyTiles
  97. ld c, $3c
  98. call CheckForUserInterruption
  99. ret c
  100. ; hip
  101. ld a, SFX_INTRO_HIP
  102. call PlaySound
  103. xor a
  104. ld [wIntroNidorinoBaseTile], a
  105. ld de, IntroNidorinoAnimation4
  106. call AnimateIntroNidorino
  107. ; hop
  108. ld a, SFX_INTRO_HOP
  109. call PlaySound
  110. ld de, IntroNidorinoAnimation5
  111. call AnimateIntroNidorino
  112. ld c, $14
  113. call CheckForUserInterruption
  114. ret c
  115. ld a, $24
  116. ld [wIntroNidorinoBaseTile], a
  117. ld de, IntroNidorinoAnimation6
  118. call AnimateIntroNidorino
  119. ld c, $1e
  120. call CheckForUserInterruption
  121. ret c
  122. ; lunge
  123. ld a, SFX_INTRO_LUNGE
  124. call PlaySound
  125. ld a, $48
  126. ld [wIntroNidorinoBaseTile], a
  127. ld de, IntroNidorinoAnimation7
  128. jp AnimateIntroNidorino
  129. AnimateIntroNidorino:
  130. ld a, [de]
  131. cp $50
  132. ret z
  133. ld [wBaseCoordY], a
  134. inc de
  135. ld a, [de]
  136. ld [wBaseCoordX], a
  137. push de
  138. ld c, 6 * 6
  139. call UpdateIntroNidorinoOAM
  140. ld c, 5
  141. call DelayFrames
  142. pop de
  143. inc de
  144. jr AnimateIntroNidorino
  145. UpdateIntroNidorinoOAM:
  146. ld hl, wOAMBuffer
  147. ld a, [wIntroNidorinoBaseTile]
  148. ld d, a
  149. .loop
  150. ld a, [wBaseCoordY]
  151. add [hl]
  152. ld [hli], a ; Y
  153. ld a, [wBaseCoordX]
  154. add [hl]
  155. ld [hli], a ; X
  156. ld a, d
  157. ld [hli], a ; tile
  158. inc hl
  159. inc d
  160. dec c
  161. jr nz, .loop
  162. ret
  163. InitIntroNidorinoOAM:
  164. ld hl, wOAMBuffer
  165. ld d, 0
  166. .loop
  167. push bc
  168. ld a, [wBaseCoordY]
  169. ld e, a
  170. .innerLoop
  171. ld a, e
  172. add 8
  173. ld e, a
  174. ld [hli], a ; Y
  175. ld a, [wBaseCoordX]
  176. ld [hli], a ; X
  177. ld a, d
  178. ld [hli], a ; tile
  179. ld a, $80
  180. ld [hli], a ; attributes
  181. inc d
  182. dec c
  183. jr nz, .innerLoop
  184. ld a, [wBaseCoordX]
  185. add 8
  186. ld [wBaseCoordX], a
  187. pop bc
  188. dec b
  189. jr nz, .loop
  190. ret
  191. IntroClearScreen:
  192. ld hl, vBGMap1
  193. ld bc, $240
  194. jr IntroClearCommon
  195. IntroClearMiddleOfScreen:
  196. ; clear the area of the tile map between the black bars on the top and bottom
  197. coord hl, 0, 4
  198. ld bc, SCREEN_WIDTH * 10
  199. IntroClearCommon:
  200. ld [hl], $0
  201. inc hl
  202. dec bc
  203. ld a, b
  204. or c
  205. jr nz, IntroClearCommon
  206. ret
  207. IntroPlaceBlackTiles:
  208. ld a, $1
  209. .loop
  210. ld [hli], a
  211. dec c
  212. jr nz, .loop
  213. ret
  214. IntroMoveMon:
  215. ; d = number of times to move the mon (2 pixels each time)
  216. ; e: $00 = move Gengar right, $01 = move Gengar left, $ff = move Nidorino right
  217. ld a, e
  218. cp $ff
  219. jr z, .moveNidorinoRight
  220. cp $1
  221. jr z, .moveGengarLeft
  222. ; move Gengar right
  223. ld a, [hSCX]
  224. dec a
  225. dec a
  226. jr .next
  227. .moveNidorinoRight
  228. push de
  229. ld a, 2
  230. ld [wBaseCoordX], a
  231. xor a
  232. ld [wBaseCoordY], a
  233. ld c, 6 * 6
  234. call UpdateIntroNidorinoOAM
  235. pop de
  236. .moveGengarLeft
  237. ld a, [hSCX]
  238. inc a
  239. inc a
  240. .next
  241. ld [hSCX], a
  242. push de
  243. ld c, 2
  244. call CheckForUserInterruption
  245. pop de
  246. ret c
  247. dec d
  248. jr nz, IntroMoveMon
  249. ret
  250. IntroCopyTiles:
  251. coord hl, 13, 7
  252. CopyTileIDsFromList_ZeroBaseTileID:
  253. ld c, 0
  254. predef_jump CopyTileIDsFromList
  255. PlayMoveSoundB:
  256. ; unused
  257. predef GetMoveSoundB
  258. ld a, b
  259. jp PlaySound
  260. LoadIntroGraphics:
  261. ld hl, FightIntroBackMon
  262. ld de, vChars2
  263. ld bc, FightIntroBackMonEnd - FightIntroBackMon
  264. ld a, BANK(FightIntroBackMon)
  265. call FarCopyData2
  266. ld hl, GameFreakIntro
  267. ld de, vChars2 + $600
  268. ld bc, GameFreakIntroEnd - GameFreakIntro
  269. ld a, BANK(GameFreakIntro)
  270. call FarCopyData2
  271. ld hl, GameFreakIntro
  272. ld de, vChars1
  273. ld bc, GameFreakIntroEnd - GameFreakIntro
  274. ld a, BANK(GameFreakIntro)
  275. call FarCopyData2
  276. ld hl, FightIntroFrontMon
  277. ld de, vChars0
  278. ld bc, FightIntroFrontMonEnd - FightIntroFrontMon
  279. ld a, BANK(FightIntroFrontMon)
  280. jp FarCopyData2
  281. PlayShootingStar:
  282. ld b, SET_PAL_GAME_FREAK_INTRO
  283. call RunPaletteCommand
  284. callba LoadCopyrightAndTextBoxTiles
  285. ld a, %11100100
  286. ld [rBGP], a
  287. ld c, 180
  288. call DelayFrames
  289. call ClearScreen
  290. call DisableLCD
  291. xor a
  292. ld [wCurOpponent], a
  293. call IntroDrawBlackBars
  294. call LoadIntroGraphics
  295. call EnableLCD
  296. ld hl, rLCDC
  297. res 5, [hl]
  298. set 3, [hl]
  299. ld c, 64
  300. call DelayFrames
  301. callba AnimateShootingStar
  302. push af
  303. pop af
  304. jr c, .next ; skip the delay if the user interrupted the animation
  305. ld c, 40
  306. call DelayFrames
  307. .next
  308. ld a, BANK(Music_IntroBattle)
  309. ld [wAudioROMBank], a
  310. ld [wAudioSavedROMBank], a
  311. ld a, MUSIC_INTRO_BATTLE
  312. ld [wNewSoundID], a
  313. call PlaySound
  314. call IntroClearMiddleOfScreen
  315. call ClearSprites
  316. jp Delay3
  317. IntroDrawBlackBars:
  318. ; clear the screen and draw black bars on the top and bottom
  319. call IntroClearScreen
  320. coord hl, 0, 0
  321. ld c, SCREEN_WIDTH * 4
  322. call IntroPlaceBlackTiles
  323. coord hl, 0, 14
  324. ld c, SCREEN_WIDTH * 4
  325. call IntroPlaceBlackTiles
  326. ld hl, vBGMap1
  327. ld c, $80
  328. call IntroPlaceBlackTiles
  329. ld hl, vBGMap1 + $1c0
  330. ld c, $80
  331. jp IntroPlaceBlackTiles
  332. EmptyFunc4:
  333. ret
  334. IntroNidorinoAnimation0:
  335. db 0, 0
  336. db $50
  337. IntroNidorinoAnimation1:
  338. ; This is a sequence of pixel movements for part of the Nidorino animation. This
  339. ; list describes how Nidorino should hop.
  340. ; First byte is y movement, second byte is x movement
  341. db 0, 0
  342. db -2, 2
  343. db -1, 2
  344. db 1, 2
  345. db 2, 2
  346. db $50 ; list terminator
  347. IntroNidorinoAnimation2:
  348. ; This is a sequence of pixel movements for part of the Nidorino animation.
  349. ; First byte is y movement, second byte is x movement
  350. db 0, 0
  351. db -2, -2
  352. db -1, -2
  353. db 1, -2
  354. db 2, -2
  355. db $50 ; list terminator
  356. IntroNidorinoAnimation3:
  357. ; This is a sequence of pixel movements for part of the Nidorino animation.
  358. ; First byte is y movement, second byte is x movement
  359. db 0, 0
  360. db -12, 6
  361. db -8, 6
  362. db 8, 6
  363. db 12, 6
  364. db $50 ; list terminator
  365. IntroNidorinoAnimation4:
  366. ; This is a sequence of pixel movements for part of the Nidorino animation.
  367. ; First byte is y movement, second byte is x movement
  368. db 0, 0
  369. db -8, -4
  370. db -4, -4
  371. db 4, -4
  372. db 8, -4
  373. db $50 ; list terminator
  374. IntroNidorinoAnimation5:
  375. ; This is a sequence of pixel movements for part of the Nidorino animation.
  376. ; First byte is y movement, second byte is x movement
  377. db 0, 0
  378. db -8, 4
  379. db -4, 4
  380. db 4, 4
  381. db 8, 4
  382. db $50 ; list terminator
  383. IntroNidorinoAnimation6:
  384. ; This is a sequence of pixel movements for part of the Nidorino animation.
  385. ; First byte is y movement, second byte is x movement
  386. db 0, 0
  387. db 2, 0
  388. db 2, 0
  389. db 0, 0
  390. db $50 ; list terminator
  391. IntroNidorinoAnimation7:
  392. ; This is a sequence of pixel movements for part of the Nidorino animation.
  393. ; First byte is y movement, second byte is x movement
  394. db -8, -16
  395. db -7, -14
  396. db -6, -12
  397. db -4, -10
  398. db $50 ; list terminator
  399. GameFreakIntro:
  400. INCBIN "gfx/gamefreak_intro.2bpp"
  401. INCBIN "gfx/gamefreak_logo.2bpp"
  402. ds $10 ; blank tile
  403. GameFreakIntroEnd:
  404. FightIntroBackMon:
  405. INCBIN "gfx/intro_fight.2bpp"
  406. FightIntroBackMonEnd:
  407. FightIntroFrontMon:
  408. IF DEF(_RED)
  409. INCBIN "gfx/red/intro_nido_1.2bpp"
  410. INCBIN "gfx/red/intro_nido_2.2bpp"
  411. INCBIN "gfx/red/intro_nido_3.2bpp"
  412. ENDC
  413. IF DEF(_BLUE)
  414. INCBIN "gfx/blue/intro_purin_1.2bpp"
  415. INCBIN "gfx/blue/intro_purin_2.2bpp"
  416. INCBIN "gfx/blue/intro_purin_3.2bpp"
  417. ENDC
  418. FightIntroFrontMonEnd:
  419. ds $10 ; blank tile