From 7166c04ff2b86d04ddabf1ccef7437cc1e32ee89 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 16 May 2024 19:12:44 +1000 Subject: [PATCH] R3000: Serialize IOP->EE ticks carry [SAVEVERSION+] --- pcsx2/R3000A.cpp | 1 + pcsx2/R3000A.h | 1 + pcsx2/R3000AInterpreter.cpp | 5 ++--- pcsx2/SaveState.h | 2 +- pcsx2/x86/iR3000A.cpp | 6 ++---- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pcsx2/R3000A.cpp b/pcsx2/R3000A.cpp index 2601a1955c..d9595e9c8d 100644 --- a/pcsx2/R3000A.cpp +++ b/pcsx2/R3000A.cpp @@ -44,6 +44,7 @@ void psxReset() psxRegs.iopBreak = 0; psxRegs.iopCycleEE = -1; + psxRegs.iopCycleEECarry = 0; psxRegs.iopNextEventCycle = psxRegs.cycle + 4; psxHwReset(); diff --git a/pcsx2/R3000A.h b/pcsx2/R3000A.h index ee97bb8d46..e204754690 100644 --- a/pcsx2/R3000A.h +++ b/pcsx2/R3000A.h @@ -110,6 +110,7 @@ struct psxRegisters { // Tracks current number of cycles IOP can run in EE cycles. When it dips below zero, // control is returned to the EE. s32 iopCycleEE; + u32 iopCycleEECarry; u32 sCycle[32]; // start cycle for signaled ints s32 eCycle[32]; // cycle delta for signaled ints (sCycle + eCycle == branch cycle) diff --git a/pcsx2/R3000AInterpreter.cpp b/pcsx2/R3000AInterpreter.cpp index 38a43f0ba8..6aedd35c76 100644 --- a/pcsx2/R3000AInterpreter.cpp +++ b/pcsx2/R3000AInterpreter.cpp @@ -279,10 +279,9 @@ static s32 intExecuteBlock( s32 eeCycles ) const u32 cdenom = 147; // PSXCLK / F //One of the Iop to EE delta clocks to be set in PS1 mode. - static u32 carry; - const u32 t = ((cnum * (psxRegs.cycle - lastIOPCycle)) + carry); + const u32 t = ((cnum * (psxRegs.cycle - lastIOPCycle)) + psxRegs.iopCycleEECarry); psxRegs.iopCycleEE -= t / cdenom; - carry = t % cdenom; + psxRegs.iopCycleEECarry = t % cdenom; } else { diff --git a/pcsx2/SaveState.h b/pcsx2/SaveState.h index 6072609235..c10a2f2d30 100644 --- a/pcsx2/SaveState.h +++ b/pcsx2/SaveState.h @@ -25,7 +25,7 @@ enum class FreezeAction // [SAVEVERSION+] // This informs the auto updater that the users savestates will be invalidated. -static const u32 g_SaveVersion = (0x9A4E << 16) | 0x0000; +static const u32 g_SaveVersion = (0x9A4F << 16) | 0x0000; // the freezing data between submodules and core diff --git a/pcsx2/x86/iR3000A.cpp b/pcsx2/x86/iR3000A.cpp index 4dcc2f2fe4..902f20d070 100644 --- a/pcsx2/x86/iR3000A.cpp +++ b/pcsx2/x86/iR3000A.cpp @@ -1141,15 +1141,13 @@ static void iPsxAddEECycles(u32 blockCycles) const u32 cnum = 1280; // PS2CLK / F const u32 cdenom = 147; // PSXCLK / F - static u32 ticks_carry = 0; - if (blockCycles != 0xFFFFFFFF) xMOV(eax, blockCycles * cnum); - xADD(eax, ptr32[&ticks_carry]); + xADD(eax, ptr32[&psxRegs.iopCycleEECarry]); xMOV(ecx, cdenom); xXOR(edx, edx); xUDIV(ecx); - xMOV(ptr32[&ticks_carry], edx); + xMOV(ptr32[&psxRegs.iopCycleEECarry], edx); xSUB(ptr32[&psxRegs.iopCycleEE], eax); }