ui: added player hp bar
authorLukas Krickl <lukas@krickl.dev>
Wed, 22 Oct 2025 03:33:34 +0000 (05:33 +0200)
committerLukas Krickl <lukas@krickl.dev>
Wed, 22 Oct 2025 03:33:34 +0000 (05:33 +0200)
src/ui.s

index 4d69e1422286469ab0f94de4a310529e3a0b35e9..c4d3ef6704fc80c67497cf7ad2410fb1e31f599e 100644 (file)
--- a/src/ui.s
+++ b/src/ui.s
@@ -38,6 +38,7 @@ ui_draw_player_hp:
 
        ld hl, UI_PLAYER_HP+7
        ld a, [player+act_hp]
+       ld b, a
        jp ui_draw_hp
        
        ; draws generic hp
@@ -45,23 +46,25 @@ ui_draw_player_hp:
        ;               hl: address to draw to
        ;                b: current hp
 ui_draw_hp:
+
+@full_loop:
        ld a, b
        cp a, 4
        jr c, @skip_full REL
 
-@full_loop:
        ld a, UI_TILE_HP_4
        ld [hl+], a
 
        ld a, b 
        sub a, 4
        ld b, a
+       jp z, @done
        jp c, @done ; no more hp to draw
        jr @full_loop REL
 
 @skip_full:
        
-       ld a, UI_TILE_HP_1
+       ld a, UI_TILE_HP_1+1
        sub a, b
        ld [hl+], a