Populate content of overworld HUD (#18); make wCurTurn 2 bytes (#25)

This commit is contained in:
xCrystal 2023-12-27 17:42:46 +01:00
parent b530cf90f4
commit 80257e4bca
6 changed files with 53 additions and 2 deletions

View File

@ -42,6 +42,9 @@ DEF MAX_LEVEL_COINS EQU 99999
DEF MAX_DELTA_COINS_DIGITS EQU 5 DEF MAX_DELTA_COINS_DIGITS EQU 5
DEF MAX_CHIPS EQU 9999 DEF MAX_CHIPS EQU 9999
; significant turns values
DEF MAX_TURNS EQU 999
; link record ; link record
DEF MAX_LINK_RECORD EQU 9999 DEF MAX_LINK_RECORD EQU 9999

View File

@ -26,7 +26,21 @@ BoardMenuScript::
xor a xor a
call ByteFill call ByteFill
ld hl, wCurTurn ld hl, wCurTurn
ld a, [hli]
cp MAX_TURNS / $100
jr nz, .not_max_turns
ld a, [hl]
cp MAX_TURNS % $100
jr z, .next
.not_max_turns
inc [hl] inc [hl]
jr nz, .next
dec hl
inc [hl]
jr .next
.next
; apply wCurTurn and wDieRoll in overworld HUD
call RefreshOverworldHUD
; reset turn-scoped event flags ; reset turn-scoped event flags
ld hl, wEventFlags + EVENT_TURN_SCOPED_FLAGS_START / 8 ld hl, wEventFlags + EVENT_TURN_SCOPED_FLAGS_START / 8
ld c, (EVENT_TURN_SCOPED_FLAGS_END / 8) - (EVENT_TURN_SCOPED_FLAGS_START / 8) ld c, (EVENT_TURN_SCOPED_FLAGS_END / 8) - (EVENT_TURN_SCOPED_FLAGS_START / 8)
@ -305,6 +319,7 @@ DIE_MAX_NUMBER EQU 6
BoardMenu_BreakDieAnimation: BoardMenu_BreakDieAnimation:
farcall LoadBoardMenuDieNumbersGFX farcall LoadBoardMenuDieNumbersGFX
call RefreshOverworldHUD ; apply wDieRoll in overworld HUD
ld a, [wDieRoll] ld a, [wDieRoll]
dec a dec a
add a add a

View File

@ -349,7 +349,9 @@ PrintGainOrLoseCoins:
call PrintNum call PrintNum
ld hl, wDisplaySecondarySprites ld hl, wDisplaySecondarySprites
set SECONDARYSPRITES_GAIN_OR_LOSE_COINS_F, [hl] set SECONDARYSPRITES_GAIN_OR_LOSE_COINS_F, [hl]
; refresh overworld HUD, and show coins string 750 ms
call UpdateActiveSprites call UpdateActiveSprites
call RefreshOverworldHUD
ld c, 45 ; 750 ms ld c, 45 ; 750 ms
call DelayFrames call DelayFrames
ld hl, wDisplaySecondarySprites ld hl, wDisplaySecondarySprites

View File

@ -29,11 +29,41 @@ _LoadOverworldHUDAttrmap:
jp ByteFill jp ByteFill
_ConstructOverworldHUDTilemap:: _ConstructOverworldHUDTilemap::
; layout
ld hl, .Tilemap ld hl, .Tilemap
ld de, wOverworldHUDTiles ld de, wOverworldHUDTiles
ld bc, .TilemapEnd - .Tilemap ; SCREEN_WIDTH ld bc, .TilemapEnd - .Tilemap ; SCREEN_WIDTH
call CopyBytes call CopyBytes
ret ; turn
ld hl, wCurTurn + 1
ld a, [hld]
or [hl]
jr z, .next1 ; skip if turn is 0 (not yet started)
ld d, h
ld e, l
ld hl, wOverworldHUDTiles + 1
lb bc, 2 | 1 << 6, 3 ; 2 bytes, left aligned, no leading zeros, 3 digits
call PrintNum
.next1
; current roll
ld de, wDieRoll
ld a, [de]
and a
jr z, .next2 ; skip if wDieRoll is 0
ld hl, wOverworldHUDTiles + 5
lb bc, 1 | 1 << 6, 2 ; 1 byte, left aligned, no leading zeros, 2 digits
call PrintNum
.next2
; coins
ld de, wCurLevelCoins
ld hl, wOverworldHUDTiles + 8
lb bc, 3 | 1 << 6, MAX_DELTA_COINS_DIGITS ; 3 bytes, left aligned, no leading zeros, 5 digits
call PrintNum
; exp points
ld de, wCurLevelExp
ld hl, wOverworldHUDTiles + 15
lb bc, 3 | 1 << 6, 5 ; 3 bytes, left aligned, no leading zeros, 5 digits
jp PrintNum
.Tilemap: .Tilemap:
db "<TURN><N_A> <DIE><N_A> <COIN>0 <XP>0 " db "<TURN><N_A> <DIE><N_A> <COIN>0 <XP>0 "

View File

@ -155,6 +155,7 @@ StartMap:
xor a xor a
ld hl, wCurTurn ld hl, wCurTurn
ld [hli], a ; wCurTurn ld [hli], a ; wCurTurn
ld [hli], a ;
ld [hli], a ; wCurSpace ld [hli], a ; wCurSpace
ld [hli], a ; wCurLevelCoins ld [hli], a ; wCurLevelCoins
ld [hli], a ; ld [hli], a ;

View File

@ -2546,7 +2546,7 @@ wYCoord:: db
wXCoord:: db wXCoord:: db
wScreenSave:: ds SCREEN_META_WIDTH * SCREEN_META_HEIGHT wScreenSave:: ds SCREEN_META_WIDTH * SCREEN_META_HEIGHT
wCurTurn:: db wCurTurn:: dw
wCurSpace:: db wCurSpace:: db
wCurLevelCoins:: ds 3 wCurLevelCoins:: ds 3
wCurLevelExp:: ds 3 wCurLevelExp:: ds 3