summaryrefslogtreecommitdiff
path: root/engine/menu/main_menu.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/menu/main_menu.asm')
-rwxr-xr-xengine/menu/main_menu.asm120
1 files changed, 63 insertions, 57 deletions
diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm
index dc936c97..eeaa4594 100755
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -1,17 +1,16 @@
MainMenu: ; 5af2 (1:5af2)
; Check save file
- call Func_5bff
+ call InitOptions
xor a
- ld [wd08a],a
+ ld [wOptionsInitialized],a
inc a
- ld [wd088],a
- call Func_609e
- jr nc,.next0
+ ld [wSaveFileStatus],a
+ call CheckForPlayerNameInSRAM
+ jr nc,.mainMenuLoop
- ; Predef 52 loads the save from SRAM to RAM
predef LoadSAV
-.next0
+.mainMenuLoop
ld c,20
call DelayFrames
xor a ; LINK_STATE_NONE
@@ -30,9 +29,10 @@ MainMenu: ; 5af2 (1:5af2)
call LoadFontTilePatterns
ld hl,wd730
set 6,[hl]
- ld a,[wd088]
+ ld a,[wSaveFileStatus]
cp a,1
- jr z,.next1
+ jr z,.noSaveFile
+; there's a save file
coord hl, 0, 0
ld b,6
ld c,13
@@ -41,7 +41,7 @@ MainMenu: ; 5af2 (1:5af2)
ld de,ContinueText
call PlaceString
jr .next2
-.next1
+.noSaveFile
coord hl, 0, 0
ld b,4
ld c,13
@@ -63,31 +63,33 @@ MainMenu: ; 5af2 (1:5af2)
ld [wTopMenuItemY],a
ld a,$B
ld [wMenuWatchedKeys],a
- ld a,[wd088]
+ ld a,[wSaveFileStatus]
ld [wMaxMenuItem],a
call HandleMenuInput
- bit 1,a
- jp nz,LoadTitlescreenGraphics ; load title screen (gfx and arrangement)
+ bit 1,a ; pressed B?
+ jp nz,DisplayTitleScreen ; if so, go back to the title screen
ld c,20
call DelayFrames
ld a,[wCurrentMenuItem]
ld b,a
- ld a,[wd088]
+ ld a,[wSaveFileStatus]
cp a,2
- jp z,.next3
- inc b ; adjust MenuArrow_Counter
-.next3
+ jp z,.skipInc
+; If there's no save file, increment the current menu item so that the numbers
+; are the same whether or not there's a save file.
+ inc b
+.skipInc
ld a,b
and a
- jr z,.next4 ; if press_A on Continue
+ jr z,.choseContinue
cp a,1
- jp z,Func_5d52 ; if press_A on NewGame
- call DisplayOptionMenu ; if press_a on Options
+ jp z,StartNewGame
+ call DisplayOptionMenu
ld a,1
- ld [wd08a],a
- jp .next0
-.next4
- call ContinueGame
+ ld [wOptionsInitialized],a
+ jp .mainMenuLoop
+.choseContinue
+ call DisplayContinueGameInfo
ld hl,wd126
set 5,[hl]
.inputLoop
@@ -100,7 +102,7 @@ MainMenu: ; 5af2 (1:5af2)
bit 0,a
jr nz,.pressedA
bit 1,a
- jp nz,.next0 ; pressedB
+ jp nz,.mainMenuLoop ; pressed B
jr .inputLoop
.pressedA
call GBPalWhiteOutWithDelay3
@@ -122,10 +124,10 @@ MainMenu: ; 5af2 (1:5af2)
call SpecialWarpIn
jp SpecialEnterMap
-Func_5bff: ; 5bff (1:5bff)
- ld a,1
+InitOptions: ; 5bff (1:5bff)
+ ld a,1 ; no delay
ld [wLetterPrintingDelayFlags],a
- ld a,3
+ ld a,3 ; medium speed
ld [W_OPTIONS],a
ret
@@ -301,7 +303,7 @@ LinkCanceledText: ; 5d4d (1:5d4d)
TX_FAR _LinkCanceledText
db "@"
-Func_5d52: ; 5d52 (1:5d52)
+StartNewGame: ; 5d52 (1:5d52)
ld hl, wd732
res 1, [hl]
call OakSpeech
@@ -337,12 +339,12 @@ CableClubOptionsText: ; 5d97 (1:5d97)
db "COLOSSEUM", $4e
db "CANCEL@"
-ContinueGame: ; 5db5 (1:5db5)
+DisplayContinueGameInfo: ; 5db5 (1:5db5)
xor a
ld [H_AUTOBGTRANSFERENABLED], a
coord hl, 4, 7
- ld b, $8
- ld c, $e
+ ld b, 8
+ ld c, 14
call TextBoxBorder
coord hl, 5, 9
ld de, SaveScreenInfoText
@@ -351,12 +353,12 @@ ContinueGame: ; 5db5 (1:5db5)
ld de, wPlayerName
call PlaceString
coord hl, 17, 11
- call Func_5e2f
+ call PrintNumBadges
coord hl, 16, 13
- call Func_5e42
+ call PrintNumOwnedMons
coord hl, 13, 15
- call Func_5e55
- ld a, $1
+ call PrintPlayTime
+ ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
ld c, 30
jp DelayFrames
@@ -377,17 +379,17 @@ PrintSaveScreenText: ; 5def (1:5def)
ld de, wPlayerName
call PlaceString
coord hl, 17, 4
- call Func_5e2f
+ call PrintNumBadges
coord hl, 16, 6
- call Func_5e42
+ call PrintNumOwnedMons
coord hl, 13, 8
- call Func_5e55
+ call PrintPlayTime
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
ld c, 30
jp DelayFrames
-Func_5e2f: ; 5e2f (1:5e2f)
+PrintNumBadges: ; 5e2f (1:5e2f)
push hl
ld hl, W_OBTAINEDBADGES
ld b, $1
@@ -397,7 +399,7 @@ Func_5e2f: ; 5e2f (1:5e2f)
ld bc, $102
jp PrintNumber
-Func_5e42: ; 5e42 (1:5e42)
+PrintNumOwnedMons: ; 5e42 (1:5e42)
push hl
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
@@ -407,7 +409,7 @@ Func_5e42: ; 5e42 (1:5e42)
ld bc, $103
jp PrintNumber
-Func_5e55: ; 5e55 (1:5e55)
+PrintPlayTime: ; 5e55 (1:5e55)
ld de, W_PLAYTIMEHOURS + 1
ld bc, $103
call PrintNumber
@@ -678,28 +680,32 @@ TextSpeedOptionData: ; 6096 (1:6096)
db 7 ; default X coordinate (Medium)
db $ff ; terminator
-Func_609e: ; 609e (1:609e)
- ld a, $a
- ld [$0], a
+CheckForPlayerNameInSRAM: ; 609e (1:609e)
+; Check if the player name data in SRAM has a string terminator character
+; (indicating that a name may have been saved there) and return whether it does
+; in carry.
+ ld a, SRAM_ENABLE
+ ld [MBC1SRamEnable], a
ld a, $1
- ld [$6000], a
- ld [$4000], a
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamBank], a
ld b, $b
- ld hl, $a598
-.asm_60b0
+ ld hl, sPlayerName
+.loop
ld a, [hli]
- cp $50
- jr z, .asm_60c1
+ cp "@"
+ jr z, .found
dec b
- jr nz, .asm_60b0
+ jr nz, .loop
+; not found
xor a
- ld [$0], a
- ld [$6000], a
+ ld [MBC1SRamEnable], a
+ ld [MBC1SRamBankingMode], a
and a
ret
-.asm_60c1
+.found
xor a
- ld [$0], a
- ld [$6000], a
+ ld [MBC1SRamEnable], a
+ ld [MBC1SRamBankingMode], a
scf
ret