This is something that went unnoticed until now. I have a controller reading routine that seems to work just fine. It's this:
GamePadCheck:
LDA #$01
STA $4016
LDA #$00
STA $4016
ReadControllerBytesLoop:
PHA
LDA $4016
AND #%00000011
CMP #%00000001
PLA
ROR
DEX
BNE ReadControllerBytesLoop
STA gamepad
RTS
This has worked with no issue. The controller behaves exactly as it should, with some defines. Up, down, left, right, select, start, b and a all function appropriately during gameplay.
The problem - I have set up a placeholder start screen. For a while, i've just had it where a press of the A button jumps to the game loop. This has worked no problem - it loops through the start screen code until A is pressed and then jumps to the main game loop. I finally got around to updating that to the 'start' button, and now it acts as if the start button is pressed at the start of the game and launches right to the main game loop. In fact, this happens for EVERY button except the A button.
Again, the buttons work correctly during game play, but it almost seems as if they are being 'activated' for a frame at the start of the game without an actual press, jumping out of the start screen loop prematurely....all of them except for the A button, which works as expected on the start screen.
Any thoughts as to what could be causing this?
***** When I pull a jump to this routine OUT of my NMI and call it at the top of the start screen loop, that seems to solve the problem...I still don't like not knowing why, if anyone has any thoughts*****
Code:
GamePadCheck:
LDA #$01
STA $4016
LDA #$00
STA $4016
ReadControllerBytesLoop:
PHA
LDA $4016
AND #%00000011
CMP #%00000001
PLA
ROR
DEX
BNE ReadControllerBytesLoop
STA gamepad
RTS
This has worked with no issue. The controller behaves exactly as it should, with some defines. Up, down, left, right, select, start, b and a all function appropriately during gameplay.
The problem - I have set up a placeholder start screen. For a while, i've just had it where a press of the A button jumps to the game loop. This has worked no problem - it loops through the start screen code until A is pressed and then jumps to the main game loop. I finally got around to updating that to the 'start' button, and now it acts as if the start button is pressed at the start of the game and launches right to the main game loop. In fact, this happens for EVERY button except the A button.
Again, the buttons work correctly during game play, but it almost seems as if they are being 'activated' for a frame at the start of the game without an actual press, jumping out of the start screen loop prematurely....all of them except for the A button, which works as expected on the start screen.
Any thoughts as to what could be causing this?
***** When I pull a jump to this routine OUT of my NMI and call it at the top of the start screen loop, that seems to solve the problem...I still don't like not knowing why, if anyone has any thoughts*****