From 80257e4bcab0dae1c97772d038ace0e3dcfe2b5e Mon Sep 17 00:00:00 2001 From: xCrystal Date: Wed, 27 Dec 2023 17:42:46 +0100 Subject: [PATCH] Populate content of overworld HUD (#18); make wCurTurn 2 bytes (#25) --- constants/misc_constants.asm | 3 +++ engine/board/menu.asm | 15 +++++++++++++++ engine/board/spaces.asm | 2 ++ engine/gfx/hud.asm | 32 +++++++++++++++++++++++++++++++- engine/overworld/events.asm | 1 + ram/wram.asm | 2 +- 6 files changed, 53 insertions(+), 2 deletions(-) diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index f1ba236bc..5c97b13c4 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -42,6 +42,9 @@ DEF MAX_LEVEL_COINS EQU 99999 DEF MAX_DELTA_COINS_DIGITS EQU 5 DEF MAX_CHIPS EQU 9999 +; significant turns values +DEF MAX_TURNS EQU 999 + ; link record DEF MAX_LINK_RECORD EQU 9999 diff --git a/engine/board/menu.asm b/engine/board/menu.asm index 565f842c0..fe3b93a3f 100755 --- a/engine/board/menu.asm +++ b/engine/board/menu.asm @@ -26,7 +26,21 @@ BoardMenuScript:: xor a call ByteFill 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] + jr nz, .next + dec hl + inc [hl] + jr .next +.next +; apply wCurTurn and wDieRoll in overworld HUD + call RefreshOverworldHUD ; reset turn-scoped event flags ld hl, wEventFlags + 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: farcall LoadBoardMenuDieNumbersGFX + call RefreshOverworldHUD ; apply wDieRoll in overworld HUD ld a, [wDieRoll] dec a add a diff --git a/engine/board/spaces.asm b/engine/board/spaces.asm index 1a641eee4..aab46a647 100755 --- a/engine/board/spaces.asm +++ b/engine/board/spaces.asm @@ -349,7 +349,9 @@ PrintGainOrLoseCoins: call PrintNum ld hl, wDisplaySecondarySprites set SECONDARYSPRITES_GAIN_OR_LOSE_COINS_F, [hl] +; refresh overworld HUD, and show coins string 750 ms call UpdateActiveSprites + call RefreshOverworldHUD ld c, 45 ; 750 ms call DelayFrames ld hl, wDisplaySecondarySprites diff --git a/engine/gfx/hud.asm b/engine/gfx/hud.asm index fe636e16a..7af1e1670 100755 --- a/engine/gfx/hud.asm +++ b/engine/gfx/hud.asm @@ -29,11 +29,41 @@ _LoadOverworldHUDAttrmap: jp ByteFill _ConstructOverworldHUDTilemap:: +; layout ld hl, .Tilemap ld de, wOverworldHUDTiles ld bc, .TilemapEnd - .Tilemap ; SCREEN_WIDTH 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: db " 0 0 " diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm index ffb2645a3..a7c3d2e61 100644 --- a/engine/overworld/events.asm +++ b/engine/overworld/events.asm @@ -155,6 +155,7 @@ StartMap: xor a ld hl, wCurTurn ld [hli], a ; wCurTurn + ld [hli], a ; ld [hli], a ; wCurSpace ld [hli], a ; wCurLevelCoins ld [hli], a ; diff --git a/ram/wram.asm b/ram/wram.asm index fb71d26a8..c9b3ce1c3 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -2546,7 +2546,7 @@ wYCoord:: db wXCoord:: db wScreenSave:: ds SCREEN_META_WIDTH * SCREEN_META_HEIGHT -wCurTurn:: db +wCurTurn:: dw wCurSpace:: db wCurLevelCoins:: ds 3 wCurLevelExp:: ds 3