From 6d926a97ab922f9df6f6802d3dd05d095d96c8c9 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Wed, 25 Jun 2025 15:53:14 +0200 Subject: [PATCH] actor: rt variables are now in regular actor_def this saves a macro call. units now move in sub-tiles in all directions. Drawing still will need to take this into account. --- src/defs.s | 22 ++++++++-------------- src/macros.inc | 13 +++++-------- src/player.s | 1 - src/unit.s | 12 ++++-------- src/unit_demo.s | 2 -- 5 files changed, 17 insertions(+), 33 deletions(-) diff --git a/src/defs.s b/src/defs.s index e53961f..db3c7ca 100644 --- a/src/defs.s +++ b/src/defs.s @@ -123,7 +123,6 @@ ; act_effects_def or act_effects_empty ; act_st_def ; act_def_draw - ; act_rt_def .se 0 ; copy of current state .de act_state, st_size @@ -132,9 +131,17 @@ .de act_pos_y, 1 ; y/x tile position .de act_pos_x, 1 + ; custom parameter .de act_p0, 1 + ; actor runtime values + + ; last collision with actor + ; set during unit_collision_woth_any_other +.de act_rt_collided_with, 2 +.de act_rt_subtile_y, 1 +.de act_rt_subtile_x, 1 ; stats1 .de act_level, 1 @@ -192,19 +199,6 @@ .de act_oam_tile, 1 .de act_oam_flags, 1 - ; actor runtime values - - ; last collision with actor - ; set during unit_collision_woth_any_other -.de act_rt_collided_with, 2 - - ; sub-tile position - ; : y subtile - ; : x subtile - ; if the subtile position overflows/underflows - ; the actor may move on to the next tile -.de act_rt_subtile_y, 1 -.de act_rt_subtile_x, 1 .de act_size, 0 ; max bge queue size diff --git a/src/macros.inc b/src/macros.inc index f805059..7237c16 100644 --- a/src/macros.inc +++ b/src/macros.inc @@ -180,6 +180,11 @@ .db $3 ; y pos .db $4 ; x pos .db $5 ; p0 + + ; act_rt_collided_with + dw 0 + .db 0 ; y-subtile + .db 0 ; x-subtile #endmacro ; defines an actor's stats (1/2) @@ -228,14 +233,6 @@ dw $4 #endmacro - ; defines default values for actor runtime values - ; these can generally not be set at build time -#macro act_rt_def - ; act_rt_collided_woth - dw 0 - ; subtile_pos - .db 0 -#endmacro ; defines an actors attributes ; such as weapon skills diff --git a/src/player.s b/src/player.s index b33d7d5..0a186eb 100644 --- a/src/player.s +++ b/src/player.s @@ -48,7 +48,6 @@ unit_player: act_effects_empty act_st_def NULL, NULL, st_unit_player_update, st_unit_idle act_def_draw unit_draw, 0x84, 0 - act_rt_def st_unit_player_update: st_def 0x00, unit_player_update, st_unit_player_update diff --git a/src/unit.s b/src/unit.s index 09cd213..f9faa48 100644 --- a/src/unit.s +++ b/src/unit.s @@ -346,7 +346,7 @@ unit_calc_movement_speed: pop hl ; now apply carry to real position ld a, [hl] - sbc a, 0 + $3 a, 0 ld [hl], a #endmacro @@ -375,7 +375,6 @@ unit_try_move_up: ret z unit_sub_tile_move act_rt_subtile_y, sub, sbc - ret unit_try_move_down: @@ -389,8 +388,7 @@ unit_try_move_down: cp a, MAP_H - 1 ; lower bound ret z - inc a - ld [hl], a + unit_sub_tile_move act_rt_subtile_y, add, adc ret unit_try_move_left: @@ -404,8 +402,7 @@ unit_try_move_left: cp a, 0 ; left bound ret z - dec a - ld [hl], a + unit_sub_tile_move act_rt_subtile_x, sub, sbc ret unit_try_move_right: @@ -420,8 +417,7 @@ unit_try_move_right: cp a, MAP_W - 1 ; right bound ret z - inc a - ld [hl], a + unit_sub_tile_move act_rt_subtile_x, add, adc ret diff --git a/src/unit_demo.s b/src/unit_demo.s index 319999f..a9f4b90 100644 --- a/src/unit_demo.s +++ b/src/unit_demo.s @@ -50,7 +50,6 @@ unit_demo_2: act_effects_empty act_st_def NULL, NULL, st_unit_demo_1_cpu_update_idle, st_unit_idle act_def_draw unit_draw, 0x84, 0 - act_rt_def unit_demo_3: st_def 0x00, unit_demo_1_init, st_unit_demo_1_cpu_update @@ -63,7 +62,6 @@ unit_demo_3: act_effects_empty act_st_def NULL, NULL, st_unit_demo_1_cpu_update, st_unit_idle act_def_draw unit_draw, 0x84, 0 - act_rt_def st_unit_demo_1_cpu_update: -- 2.30.2