From 008d7963219ef71723e58f7a832fd75fd65ddcbd Mon Sep 17 00:00:00 2001 From: xCrystal Date: Sun, 21 Jan 2024 12:26:13 +0100 Subject: [PATCH] Implement unlocking levels [Commit 3/3] (#35) --- engine/menus/cleared_level_screen.asm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/engine/menus/cleared_level_screen.asm b/engine/menus/cleared_level_screen.asm index 18fcb1b1f..3fb72871c 100755 --- a/engine/menus/cleared_level_screen.asm +++ b/engine/menus/cleared_level_screen.asm @@ -76,6 +76,10 @@ ClearLevel: ret UnlockLevels: + call ComputeLevelsToUnlock + jp SaveUnlockedLevels + +ComputeLevelsToUnlock: ld hl, LevelUnlockRequirements ld de, wUnlockedLevels - 1 ld b, 0 @@ -203,4 +207,17 @@ GetClearedLevelsStageAddress: ld hl, wClearedLevelsStage4 ret +SaveUnlockedLevels: + ld hl, wTempUnlockedLevels +.loop + ld a, [hli] + ld e, a + inc a ; cp $ff + ret z + push hl + ld b, SET_FLAG + call UnlockedLevelsFlagAction + pop hl + jr .loop + INCLUDE "data/levels/levels.asm"