From e885dfafa36e8ac246004d60c8e8b0d55ad7b2e7 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Fri, 17 Oct 2025 08:04:52 +0200 Subject: [PATCH] ui: wip hp display --- src/defs.s | 1 + src/player.s | 2 +- src/ui.s | 19 +++++++++++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/defs.s b/src/defs.s index 3ca6774..e89b5f8 100644 --- a/src/defs.s +++ b/src/defs.s @@ -18,6 +18,7 @@ #define ACTS_ENEMY_PROJECTILES 6 #define ACTS_MAX (ACTS_PLAYER_PROJECTILES + ACTS_ENEMY + ACTS_ENEMY_PROJECTILES) +#define HP_MAX 20 #define MAP_OBJ_MAX 32 #define RECT_MAX 4 diff --git a/src/player.s b/src/player.s index debbaf7..f56a47e 100644 --- a/src/player.s +++ b/src/player.s @@ -13,7 +13,7 @@ player_init: ld a, 0x30 ; initial next scroll ld [player_next_scroll_y], a - ld a, 10 + ld a, HP_MAX ld [player+act_hp], a ret diff --git a/src/ui.s b/src/ui.s index 3721c44..6003c44 100644 --- a/src/ui.s +++ b/src/ui.s @@ -9,6 +9,12 @@ ; one tile after 'Z' #define UI_WINDOW_BACKGROUND 0xF4 +#define UI_TILE_HP_4 0xC8 +#define UI_TILE_HP_3 0xC9 +#define UI_TILE_HP_2 0xCA +#define UI_TILE_HP_1 0xCB + + strz str_player, "PLAYER" strz str_enemy, "ENEMY" @@ -30,9 +36,18 @@ ui_draw_player_hp: ld hl, str_player call puts - ld de, UI_PLAYER_HP+7 + ld hl, UI_PLAYER_HP+7 ld a, [player+act_hp] - call putn + jp ui_draw_hp + + ; draws generic hp + ; inputs: + ; hl: address to draw to + ; b: current hp +ui_draw_hp: + ld a, UI_TILE_HP_4 + ld [hl+], a + ret ; draws boss hp -- 2.30.2