2023-09-30 15:10:44 -07:00
|
|
|
const_def
|
|
|
|
const TITLESCREENOPTION_MAIN_MENU
|
|
|
|
const TITLESCREENOPTION_DELETE_SAVE_DATA
|
|
|
|
const TITLESCREENOPTION_RESTART
|
|
|
|
const TITLESCREENOPTION_UNUSED
|
|
|
|
DEF NUM_TITLESCREENOPTIONS EQU const_value
|
|
|
|
|
|
|
|
IntroSequence:
|
|
|
|
callfar SplashScreen
|
|
|
|
jr c, StartTitleScreen
|
|
|
|
farcall CrystalIntro
|
|
|
|
|
|
|
|
; fallthrough
|
|
|
|
|
|
|
|
StartTitleScreen:
|
2024-03-19 11:49:36 -07:00
|
|
|
ld a, TRUE
|
|
|
|
ldh [hLCDStatIntRequired], a
|
2023-09-30 15:10:44 -07:00
|
|
|
ldh a, [rSVBK]
|
|
|
|
push af
|
|
|
|
ld a, BANK(wLYOverrides)
|
|
|
|
ldh [rSVBK], a
|
|
|
|
|
|
|
|
call .TitleScreen
|
|
|
|
call DelayFrame
|
|
|
|
.loop
|
|
|
|
call RunTitleScreen
|
|
|
|
jr nc, .loop
|
|
|
|
|
|
|
|
call ClearSprites
|
|
|
|
call ClearBGPalettes
|
|
|
|
|
|
|
|
pop af
|
|
|
|
ldh [rSVBK], a
|
|
|
|
|
|
|
|
ld hl, rLCDC
|
|
|
|
res rLCDC_SPRITE_SIZE, [hl] ; 8x8
|
|
|
|
call ClearScreen
|
|
|
|
call WaitBGMap2
|
|
|
|
xor a
|
|
|
|
ldh [hLCDCPointer], a
|
|
|
|
ldh [hSCX], a
|
|
|
|
ldh [hSCY], a
|
|
|
|
ld a, $7
|
|
|
|
ldh [hWX], a
|
|
|
|
ld a, $90
|
|
|
|
ldh [hWY], a
|
|
|
|
ld b, CGB_DIPLOMA
|
|
|
|
call GetCGBLayout
|
|
|
|
call UpdateTimePals
|
|
|
|
ld a, [wTitleScreenSelectedOption]
|
|
|
|
cp NUM_TITLESCREENOPTIONS
|
|
|
|
jr c, .ok
|
|
|
|
xor a
|
|
|
|
.ok
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
ld hl, .dw
|
|
|
|
add hl, de
|
|
|
|
add hl, de
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
jp hl
|
|
|
|
|
|
|
|
.dw
|
|
|
|
dw Intro_MainMenu
|
|
|
|
dw DeleteSaveData
|
|
|
|
dw IntroSequence
|
|
|
|
dw IntroSequence
|
|
|
|
|
|
|
|
.TitleScreen:
|
|
|
|
farcall _TitleScreen
|
|
|
|
ret
|
|
|
|
|
|
|
|
RunTitleScreen:
|
|
|
|
ld a, [wJumptableIndex]
|
|
|
|
bit 7, a
|
|
|
|
jr nz, .done_title
|
|
|
|
call TitleScreenScene
|
|
|
|
farcall SuicuneFrameIterator
|
|
|
|
call DelayFrame
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.done_title
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
TitleScreenScene:
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
ld hl, .scenes
|
|
|
|
add hl, de
|
|
|
|
add hl, de
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
jp hl
|
|
|
|
|
|
|
|
.scenes
|
|
|
|
dw TitleScreenEntrance
|
|
|
|
dw TitleScreenTimer
|
|
|
|
dw TitleScreenMain
|
|
|
|
dw TitleScreenEnd
|
|
|
|
|
|
|
|
TitleScreenEntrance:
|
|
|
|
; Animate the logo:
|
|
|
|
; Move each line by 4 pixels until our count hits 0.
|
|
|
|
ldh a, [hSCX]
|
|
|
|
and a
|
|
|
|
jr z, .done
|
|
|
|
sub 4
|
|
|
|
ldh [hSCX], a
|
|
|
|
|
|
|
|
; Lay out a base (all lines scrolling together).
|
|
|
|
ld e, a
|
|
|
|
ld hl, wLYOverrides
|
|
|
|
ld bc, 8 * 10 ; logo height
|
|
|
|
call ByteFill
|
|
|
|
|
|
|
|
; Reversed signage for every other line's position.
|
|
|
|
; This is responsible for the interlaced effect.
|
|
|
|
ld a, e
|
|
|
|
xor $ff
|
|
|
|
inc a
|
|
|
|
|
|
|
|
ld b, 8 * 10 / 2 ; logo height / 2
|
|
|
|
ld hl, wLYOverrides + 1
|
|
|
|
.loop
|
|
|
|
ld [hli], a
|
|
|
|
inc hl
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
farcall AnimateTitleCrystal
|
|
|
|
ret
|
|
|
|
|
|
|
|
.done
|
|
|
|
; Next scene
|
|
|
|
ld hl, wJumptableIndex
|
|
|
|
inc [hl]
|
|
|
|
xor a
|
|
|
|
ldh [hLCDCPointer], a
|
|
|
|
|
|
|
|
; Play the title screen music.
|
|
|
|
ld de, MUSIC_TITLE
|
|
|
|
call PlayMusic
|
|
|
|
|
|
|
|
ld a, $88
|
|
|
|
ldh [hWY], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
TitleScreenTimer:
|
|
|
|
; Next scene
|
|
|
|
ld hl, wJumptableIndex
|
|
|
|
inc [hl]
|
|
|
|
|
|
|
|
; Start a timer
|
|
|
|
ld hl, wTitleScreenTimer
|
|
|
|
ld de, 73 * 60 + 36
|
|
|
|
ld [hl], e
|
|
|
|
inc hl
|
|
|
|
ld [hl], d
|
|
|
|
ret
|
|
|
|
|
|
|
|
TitleScreenMain:
|
|
|
|
; Run the timer down.
|
|
|
|
ld hl, wTitleScreenTimer
|
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
ld d, [hl]
|
|
|
|
ld a, e
|
|
|
|
or d
|
|
|
|
jr z, .end
|
|
|
|
|
|
|
|
dec de
|
|
|
|
ld [hl], d
|
|
|
|
dec hl
|
|
|
|
ld [hl], e
|
|
|
|
|
|
|
|
; Save data can be deleted by pressing Up + B + Select.
|
|
|
|
call GetJoypad
|
|
|
|
ld hl, hJoyDown
|
|
|
|
ld a, [hl]
|
|
|
|
and D_UP + B_BUTTON + SELECT
|
|
|
|
cp D_UP + B_BUTTON + SELECT
|
|
|
|
jr z, .delete_save_data
|
|
|
|
|
|
|
|
; Press Start or A to start the game.
|
|
|
|
ld a, [hl]
|
|
|
|
and START | A_BUTTON
|
|
|
|
jr nz, .incave
|
|
|
|
ret
|
|
|
|
|
|
|
|
.incave
|
|
|
|
ld a, TITLESCREENOPTION_MAIN_MENU
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.delete_save_data
|
|
|
|
ld a, TITLESCREENOPTION_DELETE_SAVE_DATA
|
|
|
|
|
|
|
|
.done
|
|
|
|
ld [wTitleScreenSelectedOption], a
|
|
|
|
|
|
|
|
; Return to the intro sequence.
|
|
|
|
ld hl, wJumptableIndex
|
|
|
|
set 7, [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.end
|
|
|
|
; Next scene
|
|
|
|
ld hl, wJumptableIndex
|
|
|
|
inc [hl]
|
|
|
|
|
|
|
|
; Fade out the title screen music
|
|
|
|
xor a ; MUSIC_NONE
|
|
|
|
ld [wMusicFadeID], a
|
|
|
|
ld [wMusicFadeID + 1], a
|
|
|
|
ld hl, wMusicFade
|
|
|
|
ld [hl], 8 ; 1 second
|
|
|
|
|
|
|
|
ld hl, wTitleScreenTimer
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
TitleScreenEnd:
|
|
|
|
; Wait until the music is done fading.
|
|
|
|
|
|
|
|
ld hl, wTitleScreenTimer
|
|
|
|
inc [hl]
|
|
|
|
|
|
|
|
ld a, [wMusicFade]
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
ld a, TITLESCREENOPTION_RESTART
|
|
|
|
ld [wTitleScreenSelectedOption], a
|
|
|
|
|
|
|
|
; Back to the intro.
|
|
|
|
ld hl, wJumptableIndex
|
|
|
|
set 7, [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
Intro_MainMenu:
|
|
|
|
ld de, MUSIC_NONE
|
|
|
|
call PlayMusic
|
|
|
|
call DelayFrame
|
|
|
|
ld de, MUSIC_MAIN_MENU
|
|
|
|
call PlayMusic
|
|
|
|
call MainMenu
|
|
|
|
jp StartTitleScreen
|
|
|
|
|
|
|
|
DeleteSaveData:
|
|
|
|
farcall _DeleteSaveData
|
|
|
|
jp Init
|
|
|
|
|
|
|
|
Copyright:
|
|
|
|
call ClearTilemap
|
|
|
|
call LoadFrame
|
|
|
|
ld de, CopyrightGFX
|
|
|
|
ld hl, vTiles2 tile $60
|
|
|
|
lb bc, BANK(CopyrightGFX), 29
|
|
|
|
call Request2bpp
|
|
|
|
hlcoord 2, 7
|
|
|
|
ld de, CopyrightString
|
|
|
|
jp PlaceString
|
|
|
|
|
|
|
|
CopyrightString:
|
|
|
|
; ©1995-2001 Nintendo
|
|
|
|
db $60, $61, $62, $63, $64, $65, $66
|
|
|
|
db $67, $68, $69, $6a, $6b, $6c
|
|
|
|
|
|
|
|
; ©1995-2001 Creatures inc.
|
|
|
|
next $60, $61, $62, $63, $64, $65, $66
|
|
|
|
db $6d, $6e, $6f, $70, $71, $72, $7a, $7b, $7c
|
|
|
|
|
|
|
|
; ©1995-2001 GAME FREAK inc.
|
|
|
|
next $60, $61, $62, $63, $64, $65, $66
|
|
|
|
db $73, $74, $75, $76, $77, $78, $79, $7a, $7b, $7c
|
|
|
|
|
|
|
|
db "@"
|
|
|
|
|
|
|
|
GameInit::
|
|
|
|
farcall TryLoadSaveData
|
|
|
|
call ClearMenuAndWindowData
|
|
|
|
call ClearBGPalettes
|
|
|
|
call ClearTilemap
|
|
|
|
ld a, HIGH(vBGMap0)
|
|
|
|
ldh [hBGMapAddress + 1], a
|
|
|
|
xor a ; LOW(vBGMap0)
|
|
|
|
ldh [hBGMapAddress], a
|
|
|
|
ldh [hJoyDown], a
|
|
|
|
ldh [hSCX], a
|
|
|
|
ldh [hSCY], a
|
|
|
|
ld a, $90
|
|
|
|
ldh [hWY], a
|
|
|
|
call WaitBGMap
|
|
|
|
jp IntroSequence
|