From: Lukas Krickl Date: Sat, 23 Aug 2025 03:34:57 +0000 (+0200) Subject: action: added basic display for damage value X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=b87b8a328bc0996f3daf67b50a3c559dce1e2e2f;p=gbrg%2F.git action: added basic display for damage value Currently we print in hex this will need to be decimal eventually --- diff --git a/src/action.s b/src/action.s index 21adf4a..a753cb6 100644 --- a/src/action.s +++ b/src/action.s @@ -228,6 +228,11 @@ unit_action_attack_damage_calc: call unit_attack_get_attack_tile call unit_find_at + ld a, h + or a, l + ldnull bc + ret z ; no unit found + pop de push hl pop bc @@ -236,6 +241,9 @@ unit_action_attack_damage_calc: push hl call stat_calc_physical_damage_vs pop hl + + ld hl, STR_HIT_FOR + call ui_draw_status_stat ldnull bc ret diff --git a/src/strings.s b/src/strings.s index 8fc0da3..edb2302 100644 --- a/src/strings.s +++ b/src/strings.s @@ -58,6 +58,10 @@ STR_ATTACK_DIRECTION: STR_STATUS_CLEAR: .str " " +.db 0 + +STR_HIT_FOR: +.str "hit for " .db 0 ; print a 0-terminated string to the screen @@ -77,4 +81,12 @@ puts: jr puts REL @done: ret - + + ; prints a number in decimal + ; input: + ; de: tile location + ; a: the value +putn: + add a, FONT_OFFSET+1 + ld [de], a + ret diff --git a/src/ui.s b/src/ui.s index 8805fe5..23a95e2 100644 --- a/src/ui.s +++ b/src/ui.s @@ -55,5 +55,19 @@ ui_request_redraw: ld a, UI_TILE_WIDTH * UI_TILE_HEIGHT / REDRAW_TILES_PER_FRAME ld [redraw_steps], a ret + + + ; draw a string and a number + ; as a status line + ; inputs: + ; hl: text ptr + ; a: value to display +ui_draw_status_stat: + push af + ld de, UI_STATUS_LINE + call puts + pop af - + call putn + call ui_request_redraw + ret diff --git a/src/unit_demo.s b/src/unit_demo.s index 7208621..b8bda52 100644 --- a/src/unit_demo.s +++ b/src/unit_demo.s @@ -26,7 +26,7 @@ unit_demo_2: unit_demo_warrior: st_def 0x00, unit_demo_1_init, st_unit_demo_1_cpu_update act_def ACT_T_DEMO_1, 0, 9, 9, 0 - act_stat_def1 1, 1, 1, 1 + act_stat_def1 1, 3, 1, 1 act_stat_def2 1, 1, 32, 1 act_st_def st_unit_demo_1_cpu_update, st_unit_idle act_def_meta unit_draw, 0x88, OAM_FPRIO, NULL @@ -42,7 +42,7 @@ unit_demo_mage: unit_demo_thief: st_def 0x00, unit_demo_1_init, st_unit_demo_1_cpu_update act_def ACT_T_DEMO_1, 0, 9, 9, 0 - act_stat_def1 1, 1, 1, 1 + act_stat_def1 1, 2, 1, 1 act_stat_def2 1, 1, 32, 1 act_st_def st_unit_demo_1_cpu_update, st_unit_idle act_def_meta unit_draw, 0x90, OAM_FPRIO, NULL