unit: try move now writes the tile flags if collision occured
authorLukas Krickl <lukas@krickl.dev>
Sun, 10 Aug 2025 14:32:36 +0000 (16:32 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 10 Aug 2025 14:32:36 +0000 (16:32 +0200)
src/unit.s
src/wram.s

index ffe8d6f5e6369c9dd9db9778caa90a7957f50af4..b25c071bfe2ae39abd1e69b4943570feedf59060 100644 (file)
@@ -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
index d76153257012e7b4e7ee18e83470f6d226b44edc..2ea12980f4448dfe0e36a387b5719e644f2b81ec 100644 (file)
@@ -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