Added basic drawing routine for single filled and empty stats bar
authorLukas Krickl <lukas@krickl.dev>
Sat, 5 Oct 2024 16:44:20 +0000 (18:44 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sat, 5 Oct 2024 16:44:20 +0000 (18:44 +0200)
src/ui.s
src/wram.s

index 146cee54e3a950134854babd74834640d9b20260..67d35df30a64a1529eabadc8f10b79da8f640c18 100644 (file)
--- 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
index de1c43c2516f182a69961f5414effd941add01d6..cb3d59639fa331651ac91b6f4e15106b9e41c628 100644 (file)
@@ -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