From: Lukas Krickl Date: Tue, 30 Sep 2025 16:36:57 +0000 (+0200) Subject: actor: wip optimizing performacne of collision code X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=3f9ba1446311beead3c81be7240a1ee682bf8cb9;p=gbrg%2F.git actor: wip optimizing performacne of collision code --- diff --git a/src/actor.s b/src/actor.s index 5981902..574241e 100644 --- a/src/actor.s +++ b/src/actor.s @@ -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 diff --git a/src/defs.s b/src/defs.s index 75576c5..28965ba 100644 --- a/src/defs.s +++ b/src/defs.s @@ -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)