From a813eb07e367845754722e3fdd2ce25bdfcad377 Mon Sep 17 00:00:00 2001 From: David Shadoff Date: Tue, 9 Apr 2024 18:13:23 -0400 Subject: [PATCH] Fix Timer IRQ Timing ( #141 ) --- mednafen/src/pce/huc6280.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mednafen/src/pce/huc6280.cpp b/mednafen/src/pce/huc6280.cpp index 9a63333..cf64a13 100644 --- a/mednafen/src/pce/huc6280.cpp +++ b/mednafen/src/pce/huc6280.cpp @@ -42,7 +42,10 @@ namespace MDFN_IEN_PCE INLINE void HuC6280::LastCycle(void) { /*assert(((P & I_FLAG) ? 0 : (uint32)~0) == PIMaskCache);*/ - IRQSample = (IRQlow & IRQMask) & PIMaskCache; + + // TIMER interrupt to be tested after opcodes, not one cycle early + // + IRQSample = (((IRQlow & IRQMask) & PIMaskCache) & ~IQTIMER); IFlagSample = P & I_FLAG; ADDCYC(1); } @@ -604,6 +607,11 @@ NO_INLINE void HuC6280::RunSub(void) } } + // TIMER interrupt to be tested after opcodes, not one cycle early + // + if (!IFlagSample) + IRQSample |= (IRQlow & IRQMask & IQTIMER); + if(IRQSample | IRQlow) { if(MDFN_UNLIKELY(IRQSample & IQRESET))