aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-05-15 06:17:16 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-05-15 06:17:16 +0200
commit1b4058982e297a0c80750b9411f8be4d89ad2d3d (patch)
tree31d1952513a0b544f1d3dbd6ded06545e6a1c8a1 /src
parentc9a37d15e270ef28b0048eba7cdab15b73b20331 (diff)
downloadjetpac.nes-1b4058982e297a0c80750b9411f8be4d89ad2d3d.tar.gz
jetpac.nes-1b4058982e297a0c80750b9411f8be4d89ad2d3d.zip
Simplify the cycling on the rest of sprites
After all sprites have been properly put through the cycle, there is an amount of sprites which are just leftovers and need to be reset to an out of screen position. The loop that did this was unnecessarily complex and we could just rely on the 'y' register wrapping around. This has the benefit that is less error prone, even if there's still some glitches which most probably come from by-one errors and such. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/driver.s41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/driver.s b/src/driver.s
index c428475..66846ac 100644
--- a/src/driver.s
+++ b/src/driver.s
@@ -18,10 +18,9 @@
PAUSE_TIMER_VALUE = (HZ / 3)
zp_pause_timer = $32
- ;; Number of sprites available for sprite cycling.
- SPRITE_CYCLING_BYTES = (64 - Player::PLAYER_SPRITES_COUNT) * 4
-
- ;; TODO
+ ;; Index from the pool of bullets from which the sprite cycling function
+ ;; will start on. This is constantly rotating so all bullets have at least
+ ;; the chance to have the highest priority every now and then.
zp_next_bullet_cycle = $33
;; Switch from the title screen to the main screen. Note that this function
@@ -209,16 +208,16 @@
stx zp_next_bullet_cycle
;; TODO: ensure 1 enemy
- iny
- iny
- iny
- iny
+ ;; iny
+ ;; iny
+ ;; iny
+ ;; iny
;; TODO: ensure 1 item
- iny
- iny
- iny
- iny
+ ;; iny
+ ;; iny
+ ;; iny
+ ;; iny
;; TODO: rest of bullets
ldx #0
@@ -276,21 +275,25 @@
;; TODO: rest of enemies
;; TODO: rest of items
- ;; We are done with all the sprites we wanted to allocat. Now let's
+ ;; Are all spots already filled? As in, did the 'y' register wrap
+ ;; around? If so, just go to the end.
+ tya
+ beq @end
+
+ ;; We are done with all the sprites we wanted to allocate. Now let's
;; clear out the rest of the slots just in case there was some leftover
- ;; from a past sprite.
+ ;; from a past sprite. Since the OAM space is 256 bytes long, we just
+ ;; need for the 'y' register to wrap around in order to quit.
lda #$EF
- @check_cycle_end:
- cpy #SPRITE_CYCLING_BYTES
- bne @reset_sprite
- rts
@reset_sprite:
sta $200, y
iny
iny
iny
iny
- jmp @check_cycle_end ;TODO: maybe just bne?
+ bne @reset_sprite
+ @end:
+ rts
.endproc
.ifdef PAL