titlescreen.asm 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. ; copy text of fixed length NAME_LENGTH (like player name, rival name, mon names, ...)
  2. CopyFixedLengthText:
  3. ld bc, NAME_LENGTH
  4. jp CopyData
  5. SetDefaultNamesBeforeTitlescreen:
  6. ld hl, NintenText
  7. ld de, wPlayerName
  8. call CopyFixedLengthText
  9. ld hl, SonyText
  10. ld de, wRivalName
  11. call CopyFixedLengthText
  12. xor a
  13. ld [hWY], a
  14. ld [wLetterPrintingDelayFlags], a
  15. ld hl, wd732
  16. ld [hli], a
  17. ld [hli], a
  18. ld [hl], a
  19. ld a, BANK(Music_TitleScreen)
  20. ld [wAudioROMBank], a
  21. ld [wAudioSavedROMBank], a
  22. DisplayTitleScreen:
  23. call GBPalWhiteOut
  24. ld a, $1
  25. ld [H_AUTOBGTRANSFERENABLED], a
  26. xor a
  27. ld [hTilesetType], a
  28. ld [hSCX], a
  29. ld a, $40
  30. ld [hSCY], a
  31. ld a, $90
  32. ld [hWY], a
  33. call ClearScreen
  34. call DisableLCD
  35. call LoadFontTilePatterns
  36. ld hl, NintendoCopyrightLogoGraphics
  37. ld de, vTitleLogo2 + $100
  38. ld bc, $50
  39. ld a, BANK(NintendoCopyrightLogoGraphics)
  40. call FarCopyData2
  41. ld hl, GamefreakLogoGraphics
  42. ld de, vTitleLogo2 + $100 + $50
  43. ld bc, $90
  44. ld a, BANK(GamefreakLogoGraphics)
  45. call FarCopyData2
  46. ld hl, PokemonLogoGraphics
  47. ld de, vTitleLogo
  48. ld bc, $600
  49. ld a, BANK(PokemonLogoGraphics)
  50. call FarCopyData2 ; first chunk
  51. ld hl, PokemonLogoGraphics+$600
  52. ld de, vTitleLogo2
  53. ld bc, $100
  54. ld a, BANK(PokemonLogoGraphics)
  55. call FarCopyData2 ; second chunk
  56. ld hl, Version_GFX
  57. ld de, vChars2 + $600 - (Version_GFXEnd - Version_GFX - $50)
  58. ld bc, Version_GFXEnd - Version_GFX
  59. ld a, BANK(Version_GFX)
  60. call FarCopyDataDouble
  61. call ClearBothBGMaps
  62. ; place tiles for pokemon logo (except for the last row)
  63. coord hl, 2, 1
  64. ld a, $80
  65. ld de, SCREEN_WIDTH
  66. ld c, 6
  67. .pokemonLogoTileLoop
  68. ld b, $10
  69. push hl
  70. .pokemonLogoTileRowLoop ; place tiles for one row
  71. ld [hli], a
  72. inc a
  73. dec b
  74. jr nz, .pokemonLogoTileRowLoop
  75. pop hl
  76. add hl, de
  77. dec c
  78. jr nz, .pokemonLogoTileLoop
  79. ; place tiles for the last row of the pokemon logo
  80. coord hl, 2, 7
  81. ld a, $31
  82. ld b, $10
  83. .pokemonLogoLastTileRowLoop
  84. ld [hli], a
  85. inc a
  86. dec b
  87. jr nz, .pokemonLogoLastTileRowLoop
  88. call DrawPlayerCharacter
  89. ; put a pokeball in the player's hand
  90. ld hl, wOAMBuffer + $28
  91. ld a, $74
  92. ld [hl], a
  93. ; place tiles for title screen copyright
  94. coord hl, 2, 17
  95. ld de, .tileScreenCopyrightTiles
  96. ld b, $10
  97. .tileScreenCopyrightTilesLoop
  98. ld a, [de]
  99. ld [hli], a
  100. inc de
  101. dec b
  102. jr nz, .tileScreenCopyrightTilesLoop
  103. jr .next
  104. .tileScreenCopyrightTiles
  105. db $41,$42,$43,$42,$44,$42,$45,$46,$47,$48,$49,$4A,$4B,$4C,$4D,$4E ; ©'95.'96.'98 GAME FREAK inc.
  106. .next
  107. call SaveScreenTilesToBuffer2
  108. call LoadScreenTilesFromBuffer2
  109. call EnableLCD
  110. IF DEF(_RED)
  111. ld a, CHARMANDER ; which Pokemon to show first on the title screen
  112. ENDC
  113. IF DEF(_BLUE)
  114. ld a, SQUIRTLE ; which Pokemon to show first on the title screen
  115. ENDC
  116. ld [wTitleMonSpecies], a
  117. call LoadTitleMonSprite
  118. ld a, (vBGMap0 + $300) / $100
  119. call TitleScreenCopyTileMapToVRAM
  120. call SaveScreenTilesToBuffer1
  121. ld a, $40
  122. ld [hWY], a
  123. call LoadScreenTilesFromBuffer2
  124. ld a, vBGMap0 / $100
  125. call TitleScreenCopyTileMapToVRAM
  126. ld b, SET_PAL_TITLE_SCREEN
  127. call RunPaletteCommand
  128. call GBPalNormal
  129. ld a, %11100100
  130. ld [rOBP0], a
  131. ; make pokemon logo bounce up and down
  132. ld bc, hSCY ; background scroll Y
  133. ld hl, .TitleScreenPokemonLogoYScrolls
  134. .bouncePokemonLogoLoop
  135. ld a, [hli]
  136. and a
  137. jr z, .finishedBouncingPokemonLogo
  138. ld d, a
  139. cp -3
  140. jr nz, .skipPlayingSound
  141. ld a, SFX_INTRO_CRASH
  142. call PlaySound
  143. .skipPlayingSound
  144. ld a, [hli]
  145. ld e, a
  146. call .ScrollTitleScreenPokemonLogo
  147. jr .bouncePokemonLogoLoop
  148. .TitleScreenPokemonLogoYScrolls:
  149. ; Controls the bouncing effect of the Pokemon logo on the title screen
  150. db -4,16 ; y scroll amount, number of times to scroll
  151. db 3,4
  152. db -3,4
  153. db 2,2
  154. db -2,2
  155. db 1,2
  156. db -1,2
  157. db 0 ; terminate list with 0
  158. .ScrollTitleScreenPokemonLogo:
  159. ; Scrolls the Pokemon logo on the title screen to create the bouncing effect
  160. ; Scrolls d pixels e times
  161. call DelayFrame
  162. ld a, [bc] ; background scroll Y
  163. add d
  164. ld [bc], a
  165. dec e
  166. jr nz, .ScrollTitleScreenPokemonLogo
  167. ret
  168. .finishedBouncingPokemonLogo
  169. call LoadScreenTilesFromBuffer1
  170. ld c, 36
  171. call DelayFrames
  172. ld a, SFX_INTRO_WHOOSH
  173. call PlaySound
  174. ; scroll game version in from the right
  175. call PrintGameVersionOnTitleScreen
  176. ld a, SCREEN_HEIGHT_PIXELS
  177. ld [hWY], a
  178. ld d, 144
  179. .scrollTitleScreenGameVersionLoop
  180. ld h, d
  181. ld l, 64
  182. call ScrollTitleScreenGameVersion
  183. ld h, 0
  184. ld l, 80
  185. call ScrollTitleScreenGameVersion
  186. ld a, d
  187. add 4
  188. ld d, a
  189. and a
  190. jr nz, .scrollTitleScreenGameVersionLoop
  191. ld a, vBGMap1 / $100
  192. call TitleScreenCopyTileMapToVRAM
  193. call LoadScreenTilesFromBuffer2
  194. call PrintGameVersionOnTitleScreen
  195. call Delay3
  196. call WaitForSoundToFinish
  197. ld a, MUSIC_TITLE_SCREEN
  198. ld [wNewSoundID], a
  199. call PlaySound
  200. xor a
  201. ld [wUnusedCC5B], a
  202. ; Keep scrolling in new mons indefinitely until the user performs input.
  203. .awaitUserInterruptionLoop
  204. ld c, 200
  205. call CheckForUserInterruption
  206. jr c, .finishedWaiting
  207. call TitleScreenScrollInMon
  208. ld c, 1
  209. call CheckForUserInterruption
  210. jr c, .finishedWaiting
  211. callba TitleScreenAnimateBallIfStarterOut
  212. call TitleScreenPickNewMon
  213. jr .awaitUserInterruptionLoop
  214. .finishedWaiting
  215. ld a, [wTitleMonSpecies]
  216. call PlayCry
  217. call WaitForSoundToFinish
  218. call GBPalWhiteOutWithDelay3
  219. call ClearSprites
  220. xor a
  221. ld [hWY], a
  222. inc a
  223. ld [H_AUTOBGTRANSFERENABLED], a
  224. call ClearScreen
  225. ld a, vBGMap0 / $100
  226. call TitleScreenCopyTileMapToVRAM
  227. ld a, vBGMap1 / $100
  228. call TitleScreenCopyTileMapToVRAM
  229. call Delay3
  230. call LoadGBPal
  231. ld a, [hJoyHeld]
  232. ld b, a
  233. and D_UP | SELECT | B_BUTTON
  234. cp D_UP | SELECT | B_BUTTON
  235. jp z, .doClearSaveDialogue
  236. jp MainMenu
  237. .doClearSaveDialogue
  238. jpba DoClearSaveDialogue
  239. TitleScreenPickNewMon:
  240. ld a, vBGMap0 / $100
  241. call TitleScreenCopyTileMapToVRAM
  242. .loop
  243. ; Keep looping until a mon different from the current one is picked.
  244. call Random
  245. and $f
  246. ld c, a
  247. ld b, 0
  248. ld hl, TitleMons
  249. add hl, bc
  250. ld a, [hl]
  251. ld hl, wTitleMonSpecies
  252. ; Can't be the same as before.
  253. cp [hl]
  254. jr z, .loop
  255. ld [hl], a
  256. call LoadTitleMonSprite
  257. ld a, $90
  258. ld [hWY], a
  259. ld d, 1 ; scroll out
  260. callba TitleScroll
  261. ret
  262. TitleScreenScrollInMon:
  263. ld d, 0 ; scroll in
  264. callba TitleScroll
  265. xor a
  266. ld [hWY], a
  267. ret
  268. ScrollTitleScreenGameVersion:
  269. .wait
  270. ld a, [rLY]
  271. cp l
  272. jr nz, .wait
  273. ld a, h
  274. ld [rSCX], a
  275. .wait2
  276. ld a, [rLY]
  277. cp h
  278. jr z, .wait2
  279. ret
  280. DrawPlayerCharacter:
  281. ld hl, PlayerCharacterTitleGraphics
  282. ld de, vSprites
  283. ld bc, PlayerCharacterTitleGraphicsEnd - PlayerCharacterTitleGraphics
  284. ld a, BANK(PlayerCharacterTitleGraphics)
  285. call FarCopyData2
  286. call ClearSprites
  287. xor a
  288. ld [wPlayerCharacterOAMTile], a
  289. ld hl, wOAMBuffer
  290. ld de, $605a
  291. ld b, 7
  292. .loop
  293. push de
  294. ld c, 5
  295. .innerLoop
  296. ld a, d
  297. ld [hli], a ; Y
  298. ld a, e
  299. ld [hli], a ; X
  300. add 8
  301. ld e, a
  302. ld a, [wPlayerCharacterOAMTile]
  303. ld [hli], a ; tile
  304. inc a
  305. ld [wPlayerCharacterOAMTile], a
  306. inc hl
  307. dec c
  308. jr nz, .innerLoop
  309. pop de
  310. ld a, 8
  311. add d
  312. ld d, a
  313. dec b
  314. jr nz, .loop
  315. ret
  316. ClearBothBGMaps:
  317. ld hl, vBGMap0
  318. ld bc, $400 * 2
  319. ld a, " "
  320. jp FillMemory
  321. LoadTitleMonSprite:
  322. ld [wcf91], a
  323. ld [wd0b5], a
  324. coord hl, 5, 10
  325. call GetMonHeader
  326. jp LoadFrontSpriteByMonIndex
  327. TitleScreenCopyTileMapToVRAM:
  328. ld [H_AUTOBGTRANSFERDEST + 1], a
  329. jp Delay3
  330. LoadCopyrightAndTextBoxTiles:
  331. xor a
  332. ld [hWY], a
  333. call ClearScreen
  334. call LoadTextBoxTilePatterns
  335. LoadCopyrightTiles:
  336. ld de, NintendoCopyrightLogoGraphics
  337. ld hl, vChars2 + $600
  338. lb bc, BANK(NintendoCopyrightLogoGraphics), (GamefreakLogoGraphicsEnd - NintendoCopyrightLogoGraphics) / $10
  339. call CopyVideoData
  340. coord hl, 2, 7
  341. ld de, CopyrightTextString
  342. jp PlaceString
  343. CopyrightTextString:
  344. db $60,$61,$62,$61,$63,$61,$64,$7F,$65,$66,$67,$68,$69,$6A ; ©'95.'96.'98 Nintendo
  345. next $60,$61,$62,$61,$63,$61,$64,$7F,$6B,$6C,$6D,$6E,$6F,$70,$71,$72 ; ©'95.'96.'98 Creatures inc.
  346. next $60,$61,$62,$61,$63,$61,$64,$7F,$73,$74,$75,$76,$77,$78,$79,$7A,$7B ; ©'95.'96.'98 GAME FREAK inc.
  347. db "@"
  348. INCLUDE "data/title_mons.asm"
  349. ; prints version text (red, blue)
  350. PrintGameVersionOnTitleScreen:
  351. coord hl, 7, 8
  352. ld de, VersionOnTitleScreenText
  353. jp PlaceString
  354. ; these point to special tiles specifically loaded for that purpose and are not usual text
  355. VersionOnTitleScreenText:
  356. IF DEF(_RED)
  357. db $60,$61,$7F,$65,$66,$67,$68,$69,"@" ; "Red Version"
  358. ENDC
  359. IF DEF(_BLUE)
  360. db $61,$62,$63,$64,$65,$66,$67,$68,"@" ; "Blue Version"
  361. ENDC
  362. NintenText: db "NINTEN@"
  363. SonyText: db "SONY@"