aboutsummaryrefslogtreecommitdiff
path: root/include/joypad.s
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2025-12-10 14:41:35 +0100
committerMiquel Sabaté Solà <mssola@mssola.com>2025-12-15 15:31:06 +0100
commit74b1003ab8abad2f8220de4f2f18a3b118f23f01 (patch)
treeb7f2d491d708fa900d4dd9649eb5bd7fab3e8686 /include/joypad.s
parente6d9bd9f7acfd0e40025b2d579a7faff0d04ef0a (diff)
downloadjetpac.nes-74b1003ab8abad2f8220de4f2f18a3b118f23f01.tar.gz
jetpac.nes-74b1003ab8abad2f8220de4f2f18a3b118f23f01.zip
Adapt the code to play well with nasm's asan
The address sanitizer from nasm provides quite a few goodies, so let's adapt the code more to it to benefit from those. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'include/joypad.s')
-rw-r--r--include/joypad.s10
1 files changed, 5 insertions, 5 deletions
diff --git a/include/joypad.s b/include/joypad.s
index 141877f..f7268e8 100644
--- a/include/joypad.s
+++ b/include/joypad.s
@@ -10,8 +10,8 @@
BUTTON_RIGHT = 1 << 0
;; Port addresses for controllers.
- JOYPAD1 = $4016
- JOYPAD2 = $4017
+ m_joypad1 = $4016
+ ;; m_joypad2 = $4017
;; After running a `read_*` function these two variables will contain the
;; given result.
@@ -49,14 +49,14 @@
.proc unsafe_read_x
;; Start the latch process.
lda #$01
- sta Joypad::JOYPAD1
+ sta Joypad::m_joypad1
sta Joypad::zp_buttons1, x ; Bit as a guard for the loop below.
lsr
- sta Joypad::JOYPAD1
+ sta Joypad::m_joypad1
;; Now the joypad is ready to accept reads.
@loop:
- lda Joypad::JOYPAD1, x
+ lda Joypad::m_joypad1, x
and #%00000011 ; Ignore bits other than controller.
cmp #$01 ; Set carry if and only if nonzero.
rol Joypad::zp_buttons1, x ; Carry -> bit 0; bit 7 -> Carry