2023-09-30 15:10:44 -07:00
|
|
|
; GameMenu.String and GameMenu.Jumptable indexes
|
|
|
|
const_def
|
2024-02-12 04:09:18 -08:00
|
|
|
const GAMEMENU_WORLD
|
2023-09-30 15:10:44 -07:00
|
|
|
const GAMEMENU_SHOP
|
|
|
|
|
|
|
|
GameMenu:
|
|
|
|
ld de, MUSIC_NONE
|
|
|
|
call PlayMusic
|
|
|
|
call DelayFrame
|
|
|
|
ld de, MUSIC_MAIN_MENU
|
|
|
|
call PlayMusic
|
|
|
|
; fallthrough
|
|
|
|
|
|
|
|
GameMenu_KeepMusic:
|
2023-10-02 08:39:10 -07:00
|
|
|
xor a
|
|
|
|
ldh [hMapAnims], a
|
2024-03-19 11:49:36 -07:00
|
|
|
ldh [hLCDStatIntRequired], a
|
2023-09-30 15:10:44 -07:00
|
|
|
call ClearTilemap
|
|
|
|
call LoadFrame
|
|
|
|
call LoadStandardFont
|
2024-01-17 05:25:29 -08:00
|
|
|
xor a
|
|
|
|
ldh [hSCX], a
|
|
|
|
ldh [hSCY], a
|
2023-09-30 15:10:44 -07:00
|
|
|
call ClearMenuAndWindowData
|
|
|
|
ld b, CGB_DIPLOMA
|
|
|
|
call GetCGBLayout
|
2024-02-10 15:16:00 -08:00
|
|
|
call SetDefaultBGPAndOBP
|
2023-09-30 15:10:44 -07:00
|
|
|
xor a
|
|
|
|
ld [wWhichIndexSet], a
|
|
|
|
ld hl, .MenuHeader
|
|
|
|
call LoadMenuHeader
|
|
|
|
call GameMenuJoypadLoop
|
|
|
|
call CloseWindow
|
|
|
|
jr c, .quit
|
|
|
|
call ClearTilemap
|
|
|
|
ld a, [wMenuSelection]
|
|
|
|
ld hl, .Jumptable
|
|
|
|
rst JumpTable
|
|
|
|
jr GameMenu
|
|
|
|
|
|
|
|
.quit
|
|
|
|
ret
|
|
|
|
|
|
|
|
.MenuHeader:
|
|
|
|
db MENU_BACKUP_TILES ; flags
|
|
|
|
menu_coords 0, 0, 16, 7
|
|
|
|
dw .MenuData
|
|
|
|
db 1 ; default option
|
|
|
|
|
|
|
|
.MenuData:
|
|
|
|
db STATICMENU_CURSOR ; flags
|
|
|
|
db 0 ; items
|
|
|
|
dw GameMenuItems
|
|
|
|
dw PlaceMenuStrings
|
|
|
|
dw .Strings
|
|
|
|
|
|
|
|
.Strings:
|
|
|
|
; entries correspond to GAMEMENUITEM_* constants
|
2024-02-12 04:09:18 -08:00
|
|
|
db "WORLD@"
|
2023-09-30 15:10:44 -07:00
|
|
|
db "SHOP@"
|
|
|
|
|
|
|
|
.Jumptable:
|
|
|
|
; entries correspond to GAMEMENUITEM_* constants
|
2024-02-12 04:09:18 -08:00
|
|
|
dw GameMenu_World
|
2023-09-30 15:10:44 -07:00
|
|
|
dw GameMenu_Shop
|
|
|
|
|
|
|
|
GameMenuItems:
|
|
|
|
db 2
|
2024-02-12 04:09:18 -08:00
|
|
|
db GAMEMENU_WORLD
|
2023-09-30 15:10:44 -07:00
|
|
|
db GAMEMENU_SHOP
|
|
|
|
db -1
|
|
|
|
|
|
|
|
GameMenuJoypadLoop:
|
|
|
|
call SetUpMenu
|
|
|
|
.loop
|
|
|
|
ld a, [w2DMenuFlags1]
|
|
|
|
set 5, a
|
|
|
|
ld [w2DMenuFlags1], a
|
|
|
|
call GetScrollingMenuJoypad
|
|
|
|
ld a, [wMenuJoypad]
|
|
|
|
cp B_BUTTON
|
|
|
|
jr z, .b_button
|
|
|
|
cp A_BUTTON
|
|
|
|
jr z, .a_button
|
|
|
|
jr .loop
|
|
|
|
|
|
|
|
.a_button
|
|
|
|
call PlayClickSFX
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.b_button
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2024-02-12 04:09:18 -08:00
|
|
|
GameMenu_World:
|
2024-01-28 08:57:11 -08:00
|
|
|
; the following 500ms fading delay applies:
|
|
|
|
; - from post-level screen to level selection menu
|
|
|
|
; - from overworld to level selection menu
|
2024-02-12 04:09:18 -08:00
|
|
|
; - from selecting "WORLD" in game menu to level selection menu (save outside ow)
|
|
|
|
; - from selecting "WORLD" in game menu to overworld (save in ow)
|
2024-01-28 08:57:11 -08:00
|
|
|
ld a, 8
|
|
|
|
ld [wMusicFade], a
|
|
|
|
ld a, LOW(MUSIC_NONE)
|
|
|
|
ld [wMusicFadeID], a
|
|
|
|
ld a, HIGH(MUSIC_NONE)
|
|
|
|
ld [wMusicFadeID + 1], a
|
|
|
|
call ClearBGPalettes
|
|
|
|
call ClearTilemap
|
|
|
|
ld c, 30 - 8
|
|
|
|
call DelayFrames
|
|
|
|
|
2023-09-30 15:10:44 -07:00
|
|
|
ld a, [wSaveFileInOverworld]
|
|
|
|
and a
|
|
|
|
jr z, .not_in_overworld
|
|
|
|
|
2023-09-30 15:39:18 -07:00
|
|
|
ld a, MAPSETUP_CONTINUE
|
|
|
|
jr .SpawnToMap
|
|
|
|
|
|
|
|
.not_in_overworld
|
|
|
|
farcall LevelSelectionMenu
|
2024-01-28 08:57:11 -08:00
|
|
|
; dequeue all level selection menu events (which triggered during call above if set).
|
|
|
|
; game is not saved until player enters a level, so if game is turned off in the middle of
|
|
|
|
; an event or in the menu, the player will be able to replay the events when they come back.
|
|
|
|
ld a, 0
|
|
|
|
ld [wLevelSelectionMenuEntryEventQueue], a
|
2023-09-30 15:39:18 -07:00
|
|
|
ret nc ; if pressed B, go back to Game Menu
|
|
|
|
|
|
|
|
farcall ClearSpriteAnims
|
|
|
|
call ClearSprites
|
|
|
|
ld a, MAPSETUP_ENTERLEVEL
|
|
|
|
; jr .SpawnToMap
|
|
|
|
|
|
|
|
.SpawnToMap:
|
|
|
|
ldh [hMapEntryMethod], a
|
2023-09-30 15:10:44 -07:00
|
|
|
farcall JumpRoamMons
|
|
|
|
xor a
|
2023-09-30 15:39:18 -07:00
|
|
|
ld [wDontPlayMapMusicOnReload], a ; play map music
|
2023-09-30 15:10:44 -07:00
|
|
|
ld [wLinkMode], a
|
2023-10-07 10:08:54 -07:00
|
|
|
ld [wBoardMenuLastCursorPosition], a
|
|
|
|
ld hl, wGameTimer
|
2023-09-30 15:39:18 -07:00
|
|
|
set GAME_TIMER_COUNTING_F, [hl] ; start game timer counter
|
2023-09-30 15:10:44 -07:00
|
|
|
farcall OverworldLoop
|
|
|
|
|
2023-09-30 15:39:18 -07:00
|
|
|
; return from overworld loop
|
2023-10-21 10:29:29 -07:00
|
|
|
call ClearObjectStructs
|
2023-09-30 15:39:18 -07:00
|
|
|
call ClearBGPalettes
|
|
|
|
call ClearSprites
|
2024-04-04 12:26:26 -07:00
|
|
|
; initialize buffer for temporary unlocked and cleared levels
|
2024-01-29 10:52:08 -08:00
|
|
|
xor a
|
|
|
|
ld [wLastUnlockedLevelsCount], a
|
|
|
|
ld a, $ff
|
|
|
|
ld [wLastUnlockedLevels], a
|
2024-04-04 12:26:26 -07:00
|
|
|
ld [wLastClearedLevelStage], a
|
2024-01-29 10:52:08 -08:00
|
|
|
; handle overworld exit
|
2024-01-16 09:08:19 -08:00
|
|
|
ld a, [wExitOverworldReason]
|
|
|
|
cp CLEARED_LEVEL
|
|
|
|
jr nz, .save_and_return
|
2024-01-29 10:52:08 -08:00
|
|
|
; if CLEARED_LEVEL:
|
2024-02-04 05:23:58 -08:00
|
|
|
; show post-level screen, clear level, unlock levels, request appropriate LSM events
|
2024-01-16 09:08:19 -08:00
|
|
|
farcall ClearedLevelScreen
|
2024-01-28 08:57:11 -08:00
|
|
|
ld hl, wLevelSelectionMenuEntryEventQueue
|
|
|
|
set LSMEVENT_ANIMATE_TIME_OF_DAY, [hl]
|
2024-04-04 12:26:26 -07:00
|
|
|
ld a, [wLastClearedLevelStage]
|
|
|
|
inc a
|
|
|
|
jr z, .no_new_stage_cleared
|
|
|
|
set LSMEVENT_SHOW_CLEARED_LEVEL, [hl]
|
|
|
|
.no_new_stage_cleared
|
2024-01-29 10:52:08 -08:00
|
|
|
ld a, [wLastUnlockedLevelsCount]
|
2024-01-28 08:57:11 -08:00
|
|
|
and a
|
|
|
|
jr z, .save_and_return
|
|
|
|
set LSMEVENT_SHOW_UNLOCKED_LEVELS, [hl]
|
2024-01-16 09:08:19 -08:00
|
|
|
.save_and_return
|
2023-10-07 10:08:54 -07:00
|
|
|
farcall AutoSaveGameOutsideOverworld
|
2024-02-12 04:09:18 -08:00
|
|
|
jp GameMenu_World
|
2023-09-30 15:10:44 -07:00
|
|
|
|
|
|
|
GameMenu_Shop:
|
|
|
|
ret
|