Skip to content

Commit

Permalink
Fix Timer IRQ Timing ( #141 )
Browse files Browse the repository at this point in the history
  • Loading branch information
dshadoff committed Apr 9, 2024
1 parent 82fb278 commit a813eb0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mednafen/src/pce/huc6280.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit a813eb0

Please sign in to comment.