microVU: Fix for Red Faction 2

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4622 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
cottonvibes 2011-05-04 22:52:27 +00:00
parent 00132caca1
commit 9a3934af89
5 changed files with 18 additions and 14 deletions

View File

@ -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);

View File

@ -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<vuIndex>(startPC, (uptr)&mVU.prog.lpState); // Find and set correct program
return mVUsearchProg<vuIndex>(startPC & vuLimit, (uptr)&mVU.prog.lpState); // Find and set correct program
}
//------------------------------------------------------------------

View File

@ -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); }

View File

@ -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);

View File

@ -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."), \