From: notaz Date: Sat, 12 Aug 2023 16:01:22 +0000 (+0300) Subject: emulate pending irq bit somewhat X-Git-Tag: r24l~249 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c41449cbe521813de5ba6bc4751156dd19e4078d;p=pcsx_rearmed.git emulate pending irq bit somewhat --- diff --git a/libpcsxcore/new_dynarec/events.c b/libpcsxcore/new_dynarec/events.c index 71aed6b2..2a06c1f9 100644 --- a/libpcsxcore/new_dynarec/events.c +++ b/libpcsxcore/new_dynarec/events.c @@ -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; } } diff --git a/libpcsxcore/r3000a.c b/libpcsxcore/r3000a.c index 8351c949..0be8a53c 100644 --- a/libpcsxcore/r3000a.c +++ b/libpcsxcore/r3000a.c @@ -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() {