diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-03-12 22:12:40 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-03-12 22:12:40 +0100 |
| commit | 276f2e430b4fff3323e2f359712c96f9f6103f77 (patch) | |
| tree | 20cd72ca22f67cbf96afa30cafc10fb7e0eb325a | |
| parent | 9ae51a4c210b8f01718e21eda592c498715a642b (diff) | |
| download | jetpac.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>
| -rw-r--r-- | .nasm/memory.txt | 5 | ||||
| -rw-r--r-- | src/driver.s | 47 | ||||
| -rw-r--r-- | src/interrupts.s | 4 |
3 files changed, 32 insertions, 24 deletions
diff --git a/.nasm/memory.txt b/.nasm/memory.txt index cf829a2..05bf7eb 100644 --- a/.nasm/memory.txt +++ b/.nasm/memory.txt @@ -31,8 +31,7 @@ $34: zp_first_bullet $35: zp_timer $36: zp_first_enemy $37: zp_next_enemy_cycle -$38: zp_moved_out -$39: zp_pause_toggle +$38: zp_flags $40: zp_screen_y $41-$42: zp_position_y $44: zp_velocity_y @@ -77,4 +76,4 @@ $4016: m_joypad $4017: m_frame_counter --- Summary (in bytes) --- -- Internal RAM: 414/2048 (20.21%) +- Internal RAM: 413/2048 (20.17%) 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: |
