From: Lukas Krickl Date: Sun, 10 Aug 2025 14:32:36 +0000 (+0200) Subject: unit: try move now writes the tile flags if collision occured X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=42808a247648db767a0b50cd772c7b43132e3875;p=gbrg%2F.git unit: try move now writes the tile flags if collision occured --- diff --git a/src/unit.s b/src/unit.s index ffe8d6f..b25c071 100644 --- a/src/unit.s +++ b/src/unit.s @@ -346,6 +346,9 @@ unit_handle_inputs: ; $1: dec/inc instruction ; $2: collision mask for tile ; de: actor + ; returns: + ; unit_test_collision_cf_flags: 0 if not collided with a tile + ; FLAGS if collided #macro unit_test_collision ; perform tile collision check push de @@ -353,13 +356,20 @@ unit_handle_inputs: $1 push bc call map_get_tile + ; set flags result + ld [unit_test_collision_cf_flags], a and a, $2 pop bc pop de ret nz + ; set to 0 if we did not collide + xor a, a + ld [unit_test_collision_cf_flags], a + push de call unit_collides_with_any_other + ; TODO: write collided unit here as well and a, $2 pop de ret nz diff --git a/src/wram.s b/src/wram.s index d761532..2ea1298 100644 --- a/src/wram.s +++ b/src/wram.s @@ -33,6 +33,10 @@ shadow_ie: .adv 1 ; status text buffer status_text: .adv 32 + + ; stores the last collision flag result + ; that was performed by a test collision call +unit_test_collision_cf_flags: .adv 1 ; self modifying code ; the vblank interrupt jumps here