diff --git a/pcsx2/x86/microVU_Compile.inl b/pcsx2/x86/microVU_Compile.inl index 4abc6e5ed8..f24e4badb9 100644 --- a/pcsx2/x86/microVU_Compile.inl +++ b/pcsx2/x86/microVU_Compile.inl @@ -427,7 +427,7 @@ void* mVUcompile(microVU& mVU, u32 startPC, uptr pState) { mVUsetupRange(mVU, startPC, 1); // Setup Program Bounds/Range mVU.regAlloc->reset(); // Reset regAlloc mVUinitFirstPass(mVU, pState, thisPtr); - for (int branch = 0; mVUcount < endCount; mVUcount++) { + for(int branch = 0; mVUcount < endCount; mVUcount++) { incPC(1); startLoop(mVU); mVUincCycles(mVU, 1); @@ -462,7 +462,7 @@ void* mVUcompile(microVU& mVU, u32 startPC, uptr pState) { setCode(); mVUbranch = 0; u32 x = 0; - for (; x < endCount; x++) { + for( ; x < endCount; x++) { if (mVUinfo.isEOB) { handleBadOp(mVU, x); x = 0xffff; } if (mVUup.mBit) { xOR(ptr32[&mVU.regs().flags], VUFLAG_MFLAGSET); } mVUexecuteInstruction(mVU); diff --git a/pcsx2/x86/microVU_Execute.inl b/pcsx2/x86/microVU_Execute.inl index 73b8c414ba..ef9a2b42b3 100644 --- a/pcsx2/x86/microVU_Execute.inl +++ b/pcsx2/x86/microVU_Execute.inl @@ -168,13 +168,16 @@ void mVUdispatcherD(mV) { _mVUt void* __fastcall mVUexecute(u32 startPC, u32 cycles) { microVU& mVU = mVUx; - //DevCon.WriteLn("microVU%x: startPC = 0x%x, cycles = 0x%x", vuIndex, startPC, cycles); + u32 vuLimit = vuIndex ? 0x3fff : 0xfff; + if (startPC > vuLimit) { + DevCon.Warning("microVU%x Warning: startPC = 0x%x, cycles = 0x%x", vuIndex, startPC, cycles); + } - mVU.cycles = cycles; + mVU.cycles = cycles; mVU.totalCycles = cycles; xSetPtr(mVU.prog.x86ptr); // Set x86ptr to where last program left off - return mVUsearchProg(startPC, (uptr)&mVU.prog.lpState); // Find and set correct program + return mVUsearchProg(startPC & vuLimit, (uptr)&mVU.prog.lpState); // Find and set correct program } //------------------------------------------------------------------ diff --git a/pcsx2/x86/microVU_Flags.inl b/pcsx2/x86/microVU_Flags.inl index f0c1284924..fd02d0856b 100644 --- a/pcsx2/x86/microVU_Flags.inl +++ b/pcsx2/x86/microVU_Flags.inl @@ -54,7 +54,7 @@ __fi void mVUstatusFlagOp(mV) { int findFlagInst(int* fFlag, int cycles) { int j = 0, jValue = -1; - for (int i = 0; i < 4; i++) { + for(int i = 0; i < 4; i++) { if ((fFlag[i] <= cycles) && (fFlag[i] > jValue)) { j = i; jValue = fFlag[i]; } } return j; @@ -64,7 +64,7 @@ int findFlagInst(int* fFlag, int cycles) { int sortFlag(int* fFlag, int* bFlag, int cycles) { int lFlag = -5; int x = 0; - for (int i = 0; i < 4; i++) { + for(int i = 0; i < 4; i++) { bFlag[i] = findFlagInst(fFlag, cycles); if (lFlag != bFlag[i]) { x++; } lFlag = bFlag[i]; @@ -83,18 +83,18 @@ __fi void mVUsetFlags(mV, microFlagCycles& mFC) { u32 aCount = 1; // Amount of instructions needed to get valid mac flag instances for block linking // Ensure last ~4+ instructions update mac/status flags (if next block's first 4 instructions will read them) - for (int i = mVUcount; i > 0; i--, aCount++) { + for(int i = mVUcount; i > 0; i--, aCount++) { if (sFLAG.doFlag) { - if (__Mac) { mFLAG.doFlag = 1; } - if (__Status) { sFLAG.doNonSticky = 1; } - if (aCount >= 4) { break; } + if (__Mac) mFLAG.doFlag = 1; + if (__Status) sFLAG.doNonSticky = 1; + if (aCount >= 4) break; } incPC2(-2); } // Status/Mac Flags Setup Code int xS = 0, xM = 0, xC = 0; - for (int i = 0; i < 4; i++) { + for(int i = 0; i < 4; i++) { mFC.xStatus[i] = i; mFC.xMac [i] = i; mFC.xClip [i] = i; @@ -122,7 +122,7 @@ __fi void mVUsetFlags(mV, microFlagCycles& mFC) { mFC.cycles = 0; u32 xCount = mVUcount; // Backup count iPC = mVUstartPC; - for (mVUcount = 0; mVUcount < xCount; mVUcount++) { + for(mVUcount = 0; mVUcount < xCount; mVUcount++) { if (mVUlow.isFSSET && !noFlagOpts) { if (__Status) { // Don't Optimize out on the last ~4+ instructions if ((xCount - mVUcount) > aCount) { mVUstatusFlagOp(mVU); } diff --git a/pcsx2/x86/microVU_Lower.inl b/pcsx2/x86/microVU_Lower.inl index 59e3419c86..878b4c5a44 100644 --- a/pcsx2/x86/microVU_Lower.inl +++ b/pcsx2/x86/microVU_Lower.inl @@ -1346,7 +1346,7 @@ void normJumpPass2(mV) { xSHL(gprT1, 3); xAND(gprT1, mVU.microMemSize - 8); xMOV(ptr32[&mVU.branch], gprT1); - if (!mVUlow.evilBranch) xMOV(ptr32[&mVU.branch], gprT1); + if (!mVUlow.evilBranch) xMOV(ptr32[&mVU.branch], gprT1); else xMOV(ptr32[&mVU.evilBranch], gprT1); if (mVUlow.badBranch) { xADD(gprT1, 8); diff --git a/pcsx2/x86/microVU_Misc.h b/pcsx2/x86/microVU_Misc.h index c6e3c32378..960322b421 100644 --- a/pcsx2/x86/microVU_Misc.h +++ b/pcsx2/x86/microVU_Misc.h @@ -227,6 +227,7 @@ typedef u32 (__fastcall *mVUCall)(void*, void*); #define shuffleSS(x) ((x==1)?(0x27):((x==2)?(0xc6):((x==4)?(0xe1):(0xe4)))) #define clampE CHECK_VU_EXTRA_OVERFLOW #define elif else if +#define varPrint(x) DevCon.WriteLn(#x " = %d", (int)x) #define branchAddr ( \ pxAssumeDev((iPC & 1) == 0, "microVU: Expected Lower Op for valid branch addr."), \