pokered/engine/movie/titlescreen.asm

404 lines
8.1 KiB
NASM
Raw Normal View History

; copy text of fixed length NAME_LENGTH (like player name, rival name, mon names, ...)
2016-06-12 00:24:04 +00:00
CopyFixedLengthText:
ld bc, NAME_LENGTH
2014-05-22 22:13:20 +00:00
jp CopyData
SetDefaultNamesBeforeTitlescreen::
2014-05-22 22:13:20 +00:00
ld hl, NintenText
ld de, wPlayerName
2014-05-22 22:13:20 +00:00
call CopyFixedLengthText
ld hl, SonyText
2015-08-31 02:38:41 +00:00
ld de, wRivalName
2014-05-22 22:13:20 +00:00
call CopyFixedLengthText
xor a
2014-09-23 22:02:03 +00:00
ld [hWY], a
2015-07-15 02:46:52 +00:00
ld [wLetterPrintingDelayFlags], a
ld hl, wd732
2014-05-22 22:13:20 +00:00
ld [hli], a
ld [hli], a
ld [hl], a
2014-06-09 20:18:29 +00:00
ld a, BANK(Music_TitleScreen)
2015-08-09 05:32:44 +00:00
ld [wAudioROMBank], a
ld [wAudioSavedROMBank], a
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
DisplayTitleScreen:
2014-05-22 22:13:20 +00:00
call GBPalWhiteOut
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
2014-05-22 22:13:20 +00:00
xor a
2014-09-14 18:29:18 +00:00
ld [hTilesetType], a
2015-02-07 10:43:08 +00:00
ld [hSCX], a
2014-05-22 22:13:20 +00:00
ld a, $40
2015-02-07 10:43:08 +00:00
ld [hSCY], a
2014-05-22 22:13:20 +00:00
ld a, $90
2014-09-23 22:02:03 +00:00
ld [hWY], a
2014-05-22 22:13:20 +00:00
call ClearScreen
call DisableLCD
call LoadFontTilePatterns
ld hl, NintendoCopyrightLogoGraphics
2014-05-29 08:31:46 +00:00
ld de, vTitleLogo2 + $100
2014-05-22 22:13:20 +00:00
ld bc, $50
ld a, BANK(NintendoCopyrightLogoGraphics)
call FarCopyData2
ld hl, GamefreakLogoGraphics
2014-05-29 08:31:46 +00:00
ld de, vTitleLogo2 + $100 + $50
2014-05-22 22:13:20 +00:00
ld bc, $90
ld a, BANK(GamefreakLogoGraphics)
call FarCopyData2
ld hl, PokemonLogoGraphics
2014-05-29 08:31:46 +00:00
ld de, vTitleLogo
2014-05-22 22:13:20 +00:00
ld bc, $600
ld a, BANK(PokemonLogoGraphics)
call FarCopyData2 ; first chunk
ld hl, PokemonLogoGraphics+$600
2014-05-29 08:31:46 +00:00
ld de, vTitleLogo2
2014-05-22 22:13:20 +00:00
ld bc, $100
ld a, BANK(PokemonLogoGraphics)
call FarCopyData2 ; second chunk
ld hl, Version_GFX
ld de, vChars2 + $600 - (Version_GFXEnd - Version_GFX - $50)
2015-08-10 04:56:20 +00:00
ld bc, Version_GFXEnd - Version_GFX
2014-05-22 22:13:20 +00:00
ld a, BANK(Version_GFX)
call FarCopyDataDouble
2015-07-17 07:16:27 +00:00
call ClearBothBGMaps
; place tiles for pokemon logo (except for the last row)
2015-07-18 20:52:03 +00:00
coord hl, 2, 1
2014-05-22 22:13:20 +00:00
ld a, $80
2015-07-14 07:16:19 +00:00
ld de, SCREEN_WIDTH
2015-07-17 07:16:27 +00:00
ld c, 6
.pokemonLogoTileLoop
2014-05-22 22:13:20 +00:00
ld b, $10
push hl
2015-07-17 07:16:27 +00:00
.pokemonLogoTileRowLoop ; place tiles for one row
2014-05-22 22:13:20 +00:00
ld [hli], a
inc a
dec b
2015-07-17 07:16:27 +00:00
jr nz, .pokemonLogoTileRowLoop
2014-05-22 22:13:20 +00:00
pop hl
add hl, de
dec c
2015-07-17 07:16:27 +00:00
jr nz, .pokemonLogoTileLoop
; place tiles for the last row of the pokemon logo
2015-07-18 20:52:03 +00:00
coord hl, 2, 7
2014-05-22 22:13:20 +00:00
ld a, $31
ld b, $10
2015-07-17 07:16:27 +00:00
.pokemonLogoLastTileRowLoop
2014-05-22 22:13:20 +00:00
ld [hli], a
inc a
dec b
2015-07-17 07:16:27 +00:00
jr nz, .pokemonLogoLastTileRowLoop
call DrawPlayerCharacter
; put a pokeball in the player's hand
ld hl, wOAMBuffer + $28
2014-05-22 22:13:20 +00:00
ld a, $74
ld [hl], a
2015-07-17 07:16:27 +00:00
; place tiles for title screen copyright
2015-07-18 20:52:03 +00:00
coord hl, 2, 17
2015-07-17 07:16:27 +00:00
ld de, .tileScreenCopyrightTiles
2014-05-22 22:13:20 +00:00
ld b, $10
2015-07-17 07:16:27 +00:00
.tileScreenCopyrightTilesLoop
2014-05-22 22:13:20 +00:00
ld a, [de]
ld [hli], a
inc de
dec b
2015-07-17 07:16:27 +00:00
jr nz, .tileScreenCopyrightTilesLoop
jr .next
2014-05-22 22:13:20 +00:00
2016-06-12 06:42:19 +00:00
.tileScreenCopyrightTiles
2014-05-22 22:13:20 +00:00
db $41,$42,$43,$42,$44,$42,$45,$46,$47,$48,$49,$4A,$4B,$4C,$4D,$4E ; ©'95.'96.'98 GAME FREAK inc.
2015-07-17 07:16:27 +00:00
.next
2014-05-22 22:13:20 +00:00
call SaveScreenTilesToBuffer2
call LoadScreenTilesFromBuffer2
call EnableLCD
2014-10-17 08:42:32 +00:00
IF DEF(_RED)
ld a, CHARMANDER ; which Pokemon to show first on the title screen
2014-05-22 22:13:20 +00:00
ENDC
2014-10-17 08:42:32 +00:00
IF DEF(_BLUE)
ld a, SQUIRTLE ; which Pokemon to show first on the title screen
2014-05-22 22:13:20 +00:00
ENDC
2015-07-17 07:16:27 +00:00
ld [wTitleMonSpecies], a
call LoadTitleMonSprite
ld a, (vBGMap0 + $300) / $100
call TitleScreenCopyTileMapToVRAM
2014-05-22 22:13:20 +00:00
call SaveScreenTilesToBuffer1
ld a, $40
2014-09-23 22:02:03 +00:00
ld [hWY], a
2014-05-22 22:13:20 +00:00
call LoadScreenTilesFromBuffer2
2015-07-17 07:16:27 +00:00
ld a, vBGMap0 / $100
call TitleScreenCopyTileMapToVRAM
2015-08-12 09:16:56 +00:00
ld b, SET_PAL_TITLE_SCREEN
call RunPaletteCommand
2014-05-22 22:13:20 +00:00
call GBPalNormal
2015-07-17 07:16:27 +00:00
ld a, %11100100
ld [rOBP0], a
2015-07-17 07:16:27 +00:00
; make pokemon logo bounce up and down
ld bc, hSCY ; background scroll Y
ld hl, .TitleScreenPokemonLogoYScrolls
2015-07-17 07:16:27 +00:00
.bouncePokemonLogoLoop
2014-05-22 22:13:20 +00:00
ld a, [hli]
and a
2015-07-17 07:16:27 +00:00
jr z, .finishedBouncingPokemonLogo
2014-05-22 22:13:20 +00:00
ld d, a
2015-07-17 07:16:27 +00:00
cp -3
jr nz, .skipPlayingSound
2015-07-19 08:46:12 +00:00
ld a, SFX_INTRO_CRASH
2014-05-22 22:13:20 +00:00
call PlaySound
2015-07-17 07:16:27 +00:00
.skipPlayingSound
2014-05-22 22:13:20 +00:00
ld a, [hli]
ld e, a
call .ScrollTitleScreenPokemonLogo
2015-07-17 07:16:27 +00:00
jr .bouncePokemonLogoLoop
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
.TitleScreenPokemonLogoYScrolls:
2014-05-22 22:13:20 +00:00
; Controls the bouncing effect of the Pokemon logo on the title screen
db -4,16 ; y scroll amount, number of times to scroll
db 3,4
db -3,4
db 2,2
db -2,2
db 1,2
db -1,2
db 0 ; terminate list with 0
2016-06-12 04:30:05 +00:00
.ScrollTitleScreenPokemonLogo:
2014-05-22 22:13:20 +00:00
; Scrolls the Pokemon logo on the title screen to create the bouncing effect
; Scrolls d pixels e times
call DelayFrame
2015-07-17 07:16:27 +00:00
ld a, [bc] ; background scroll Y
2014-05-22 22:13:20 +00:00
add d
ld [bc], a
dec e
jr nz, .ScrollTitleScreenPokemonLogo
ret
2015-07-17 07:16:27 +00:00
.finishedBouncingPokemonLogo
2014-05-22 22:13:20 +00:00
call LoadScreenTilesFromBuffer1
ld c, 36
2014-05-22 22:13:20 +00:00
call DelayFrames
2015-07-19 08:46:12 +00:00
ld a, SFX_INTRO_WHOOSH
2014-05-22 22:13:20 +00:00
call PlaySound
2015-07-17 07:16:27 +00:00
; scroll game version in from the right
2014-05-22 22:13:20 +00:00
call PrintGameVersionOnTitleScreen
2015-07-17 07:16:27 +00:00
ld a, SCREEN_HEIGHT_PIXELS
2014-09-23 22:02:03 +00:00
ld [hWY], a
2015-07-17 07:16:27 +00:00
ld d, 144
.scrollTitleScreenGameVersionLoop
2014-05-22 22:13:20 +00:00
ld h, d
2015-07-17 07:16:27 +00:00
ld l, 64
call ScrollTitleScreenGameVersion
ld h, 0
ld l, 80
call ScrollTitleScreenGameVersion
2014-05-22 22:13:20 +00:00
ld a, d
2015-07-17 07:16:27 +00:00
add 4
2014-05-22 22:13:20 +00:00
ld d, a
and a
2015-07-17 07:16:27 +00:00
jr nz, .scrollTitleScreenGameVersionLoop
ld a, vBGMap1 / $100
call TitleScreenCopyTileMapToVRAM
2014-05-22 22:13:20 +00:00
call LoadScreenTilesFromBuffer2
call PrintGameVersionOnTitleScreen
call Delay3
call WaitForSoundToFinish
ld a, MUSIC_TITLE_SCREEN
2015-08-09 05:32:44 +00:00
ld [wNewSoundID], a
2014-05-22 22:13:20 +00:00
call PlaySound
xor a
2015-08-13 05:14:31 +00:00
ld [wUnusedCC5B], a
2015-07-17 07:16:27 +00:00
; Keep scrolling in new mons indefinitely until the user performs input.
.awaitUserInterruptionLoop
ld c, 200
2014-05-22 22:13:20 +00:00
call CheckForUserInterruption
2015-07-17 07:16:27 +00:00
jr c, .finishedWaiting
call TitleScreenScrollInMon
ld c, 1
2014-05-22 22:13:20 +00:00
call CheckForUserInterruption
2015-07-17 07:16:27 +00:00
jr c, .finishedWaiting
callba TitleScreenAnimateBallIfStarterOut
call TitleScreenPickNewMon
jr .awaitUserInterruptionLoop
.finishedWaiting
ld a, [wTitleMonSpecies]
2014-05-22 22:13:20 +00:00
call PlayCry
call WaitForSoundToFinish
call GBPalWhiteOutWithDelay3
2014-05-23 22:34:35 +00:00
call ClearSprites
2014-05-22 22:13:20 +00:00
xor a
2014-09-23 22:02:03 +00:00
ld [hWY], a
2014-05-22 22:13:20 +00:00
inc a
ld [H_AUTOBGTRANSFERENABLED], a
2014-05-22 22:13:20 +00:00
call ClearScreen
2015-07-17 07:16:27 +00:00
ld a, vBGMap0 / $100
call TitleScreenCopyTileMapToVRAM
ld a, vBGMap1 / $100
call TitleScreenCopyTileMapToVRAM
2014-05-22 22:13:20 +00:00
call Delay3
call LoadGBPal
2014-05-25 17:51:53 +00:00
ld a, [hJoyHeld]
2014-05-22 22:13:20 +00:00
ld b, a
2015-02-08 06:18:42 +00:00
and D_UP | SELECT | B_BUTTON
cp D_UP | SELECT | B_BUTTON
jp z, .doClearSaveDialogue
2014-05-22 22:13:20 +00:00
jp MainMenu
2015-02-08 06:18:42 +00:00
.doClearSaveDialogue
2015-07-19 18:56:13 +00:00
jpba DoClearSaveDialogue
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
TitleScreenPickNewMon:
2015-07-17 07:16:27 +00:00
ld a, vBGMap0 / $100
call TitleScreenCopyTileMapToVRAM
2014-05-22 22:13:20 +00:00
2015-07-17 07:16:27 +00:00
.loop
; Keep looping until a mon different from the current one is picked.
call Random
2014-05-22 22:13:20 +00:00
and $f
ld c, a
ld b, 0
ld hl, TitleMons
add hl, bc
ld a, [hl]
2015-07-17 07:16:27 +00:00
ld hl, wTitleMonSpecies
2014-05-22 22:13:20 +00:00
; Can't be the same as before.
cp [hl]
2015-07-17 07:16:27 +00:00
jr z, .loop
2014-05-22 22:13:20 +00:00
ld [hl], a
2015-07-17 07:16:27 +00:00
call LoadTitleMonSprite
2014-05-22 22:13:20 +00:00
ld a, $90
2014-09-23 22:02:03 +00:00
ld [hWY], a
2014-05-22 22:13:20 +00:00
ld d, 1 ; scroll out
callba TitleScroll
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
TitleScreenScrollInMon:
2014-05-22 22:13:20 +00:00
ld d, 0 ; scroll in
callba TitleScroll
2014-05-22 22:13:20 +00:00
xor a
2014-09-23 22:02:03 +00:00
ld [hWY], a
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
ScrollTitleScreenGameVersion:
2014-05-22 22:13:20 +00:00
.wait
2015-07-15 02:46:52 +00:00
ld a, [rLY]
2014-05-22 22:13:20 +00:00
cp l
jr nz, .wait
ld a, h
ld [rSCX], a
2014-05-22 22:13:20 +00:00
.wait2
2015-07-15 02:46:52 +00:00
ld a, [rLY]
2014-05-22 22:13:20 +00:00
cp h
jr z, .wait2
ret
2016-06-12 00:24:04 +00:00
DrawPlayerCharacter:
ld hl, PlayerCharacterTitleGraphics
2014-05-29 08:31:46 +00:00
ld de, vSprites
2015-08-10 04:56:20 +00:00
ld bc, PlayerCharacterTitleGraphicsEnd - PlayerCharacterTitleGraphics
2014-05-22 22:13:20 +00:00
ld a, BANK(PlayerCharacterTitleGraphics)
call FarCopyData2
2014-05-23 22:34:35 +00:00
call ClearSprites
2014-05-22 22:13:20 +00:00
xor a
2015-07-17 07:16:27 +00:00
ld [wPlayerCharacterOAMTile], a
2014-05-22 22:13:20 +00:00
ld hl, wOAMBuffer
ld de, $605a
2015-07-17 07:16:27 +00:00
ld b, 7
.loop
2014-05-22 22:13:20 +00:00
push de
2015-07-17 07:16:27 +00:00
ld c, 5
.innerLoop
2014-05-22 22:13:20 +00:00
ld a, d
2015-07-17 07:16:27 +00:00
ld [hli], a ; Y
2014-05-22 22:13:20 +00:00
ld a, e
2015-07-17 07:16:27 +00:00
ld [hli], a ; X
add 8
2014-05-22 22:13:20 +00:00
ld e, a
2015-07-17 07:16:27 +00:00
ld a, [wPlayerCharacterOAMTile]
ld [hli], a ; tile
2014-05-22 22:13:20 +00:00
inc a
2015-07-17 07:16:27 +00:00
ld [wPlayerCharacterOAMTile], a
2014-05-22 22:13:20 +00:00
inc hl
dec c
2015-07-17 07:16:27 +00:00
jr nz, .innerLoop
2014-05-22 22:13:20 +00:00
pop de
2015-07-17 07:16:27 +00:00
ld a, 8
2014-05-22 22:13:20 +00:00
add d
ld d, a
dec b
2015-07-17 07:16:27 +00:00
jr nz, .loop
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
ClearBothBGMaps:
2014-05-29 08:31:46 +00:00
ld hl, vBGMap0
2015-07-17 07:16:27 +00:00
ld bc, $400 * 2
ld a, " "
2014-05-22 22:13:20 +00:00
jp FillMemory
2016-06-12 00:24:04 +00:00
LoadTitleMonSprite:
ld [wcf91], a
ld [wd0b5], a
2015-07-18 20:52:03 +00:00
coord hl, 5, 10
2014-05-22 22:13:20 +00:00
call GetMonHeader
jp LoadFrontSpriteByMonIndex
2016-06-12 00:24:04 +00:00
TitleScreenCopyTileMapToVRAM:
ld [H_AUTOBGTRANSFERDEST + 1], a
2014-05-22 22:13:20 +00:00
jp Delay3
2016-06-12 00:24:04 +00:00
LoadCopyrightAndTextBoxTiles:
2014-05-22 22:13:20 +00:00
xor a
2014-09-23 22:02:03 +00:00
ld [hWY], a
2014-05-22 22:13:20 +00:00
call ClearScreen
call LoadTextBoxTilePatterns
2016-06-12 00:24:04 +00:00
LoadCopyrightTiles:
ld de, NintendoCopyrightLogoGraphics
2014-05-29 08:31:46 +00:00
ld hl, vChars2 + $600
2015-08-10 04:56:20 +00:00
lb bc, BANK(NintendoCopyrightLogoGraphics), (GamefreakLogoGraphicsEnd - NintendoCopyrightLogoGraphics) / $10
2014-05-22 22:13:20 +00:00
call CopyVideoData
2015-07-18 20:52:03 +00:00
coord hl, 2, 7
ld de, CopyrightTextString
2014-05-22 22:13:20 +00:00
jp PlaceString
2016-06-12 00:24:04 +00:00
CopyrightTextString:
2014-05-22 22:13:20 +00:00
db $60,$61,$62,$61,$63,$61,$64,$7F,$65,$66,$67,$68,$69,$6A ; ©'95.'96.'98 Nintendo
next $60,$61,$62,$61,$63,$61,$64,$7F,$6B,$6C,$6D,$6E,$6F,$70,$71,$72 ; ©'95.'96.'98 Creatures inc.
next $60,$61,$62,$61,$63,$61,$64,$7F,$73,$74,$75,$76,$77,$78,$79,$7A,$7B ; ©'95.'96.'98 GAME FREAK inc.
db "@"
INCLUDE "data/title_mons.asm"
; prints version text (red, blue)
2016-06-12 00:24:04 +00:00
PrintGameVersionOnTitleScreen:
2015-07-18 20:52:03 +00:00
coord hl, 7, 8
2014-05-22 22:13:20 +00:00
ld de, VersionOnTitleScreenText
jp PlaceString
; these point to special tiles specifically loaded for that purpose and are not usual text
2016-06-12 00:24:04 +00:00
VersionOnTitleScreenText:
2014-10-17 08:42:32 +00:00
IF DEF(_RED)
2014-05-22 22:13:20 +00:00
db $60,$61,$7F,$65,$66,$67,$68,$69,"@" ; "Red Version"
ENDC
2014-10-17 08:42:32 +00:00
IF DEF(_BLUE)
2014-05-22 22:13:20 +00:00
db $61,$62,$63,$64,$65,$66,$67,$68,"@" ; "Blue Version"
ENDC
2016-09-18 00:37:32 +00:00
NintenText: db "NINTEN@"
SonyText: db "SONY@"