6522: Fix IFR.T2 when counter.b15=1

This commit is contained in:
tomcw 2022-02-26 21:10:42 +00:00
parent c277c5152d
commit 514d2adb79
1 changed files with 4 additions and 2 deletions

View File

@ -292,8 +292,10 @@ bool SY6522::IsTimer1Underflowed(BYTE reg)
bool SY6522::IsTimer2Underflowed(BYTE reg)
{
// FIXME: "m_regs.TIMER2_COUNTER.w >= 0" is always true! So function returns true when GetTimer2Counter() returns with b15==1
return m_regs.TIMER2_COUNTER.w >= 0 && (short)GetTimer2Counter(reg) < 0;
USHORT counter = m_regs.TIMER2_COUNTER.w; // NB. don't update the real T2C
int timerIrqDelay = m_timer2IrqDelay; // NB. don't update the real timer2IrqDelay
const UINT opcodeCycleAdjust = GetOpcodeCyclesForRead(reg); // to compensate for the 4/5/6 cycle read opcode
return CheckTimerUnderflow(counter, timerIrqDelay, opcodeCycleAdjust);
}
//-----------------------------------------------------------------------------