C64: CIA was sometimes delaying too long to fire interrupts by 1 cycle.

- This could have implications for existing TASes (!)
This commit is contained in:
SaxxonPike 2019-07-05 23:59:01 -05:00
parent 69f8b143a3
commit 400b04b690
1 changed files with 24 additions and 25 deletions

View File

@ -144,34 +144,29 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
_lastCnt = true; _lastCnt = true;
} }
private void CheckIrqs()
{
if (_taIrqNextCycle)
{
_taIrqNextCycle = false;
TriggerInterrupt(1);
}
if (_tbIrqNextCycle)
{
_tbIrqNextCycle = false;
TriggerInterrupt(2);
}
}
public void ExecutePhase() public void ExecutePhase()
{ {
_thisCnt = ReadCnt(); _thisCnt = ReadCnt();
_taUnderflow = false; _taUnderflow = false;
if (DelayedInterrupts)
{ if (_taIrqNextCycle)
CheckIrqs(); {
} _taIrqNextCycle = false;
TriggerInterrupt(1);
}
if (_tbIrqNextCycle)
{
_tbIrqNextCycle = false;
TriggerInterrupt(2);
}
if (_taPrb6NegativeNextCycle) if (_taPrb6NegativeNextCycle)
{ {
_prb &= 0xBF; _prb &= 0xBF;
_taPrb6NegativeNextCycle = false; _taPrb6NegativeNextCycle = false;
} }
if (_tbPrb7NegativeNextCycle) if (_tbPrb7NegativeNextCycle)
{ {
_prb &= 0x7F; _prb &= 0x7F;
@ -277,11 +272,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
} }
_flagLatch = _flagInput; _flagLatch = _flagInput;
if (!DelayedInterrupts)
{
CheckIrqs();
}
if ((_cra & 0x02) != 0) if ((_cra & 0x02) != 0)
_ddra |= 0x40; _ddra |= 0x40;
if ((_crb & 0x02) != 0) if ((_crb & 0x02) != 0)
@ -309,7 +299,12 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
private void Ta_Interrupt() private void Ta_Interrupt()
{ {
_ta = _latcha; _ta = _latcha;
_taIrqNextCycle = true;
if (DelayedInterrupts)
_taIrqNextCycle = true;
else
TriggerInterrupt(1);
_icr |= 1; _icr |= 1;
if ((_cra & 0x08) != 0) if ((_cra & 0x08) != 0)
@ -418,7 +413,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
private void Tb_Interrupt() private void Tb_Interrupt()
{ {
_tb = _latchb; _tb = _latchb;
_tbIrqNextCycle = true; if (DelayedInterrupts)
_tbIrqNextCycle = true;
else
TriggerInterrupt(2);
_icr |= 2; _icr |= 2;
if ((_crb & 0x08) != 0) if ((_crb & 0x08) != 0)