microVU: Fixed a bug in my handling of branch in branch-delay slots.

Fixes Hot Wheels Velocity Maximum Justice, and now makes the game playable with pcsx2 from what I can see :D
This revision might also fix other games that were still having problems that do branches in branch-delay slots.


git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4657 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
cottonvibes 2011-05-20 06:20:36 +00:00
parent 1420318b04
commit daefeb1649
3 changed files with 16 additions and 13 deletions

View File

@ -441,6 +441,7 @@ __ri int mVUbranchCheck(mV) {
if (!mVUcount) return 0; if (!mVUcount) return 0;
incPC(-2); incPC(-2);
if (mVUlow.branch) { if (mVUlow.branch) {
u32 branchType = mVUlow.branch;
if (doBranchInDelaySlot) { if (doBranchInDelaySlot) {
mVUlow.badBranch = 1; mVUlow.badBranch = 1;
incPC(2); incPC(2);
@ -450,13 +451,15 @@ __ri int mVUbranchCheck(mV) {
mVUregs.flagInfo = 0; mVUregs.flagInfo = 0;
mVUregs.fullFlags0 = 0; mVUregs.fullFlags0 = 0;
mVUregs.fullFlags1 = 0; mVUregs.fullFlags1 = 0;
DevCon.Warning("microVU%d Warning: Branch in Branch delay slot! [%04x]", mVU.index, xPC); DevCon.Warning("microVU%d Warning: Branch[%d] in Branch[%d] delay slot! [%04x]",
mVU.index, branchType, mVUlow.branch, xPC);
return 1; return 1;
} }
else { else {
incPC(2); incPC(2);
mVUlow.isNOP = 1; mVUlow.isNOP = 1;
DevCon.Warning("microVU%d Warning: Branch in Branch delay slot! [%04x]", mVU.index, xPC); DevCon.Warning("microVU%d Warning: Branch[%d] in Branch[%d] delay slot! [%04x]",
mVU.index, branchType, mVUlow.branch, xPC);
return 0; return 0;
} }
} }
@ -489,8 +492,8 @@ __fi void mVUanalyzeNormBranch(mV, int It, bool isBAL) {
} }
__ri void mVUanalyzeJump(mV, int Is, int It, bool isJALR) { __ri void mVUanalyzeJump(mV, int Is, int It, bool isJALR) {
mVUbranchCheck(mVU);
mVUlow.branch = (isJALR) ? 10 : 9; mVUlow.branch = (isJALR) ? 10 : 9;
mVUbranchCheck(mVU);
if (mVUconstReg[Is].isValid && doConstProp) { if (mVUconstReg[Is].isValid && doConstProp) {
mVUlow.constJump.isValid = 1; mVUlow.constJump.isValid = 1;
mVUlow.constJump.regValue = mVUconstReg[Is].regValue; mVUlow.constJump.regValue = mVUconstReg[Is].regValue;

View File

@ -435,19 +435,19 @@ void* mVUcompile(microVU& mVU, u32 startPC, uptr pState) {
mVUincCycles(mVU, 1); mVUincCycles(mVU, 1);
mVUopU(mVU, 0); mVUopU(mVU, 0);
mVUcheckBadOp(mVU); mVUcheckBadOp(mVU);
if (curI & _Ebit_) { eBitPass1(mVU, branch); } if (curI & _Ebit_) { eBitPass1(mVU, branch); }
if (curI & _DTbit_) { branch = 4; } if (curI & _DTbit_) { branch = 4; }
if (curI & _Mbit_) { mVUup.mBit = 1; } if (curI & _Mbit_) { mVUup.mBit = 1; }
if (curI & _Ibit_) { mVUlow.isNOP = 1; mVUup.iBit = 1; } if (curI & _Ibit_) { mVUlow.isNOP = 1; mVUup.iBit = 1; }
else { incPC(-1); mVUopL(mVU, 0); incPC(1); } else { incPC(-1); mVUopL(mVU, 0); incPC(1); }
mVUsetCycles(mVU); mVUsetCycles(mVU);
mVUinfo.readQ = mVU.q; mVUinfo.readQ = mVU.q;
mVUinfo.writeQ = !mVU.q; mVUinfo.writeQ = !mVU.q;
mVUinfo.readP = mVU.p; mVUinfo.readP = mVU.p;
mVUinfo.writeP = !mVU.p; mVUinfo.writeP = !mVU.p;
if (branch >= 2) { mVUinfo.isEOB = 1; if (branch == 3) { mVUinfo.isBdelay = 1; } mVUcount++; branchWarning(mVU); break; } if (branch >= 2) { mVUinfo.isEOB = 1; if (branch == 3) { mVUinfo.isBdelay = 1; } mVUcount++; branchWarning(mVU); break; }
else if (branch == 1) { branch = 2; } elif (branch == 1) { branch = 2; }
if (mVUbranch) { mVUsetFlagInfo(mVU); eBitWarning(mVU); branch = 3; mVUbranch = 0; } if (mVUbranch) { mVUsetFlagInfo(mVU); eBitWarning(mVU); branch = 3; mVUbranch = 0; }
incPC(1); incPC(1);
} }

View File

@ -1228,9 +1228,9 @@ void condEvilBranch(mV, int JMPcc) {
xMOV(ptr32[&mVU.badBranch], branchAddrN); xMOV(ptr32[&mVU.badBranch], branchAddrN);
xCMP(gprT1b, 0); xCMP(gprT1b, 0);
xForwardJump8 cJMP((JccComparisonType)JMPcc); xForwardJump8 cJMP((JccComparisonType)JMPcc);
incPC(4); // Branch Not Taken incPC(6); // Branch Not Taken Addr + 8
xMOV(ptr32[&mVU.badBranch], xPC); xMOV(ptr32[&mVU.badBranch], xPC);
incPC(-4); incPC(-6);
cJMP.SetTarget(); cJMP.SetTarget();
return; return;
} }