Level cleared transition: placeholder screen, update wCoins with wCurLevelCoins, advance time of day (#35)

This commit is contained in:
xCrystal
2024-01-16 18:08:19 +01:00
parent 20e7791a83
commit f6320585bf
8 changed files with 103 additions and 3 deletions

View File

@@ -0,0 +1,57 @@
ClearedLevelScreen:
xor a
ldh [hMapAnims], a
ldh [hSCY], a
ld a, -$4
ldh [hSCX], a
call ClearTilemap
call LoadFrame
call LoadStandardFont
call ClearMenuAndWindowData
ld b, CGB_DIPLOMA
call GetCGBLayout
call SetPalettes
ld hl, .LevelCleared1Text
bccoord 3, 1
call PrintHLTextAtBC
ld hl, .LevelCleared2Text
bccoord 3, 3
call PrintHLTextAtBC
.loop
call DelayFrame
call GetJoypad
ldh a, [hJoyPressed]
bit A_BUTTON_F, a
jr nz, .exit
bit B_BUTTON_F, a
jr z, .loop
.exit
call AddLevelCoinsToBalance
ld c, 30
jp DelayFrames
.LevelCleared1Text:
text " L E V E L"
done
.LevelCleared2Text:
text "C L E A R E D"
done
AddLevelCoinsToBalance:
; givecoins YOUR_COINS, COINS_FROM_RAM | wCurLevelCoins
ld de, wCoins ; YOUR_COINS
ld hl, wCurLevelCoins
ld bc, hCoinsTemp
push bc
ld a, [hli]
ld [bc], a
inc bc
ld a, [hli]
ld [bc], a
inc bc
ld a, [hl]
ld [bc], a
pop bc
farcall GiveCoins
ret

View File

@@ -133,6 +133,12 @@ GameMenu_WorldMap:
call ClearObjectStructs
call ClearBGPalettes
call ClearSprites
ld a, [wExitOverworldReason]
cp CLEARED_LEVEL
jr nz, .save_and_return
call AdvanceTimeOfDay
farcall ClearedLevelScreen
.save_and_return
farcall AutoSaveGameOutsideOverworld
ret

View File

@@ -1883,7 +1883,9 @@ GetCoinsAccount:
LoadCoinsAmountToMem:
ld bc, hCoinsTemp
call GetScriptByte
cp HIGH(BLUE_RED_SPACE_COINS)
cp COINS_FROM_RAM >> 16
jr z, .coins_from_ram
cp BLUE_RED_SPACE_COINS >> 16
jr z, .blue_red_space_coins
push bc
ld [bc], a
@@ -1896,6 +1898,26 @@ LoadCoinsAmountToMem:
pop bc
ret
.coins_from_ram
; if the highest byte was COINS_FROM_RAM, the lowest two bytes are a RAM address.
; but the script argument is dt, which is big endian rather than little endian like dw.
call GetScriptByte
ld h, a
call GetScriptByte
ld l, a
push bc
ld a, [hli]
ld [bc], a
inc bc
ld a, [hli]
ld [bc], a
inc bc
ld a, [hl]
ld [bc], a
pop bc
ret
.blue_red_space_coins
push de
call GetScriptByte
@@ -2435,6 +2457,7 @@ ReturnFromCredits:
Script_exitoverworld:
call GetScriptByte
ld [wExitOverworldReason], a
call Script_endall
ld a, MAPSTATUS_DONE
call LoadMapStatus