From 4826b2b7ec2ee7773908480fc3df1804489697f4 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sat, 5 Oct 2024 16:07:36 +0200 Subject: [PATCH] Added atk and def bars --- src/player.s | 6 ++++-- src/ui.s | 22 +++++++++++++++++++++- src/wram.s | 2 ++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/player.s b/src/player.s index 322ff0b..7c319d3 100644 --- a/src/player.s +++ b/src/player.s @@ -29,11 +29,13 @@ player_init: ; default def ld a, PLAYER_DEFAULT_DEF - ld [hl+], a + ld [hl+], a ; def + ld [hl+], a ; def max ; default atk ld a, PLAYER_DEFAULT_ATK - ld [hl+], a + ld [hl+], a ; atk + ld [hl+], a ; atk max ret diff --git a/src/ui.s b/src/ui.s index 18917c9..146cee5 100644 --- a/src/ui.s +++ b/src/ui.s @@ -9,7 +9,7 @@ ; only call during blanking ui_init: ; darw mp and hp on first frame - ld a, UI_REDRAW_HP | UI_REDRAW_MP + ld a, UI_REDRAW_HP | UI_REDRAW_MP | UI_REDRAW_ATK | UI_REDRAW_DEF ld [ui_flags], a ; hp icon @@ -69,6 +69,16 @@ ui_draw_mp_bar: ; directly jump without a return jp ui_draw_bar +ui_draw_atk_bar: + ld hl, SCRN0_UI+SCRN_W+1 + ld de, player + player_atk + jp ui_draw_bar + +ui_draw_def_bar: + ld hl, SCRN0_UI+SCRN_W+11 + ld de, player + player_def + jp ui_draw_bar + ; update the UI ; this should only be called ; during blanking @@ -87,6 +97,16 @@ ui_draw: and a, UI_REDRAW_HP call nz, ui_draw_mp_bar + ; check if we should draw atk bar + ld a, [ui_flags] + and a, UI_REDRAW_ATK + call nz, ui_draw_atk_bar + + ; check if we should draw def bar + ld a, [ui_flags] + and a, UI_REDRAW_DEF + call nz, ui_draw_def_bar + ; set flags to 0 xor a, a ld [ui_flags], a diff --git a/src/wram.s b/src/wram.s index ce2ba56..de1c43c 100644 --- a/src/wram.s +++ b/src/wram.s @@ -47,7 +47,9 @@ actor_table: .adv ACTORS_MAX * actor_size .de player_mp, 1 .de player_mp_max, 1 .de player_def, 1 +.de player_def_max, 1 .de player_atk, 1 +.de player_atk_max, 1 .de player_size, 0 -- 2.30.2