From f72884c4cb67bc3e59d0623c8ebe524f267a7f16 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sat, 5 Oct 2024 18:44:20 +0200 Subject: [PATCH] Added basic drawing routine for single filled and empty stats bar --- src/ui.s | 32 ++++++++++++++++++++++++++++++++ src/wram.s | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/ui.s b/src/ui.s index 146cee5..67d35df 100644 --- a/src/ui.s +++ b/src/ui.s @@ -2,7 +2,11 @@ #define TMP_ICON 0x37 #define TATK_ICON 0x3B #define TDEF_ICON 0x3C + #define THP_BAR_START 0x34 +#define THP_BAR_SINGLE_EMPTY 0x3E +#define THP_BAR_SINGLE_FULL 0x3D + ; sets up static parts of the UI ; all other parts are drawin by ui_draw @@ -34,6 +38,24 @@ ui_init: ret + ; draw a single item only + ; inputs: + ; b: current bar value (either 1 or 0) + ; hl: screen location +ui_draw_bar_single: + ld a, b ; b = current + + cp a, 0 + jp z, @draw_empty +@draw_full: + ld a, THP_BAR_SINGLE_FULL + ld [hl+], a + ret +@draw_empty: + ld a, THP_BAR_SINGLE_EMPTY + ld [hl+], a + ret + ; draws a UI bar ; the bar will be filled up to hp/mp ; al others will be empty @@ -41,8 +63,18 @@ ui_init: ; hl: screen location ; [de]: ptr to hp/mp where hp/mp max is [de+1] ui_draw_bar: + ld a, [de] ; load non-max value + inc de ; move to max value + ld b, a ; b = current value + ; check if we only need a single obj + ld a, [de] ; a = max value + + cp a, 1 + jp c, ui_draw_bar_single + jp z, ui_draw_bar_single + ; first we draw the filled bar ld a, THP_BAR_START ld [hl+], a inc a diff --git a/src/wram.s b/src/wram.s index de1c43c..cb3d596 100644 --- a/src/wram.s +++ b/src/wram.s @@ -32,7 +32,7 @@ actor_table: .adv ACTORS_MAX * actor_size #define PLAYER_DEFAULT_HP 3 #define PLAYER_DEFAULT_MP 3 -#define PLAYER_DEFAULT_DEF 1 +#define PLAYER_DEFAULT_DEF 0 #define PLAYER_DEFAULT_ATK 1 ; struct player -- 2.30.2