6502: added RDY pin, required for C64 and possibly others
This commit is contained in:
parent
af9bbd9ae4
commit
459368dd5b
File diff suppressed because it is too large
Load Diff
|
@ -27,6 +27,7 @@ namespace BizHawk.Emulation.CPUs.M6502
|
||||||
mi = 0;
|
mi = 0;
|
||||||
opcode = 256;
|
opcode = 256;
|
||||||
iflag_pending = true;
|
iflag_pending = true;
|
||||||
|
RDY = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NESSoftReset()
|
public void NESSoftReset()
|
||||||
|
@ -82,6 +83,7 @@ namespace BizHawk.Emulation.CPUs.M6502
|
||||||
|
|
||||||
public bool IRQ;
|
public bool IRQ;
|
||||||
public bool NMI;
|
public bool NMI;
|
||||||
|
public bool RDY;
|
||||||
|
|
||||||
public void SyncState(Serializer ser)
|
public void SyncState(Serializer ser)
|
||||||
{
|
{
|
||||||
|
@ -94,6 +96,7 @@ namespace BizHawk.Emulation.CPUs.M6502
|
||||||
ser.Sync("S", ref S);
|
ser.Sync("S", ref S);
|
||||||
ser.Sync("NMI", ref NMI);
|
ser.Sync("NMI", ref NMI);
|
||||||
ser.Sync("IRQ", ref IRQ);
|
ser.Sync("IRQ", ref IRQ);
|
||||||
|
ser.Sync("RDY", ref RDY);
|
||||||
ser.Sync("TotalExecutedCycles", ref TotalExecutedCycles);
|
ser.Sync("TotalExecutedCycles", ref TotalExecutedCycles);
|
||||||
ser.Sync("opcode", ref opcode);
|
ser.Sync("opcode", ref opcode);
|
||||||
ser.Sync("opcode2", ref opcode2);
|
ser.Sync("opcode2", ref opcode2);
|
||||||
|
|
|
@ -13,14 +13,9 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
|
|
||||||
private MOS6502X cpu;
|
private MOS6502X cpu;
|
||||||
private List<GCHandle> disposeList = new List<GCHandle>();
|
private List<GCHandle> disposeList = new List<GCHandle>();
|
||||||
private bool freezeCpu;
|
//private bool freezeCpu;
|
||||||
private bool pinNMILast;
|
private bool pinNMILast;
|
||||||
private LatchedPort port;
|
private LatchedPort port;
|
||||||
private bool unusedPin0;
|
|
||||||
private bool unusedPin1;
|
|
||||||
private uint unusedPinTTL0;
|
|
||||||
private uint unusedPinTTL1;
|
|
||||||
private uint unusedPinTTLCycles;
|
|
||||||
|
|
||||||
public Func<int, byte> PeekMemory;
|
public Func<int, byte> PeekMemory;
|
||||||
public Action<int, byte> PokeMemory;
|
public Action<int, byte> PokeMemory;
|
||||||
|
@ -43,9 +38,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
cpu.ReadMemory = Read;
|
cpu.ReadMemory = Read;
|
||||||
cpu.WriteMemory = Write;
|
cpu.WriteMemory = Write;
|
||||||
|
|
||||||
// todo: verify this value (I only know that unconnected bits fade after a number of cycles)
|
|
||||||
unusedPinTTLCycles = 40;
|
|
||||||
|
|
||||||
// perform hard reset
|
// perform hard reset
|
||||||
HardReset();
|
HardReset();
|
||||||
}
|
}
|
||||||
|
@ -74,10 +66,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
|
|
||||||
// NMI is high on startup (todo: verify)
|
// NMI is high on startup (todo: verify)
|
||||||
pinNMILast = true;
|
pinNMILast = true;
|
||||||
|
|
||||||
// reset unused IO pin TTLs
|
|
||||||
unusedPinTTL0 = 0;
|
|
||||||
unusedPinTTL1 = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
|
@ -88,8 +76,8 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
|
|
||||||
public void ExecutePhase2()
|
public void ExecutePhase2()
|
||||||
{
|
{
|
||||||
if (ReadAEC() && !freezeCpu)
|
cpu.RDY = ReadRDY();
|
||||||
{
|
|
||||||
// the 6502 core expects active high
|
// the 6502 core expects active high
|
||||||
// so we reverse the polarity here
|
// so we reverse the polarity here
|
||||||
bool thisNMI = ReadNMI();
|
bool thisNMI = ReadNMI();
|
||||||
|
@ -103,21 +91,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
cpu.ExecuteOne();
|
cpu.ExecuteOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
// unfreeze cpu if BA is high
|
|
||||||
if (ReadRDY()) freezeCpu = false;
|
|
||||||
|
|
||||||
// process unused pin TTL
|
|
||||||
if (unusedPinTTL0 == 0)
|
|
||||||
unusedPin0 = false;
|
|
||||||
else
|
|
||||||
unusedPinTTL0--;
|
|
||||||
|
|
||||||
if (unusedPinTTL1 == 0)
|
|
||||||
unusedPin1 = false;
|
|
||||||
else
|
|
||||||
unusedPinTTL1--;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
|
|
||||||
public ushort PC
|
public ushort PC
|
||||||
|
@ -162,10 +135,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
|
|
||||||
public byte Read(ushort addr)
|
public byte Read(ushort addr)
|
||||||
{
|
{
|
||||||
// cpu freezes after first read when RDY is low
|
|
||||||
if (!ReadRDY())
|
|
||||||
freezeCpu = true;
|
|
||||||
|
|
||||||
if (addr == 0x0000)
|
if (addr == 0x0000)
|
||||||
return port.Direction;
|
return port.Direction;
|
||||||
else if (addr == 0x0001)
|
else if (addr == 0x0001)
|
||||||
|
@ -177,13 +146,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
||||||
public void SyncState(Serializer ser)
|
public void SyncState(Serializer ser)
|
||||||
{
|
{
|
||||||
cpu.SyncState(ser);
|
cpu.SyncState(ser);
|
||||||
ser.Sync("freezeCpu", ref freezeCpu);
|
|
||||||
ser.Sync("pinNMILast", ref pinNMILast);
|
ser.Sync("pinNMILast", ref pinNMILast);
|
||||||
ser.Sync("unusedPin0", ref unusedPin0);
|
|
||||||
ser.Sync("unusedPin1", ref unusedPin1);
|
|
||||||
ser.Sync("unusedPinTTL0", ref unusedPinTTL0);
|
|
||||||
ser.Sync("unusedPinTTL1", ref unusedPinTTL1);
|
|
||||||
ser.Sync("unusedPinTTLCycles", ref unusedPinTTLCycles);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write(ushort addr, byte val)
|
public void Write(ushort addr, byte val)
|
||||||
|
|
Loading…
Reference in New Issue