From 533f7c259eee6e75dd9453ebc1b0ff56a97ce5be Mon Sep 17 00:00:00 2001 From: xCrystal Date: Thu, 25 Jan 2024 17:17:24 +0100 Subject: [PATCH] Persist level selection menu landmark when coming back (#12) --- docs/develop/index.md | 3 ++- engine/menus/intro_menu.asm | 2 ++ engine/menus/level_selection_menu.asm | 3 ++- ram/wram.asm | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/develop/index.md b/docs/develop/index.md index f3857f535..628003b9e 100755 --- a/docs/develop/index.md +++ b/docs/develop/index.md @@ -83,7 +83,6 @@ - **wSpacesLeft** - Addresses within *wCurMapData* ~ *wCurMapDataEnd*: preserved on save. Initialized when entering a level (in StartMap), and updated accordingly throughout the level. Includes: - - **wCurLevel**: this one is not initialized in StartMap, but in LevelSelectionMenu (where it is also used), and stays static during the level. - **wCurTurn** - **wCurSpace** - **wCurLevelCoins** @@ -98,6 +97,8 @@ - **wUnlockedLevels**: flag array that tracks progression regarding which levels have been unlocked. - **wClearedLevelsStage**: flag array that tracks progression regarding which levels have been cleared. Each level can have up to four clearable endings (N). - **wUnlockedTechniques**: flag array that tracks progression regarding which techniques have been unlocked. + - **wCurLevel**: initialized in LevelSelectionMenu (where it is also used), and stays static during the level. + - **wDefaultLevelSelectionMenuLandmark**: used to know in which landmark to place the player when entering level selection menu. - **wCurOverworldMiscPal** - These addresses share memory region with string buffers from *wStringBuffer3* onwards. They are placed in memory in the following order. diff --git a/engine/menus/intro_menu.asm b/engine/menus/intro_menu.asm index f725dd74a..31b713b67 100644 --- a/engine/menus/intro_menu.asm +++ b/engine/menus/intro_menu.asm @@ -26,6 +26,8 @@ if DEF(_DEBUG) ld a, -1 ld [wUnlockedLevels], a ; debug endc + xor a ; LANDMARK_LEVEL_1 + ld [wDefaultLevelSelectionMenuLandmark], a farcall AutoSaveGameOutsideOverworld jp GameMenu diff --git a/engine/menus/level_selection_menu.asm b/engine/menus/level_selection_menu.asm index 4b03ce1c1..17b8092cb 100755 --- a/engine/menus/level_selection_menu.asm +++ b/engine/menus/level_selection_menu.asm @@ -17,7 +17,7 @@ LevelSelectionMenu:: ld a, LCDC_DEFAULT ldh [rLCDC], a - xor a + ld a, [wDefaultLevelSelectionMenuLandmark] ld [wLevelSelectionMenuCurrentLandmark], a call LevelSelectionMenu_GetLandmarkPage ld [wLevelSelectionMenuCurrentPage], a @@ -1002,6 +1002,7 @@ _LevelSelectionMenuHandleTransition: ; set new landmark ld a, [de] ld [wLevelSelectionMenuCurrentLandmark], a + ld [wDefaultLevelSelectionMenuLandmark], a ; make the player sprite face down as the default state ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID add hl, bc diff --git a/ram/wram.asm b/ram/wram.asm index ffe82d321..0678213f8 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -2543,6 +2543,8 @@ wRepelEffect:: db ; If a Repel is in use, it contains the nr of steps it's still wBikeStep:: dw wKurtApricornQuantity:: db +wCurLevel:: db +wDefaultLevelSelectionMenuLandmark:: db wCurOverworldMiscPal:: db wPlayerDataEnd:: @@ -2571,7 +2573,6 @@ wYCoord:: db wXCoord:: db wScreenSave:: ds SCREEN_META_WIDTH * SCREEN_META_HEIGHT -wCurLevel:: db wCurTurn:: dw wCurSpace:: db wCurLevelCoins:: ds 3