From: Lukas Krickl Date: Tue, 14 Jan 2025 20:42:57 +0000 (+0100) Subject: actor: Fixed actor tile flagging X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=4f476e297f1b15031c0de4d1b0d9245e1764c082;p=gbrg%2F.git actor: Fixed actor tile flagging Actors now flag the correct tile, but they will unflag during their next turn. This means that collision is till broken, but less broken than before :^) The actors flagged the wrong tile due to a missing offset for the target position. --- diff --git a/src/actor.s b/src/actor.s index ebb3456..a8b63ec 100644 --- a/src/actor.s +++ b/src/actor.s @@ -183,16 +183,20 @@ actor_anim_verify: ; sets the RF_ACTOR flag at target_y/x ; unsets RF_ACTOR at [bc] and [bc+1] ; preserves registers -actor_tile_update_flag: +actor_tile_update_rf_flags: push_all ; first unset existing flags + ; add +8 to positions to center on tile + inc bc ; bc = y pos ld a, [bc] + sub a, ANIM_MOVE_TILE_SIZE / 2 ; -8 to be in center ld d, a ; d = y pos inc bc ; bc = x pos ld a, [bc] + sub a, ANIM_MOVE_TILE_SIZE / 2 ; -8 to be in center ld e, a ; e = x pos call room_get_flag_ptr @@ -204,8 +208,10 @@ actor_tile_update_flag: ; then set the new position's flag ld a, [anim_target_y] + sub a, ANIM_MOVE_TILE_SIZE / 2 ; -8 to be in center ld d, a ; d = y pos ld a, [anim_target_x] + sub a, ANIM_MOVE_TILE_SIZE / 2 ; -8 to be in center ld e, a ; e = x pos call room_get_flag_ptr @@ -280,7 +286,7 @@ actor_update_bat: ; check anim collision call actor_anim_verify ; set flags on z - call z, actor_tile_update_flag + call z, actor_tile_update_rf_flags turn_finish diff --git a/src/map.s b/src/map.s index 9b96ef9..1c0a769 100644 --- a/src/map.s +++ b/src/map.s @@ -435,7 +435,6 @@ room_get_flag_ptr: ; d : y pos ; e : x pos ; a: mask - ; ct_mask: bit mask for flag to check (tile & mask) ; returns: ; a: masked flag ; z-flag is set diff --git a/src/player.s b/src/player.s index fd75f7b..ab233d7 100644 --- a/src/player.s +++ b/src/player.s @@ -255,14 +255,24 @@ player_update: @no_door_hit: + + ld a, h ; restore original a for next check + and a, RF_ACTOR + jr z, @no_enemy_hit REL + + ; TODO add enemy hit logic + +@no_enemy_hit: + ld a, h ; restore original a for next check - and a, RF_WALL + and a, RF_WALL | RF_ACTOR pop hl jr z, @no_collision REL ; clear anim memory call anim_clear @no_collision: + @skip_input: ; hl should be player_y here