From 511a06f833454a9cacdb842c445c00d9741b97cc Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Mon, 13 Jan 2025 09:36:44 +0100 Subject: [PATCH] actor: Added code for allowing actors to set RF_ACTOR This seems to still be a bit broken, but actors are now setting up their room flags when they move. --- src/actor.s | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/actor.s b/src/actor.s index 0c094ce..ebb3456 100644 --- a/src/actor.s +++ b/src/actor.s @@ -162,7 +162,7 @@ actor_anim_verify: ld a, [anim_target_x] sub a, ANIM_MOVE_TILE_SIZE / 2 ; -8 to be in center ld e, a - ld a, RF_WALL | RF_DOOR + ld a, RF_WALL | RF_DOOR | RF_ACTOR call room_get_flag_masked pop bc @@ -182,7 +182,39 @@ actor_anim_verify: ; returns: ; sets the RF_ACTOR flag at target_y/x ; unsets RF_ACTOR at [bc] and [bc+1] + ; preserves registers actor_tile_update_flag: + push_all + + ; first unset existing flags + + inc bc ; bc = y pos + ld a, [bc] + ld d, a ; d = y pos + inc bc ; bc = x pos + ld a, [bc] + ld e, a ; e = x pos + call room_get_flag_ptr + + ; unset flag + ld a, [hl] + and a, 0xFF ^ RF_ACTOR + ld [hl], a + + + ; then set the new position's flag + ld a, [anim_target_y] + ld d, a ; d = y pos + ld a, [anim_target_x] + ld e, a ; e = x pos + call room_get_flag_ptr + + ; set flag + ld a, [hl] + or a, RF_ACTOR + ld [hl], a + + pop_all ret ; function ptrs for each actor type @@ -247,6 +279,8 @@ actor_update_bat: ; check anim collision call actor_anim_verify + ; set flags on z + call z, actor_tile_update_flag turn_finish -- 2.30.2