action: added basic display for damage value
authorLukas Krickl <lukas@krickl.dev>
Sat, 23 Aug 2025 03:34:57 +0000 (05:34 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sat, 23 Aug 2025 03:34:57 +0000 (05:34 +0200)
Currently we print in hex this will need to be decimal eventually

src/action.s
src/strings.s
src/ui.s
src/unit_demo.s

index 21adf4afd7f9d17996b85b030b03d594e36c7a5b..a753cb6dd403975e6f26fee0d0b60d2786731114 100644 (file)
@@ -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
index 8fc0da3c770d6dc36082842627bcfafb877e9b8f..edb2302f9a5f9d02986284e94d7ddb6fb1f1c43c 100644 (file)
@@ -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
index 8805fe5826b4bfcd83a2133c70d6064b312edf2e..23a95e28f7a785908b75a96f815c53d6f5a0a9b4 100644 (file)
--- 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
index 72086216ef7b43547936427cb90883b09324a70a..b8bda52de5b8d7329a658a2b81f6e5c2efd33438 100644 (file)
@@ -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