aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-03-06 16:14:17 +0100
committerMiquel Sabaté Solà <mssola@mssola.com>2026-03-06 16:14:17 +0100
commit3302f760f1461bc4582c99ee2e4ed0ccc1d5b186 (patch)
tree8a9808677dc972c1115f6d6a75cab86a6651992a /src
parent695d225256ed129ce55eb2dfde9de33d3d5f3af9 (diff)
downloadjetpac.nes-3302f760f1461bc4582c99ee2e4ed0ccc1d5b186.tar.gz
jetpac.nes-3302f760f1461bc4582c99ee2e4ed0ccc1d5b186.zip
Don't toggle pause from a holded button
If you just holded the Select or Start buttons, it would be forever toggling pause/unpause, which is an unexpected behavior. Fix this by saving which value from the joypad was previously read. With this, whenever the pause timer reaches zero, we can check whether either button is still pressed, and avoid toggling if that is the case. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'src')
-rw-r--r--src/driver.s9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/driver.s b/src/driver.s
index c4bd8e7..2b61e17 100644
--- a/src/driver.s
+++ b/src/driver.s
@@ -173,8 +173,13 @@
lda zp_pause_timer
bne @skip_pause_handling
- ;; The timer is zero and the player asked to pause, let's reset the
- ;; timer.
+ ;; The timer reached zero, but is the player actually just holding the
+ ;; button? If so ignore it until it unholds it.
+ eor Joypad::zp_prev
+ and #(Joypad::BUTTON_START | Joypad::BUTTON_SELECT)
+ bne @skip_pause_handling
+
+ ;; Let's reset the timer.
lda #PAUSE_TIMER_VALUE
sta zp_pause_timer