From 1c37a9abf46b6476c4c7215aa1ebe5e34147e71b Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Sun, 16 Aug 2009 02:49:25 +0000 Subject: [PATCH] microVU: Implemented some undocumented stuff which lets Champions Return to Arms get in-game. The game still looks ugly, I'm not sure if its problems are gsdx or pcsx2. zeroGS just renders a black screen which it no help xD Note: I still need to optimize this fix. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1630 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/x86/microVU.h | 11 ++++++----- pcsx2/x86/microVU_Analyze.inl | 8 ++++++-- pcsx2/x86/microVU_Compile.inl | 7 +++++++ pcsx2/x86/microVU_IR.h | 1 + 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/pcsx2/x86/microVU.h b/pcsx2/x86/microVU.h index cb4fff6963..38b15cce9d 100644 --- a/pcsx2/x86/microVU.h +++ b/pcsx2/x86/microVU.h @@ -83,11 +83,12 @@ public: } else { // Can do Simple Search (Only Matches the Important Pipeline Stuff) for (int i = 0; i <= listI; i++) { - if ((linkI->block->pState.q == pState->q) - && (linkI->block->pState.p == pState->p) - && (linkI->block->pState.vi15 == pState->vi15) - && (linkI->block->pState.flags == pState->flags) - && (linkI->block->pState.xgkick == pState->xgkick) + if ((linkI->block->pState.q == pState->q) + && (linkI->block->pState.p == pState->p) + && (linkI->block->pState.vi15 == pState->vi15) + && (linkI->block->pState.flags == pState->flags) + && (linkI->block->pState.xgkick == pState->xgkick) + && (linkI->block->pState.viBackUp == pState->viBackUp) && !(linkI->block->pState.needExactMatch & 5)) { return linkI->block; } linkI = linkI->next; } diff --git a/pcsx2/x86/microVU_Analyze.inl b/pcsx2/x86/microVU_Analyze.inl index 44659e7fd3..f0b4ca364a 100644 --- a/pcsx2/x86/microVU_Analyze.inl +++ b/pcsx2/x86/microVU_Analyze.inl @@ -356,10 +356,14 @@ microVUt(void) mVUanalyzeXGkick(mV, int Fs, int xCycles) { microVUt(void) analyzeBranchVI(mV, int xReg, bool &infoVar) { if (!xReg) return; int i; - int iEnd = aMin(5, mVUcount); + int iEnd = aMin(5, (mVUcount+1)); int bPC = iPC; incPC2(-2); for (i = 0; i < iEnd; i++) { + if (i == mVUcount) { + if (mVUpBlock->pState.viBackUp == xReg) infoVar = 1; + break; + } if ((mVUlow.VI_write.reg == xReg) && mVUlow.VI_write.used) { if (mVUlow.readFlags || i == 5) break; if (i == 0) { incPC2(-2); continue; } @@ -371,7 +375,7 @@ microVUt(void) analyzeBranchVI(mV, int xReg, bool &infoVar) { } if (i) { incPC2(2); - mVUlow.backupVI = 1; + if (!infoVar) mVUlow.backupVI = 1; iPC = bPC; infoVar = 1; DevCon::Status("microVU%d: Branch VI-Delay (%d) [%04x]", params getIndex, i, xPC); diff --git a/pcsx2/x86/microVU_Compile.inl b/pcsx2/x86/microVU_Compile.inl index 3013f1e60c..b9785572bb 100644 --- a/pcsx2/x86/microVU_Compile.inl +++ b/pcsx2/x86/microVU_Compile.inl @@ -162,6 +162,12 @@ microVUt(void) branchWarning(mV) { Console::Error("microVU%d Warning: Branch in E-bit/Branch delay slot! [%04x]", params mVU->index, xPC); mVUlow.isNOP = 1; } + if (mVUinfo.isBdelay) { // Check if VI Reg Written to on Branch Delay + if (mVUlow.VI_write.reg && mVUlow.VI_write.used) { + mVUlow.backupVI = 1; + mVUregs.viBackUp = mVUlow.VI_write.reg; + } + } } // Optimizes the End Pipeline State Removing Unnecessary Info @@ -294,6 +300,7 @@ microVUt(void) mVUinitFirstPass(microVU* mVU, microBlock* &pBlock, uptr pState, mVUblock.x86ptrStart = thisPtr; pBlock = mVUblocks[mVUstartPC/2]->add(&mVUblock); // Add this block to block manager mVUpBlock = pBlock; + mVUregs.viBackUp= 0; mVUregs.flags = 0; mVUflagInfo = 0; mVUsFlagHack = CHECK_VU_FLAGHACK; diff --git a/pcsx2/x86/microVU_IR.h b/pcsx2/x86/microVU_IR.h index 6b78bbc630..70a9cc3548 100644 --- a/pcsx2/x86/microVU_IR.h +++ b/pcsx2/x86/microVU_IR.h @@ -40,6 +40,7 @@ __declspec(align(16)) struct microRegInfo { // Ordered for Faster Compares u8 p; u8 r; u8 xgkick; + u8 viBackUp; u8 VI[16]; regInfo VF[32]; u8 flags; // clip x2 :: status x2