stats: Added basic hp display
authorLukas Krickl <lukas@krickl.dev>
Sat, 23 Aug 2025 12:52:42 +0000 (14:52 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sat, 23 Aug 2025 12:52:42 +0000 (14:52 +0200)
src/stats.s
src/strings.s
src/ui.s

index ffac5a3b805e9638d5dc7f56a0c0e0b6c822a633..8b401413e47ea2ec8b8bc137118a5be55e01aa9a 100644 (file)
@@ -29,6 +29,28 @@ stat_calc_str:
        ld a, [hl]
   ret
        
+       ; calculates hp
+       ; inputs:
+       ;               de: actor
+       ;       returns:
+       ;               a: hp
+stat_calc_hp:
+       ld hl, act_hp
+       add hl, de
+       ld a, [hl]
+       ret
+       
+       ; calculates mp
+       ;       inputs:
+       ;               de: actor
+       ;       returns:
+       ;               a: mp
+stat_calc_mp:
+       ld hl, act_mp
+       add hl, de
+       ld a, [hl]
+       ret
+       
        ; calculates weapon damage
        ; inputs:
        ;               de actor
@@ -62,6 +84,14 @@ stat_calc_hp_max:
        add a, 2 ; base health
        ret
        
+       ; calculates mp max
+       ; inputs:
+       ;               de: actor
+       ;       returns:
+       ;               a: mp max
+stat_calc_mp_max:
+       ret
+       
        ; calculates physical damage of 
        ; one actor agains another
        ; formula:
index d43a9615fbe3385e22d82f3f7c125aaaf083c4dc..cc75efbbc20a4d89dd3666142014322d7766c99b 100644 (file)
@@ -52,6 +52,10 @@ STR_DELETE:
 .str "DELETE"
 .db 0
 
+STR_HP:
+.str "HP "
+.db 0
+
 STR_ATTACK_DIRECTION:
 .str "attack direction?"
 .db 0
index 23a95e28f7a785908b75a96f815c53d6f5a0a9b4..82ae143c13cc8982d860ca6ccdaceb6651135e1f 100644 (file)
--- a/src/ui.s
+++ b/src/ui.s
@@ -22,9 +22,16 @@ ui_init:
   
   ; updates HP UI
 ui_redraw_hp:
-  ld hl, STR_TEST
-  ld de, shadow_ui + 34
+       ld hl, STR_HP
+       ld de, UI_STATUS_LINE+32
   call puts
+
+       push de
+       ld de, player_unit
+       call stat_calc_hp
+       pop de
+       
+       call putn
   ret
        
        ; clears the status line