Check interrupt sources after every opcode when in normal speed. (#651)

This commit is contained in:
tomcw 2019-06-01 16:54:58 +01:00
parent 941ef46e9a
commit 3a41061f83
5 changed files with 11 additions and 10 deletions

View File

@ -132,10 +132,11 @@ unsigned __int64 g_nCumulativeCycles = 0;
static ULONG g_nCyclesExecuted; // # of cycles executed up to last IO access
//static signed long g_uInternalExecutedCycles;
// TODO: Use IRQ_CHECK_TIMEOUT=128 when running at full-speed else with IRQ_CHECK_TIMEOUT=1
// Use IRQ_CHECK_TIMEOUT=128 when running at full-speed; else use IRQ_CHECK_TIMEOUT=1 (GH#651)
// - What about when running benchmark?
static const int IRQ_CHECK_TIMEOUT = 128;
static signed int g_nIrqCheckTimeout = IRQ_CHECK_TIMEOUT;
static const int IRQ_CHECK_TIMEOUT_FULL_SPEED = 128;
static const int IRQ_CHECK_TIMEOUT_NORMAL_SPEED = 1;
static signed int g_nIrqCheckTimeout = IRQ_CHECK_TIMEOUT_NORMAL_SPEED;
//
@ -417,20 +418,20 @@ static __forceinline void IRQ(ULONG& uExecutedCycles, BOOL& flagc, BOOL& flagn,
}
}
static __forceinline void CheckInterruptSources(ULONG uExecutedCycles)
static __forceinline void CheckInterruptSources(ULONG uExecutedCycles, const bool bVideoUpdate)
{
if (g_nIrqCheckTimeout < 0)
{
MB_UpdateCycles(uExecutedCycles);
sg_Mouse.SetVBlank( !VideoGetVblBar(uExecutedCycles) );
g_nIrqCheckTimeout = IRQ_CHECK_TIMEOUT;
g_nIrqCheckTimeout = bVideoUpdate ? IRQ_CHECK_TIMEOUT_NORMAL_SPEED : IRQ_CHECK_TIMEOUT_FULL_SPEED;
}
}
// GH#608: IRQ needs to occur within 17 cycles (6 opcodes) of configuring the timer interrupt
void CpuAdjustIrqCheck(UINT uCyclesUntilInterrupt)
{
if (uCyclesUntilInterrupt < IRQ_CHECK_TIMEOUT)
if (g_bFullSpeed && uCyclesUntilInterrupt < IRQ_CHECK_TIMEOUT_FULL_SPEED)
g_nIrqCheckTimeout = uCyclesUntilInterrupt;
}

View File

@ -318,7 +318,7 @@ static DWORD Cpu6502(DWORD uTotalCycles, const bool bVideoUpdate)
#undef $
}
CheckInterruptSources(uExecutedCycles);
CheckInterruptSources(uExecutedCycles, bVideoUpdate);
NMI(uExecutedCycles, flagc, flagn, flagv, flagz);
IRQ(uExecutedCycles, flagc, flagn, flagv, flagz);

View File

@ -321,7 +321,7 @@ static DWORD Cpu65C02(DWORD uTotalCycles, const bool bVideoUpdate)
#undef $
}
CheckInterruptSources(uExecutedCycles);
CheckInterruptSources(uExecutedCycles, bVideoUpdate);
NMI(uExecutedCycles, flagc, flagn, flagv, flagz);
IRQ(uExecutedCycles, flagc, flagn, flagv, flagz);

View File

@ -406,7 +406,7 @@ static DWORD Cpu65D02(DWORD uTotalCycles, const bool bVideoUpdate)
}
#undef $
CheckInterruptSources(uExecutedCycles);
CheckInterruptSources(uExecutedCycles, bVideoUpdate);
NMI(uExecutedCycles, flagc, flagn, flagv, flagz);
IRQ(uExecutedCycles, flagc, flagn, flagv, flagz);

View File

@ -54,7 +54,7 @@ static __forceinline void DoIrqProfiling(DWORD uCycles)
{
}
static __forceinline void CheckInterruptSources(ULONG uExecutedCycles)
static __forceinline void CheckInterruptSources(ULONG uExecutedCycles, const bool bVideoUpdate)
{
}