actor: removed sub-tile movement
authorLukas Krickl <lukas@krickl.dev>
Wed, 25 Jun 2025 17:23:05 +0000 (19:23 +0200)
committerLukas Krickl <lukas@krickl.dev>
Wed, 25 Jun 2025 17:23:05 +0000 (19:23 +0200)
Instead it will be replaced by a delay state that will update
an offset for rendering.
This state will move faster or slower depending on movement speed.

src/actortables.s
src/unit.s

index 511da3df8f0be5062150465459f0aac3e23e022d..82206988f8b4b01b26217a2967049bbc13b7949c 100644 (file)
@@ -1,7 +1,7 @@
 #include "unit_demo.s"
 
 default_map_actor_table:
-.db 19 ; size
+.db 0; 19 ; size
 dw unit_demo_2
 dw unit_demo_3
 dw unit_demo_3
index f9faa481d0a7fb6e6ad362d5e24c77d3d2569b8a..223ffa5cef35dac2f6356788c886ad4fc3ae0325 100644 (file)
@@ -305,50 +305,15 @@ unit_collides_with_any_other:
   ld a, CF_COLLISION
   ret
 #undefine scratch_loop_i
-
-  ; calculates movement speed based un the current unit
-  ; inputs:
-  ;   de: unit
-  ; returns: 
-  ;   a: movement speed 
-unit_calc_movement_speed:
-  call stat_calc_speed
-  sla a ; * 2
-  ret
-
-  ; performs a sub tile move
+  
+  ; transitions a unit
+  ; to a movement animation
+  ; the animation time is dependant on movement
+  ; speed (100-stat_calc_speed)
   ; inputs:
   ;   de: actor
-  ;   hl: y/x position ptr
-  ;   $1: subtile_y/x 
-  ;   $2: add/sub for sub tile calculation
-  ;   $3: adc/sbc for tile calculation
-  ; carry bit is set if subtile position has a carry
-  ; preserves:
-  ;   hl
-#macro unit_sub_tile_move
-  push hl
-
-  push de
-  call unit_calc_movement_speed
-  ; a = movement speed
-  pop de
-  
-  ld b, a ; b = movement speed
-
-  ld hl, $1 
-  add hl, de ; hl = subtile pos
-  
-  ld a, [hl] ; load position
-  $2 a, b ; add or sub position
-  ld [hl], a ; store new sub-tile position
-
-  pop hl
-  ; now apply carry to real position
-  ld a, [hl]
-  $3 a, 0
-  ld [hl], a
-#endmacro
+unit_transition_to_move_animation:
+  ret
 
   ; moves a unit up
   ; moves are aborted 
@@ -374,7 +339,11 @@ unit_try_move_up:
   pop de
   ret z
 
-  unit_sub_tile_move act_rt_subtile_y, sub, sbc
+  dec a 
+  ld [hl], a
+
+  call unit_transition_to_move_animation
+
   ret
 
 unit_try_move_down:
@@ -387,8 +356,12 @@ unit_try_move_down:
   ld a, [hl]
   cp a, MAP_H - 1 ; lower bound
   ret z
+  
+  inc a
+  ld [hl], a
 
-  unit_sub_tile_move act_rt_subtile_y, add, adc
+  call unit_transition_to_move_animation
+  
   ret
 
 unit_try_move_left:
@@ -401,8 +374,12 @@ unit_try_move_left:
   ld a, [hl]
   cp a, 0 ; left bound
   ret z
-
-  unit_sub_tile_move act_rt_subtile_x, sub, sbc
+  
+  dec a
+  ld [hl], a
+  
+  call unit_transition_to_move_animation
+  
   ret
 
 unit_try_move_right:
@@ -416,8 +393,12 @@ unit_try_move_right:
   ld a, [hl]
   cp a, MAP_W - 1 ; right bound
   ret z
+  
+  inc a
+  ld [hl], a
+
+  call unit_transition_to_move_animation
 
-  unit_sub_tile_move act_rt_subtile_x, add, adc
   ret