From f99a1d5b3273f8ddfed292c3fc263e6b0ddc11d4 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sun, 30 Mar 2025 07:41:21 +0200 Subject: [PATCH] ui: Added more strings and adjuted label position --- src/macros.inc | 8 ++++++++ src/strings.s | 5 +++++ src/ui.s | 29 +++++++++++++++++++++++------ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/macros.inc b/src/macros.inc index b4d6163..12d26ac 100644 --- a/src/macros.inc +++ b/src/macros.inc @@ -132,3 +132,11 @@ #macro ldnull ld $1, 0 #endmacro + + ; creates a NUL terminated string + ; inputs: + ; $1: string +#macro strt + .str $1 + .db 0 +#endmacro diff --git a/src/strings.s b/src/strings.s index 836899d..124bd3b 100644 --- a/src/strings.s +++ b/src/strings.s @@ -23,6 +23,11 @@ STR_WAREHOUSE: .str "WAREHOUSE" .db 0 +STR_ROAD: strt "ROAD" +STR_FARM: strt "FARM" +STR_LUMBER: strt "LUMBER" + + STR_PANIC: .str "PANIC" .db 0 diff --git a/src/ui.s b/src/ui.s index ef26bfc..8fd09e7 100644 --- a/src/ui.s +++ b/src/ui.s @@ -4,16 +4,23 @@ #define UI_TILE_FARM 130 #define UI_TILE_LUMBER 131 +#define UI_BUILDING_TEXT_X 2 +#define UI_BUILDING_TEXT_Y 120 + #define UI_CURSOR_BUILDING_BASE_X 2 -#define UI_CURSOR_BUILDING_BASE_Y 120 +#define UI_CURSOR_BUILDING_BASE_Y 128 -#define UI_TEXT_SPRITE_0 shadow_oam+4 +#define UI_TEXT_SPRITE_LEN oamsize*10 +#define UI_TEXT_SPRITE_0 shadow_oam+oamsize ; lookup table for ; labels displayed when hovering ; over a building ui_cursor_label_table: dw STR_WAREHOUSE + dw STR_ROAD + dw STR_FARM + dw STR_LUMBER ; inits UI ui_init: @@ -24,7 +31,7 @@ ui_init: ; this should only be called ; during blanking ui_draw: - ld hl, SCRN1 + ld hl, SCRN1+32 inc hl ld a, UI_TILE_WAREHOUSE @@ -49,7 +56,10 @@ ui_building_selector_update: pop bc ret + ; draw building selector cursor + ; and text ui_building_selector_draw: + ; draw cursor ld hl, PLAYER_SPRITE1 ld a, UI_CURSOR_BUILDING_BASE_Y @@ -69,7 +79,13 @@ ui_building_selector_draw: ld a, CURSOR_TILE ld [hl+], a - ; TODO: print based on cursor location + ; clear text objects + ld hl, UI_TEXT_SPRITE_0 + ld bc, UI_TEXT_SPRITE_LEN + ld d, 0 + call memset + + ; draw text ld a, [ui_cursor_pos] sla a ; * 2 ld hl, ui_cursor_label_table @@ -85,8 +101,8 @@ ui_building_selector_draw: ld h, a ; hl = string ptr - ld b, 10 - ld c, 10 + ld b, UI_BUILDING_TEXT_Y + ld c, UI_BUILDING_TEXT_X ld de, UI_TEXT_SPRITE_0 call objputs @@ -100,6 +116,7 @@ ui_building_selector_exit: ldnull bc ret + ; building selectr input reader ui_building_selector_inputs: input_just BTNSELECT jr z, @not_select REL -- 2.30.2