emulate pending irq bit somewhat
authornotaz <notasas@gmail.com>
Sat, 12 Aug 2023 16:01:22 +0000 (19:01 +0300)
committernotaz <notasas@gmail.com>
Sat, 12 Aug 2023 16:01:22 +0000 (19:01 +0300)
libpcsxcore/new_dynarec/events.c
libpcsxcore/r3000a.c

index 71aed6b..2a06c1f 100644 (file)
@@ -68,8 +68,11 @@ static void irq_test(psxCP0Regs *cp0)
                }
        }
 
-       if ((psxHu32(0x1070) & psxHu32(0x1074)) && (cp0->n.SR & 0x401) == 0x401) {
-               psxException(0x400, 0, cp0);
+       cp0->n.Cause &= ~0x400;
+       if (psxHu32(0x1070) & psxHu32(0x1074))
+               cp0->n.Cause |= 0x400;
+       if (((cp0->n.Cause | 1) & cp0->n.SR & 0x401) == 0x401) {
+               psxException(0, 0, cp0);
                pending_exception = 1;
        }
 }
index 8351c94..0be8a53 100644 (file)
@@ -109,7 +109,7 @@ void psxException(u32 cause, enum R3000Abdt bdt, psxCP0Regs *cp0) {
        }
 
        // Set the Cause
-       cp0->n.Cause = (bdt << 30) | (cp0->n.Cause & 0x300) | cause;
+       cp0->n.Cause = (bdt << 30) | (cp0->n.Cause & 0x700) | cause;
 
        // Set the EPC & PC
        cp0->n.EPC = bdt ? psxRegs.pc - 4 : psxRegs.pc;
@@ -196,15 +196,11 @@ void psxBranchTest() {
                }
        }
 
-       if (psxHu32(0x1070) & psxHu32(0x1074)) {
-               if ((psxRegs.CP0.n.SR & 0x401) == 0x401) {
-#ifdef PSXCPU_LOG
-                       PSXCPU_LOG("Interrupt: %x %x\n", psxHu32(0x1070), psxHu32(0x1074));
-#endif
-//                     SysPrintf("Interrupt (%x): %x %x\n", psxRegs.cycle, psxHu32(0x1070), psxHu32(0x1074));
-                       psxException(0x400, 0, &psxRegs.CP0);
-               }
-       }
+       psxRegs.CP0.n.Cause &= ~0x400;
+       if (psxHu32(0x1070) & psxHu32(0x1074))
+               psxRegs.CP0.n.Cause |= 0x400;
+       if (((psxRegs.CP0.n.Cause | 1) & psxRegs.CP0.n.SR & 0x401) == 0x401)
+               psxException(0, 0, &psxRegs.CP0);
 }
 
 void psxJumpTest() {