Skip to content

Commit

Permalink
VU: scale VU0 cycle rate with EE
Browse files Browse the repository at this point in the history
Also fix cycle underflow issue
  • Loading branch information
refractionpcsx2 committed Nov 2, 2023
1 parent f832a07 commit 1945755
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pcsx2/x86/microVU.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ struct microVU
u32 p; // Holds current P instance index
u32 q; // Holds current Q instance index
u32 totalCycles; // Total Cycles that mVU is expected to run for
u32 cycles; // Cycles Counter
s32 cycles; // Cycles Counter

VURegs& regs() const { return ::vuRegs[index]; }

Expand Down
26 changes: 26 additions & 0 deletions pcsx2/x86/microVU_Compile.inl
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,32 @@ void mVUtestCycles(microVU& mVU, microFlagCycles& mFC)
{
iPC = mVUstartPC;

if (isVU0 && EmuConfig.Speedhacks.EECycleRate != 0)
{
switch (std::min(static_cast<int>(EmuConfig.Speedhacks.EECycleRate), static_cast<int>(mVUcycles)))
{
case -3: // 50%
mVUcycles *= 2.0f;
break;
case -2: // 60%
mVUcycles *= 1.6666667f;
break;
case -1: // 75%
mVUcycles *= 1.3333333f;
break;
case 1: // 130%
mVUcycles /= 1.3f;
break;
case 2: // 180%
mVUcycles /= 1.8f;
break;
case 3: // 300%
mVUcycles /= 3.0f;
break;
default:
break;
}
}
xMOV(eax, ptr32[&mVU.cycles]);
if (EmuConfig.Gamefixes.VUSyncHack)
xSUB(eax, mVUcycles); // Running behind, make sure we have time to run the block
Expand Down
4 changes: 2 additions & 2 deletions pcsx2/x86/microVU_Execute.inl
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,12 @@ _mVUt void mVUcleanUp()
mVUreset(mVU, false);
}

mVU.cycles = mVU.totalCycles - mVU.cycles;
mVU.cycles = mVU.totalCycles - std::max(0, mVU.cycles);
mVU.regs().cycle += mVU.cycles;

if (!vuIndex || !THREAD_VU1)
{
u32 cycles_passed = std::min(mVU.cycles, 3000u) * EmuConfig.Speedhacks.EECycleSkip;
u32 cycles_passed = std::min(mVU.cycles, 3000) * EmuConfig.Speedhacks.EECycleSkip;
if (cycles_passed > 0)
{
s32 vu0_offset = VU0.cycle - cpuRegs.cycle;
Expand Down

0 comments on commit 1945755

Please sign in to comment.