From b32703333340d85d86d14ac53667b5515e420918 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Fri, 30 Jun 2023 18:18:47 +0100 Subject: [PATCH] Counters: Process overflow before Target in case of Target = 0 --- pcsx2/Counters.cpp | 12 ++++++++---- pcsx2/IopCounters.cpp | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pcsx2/Counters.cpp b/pcsx2/Counters.cpp index a25828f307..306c338492 100644 --- a/pcsx2/Counters.cpp +++ b/pcsx2/Counters.cpp @@ -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<