Counters: Process overflow before Target in case of Target = 0

This commit is contained in:
refractionpcsx2 2023-06-30 18:18:47 +01:00
parent 36c9b68b6c
commit b327033333
2 changed files with 11 additions and 7 deletions

View File

@ -156,7 +156,9 @@ static __fi void cpuRcntSet()
_rcntSet( i );
// sanity check!
if( nextCounter < 0 ) nextCounter = 0;
if (nextCounter < 0)
nextCounter = 0;
cpuSetNextEvent(nextsCounter, nextCounter); // Need to update on counter resets/target changes
}
@ -811,8 +813,9 @@ static __fi void _cpuTestOverflow( int i )
// well forceinline it!
__fi void rcntUpdate()
{
rcntUpdate_hScanline();
rcntUpdate_vSync();
// HBlank after as VSync can do error compensation
rcntUpdate_hScanline();
// Update counters so that we can perform overflow and target tests.
@ -835,8 +838,9 @@ __fi void rcntUpdate()
counters[i].sCycleT = cpuRegs.cycle - change;
// Check Counter Targets and Overflows:
_cpuTestTarget( i );
// Check Overflow first, in case the target is 0
_cpuTestOverflow( i );
_cpuTestTarget(i);
}
else counters[i].sCycleT = cpuRegs.cycle;
}
@ -886,8 +890,8 @@ static __fi void rcntStartGate(bool isVblank, u32 sCycle)
// currectly by rcntUpdate (since it's not being scheduled for these counters)
counters[i].count += HBLANK_COUNTER_SPEED;
_cpuTestOverflow(i);
_cpuTestTarget( i );
_cpuTestOverflow( i );
}
if (!(gates & (1<<i))) continue;

View File

@ -379,16 +379,16 @@ void psxCheckStartGate16(int i)
(psxCounters[1].mode & stoppedGateCheck) == altSourceCheck)
{
psxCounters[1].count++;
_rcntTestTarget(1);
_rcntTestOverflow(1);
_rcntTestTarget(1);
}
if ((psxCounters[3].mode & altSourceCheck) == IOPCNT_ALT_SOURCE ||
(psxCounters[3].mode & stoppedGateCheck) == altSourceCheck)
{
psxCounters[3].count++;
_rcntTestTarget(3);
_rcntTestOverflow(3);
_rcntTestTarget(3);
}
}
@ -488,8 +488,8 @@ void psxRcntUpdate()
if (psxCounters[i].mode & IOPCNT_STOPPED)
continue;
_rcntTestTarget(i);
_rcntTestOverflow(i);
_rcntTestTarget(i);
// perform second target test because if we overflowed above it's possible we
// already shot past our target if it was very near zero.