From: Lukas Krickl Date: Wed, 25 Jun 2025 17:23:05 +0000 (+0200) Subject: actor: removed sub-tile movement X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=e534bd8297db55a317c486c0a37cec5f83ede4a3;p=gbrg%2F.git actor: removed sub-tile movement 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. --- diff --git a/src/actortables.s b/src/actortables.s index 511da3d..8220698 100644 --- a/src/actortables.s +++ b/src/actortables.s @@ -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 diff --git a/src/unit.s b/src/unit.s index f9faa48..223ffa5 100644 --- a/src/unit.s +++ b/src/unit.s @@ -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