#define THP_ICON 0x33
#define TMP_ICON 0x37
- ; update the UI
- ; this should only be called
- ; during blanking
-ui_draw:
+ ; sets up static parts of the UI
+ ; all other parts are drawin by ui_draw
+ ; only call during blanking
+ui_init:
; draw hp string
ld hl, STR_HP
ld de, SCRN0_UI
ld hl, STR_MP
ld de, SCRN0_UI+10
call puts
+
+ ; darw mp and hp on first frame
+ ld a, UI_REDRAW_HP | UI_REDRAW_MP
+ ld [ui_flags], a
+
+ ret
+
+ ; draws a UI bar
+ ; inputs:
+ ; hl: screen location
+ ; [de]: amount of bars to draw
+ui_draw_bar:
- ; draw hp UI
+
ld a, THP_ICON
- ld hl, SCRN0_UI+SCRN_W
ld [hl+], a
inc a
ld [hl+], a
ld [hl+], a
inc a
ld [hl+], a
+ ret
+
+ ; update the UI
+ ; this should only be called
+ ; during blanking
+ui_draw:
+ ; check if we should darw hp bar
+ ld a, [ui_flags]
+ cp a, 0
+ jr z, @skip REL
+
+ ; draw hp UI
+ ld hl, SCRN0_UI+SCRN_W
+ ; player hp ptr
+ ld de, player + player_hp
+ ; check redraw hp flag
+ and a, UI_REDRAW_HP
+ call nz, ui_draw_bar
+
+ ; check if we should draw mp bar
+ ld a, [ui_flags]
+ and a, UI_REDRAW_HP
+ jr z, @no_mp_draw REL
; draw mp UI
ld a, TMP_ICON
ld [hl+], a
inc a
ld [hl+], a
+@no_mp_draw:
+ ; set flags to 0
+ xor a, a
+ ld [ui_flags], a
+@skip:
ret