unit: working on fixing sprite flickering when moving
authorLukas Krickl <lukas@krickl.dev>
Wed, 21 May 2025 15:58:02 +0000 (17:58 +0200)
committerLukas Krickl <lukas@krickl.dev>
Wed, 21 May 2025 15:58:02 +0000 (17:58 +0200)
src/map.s
src/unit.s

index e4e12655793be0278ea016bb3b80015d0ba65c25..43a9503a1c5691ab8c2dd0f0309e19463c765943 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -113,6 +113,11 @@ map_load_demo_actors:
   ld hl, p0_units + act_size
   ld bc, act_size
   call memcpy
+
+  ld de, unit_demo_3
+  ld hl, p0_units + act_size * 2
+  ld bc, act_size
+  call memcpy
   
   ld de, p_empty_unit
   call unit_next_request
index ca3d3886fe93431814014dc8d760df3d53b53562..ffe9524b8b05885693a63a93ef3b2d30f1c14bca 100644 (file)
@@ -81,6 +81,14 @@ unit_demo_1_draw:
   ldnull bc
   ret
 
+  ; inputs:
+  ;   de: actor
+unit_demo_1_delay_to_active:
+  push de
+  call unit_demo_1_draw
+  pop de
+  jp unit_delay_to_active
+
   ; draws any unit
   ; inputs:
   ;  de: actor
@@ -137,7 +145,7 @@ unit_handle_inputs:
   jr z, @notup REL
 
     call unit_try_move_up
-    ld bc, st_unit_delay_to_active
+    ld bc, st_unit_demo_1_delay_to_active
     ret
 @notup:
 
@@ -145,7 +153,7 @@ unit_handle_inputs:
   jr z, @notdown REL
     
     call unit_try_move_down
-    ld bc, st_unit_delay_to_active
+    ld bc, st_unit_demo_1_delay_to_active
     ret
 @notdown:
 
@@ -153,7 +161,7 @@ unit_handle_inputs:
   jr z, @notleft REL
 
     call unit_try_move_left
-    ld bc, st_unit_delay_to_active
+    ld bc, st_unit_demo_1_delay_to_active
     ret
 @notleft:
 
@@ -161,7 +169,7 @@ unit_handle_inputs:
   jr z, @notright REL
 
     call unit_try_move_right
-    ld bc, st_unit_delay_to_active
+    ld bc, st_unit_demo_1_delay_to_active
     ret
 @notright:
 
@@ -571,7 +579,12 @@ unit_demo_1:
 
 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, 0, 5, 3, 3, 0 
+  act_def ACT_T_DEMO_1, 0, 1, 2, 3, 1, 5, 3, 3, 0 
+  act_st_def NULL, NULL, st_unit_demo_1_update, st_unit_demo_1_idle
+
+unit_demo_3:
+  st_def 0x00, unit_demo_1_init, st_unit_demo_1_idle
+  act_def ACT_T_DEMO_1, 0, 1, 2, 3, 0, 5, 4, 4, 0 
   act_st_def NULL, NULL, st_unit_demo_1_update, st_unit_demo_1_idle
 
 st_unit_demo_1_update:
@@ -580,8 +593,8 @@ 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_to_active:
-  st_def CURSOR_MOVE_TIMER, unit_delay_to_active, st_unit_switch_to_active
+st_unit_demo_1_delay_to_active:
+  st_def CURSOR_MOVE_TIMER, unit_demo_1_delay_to_active, st_unit_switch_to_active
 
 st_unit_switch_to_active:
   st_def 0, unit_switch_to_active, st_unit_switch_to_active