psxinterpreter: a bit more accurate Cause reg handling
authornotaz <notasas@gmail.com>
Tue, 25 Oct 2011 21:01:47 +0000 (00:01 +0300)
committernotaz <notasas@gmail.com>
Sun, 30 Oct 2011 21:48:08 +0000 (23:48 +0200)
libpcsxcore/psxinterpreter.c
libpcsxcore/r3000a.c

index 66730d9..ff49491 100644 (file)
@@ -780,10 +780,9 @@ void psxMFC0() { if (!_Rt_) return; _i32(_rRt_) = (int)_rFs_; }
 void psxCFC0() { if (!_Rt_) return; _i32(_rRt_) = (int)_rFs_; }
 
 void psxTestSWInts() {
-       // the next code is untested, if u know please
-       // tell me if it works ok or not (linuzappz)
        if (psxRegs.CP0.n.Cause & psxRegs.CP0.n.Status & 0x0300 &&
-               psxRegs.CP0.n.Status & 0x1) {
+          psxRegs.CP0.n.Status & 0x1) {
+               psxRegs.CP0.n.Cause &= ~0x7c;
                psxException(psxRegs.CP0.n.Cause, branch);
        }
 }
@@ -797,7 +796,8 @@ void MTC0(int reg, u32 val) {
                        break;
 
                case 13: // Cause
-                       psxRegs.CP0.n.Cause = val & ~(0xfc00);
+                       psxRegs.CP0.n.Cause &= ~0x0300;
+                       psxRegs.CP0.n.Cause |= val & 0x0300;
                        psxTestSWInts();
                        break;
 
index cccfa60..f5996ac 100644 (file)
@@ -89,7 +89,7 @@ void psxException(u32 code, u32 bd) {
        }
 
        // Set the Cause
-       psxRegs.CP0.n.Cause = code;
+       psxRegs.CP0.n.Cause = (psxRegs.CP0.n.Cause & 0x300) | code;
 
        // Set the EPC & PC
        if (bd) {