Skip to content

Commit

Permalink
SNES: Allow gamepad auto-read to be disabled while it's running
Browse files Browse the repository at this point in the history
Matches new hardware tests: clear-autojoy-1st-vb-sl / clear-autojoy-during-autojoy
  • Loading branch information
SourMesen committed Dec 17, 2024
1 parent 8499522 commit d1aa957
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Core/SNES/InternalRegisters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ void InternalRegisters::SetAutoJoypadReadClock()

void InternalRegisters::ProcessAutoJoypad()
{
//Some details/timings may still be incorrect
//This is based on these test roms: https://github.com/undisbeliever/snes-test-roms/blob/master/src/hardware-tests/
//As well as the CPU schematics here: https://github.com/rgalland/SNES_S-CPU_Schematics/
if(_autoReadClockStart == 0) {
return;
}
Expand All @@ -77,6 +80,15 @@ void InternalRegisters::ProcessAutoJoypad()
for(uint64_t clock = _autoReadNextClock; clock <= _console->GetMasterClock(); clock += 128) {
_autoReadNextClock = clock + 128;
int step = (clock - _autoReadClockStart) / 128;

if(step >= 2 && !_state.EnableAutoJoypadRead) {
//Disable auto-read for the rest of the frame at this point if the enable flag is turned off
_autoReadClockStart = 0;
_autoReadNextClock = 0;
_autoReadActive = false;
_controlManager->SetAutoReadStrobe(false);
return;
}

switch(step) {
case 0:
Expand Down

0 comments on commit d1aa957

Please sign in to comment.