INTC: Give grace period after event for reading INTC

If a game is in a tight loop waiting for a bit of INTC, we could skip a bunch of cycles incorrectly.
This commit is contained in:
refractionpcsx2 2022-06-13 04:00:17 +01:00
parent 44b672b6f5
commit 02ac3943f2
3 changed files with 5 additions and 4 deletions

View File

@ -30,7 +30,7 @@ static __fi void IntCHackCheck()
// Sanity check: To protect from accidentally "rewinding" the cyclecount
// on the few times nextBranchCycle can be behind our current cycle.
s32 diff = g_nextEventCycle - cpuRegs.cycle;
if( diff > 0 ) cpuRegs.cycle = g_nextEventCycle;
if (diff > 0 && (cpuRegs.cycle - g_lastEventCycle) > 8) cpuRegs.cycle = g_nextEventCycle;
}
template< uint page > RETURNS_R128 _hwRead128(u32 mem);

View File

@ -365,14 +365,14 @@ static bool cpuIntsEnabled(int Interrupt)
// if cpuRegs.cycle is greater than this cycle, should check cpuEventTest for updates
u32 g_nextEventCycle = 0;
u32 g_lastEventCycle = 0;
// Shared portion of the branch test, called from both the Interpreter
// and the recompiler. (moved here to help alleviate redundant code)
__fi void _cpuEventTest_Shared()
{
eeEventTestIsActive = true;
g_nextEventCycle = cpuRegs.cycle + eeWaitCycles;
g_lastEventCycle = cpuRegs.cycle;
// ---- INTC / DMAC (CPU-level Exceptions) -----------------
// Done first because exceptions raised during event tests need to be postponed a few
// cycles (fixes Grandia II [PAL], which does a spin loop on a vsync and expects to
@ -387,7 +387,7 @@ __fi void _cpuEventTest_Shared()
// escape/suspend hooks, and it's really a good idea to suspend/resume emulation before
// doing any actual meaningful branchtest logic.
if( cpuTestCycle( nextsCounter, nextCounter ) )
if ( cpuTestCycle( nextsCounter, nextCounter ) )
{
rcntUpdate();
_cpuTestPERF();

View File

@ -260,6 +260,7 @@ alignas(16) extern fpuRegisters fpuRegs;
alignas(16) extern tlbs tlb[48];
extern u32 g_nextEventCycle;
extern u32 g_lastEventCycle;
extern bool eeEventTestIsActive;
extern u32 s_iLastCOP0Cycle;
extern u32 s_iLastPERFCycle[2];