From: Lukas Krickl Date: Sat, 23 Aug 2025 12:52:42 +0000 (+0200) Subject: stats: Added basic hp display X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=2bd05ef0acb06068db14bd5646a860b467fafb8c;p=gbrg%2F.git stats: Added basic hp display --- diff --git a/src/stats.s b/src/stats.s index ffac5a3..8b40141 100644 --- a/src/stats.s +++ b/src/stats.s @@ -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: diff --git a/src/strings.s b/src/strings.s index d43a961..cc75efb 100644 --- a/src/strings.s +++ b/src/strings.s @@ -52,6 +52,10 @@ STR_DELETE: .str "DELETE" .db 0 +STR_HP: +.str "HP " +.db 0 + STR_ATTACK_DIRECTION: .str "attack direction?" .db 0 diff --git a/src/ui.s b/src/ui.s index 23a95e2..82ae143 100644 --- 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