MB:6522: fix edge case for IRQ not firing for very small latch values. (Fixes #1175)

This commit is contained in:
tomcw 2023-02-04 12:09:19 +00:00
parent 958c71de5f
commit 6a3a3114c7
2 changed files with 3 additions and 0 deletions

View File

@ -52,6 +52,7 @@ public:
USHORT GetRegT2C(void) { return m_regs.TIMER2_COUNTER.w; }
void GetRegs(BYTE regs[SIZE_6522_REGS]) { memcpy(&regs[0], (BYTE*)&m_regs, SIZE_6522_REGS); } // For debugger
void SetRegORA(BYTE reg) { m_regs.ORA = reg; }
bool IsTimer1IrqDelay(void) { return m_timer1IrqDelay ? true : false; }
BYTE Read(BYTE nReg);
void Write(BYTE nReg, BYTE nValue);

View File

@ -834,6 +834,8 @@ int MockingboardCard::MB_SyncEventCallbackInternal(int id, int /*cycles*/, ULONG
if ((pMB->sy6522.GetReg(SY6522::rACR) & SY6522::ACR_RUNMODE) == SY6522::ACR_RM_FREERUNNING)
{
pMB->sy6522.StartTimer1();
if (pMB->sy6522.IsTimer1IrqDelay())
return 0x0001; // T1C=0xFFFF, which is really -1, as there's 1 cycle until underflow occurs
return pMB->sy6522.GetRegT1C() + SY6522::kExtraTimerCycles;
}