aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-03-12 22:12:40 +0100
committerMiquel Sabaté Solà <mssola@mssola.com>2026-03-12 22:12:40 +0100
commit276f2e430b4fff3323e2f359712c96f9f6103f77 (patch)
tree20cd72ca22f67cbf96afa30cafc10fb7e0eb325a /src
parent9ae51a4c210b8f01718e21eda592c498715a642b (diff)
downloadjetpac.nes-276f2e430b4fff3323e2f359712c96f9f6103f77.tar.gz
jetpac.nes-276f2e430b4fff3323e2f359712c96f9f6103f77.zip
Join 'zp_moved_out' and 'zp_pause_toggle'
It was wasteful, and it was there just because of my lazyness. Let's be a bit less careless. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'src')
-rw-r--r--src/driver.s47
-rw-r--r--src/interrupts.s4
2 files changed, 30 insertions, 21 deletions
diff --git a/src/driver.s b/src/driver.s
index 8b366b7..421dd69 100644
--- a/src/driver.s
+++ b/src/driver.s
@@ -55,23 +55,21 @@
;; Same as `zp_next_bullet_cycle` but for enemies.
zp_next_enemy_cycle = $37
- ;; Whether sprites have already been moved out in the 'move_sprites_out'
- ;; situation. It's probably a waste of resources to spend a full byte for
- ;; this, but I didn't see where to put it either, and we still have plenty
- ;; of RAM left.
- zp_moved_out = $38
-
- ;; Whether the pause message on the HUD has to be toggled. Like
- ;; 'zp_moved_out', maybe a waste of resource to dedicate a full byte for
- ;; this, but we have plenty of RAM left.
- zp_pause_toggle = $39
+ ;; Bitmap of various boolean values lumped together.
+ ;;
+ ;; |SP-- ----|
+ ;; |
+ ;; |- S: whether sprites have already been moved out in the
+ ;; | 'move_sprites_out' situation.
+ ;; |- P: whether the pause message on the HUD has to be toggled.
+ zp_flags = $38
;; Initialization routine that is to be called before enabling NMIs back for
;; the first time.
.proc init_before_nmi
lda #0
- sta Driver::zp_pause_toggle
sta Driver::zp_blink_status
+ sta Driver::zp_flags
rts
.endproc
@@ -173,8 +171,9 @@
;; Set that we have done this operation so it's not done in future
;; cycles.
- lda #1
- sta Driver::zp_moved_out
+ lda Driver::zp_flags
+ ora #$80
+ sta Driver::zp_flags
rts
.endproc
@@ -222,10 +221,14 @@
jsr Explosions::init
jsr Items::init
- ;; Initialize pause timer and some boolean values.
+ ;; Initialize pause timer.
lda #0
sta zp_pause_timer
- sta Driver::zp_moved_out
+
+ ;; Clear out the 'S' flag.
+ lda Driver::zp_flags
+ and #$7F
+ sta Driver::zp_flags
;; Initialize variables for sprite cycling.
sta zp_next_bullet_cycle
@@ -257,8 +260,9 @@
sta zp_pause_timer
;; Toggle the message on the HUD.
- lda #1
- sta Driver::zp_pause_toggle
+ lda Driver::zp_flags
+ ora #$40
+ sta Driver::zp_flags
;; Pause vs unpause.
lda #%00001000
@@ -310,8 +314,8 @@
beq @sprite_cycling
;; Invalidate bullets and enemies if we haven't already.
- lda Driver::zp_moved_out
- bne @check_explosions
+ bit Driver::zp_flags
+ bmi @check_explosions
jsr move_sprites_out
@check_explosions:
@@ -625,6 +629,11 @@
;;
;; NOTE: only call this function from NMI code.
.proc hud_toggle_pause
+ ;; Unset the 'P' flag.
+ lda Driver::zp_flags
+ and #%10111111
+ sta Driver::zp_flags
+
lda #%00001000
and Globals::zp_flags
bne @paused
diff --git a/src/interrupts.s b/src/interrupts.s
index 81709ed..2c78099 100644
--- a/src/interrupts.s
+++ b/src/interrupts.s
@@ -28,8 +28,8 @@
sta OAM::m_dma
;; Toggle pause message from the HUD.
- lda Driver::zp_pause_toggle
- beq @increase_rand
+ bit Driver::zp_flags
+ bvc @increase_rand
jsr Driver::hud_toggle_pause
@increase_rand: