C64: Apparently the 6502X core needs interrupts delayed by a cycle, do that with IRQ and NMI
This commit is contained in:
parent
3bbfb98fc2
commit
e8902b829a
|
@ -11,9 +11,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
|
||||||
{
|
{
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
private readonly MOS6502X<CpuLink> _cpu;
|
private readonly MOS6502X<CpuLink> _cpu;
|
||||||
private bool _pinNmiLast;
|
|
||||||
private LatchedPort _port;
|
private LatchedPort _port;
|
||||||
private bool _thisNmi;
|
private int _irqDelay;
|
||||||
|
private int _nmiDelay;
|
||||||
|
|
||||||
private struct CpuLink : IMOS6502XLink
|
private struct CpuLink : IMOS6502XLink
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
|
||||||
Direction = 0x00,
|
Direction = 0x00,
|
||||||
Latch = 0xFF
|
Latch = 0xFF
|
||||||
};
|
};
|
||||||
_pinNmiLast = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SoftReset()
|
public void SoftReset()
|
||||||
|
@ -89,11 +88,13 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
public void ExecutePhase()
|
public void ExecutePhase()
|
||||||
{
|
{
|
||||||
|
_irqDelay >>= 1;
|
||||||
|
_nmiDelay >>= 1;
|
||||||
|
_irqDelay |= ReadIrq() ? 0x0 : 0x2;
|
||||||
|
_nmiDelay |= ReadNmi() ? 0x0 : 0x2;
|
||||||
_cpu.RDY = ReadRdy();
|
_cpu.RDY = ReadRdy();
|
||||||
_cpu.IRQ = !ReadIrq();
|
_cpu.IRQ = (_irqDelay & 1) != 0;
|
||||||
_pinNmiLast = _thisNmi;
|
_cpu.NMI |= (_nmiDelay & 3) == 2;
|
||||||
_thisNmi = ReadNmi();
|
|
||||||
_cpu.NMI |= _pinNmiLast && !_thisNmi;
|
|
||||||
_cpu.ExecuteOne();
|
_cpu.ExecuteOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,13 +151,12 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
|
||||||
_cpu.SyncState(ser);
|
_cpu.SyncState(ser);
|
||||||
ser.EndSection();
|
ser.EndSection();
|
||||||
|
|
||||||
ser.Sync(nameof(_pinNmiLast), ref _pinNmiLast);
|
|
||||||
|
|
||||||
ser.BeginSection(nameof(_port));
|
ser.BeginSection(nameof(_port));
|
||||||
_port.SyncState(ser);
|
_port.SyncState(ser);
|
||||||
ser.EndSection();
|
ser.EndSection();
|
||||||
|
|
||||||
ser.Sync(nameof(_thisNmi), ref _thisNmi);
|
ser.Sync(nameof(_irqDelay), ref _irqDelay);
|
||||||
|
ser.Sync(nameof(_nmiDelay), ref _nmiDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write(int addr, int val)
|
public void Write(int addr, int val)
|
||||||
|
|
Loading…
Reference in New Issue