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
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:
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:
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:
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