From 0e7d46c46f398c07adc5e30b7d1f8cbf11a313e5 Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Sat, 30 May 2015 09:28:07 -0400 Subject: [PATCH] Don't read joysticks during auto-joypad read. --- pewpew.asm | 10 +++++++--- registers.asm | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/pewpew.asm b/pewpew.asm index 5e30721..10f3f91 100644 --- a/pewpew.asm +++ b/pewpew.asm @@ -322,7 +322,7 @@ MainLoop: lda #%00000001 ; Disable NMI interrupt while processing. sta NMITIMEN - jsr JoypadDebug + jsr JoypadRead jsr JoypadHandler jsr UpdateWorld jsr FillSecondarySpriteTable @@ -331,8 +331,12 @@ MainLoop: -JoypadDebug: - ; Load joypad registers into RAM for easier inspection. +JoypadRead: + ; Load joypad registers into RAM for easy inspection & manipulation. +- + lda HVBJOY + bit #$01 ; If auto-joypad read is happening, loop. + bne - ldx JOY1L stx joy1 ldx JOY2L diff --git a/registers.asm b/registers.asm index f350027..8477697 100644 --- a/registers.asm +++ b/registers.asm @@ -145,6 +145,20 @@ ; Each bit that's set enables one channel: 76543210 .define DMAENABLE $420B +; $4212: VBlank/HBlank/Joypad status [HVBJOY] +; vh-----a +; v = V-Blank Flag. If we're currently in V-Blank, this flag is set, +; otherwise it is clear. The setting seems to occur at H Counter +; about $16-$17 when V Counter is $E1, and the clearing at about $1E +; with V Counter 0. +; h = H-Blank Flag. If we're currently in H-Blank, this flag is set, +; otherwise it is clear. The setting seems to occur at H Counter +; about $121-$122, and the clearing at about $12-$18. +; a = Auto-Joypad Status. This is set while Auto-Joypad Read is in +; progress, and cleared when complete. It typically turns on at +; the start of V-Blank, and completes 3 scanlines later. +.define HVBJOY $4212 + ; $4218: Joypad #1 status [JOY1L] ; Format: AXLR0000 .define JOY1L $4218