Fixed off-by-one-tstate frame timing issue

This commit is contained in:
Asnivor 2018-02-16 08:49:41 +00:00
parent ec7445669c
commit c8ea81bfd8
4 changed files with 7 additions and 5 deletions

View File

@ -123,7 +123,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
PollInput(); PollInput();
while (CurrentFrameCycle <= ULADevice.FrameLength) // UlaFrameCycleCount) while (CurrentFrameCycle < ULADevice.FrameLength) // UlaFrameCycleCount)
{ {
// check for interrupt // check for interrupt
ULADevice.CheckForInterrupt(CurrentFrameCycle); ULADevice.CheckForInterrupt(CurrentFrameCycle);

View File

@ -254,7 +254,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <summary> /// <summary>
/// The longest instruction cycle count /// The longest instruction cycle count
/// </summary> /// </summary>
protected const int LONGEST_OP_CYCLES = 23; protected int LongestOperationCycles = 23;
/// <summary> /// <summary>
/// Signs that an interrupt has been raised in this frame. /// Signs that an interrupt has been raised in this frame.
@ -288,19 +288,19 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
return; return;
} }
if (currentCycle < InterruptPeriod) if (currentCycle < LongestOperationCycles)// InterruptPeriod)
{ {
// interrupt does not need to be raised yet // interrupt does not need to be raised yet
return; return;
} }
if (currentCycle > InterruptPeriod + LONGEST_OP_CYCLES) if (currentCycle >= InterruptPeriod + LongestOperationCycles)
{ {
// interrupt should have already been raised and the cpu may or // interrupt should have already been raised and the cpu may or
// may not have caught it. The time has passed so revoke the signal // may not have caught it. The time has passed so revoke the signal
InterruptRevoked = true; InterruptRevoked = true;
_machine.CPU.FlagI = false; _machine.CPU.FlagI = false;
return;
} }
if (InterruptRaised) if (InterruptRaised)

View File

@ -9,6 +9,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
: base(machine) : base(machine)
{ {
InterruptPeriod = 36; InterruptPeriod = 36;
LongestOperationCycles = 23;
FrameLength = 70908; FrameLength = 70908;
ClockSpeed = 3546900; ClockSpeed = 3546900;

View File

@ -9,6 +9,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
: base(machine) : base(machine)
{ {
InterruptPeriod = 32; InterruptPeriod = 32;
LongestOperationCycles = 23;
FrameLength = 69888; FrameLength = 69888;
ClockSpeed = 3500000; ClockSpeed = 3500000;