ui: the mp/hp icons do not get redrawn when the bar changes
authorLukas Krickl <lukas@krickl.dev>
Fri, 4 Oct 2024 15:46:28 +0000 (17:46 +0200)
committerLukas Krickl <lukas@krickl.dev>
Fri, 4 Oct 2024 15:46:28 +0000 (17:46 +0200)
src/ui.s

index 00c4030726001eff4f29ea658c28a61ca108667e..6479c6ae5d469b6c4d96495a48a4a9316a300107 100644 (file)
--- a/src/ui.s
+++ b/src/ui.s
@@ -1,5 +1,6 @@
 #define THP_ICON 0x33
 #define TMP_ICON 0x37
+#define THP_BAR_START 0x34
 
   ; sets up static parts of the UI
   ; all other parts are drawin by ui_draw
@@ -18,19 +19,27 @@ ui_init:
   ; darw mp and hp on first frame 
   ld a, UI_REDRAW_HP | UI_REDRAW_MP 
   ld [ui_flags], a
+  
+  ; hp icon 
+  ld hl, SCRN0_UI+SCRN_W
+  ld a, THP_ICON
+  ld [hl], a
+
+  ; mp icon 
+  ld a, TMP_ICON
+  ld hl, SCRN0_UI+SCRN_W+10
+  ld [hl], a
 
   ret
 
   ; draws a UI bar 
   ; inputs:
   ;   hl: screen location
-  ;   [de]: amount of bars to draw
+  ;   [de]: ptr to hp/mp where hp/mp max is [de+1]
 ui_draw_bar:
   
 
-  ld a, THP_ICON
-  ld [hl+], a
-  inc a
+  ld a, THP_BAR_START
   ld [hl+], a
   inc a
   ld [hl+], a
@@ -48,7 +57,7 @@ ui_draw:
   jr z, @skip REL
 
   ; draw hp UI
-  ld hl, SCRN0_UI+SCRN_W
+  ld hl, SCRN0_UI+SCRN_W+1
   ; player hp ptr
   ld de, player + player_hp
   ; check redraw hp flag
@@ -61,11 +70,8 @@ ui_draw:
   jr z, @no_mp_draw REL
   
   ; draw mp UI 
-  ld a, TMP_ICON
-  ld hl, SCRN0_UI+SCRN_W+10
-  ld [hl+], a
-  
-  ld a, THP_ICON+1 ; the bar
+  ld hl, SCRN0_UI+SCRN_W+11
+  ld a, THP_BAR_START ; the bar
 
   ld [hl+], a
   inc a