From 33147295f3f4d469fa9ae28aa1d971b9bd58c930 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Thu, 15 May 2025 17:00:43 +0200 Subject: bullet: Do not clash with the pool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One of the glitches as hinted by commit ae857d302cd6 ("Implement the base for moving bullets") actually came from the fact that the temporary screen coordinates were pointing at the first sprite from the pool of bullets. This commit moves these variables into a memory region where there won't be any clashes. Signed-off-by: Miquel Sabaté Solà --- src/bullets.s | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/bullets.s b/src/bullets.s index 736a226..db8bfd7 100644 --- a/src/bullets.s +++ b/src/bullets.s @@ -6,6 +6,9 @@ ;; Maximum amount of bullets allowed on screen at the same time. BULLETS_POOL_CAPACITY = 10 + ;; The capacity of the bullets pool in bytes. + BULLETS_POOL_CAPACITY_BYTES = BULLETS_POOL_CAPACITY * 3 + ;; Base address for the pool of bullets used on this game. The pool has ;; #BULLETS_POOL_CAPACITY bullet objects where each one is 3 bytes long: ;; 1. State: which can have two formats: @@ -17,15 +20,6 @@ ;; 3. X coordinate. zp_bullets_pool_base = $A0 - ;; The screen coordinates of the bullet being inspected right now. Used when - ;; computing the move of bullets and checking possible collisions with - ;; background/enemies. - zp_current_bullet_y = $A1 - zp_current_bullet_x = $A2 - - ;; The capacity of the bullets pool in bytes. - BULLETS_POOL_CAPACITY_BYTES = BULLETS_POOL_CAPACITY * 3 - ;; The current amount of bullets on screen. zp_bullets_pool_size = $E0 @@ -34,6 +28,12 @@ ;; time, as consecutive allocation is a very common case. zp_last_allocated_index = $E1 + ;; The screen coordinates of the bullet being inspected right now. Used when + ;; computing the move of bullets and checking possible collisions with + ;; background/enemies. + zp_current_bullet_y = $E2 + zp_current_bullet_x = $E3 + ;; The amount of time we are not allowing B presses. This is a rather low ;; value so you can have quite some presses per frame. zp_bullet_timer = $35 -- cgit v1.2.3