From 48f3a562c7d4d6e95c18d44e201a8c172f107a5e Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 10 Feb 2026 16:16:21 +0100 Subject: Simplify allocation for the rest of bullets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- src/driver.s | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/driver.s b/src/driver.s index 75e56b6..7966d71 100644 --- a/src/driver.s +++ b/src/driver.s @@ -258,22 +258,26 @@ ;; iny ;; iny + ;; Allocate the rest of valid bullets from the pool. ldx #0 @rest_o_bullets: + ;; If we are already passed the amount of bytes we could allocate for + ;; bullets, then jump to enemies. If the current indexed bullet is the one + ;; we allocated as the first fixed one, then skip it. cpx #Bullets::BULLETS_POOL_CAPACITY_BYTES beq @rest_o_enemies cpx zp_first_bullet - bne @do_bullet - inx - inx - inx - cpx #Bullets::BULLETS_POOL_CAPACITY_BYTES - beq @rest_o_enemies + beq @next_bullet + @do_bullet: + ;; Ok, so the bullet has not been allocated yet and we have space for + ;; it. Is it valid? lda Bullets::zp_bullets_pool_base, x cmp #$FF beq @next_bullet + ;; Yes! Then allocate now. + lda Bullets::zp_bullets_pool_base + 1, x sta OAM::m_sprites, y iny -- cgit v1.2.3