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

@ -24,7 +24,8 @@ DEF STRING_BUFFER_LENGTH EQU 19
const HAVE_LESS ; 2
; givecoins/takecoins/checkcoins special amount values
DEF BLUE_RED_SPACE_COINS EQU $ffffff
DEF BLUE_RED_SPACE_COINS EQU $ff0000
DEF COINS_FROM_RAM EQU $fe0000
; checkpokemail return values
const_def
@ -342,7 +343,7 @@ DEF NUM_UNOWN_PUZZLES EQU const_value
const BOARDEVENT_RESUME_BRANCH ; 6
DEF NUM_BOARD_EVENTS EQU const_value - 1
; exitoverworld arguments
; exitoverworld arguments (wExitOverworldReason)
const_def
const ABANDONED_LEVEL ; 0
const CLEARED_LEVEL ; 1

View File

@ -116,6 +116,11 @@
- **wDisabledSpacesBackups**: preserved on save to **sDisabledSpacesBackups**.
- **wMapObjectsBackups**: preserved on save to **sMapObjectsBackups**.
- Other WRAM 0 addresses (not preserved on save):
- **wText2bpp**
- **wWhichHUD**
- **wExitOverworldReason**
### Overworld workflow
1) ``OverworldLoop`` is called from ``GameMenu_WorldMap`` with either ``hMapEntryMethod`` = ``MAPSETUP_ENTERLEVEL`` or ``hMapEntryMethod`` = ``MAPSETUP_CONTINUE``.

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

View File

@ -82,6 +82,7 @@ ROMX $15
"Map Scripts 1"
ROMX $1d
"Level Selection Menu"
"Level Transition"
ROMX $1e
"Board 1"
ROMX $20

View File

@ -240,6 +240,11 @@ SECTION "Level Selection Menu", ROMX
INCLUDE "engine/menus/level_selection_menu.asm"
SECTION "Level Transition", ROMX
INCLUDE "engine/menus/cleared_level_screen.asm"
SECTION "Board 1", ROMX
INCLUDE "engine/board/menu.asm"

View File

@ -1248,6 +1248,8 @@ wWhichHUD::
; index to LoadHUD
db
wExitOverworldReason:: db
wOptions::
; bit 0-2: number of frames to delay when printing text
; fast 1; mid 3; slow 5