From 74b1003ab8abad2f8220de4f2f18a3b118f23f01 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Wed, 10 Dec 2025 14:41:35 +0100 Subject: Adapt the code to play well with nasm's asan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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à --- include/joypad.s | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include/joypad.s') 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 -- cgit v1.2.3