Fixed 6522 & interrupt:

. Broadside needs to see IRQ within 17 cycles (6 opcodes) of 6522 counter underflowing to detect Mockingboard. (Fixes #605)
This commit is contained in:
tomcw 2019-01-06 16:54:54 +00:00
parent eea8cb3cdf
commit ceb0416bf3
3 changed files with 10 additions and 0 deletions

View File

@ -427,6 +427,13 @@ static __forceinline void CheckInterruptSources(ULONG uExecutedCycles)
}
}
// GH#605: IRQ needs to occur within 17 cycles (6 opcodes) of configuring the timer interrupt
void CpuAdjustIrqCheck(UINT uCyclesUntilInterrupt)
{
if (uCyclesUntilInterrupt < IRQ_CHECK_TIMEOUT)
g_nIrqCheckTimeout = uCyclesUntilInterrupt;
}
//===========================================================================
#include "CPU/cpu6502.h" // MOS 6502

View File

@ -14,6 +14,7 @@ struct regsrec
extern regsrec regs;
extern unsigned __int64 g_nCumulativeCycles;
void CpuAdjustIrqCheck(UINT uCyclesUntilInterrupt);
void CpuDestroy ();
void CpuCalcCycles(ULONG nExecutedCycles);
DWORD CpuExecute(const DWORD uCycles, const bool bVideoUpdate);

View File

@ -427,6 +427,7 @@ static void SY6522_Write(BYTE nDevice, BYTE nReg, BYTE nValue)
pMB->sy6522.TIMER1_COUNTER.w = pMB->sy6522.TIMER1_LATCH.w;
StartTimer1(pMB);
CpuAdjustIrqCheck(pMB->sy6522.TIMER1_LATCH.w); // Sync IRQ check timeout with 6522 counter underflow - GH#608
break;
case 0x07: // TIMER1H_LATCH
// Clear Timer1 Interrupt Flag.
@ -444,6 +445,7 @@ static void SY6522_Write(BYTE nDevice, BYTE nReg, BYTE nValue)
pMB->sy6522.TIMER2_COUNTER.w = pMB->sy6522.TIMER2_LATCH.w;
StartTimer2(pMB);
CpuAdjustIrqCheck(pMB->sy6522.TIMER1_LATCH.w); // Sync IRQ check timeout with 6522 counter underflow - GH#608
break;
case 0x0a: // SERIAL_SHIFT
break;