unit: wip unit selector
authorLukas Krickl <lukas@krickl.dev>
Tue, 20 May 2025 03:57:52 +0000 (05:57 +0200)
committerLukas Krickl <lukas@krickl.dev>
Tue, 20 May 2025 03:57:52 +0000 (05:57 +0200)
src/map.s
src/ui.s
src/unit.s

index 1e777e6f994a27054d8e9fbc758904c85e843419..1aa148dc6b69f9a5a698bce13f661bf0689148f1 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -109,10 +109,13 @@ map_load_demo_actors:
   ld bc, act_size
   call memcpy
 
-  ld de, unit_demo_1
+  ld de, unit_demo_2
   ld hl, p0_units + act_size
   ld bc, act_size
   call memcpy
+
+  call unit_next_no_current 
+
   ret
 
 #include "default_map.s"
index 5b5f521319df511a5e8afc8eeeaf07411b354d24..b305c00f16a1ad84b4c3870067c600a8a63ace83 100644 (file)
--- a/src/ui.s
+++ b/src/ui.s
@@ -24,10 +24,25 @@ ui_unit_need_draw:
 
   ret
 
+  ; displays the current unit
+ui_display_current_unit:
+  ld a, [ui_draw_actor]
+  ld e, a
+  ld a, [ui_draw_actor+1]
+  ld d, a
+  
+  ld b, CURSOR_TILE
+  ld c, 0
+  call unit_generic_draw
+
+  ret
+
   ; update the UI 
   ; this should only be called 
   ; during blanking 
 ui_draw:
+  call ui_display_current_unit
+
   ld a, [draw_flags]
   xor a, DRAWF_UPDATE_UI
   ld [draw_flags], a
index 6e13caf4e539892e9298087f2c9581387d9fafc8..201277a36c9f7a3bc1ee590af97fd7ecdc637247 100644 (file)
@@ -64,6 +64,12 @@ unit_demo_1_update:
   call unit_demo_1_draw
   pop bc
   ret
+  
+  ; inputs
+  ;   de: actor
+unit_demo_1_idle:
+  call unit_demo_1_draw
+  ret
 
   ; inputs
   ;   de: actor
@@ -354,6 +360,7 @@ unit_next:
   ld hl, act_moves
   add hl, de
   ld [hl], 0 ; moves = 0
+unit_next_no_current:
 @again:
   xor a, a
   ld [unit_next_best_init], a
@@ -470,13 +477,22 @@ unit_reset_all_moves:
 
 
 unit_demo_1:
-  st_def 0x00, unit_demo_1_init, st_unit_demo_1_update
+  st_def 0x00, unit_demo_1_init, st_unit_demo_1_idle
   act_def ACT_T_DEMO_1, 0, 1, 2, 3, 4, 5, 2, 2, 0 
-  act_st_def NULL, NULL, st_unit_demo_1_update, NULL
-  
+  act_st_def NULL, NULL, st_unit_demo_1_update, st_unit_demo_1_idle
+
+
+unit_demo_2:
+  st_def 0x00, unit_demo_1_init, st_unit_demo_1_idle
+  act_def ACT_T_DEMO_1, 0, 1, 2, 3, 4, 5, 3, 3, 0 
+  act_st_def NULL, NULL, st_unit_demo_1_update, st_unit_demo_1_idle
+
 st_unit_demo_1_update:
   st_def 0x00, unit_demo_1_update, st_unit_demo_1_update 
 
+st_unit_demo_1_idle:
+  st_def 0x00, unit_demo_1_idle, st_unit_demo_1_idle
+
 st_unit_delay:
   st_def CURSOR_MOVE_TIMER, st_null_fn, st_unit_switch_to_active