aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-02-10 16:16:21 +0100
committerMiquel Sabaté Solà <mssola@mssola.com>2026-02-10 16:16:21 +0100
commit48f3a562c7d4d6e95c18d44e201a8c172f107a5e (patch)
treeec01feaccdd8657cfd23e4fe7a7b0b4f85f74471
parent29c2f3b8b4eb1bd8190d8ed302d172c54efc1450 (diff)
downloadjetpac.nes-48f3a562c7d4d6e95c18d44e201a8c172f107a5e.tar.gz
jetpac.nes-48f3a562c7d4d6e95c18d44e201a8c172f107a5e.zip
Simplify allocation for the rest of bullets
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
-rw-r--r--src/driver.s16
1 files changed, 10 insertions, 6 deletions
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