gamefreak.asm 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. LoadShootingStarGraphics:
  2. ld a, $f9
  3. ld [rOBP0], a
  4. ld a, $a4
  5. ld [rOBP1], a
  6. ld de, AnimationTileset2 + $30 ; star tile (top left quadrant)
  7. ld hl, vChars1 + $200
  8. lb bc, BANK(AnimationTileset2), $01
  9. call CopyVideoData
  10. ld de, AnimationTileset2 + $130 ; star tile (bottom left quadrant)
  11. ld hl, vChars1 + $210
  12. lb bc, BANK(AnimationTileset2), $01
  13. call CopyVideoData
  14. ld de, FallingStar
  15. ld hl, vChars1 + $220
  16. lb bc, BANK(FallingStar), (FallingStarEnd - FallingStar) / $10
  17. call CopyVideoData
  18. ld hl, GameFreakLogoOAMData
  19. ld de, wOAMBuffer + $60
  20. ld bc, GameFreakLogoOAMDataEnd - GameFreakLogoOAMData
  21. call CopyData
  22. ld hl, GameFreakShootingStarOAMData
  23. ld de, wOAMBuffer
  24. ld bc, GameFreakShootingStarOAMDataEnd - GameFreakShootingStarOAMData
  25. jp CopyData
  26. AnimateShootingStar:
  27. call LoadShootingStarGraphics
  28. ld a, SFX_SHOOTING_STAR
  29. call PlaySound
  30. ; Move the big star down and left across the screen.
  31. ld hl, wOAMBuffer
  32. lb bc, $a0, $4
  33. .bigStarLoop
  34. push hl
  35. push bc
  36. .bigStarInnerLoop
  37. ld a, [hl] ; Y
  38. add 4
  39. ld [hli], a
  40. ld a, [hl] ; X
  41. add -4
  42. ld [hli], a
  43. inc hl
  44. inc hl
  45. dec c
  46. jr nz, .bigStarInnerLoop
  47. ld c, 1
  48. call CheckForUserInterruption
  49. pop bc
  50. pop hl
  51. ret c
  52. ld a, [hl]
  53. cp 80
  54. jr nz, .next
  55. jr .bigStarLoop
  56. .next
  57. cp b
  58. jr nz, .bigStarLoop
  59. ; Clear big star OAM.
  60. ld hl, wOAMBuffer
  61. ld c, 4
  62. ld de, 4
  63. .clearOAMLoop
  64. ld [hl], 160
  65. add hl, de
  66. dec c
  67. jr nz, .clearOAMLoop
  68. ; Make Gamefreak logo flash.
  69. ld b, 3
  70. .flashLogoLoop
  71. ld hl, rOBP0
  72. rrc [hl]
  73. rrc [hl]
  74. ld c, 10
  75. call CheckForUserInterruption
  76. ret c
  77. dec b
  78. jr nz, .flashLogoLoop
  79. ; Copy 24 instances of the small stars OAM data.
  80. ; Note that their coordinates put them off-screen.
  81. ld de, wOAMBuffer
  82. ld a, 24
  83. .initSmallStarsOAMLoop
  84. push af
  85. ld hl, SmallStarsOAM
  86. ld bc, SmallStarsOAMEnd - SmallStarsOAM
  87. call CopyData
  88. pop af
  89. dec a
  90. jr nz, .initSmallStarsOAMLoop
  91. ; Animate the small stars falling from the Gamefreak logo.
  92. xor a
  93. ld [wMoveDownSmallStarsOAMCount], a
  94. ld hl, SmallStarsWaveCoordsPointerTable
  95. ld c, 6
  96. .smallStarsLoop
  97. ld a, [hli]
  98. ld e, a
  99. ld a, [hli]
  100. ld d, a
  101. push bc
  102. push hl
  103. ld hl, wOAMBuffer + $50
  104. ld c, 4
  105. .smallStarsInnerLoop ; introduce new wave of 4 small stars OAM entries
  106. ld a, [de]
  107. cp $ff
  108. jr z, .next2
  109. ld [hli], a ; Y
  110. inc de
  111. ld a, [de]
  112. ld [hli], a ; X
  113. inc de
  114. inc hl
  115. inc hl
  116. dec c
  117. jr nz, .smallStarsInnerLoop
  118. ld a, [wMoveDownSmallStarsOAMCount]
  119. cp 24
  120. jr z, .next2
  121. add 6 ; should be 4, but the extra 2 aren't visible on screen
  122. ld [wMoveDownSmallStarsOAMCount], a
  123. .next2
  124. call MoveDownSmallStars
  125. push af
  126. ; shift the existing OAM entries down to make room for the next wave
  127. ld hl, wOAMBuffer + $10
  128. ld de, wOAMBuffer
  129. ld bc, $50
  130. call CopyData
  131. pop af
  132. pop hl
  133. pop bc
  134. ret c
  135. dec c
  136. jr nz, .smallStarsLoop
  137. and a
  138. ret
  139. SmallStarsOAM:
  140. db $00,$00,$A2,$90
  141. SmallStarsOAMEnd:
  142. SmallStarsWaveCoordsPointerTable:
  143. dw SmallStarsWave1Coords
  144. dw SmallStarsWave2Coords
  145. dw SmallStarsWave3Coords
  146. dw SmallStarsWave4Coords
  147. dw SmallStarsEmptyWave
  148. dw SmallStarsEmptyWave
  149. ; The stars that fall from the Gamefreak logo come in 4 waves of 4 OAM entries.
  150. ; These arrays contain the Y and X coordinates of each OAM entry.
  151. SmallStarsWave1Coords:
  152. db $68,$30
  153. db $68,$40
  154. db $68,$58
  155. db $68,$78
  156. SmallStarsWave2Coords:
  157. db $68,$38
  158. db $68,$48
  159. db $68,$60
  160. db $68,$70
  161. SmallStarsWave3Coords:
  162. db $68,$34
  163. db $68,$4C
  164. db $68,$54
  165. db $68,$64
  166. SmallStarsWave4Coords:
  167. db $68,$3C
  168. db $68,$5C
  169. db $68,$6C
  170. db $68,$74
  171. SmallStarsEmptyWave:
  172. db $FF
  173. MoveDownSmallStars:
  174. ld b, 8
  175. .loop
  176. ld hl, wOAMBuffer + $5c
  177. ld a, [wMoveDownSmallStarsOAMCount]
  178. ld de, -4
  179. ld c, a
  180. .innerLoop
  181. inc [hl] ; Y
  182. add hl, de
  183. dec c
  184. jr nz, .innerLoop
  185. ; Toggle the palette so that the lower star in the small stars tile blinks in
  186. ; and out.
  187. ld a, [rOBP1]
  188. xor %10100000
  189. ld [rOBP1], a
  190. ld c, 3
  191. call CheckForUserInterruption
  192. ret c
  193. dec b
  194. jr nz, .loop
  195. ret
  196. GameFreakLogoOAMData:
  197. db $48,$50,$8D,$00
  198. db $48,$58,$8E,$00
  199. db $50,$50,$8F,$00
  200. db $50,$58,$90,$00
  201. db $58,$50,$91,$00
  202. db $58,$58,$92,$00
  203. db $60,$30,$80,$00
  204. db $60,$38,$81,$00
  205. db $60,$40,$82,$00
  206. db $60,$48,$83,$00
  207. db $60,$50,$93,$00
  208. db $60,$58,$84,$00
  209. db $60,$60,$85,$00
  210. db $60,$68,$83,$00
  211. db $60,$70,$81,$00
  212. db $60,$78,$86,$00
  213. GameFreakLogoOAMDataEnd:
  214. GameFreakShootingStarOAMData:
  215. db $00,$A0,$A0,$10
  216. db $00,$A8,$A0,$30
  217. db $08,$A0,$A1,$10
  218. db $08,$A8,$A1,$30
  219. GameFreakShootingStarOAMDataEnd:
  220. FallingStar:
  221. INCBIN "gfx/falling_star.2bpp"
  222. FallingStarEnd: