mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-11-16 11:27:33 -08:00
parent
52bb92028e
commit
9d0fbf3883
@ -29,3 +29,7 @@ DEF STAGE_4 EQU 1 << STAGE_4_F
|
||||
const UNLOCK_WHEN_LEVELS_CLEARED ; 00
|
||||
const UNLOCK_WHEN_NUMBER_OF_LEVELS_CLEARED ; 01
|
||||
const UNLOCK_WHEN_TECHNIQUES_CLEARED ; 02
|
||||
|
||||
; maximum amount of levels that can be unlocked in a single level cleared run.
|
||||
; levels to unlock are processed in level order.
|
||||
DEF MAX_UNLOCK_LEVELS_AT_ONCE EQU 10
|
||||
|
@ -31,10 +31,6 @@ ClearedLevelScreen:
|
||||
.exit
|
||||
call AddLevelCoinsToBalance
|
||||
call ClearLevel
|
||||
xor a
|
||||
ld [wNumTempUnlockedLevels], a
|
||||
ld a, $ff
|
||||
ld [wTempUnlockedLevels], a
|
||||
jp UnlockLevels
|
||||
|
||||
.LevelCleared1Text:
|
||||
@ -92,7 +88,10 @@ ComputeLevelsToUnlock:
|
||||
inc b
|
||||
ld a, b
|
||||
cp NUM_LEVELS
|
||||
jr z, .done
|
||||
jr z, .done ; done if went through all existing levels
|
||||
ld a, [wLastUnlockedLevelsCount]
|
||||
cp MAX_UNLOCK_LEVELS_AT_ONCE
|
||||
jr nc, .done ; done if reached the capacity of wLastUnlockedLevels
|
||||
; advance hl to next level in LevelUnlockRequirements
|
||||
.loop
|
||||
ld a, [hli]
|
||||
@ -169,19 +168,19 @@ ComputeLevelsToUnlock:
|
||||
jr .check_techniques_cleared_loop
|
||||
|
||||
.reqs_met
|
||||
; add level to wTempUnlockedLevels
|
||||
; add level to wLastUnlockedLevels
|
||||
pop bc ; b = which level
|
||||
push hl
|
||||
ld a, [wNumTempUnlockedLevels]
|
||||
ld a, [wLastUnlockedLevelsCount]
|
||||
ld e, a
|
||||
ld d, 0
|
||||
ld hl, wTempUnlockedLevels
|
||||
ld hl, wLastUnlockedLevels
|
||||
add hl, de
|
||||
ld [hl], b
|
||||
inc hl
|
||||
ld [hl], $ff
|
||||
inc a
|
||||
ld [wNumTempUnlockedLevels], a
|
||||
ld [wLastUnlockedLevelsCount], a
|
||||
pop hl
|
||||
pop de
|
||||
ret
|
||||
@ -192,7 +191,7 @@ ComputeLevelsToUnlock:
|
||||
ret
|
||||
|
||||
SaveUnlockedLevels:
|
||||
ld hl, wTempUnlockedLevels
|
||||
ld hl, wLastUnlockedLevels
|
||||
.loop
|
||||
ld a, [hli]
|
||||
ld e, a
|
||||
|
@ -145,14 +145,22 @@ GameMenu_WorldMap:
|
||||
call ClearObjectStructs
|
||||
call ClearBGPalettes
|
||||
call ClearSprites
|
||||
; clear unlocked levels
|
||||
xor a
|
||||
ld [wLastUnlockedLevelsCount], a
|
||||
ld a, $ff
|
||||
ld [wLastUnlockedLevels], a
|
||||
; handle overworld exit
|
||||
ld a, [wExitOverworldReason]
|
||||
cp CLEARED_LEVEL
|
||||
jr nz, .save_and_return
|
||||
; if CLEARED_LEVEL:
|
||||
; show post-level screen, clear level, unlock levels, advance ToD, request appropriate LSM events
|
||||
farcall ClearedLevelScreen
|
||||
call AdvanceTimeOfDay
|
||||
ld hl, wLevelSelectionMenuEntryEventQueue
|
||||
set LSMEVENT_ANIMATE_TIME_OF_DAY, [hl]
|
||||
ld a, [wNumTempUnlockedLevels]
|
||||
ld a, [wLastUnlockedLevelsCount]
|
||||
and a
|
||||
jr z, .save_and_return
|
||||
set LSMEVENT_SHOW_UNLOCKED_LEVELS, [hl]
|
||||
|
@ -23,14 +23,18 @@ LevelSelectionMenu::
|
||||
bit LSMEVENT_SHOW_UNLOCKED_LEVELS, a
|
||||
jr z, .load_default_landmark
|
||||
|
||||
ld hl, wTempUnlockedLevels
|
||||
ld a, [wLastUnlockedLevelsCount]
|
||||
and a
|
||||
jr z, .load_default_landmark
|
||||
|
||||
ld hl, wLastUnlockedLevels
|
||||
.show_unlocked_levels_loop
|
||||
ld a, [hli]
|
||||
cp $ff
|
||||
jr z, .load_default_landmark
|
||||
|
||||
push hl
|
||||
; perform level-to-landmark lookup of wTempUnlockedLevels[i] in $ff-terminated LandmarkToLevelTable.
|
||||
; perform level-to-landmark lookup of wLastUnlockedLevels[i] in $ff-terminated LandmarkToLevelTable.
|
||||
; stop at the first match and load it to wLevelSelectionMenuCurrentLandmark.
|
||||
ld hl, LandmarkToLevelTable
|
||||
ld c, 0
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 390 B After Width: | Height: | Size: 391 B |
11
ram/wram.asm
11
ram/wram.asm
@ -711,13 +711,6 @@ wOverworldMapBlocks:: ds 1300
|
||||
wOverworldMapBlocksEnd::
|
||||
|
||||
|
||||
SECTION UNION "Overworld Map", WRAM0
|
||||
|
||||
; temporary list of unlocked levels during post-level screen
|
||||
wNumTempUnlockedLevels:: db
|
||||
wTempUnlockedLevels:: ds NUM_LEVELS
|
||||
|
||||
|
||||
SECTION UNION "Overworld Map", WRAM0
|
||||
|
||||
; GB Printer data
|
||||
@ -2548,6 +2541,10 @@ wDefaultLevelSelectionMenuLandmark:: db
|
||||
wCurOverworldMiscPal:: db
|
||||
wLevelSelectionMenuEntryEventQueue:: flag_array NUM_LSM_EVENTS
|
||||
|
||||
; list of unlocked levels during post-level screen
|
||||
wLastUnlockedLevelsCount:: db
|
||||
wLastUnlockedLevels:: ds MAX_UNLOCK_LEVELS_AT_ONCE + 1
|
||||
|
||||
wPlayerDataEnd::
|
||||
|
||||
wCurMapData::
|
||||
|
Loading…
Reference in New Issue
Block a user