actor: wip optimizing performacne of collision code
authorLukas Krickl <lukas@krickl.dev>
Tue, 30 Sep 2025 16:36:57 +0000 (18:36 +0200)
committerLukas Krickl <lukas@krickl.dev>
Tue, 30 Sep 2025 16:36:57 +0000 (18:36 +0200)
src/actor.s
src/defs.s

index 59819024f2646e5baf6fac477664b02fcb45b913..574241e2720ec74613ae48411d974dac56e480c9 100644 (file)
@@ -278,13 +278,17 @@ actor_test_movement:
        ; check all static rectangles
        ld hl, rectangles
        ld b, RECT_MAX
-       ld de, r_size
 
 @rect_test_loop:
+       push hl
+       push bc
        call actor_test_rect
+       pop bc
+       pop hl
        cp a, 0
        jp nz, @rect_collision
 @skip_rect:
+               ld de, r_size
                add hl, de ; next rect (de = r_size)
                dec b
                jp nz, @rect_test_loop
@@ -312,11 +316,13 @@ actor_test_movement:
 @test_actor:
                push de
                push hl
+               push bc
                ld de, act_rect
                add hl, de ; hl = rectangle for actor
                
                call actor_test_rect
                cp a, 0
+               pop bc
                pop hl
                pop de
                jp nz, @actor_collision
@@ -414,9 +420,7 @@ actor_test_movement_write_points:
        ;       returns:
        ;               a: 1 collision
        ;                       a: 0 no collision
-       ;       preserves: all registers 
 actor_test_rect:
-       push_all
 
        ; pre-filter rectangle mask
        ld a, [tmp_rect_mask]
@@ -429,11 +433,9 @@ actor_test_rect:
        actor_test_movement_corner @rect_collision
 
 @no_collision:
-       pop_all
        xor a, a
        ret
 @rect_collision:
-       pop_all
        ld a, 1
        ret
        
index 75576c5d4285aa9a7a5d767bf8f799606bc265cf..28965baba33027a9ce7b208563aec6a1756d608b 100644 (file)
@@ -13,7 +13,7 @@
 
 #define NULL 0
 
-#define ACTS_PLAYER_PROJECTILES 3
+#define ACTS_PLAYER_PROJECTILES 6
 #define ACTS_ENEMY 6
 #define ACTS_ENEMY_PROJECTILES 6
 #define ACTS_MAX (ACTS_PLAYER_PROJECTILES + ACTS_ENEMY + ACTS_ENEMY_PROJECTILES)