diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj index 584d3c09eb..10d71770da 100644 --- a/BizHawk.Emulation/BizHawk.Emulation.csproj +++ b/BizHawk.Emulation/BizHawk.Emulation.csproj @@ -94,6 +94,7 @@ + diff --git a/BizHawk.Emulation/Computers/Commodore64/1541.cs b/BizHawk.Emulation/Computers/Commodore64/1541.cs index 4196cc9d7b..deb70f9214 100644 --- a/BizHawk.Emulation/Computers/Commodore64/1541.cs +++ b/BizHawk.Emulation/Computers/Commodore64/1541.cs @@ -74,11 +74,11 @@ namespace BizHawk.Emulation.Computers.Commodore64 } else if (addr >= 0x1800 && addr < 0x1810) { - return via0.regs[addr]; + return via0.Peek(addr); } else if (addr >= 0x1C00 && addr < 0x1C10) { - return via1.regs[addr]; + return via1.Peek(addr); } else if (addr >= 0xC000) { @@ -101,11 +101,11 @@ namespace BizHawk.Emulation.Computers.Commodore64 } else if (addr >= 0x1800 && addr < 0x1810) { - via0.regs[addr] = val; + via0.Poke(addr, val); } else if (addr >= 0x1C00 && addr < 0x1C10) { - via1.regs[addr] = val; + via1.Poke(addr, val); } } @@ -117,11 +117,11 @@ namespace BizHawk.Emulation.Computers.Commodore64 } else if (addr >= 0x1800 && addr < 0x1810) { - return via0.regs[addr]; + return via0.Read(addr); } else if (addr >= 0x1C00 && addr < 0x1C10) { - return via1.regs[addr]; + return via1.Read(addr); } else if (addr >= 0xC000) { @@ -144,11 +144,11 @@ namespace BizHawk.Emulation.Computers.Commodore64 } else if (addr >= 0x1800 && addr < 0x1810) { - via0.regs[addr] = val; + via0.Write(addr, val); } else if (addr >= 0x1C00 && addr < 0x1C10) { - via1.regs[addr] = val; + via1.Write(addr, val); } } } diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.core.cs b/BizHawk.Emulation/Computers/Commodore64/C64.core.cs index 3094e2101e..601cdb1c3d 100644 --- a/BizHawk.Emulation/Computers/Commodore64/C64.core.cs +++ b/BizHawk.Emulation/Computers/Commodore64/C64.core.cs @@ -39,6 +39,21 @@ namespace BizHawk.Emulation.Computers.Commodore64 //private Emulation.Sound.Utilities.DCFilter sidDCFilter; private SidSyncSoundProvider syncSid; + public bool DriveLED + { + get + { + if (diskDriveAttached) + { + return (diskDrive.Peek(0x1C00) & 0x8) != 0; + } + else + { + return false; + } + } + } + public void HardReset() { // initalize cpu diff --git a/BizHawk.Emulation/Computers/Commodore64/DataPort.cs b/BizHawk.Emulation/Computers/Commodore64/DataPort.cs index 038065f5e1..d972939a14 100644 --- a/BizHawk.Emulation/Computers/Commodore64/DataPort.cs +++ b/BizHawk.Emulation/Computers/Commodore64/DataPort.cs @@ -162,6 +162,15 @@ namespace BizHawk.Emulation.Computers.Commodore64 private Action WriteData; private Action WriteDirection; + public DataPortConnector(DataPortConnector source) + { + ReadData = source.ReadData; + ReadDirection = source.ReadDirection; + ReadRemoteData = source.ReadRemoteData; + WriteData = source.WriteData; + WriteDirection = source.WriteDirection; + } + public DataPortConnector(Func newReadData, Func newReadDirection, Func newReadRemoteData, Action newWriteData, Action newWriteDirection) { ReadData = newReadData; diff --git a/BizHawk.Emulation/Computers/Commodore64/SerialCable.cs b/BizHawk.Emulation/Computers/Commodore64/SerialCable.cs new file mode 100644 index 0000000000..2a2cbac83f --- /dev/null +++ b/BizHawk.Emulation/Computers/Commodore64/SerialCable.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Emulation.Computers.Commodore64 +{ + // adapter for converting CIA output to VIA + // inherits DataPortConnector so the conversion is invisible + // to both devices + + struct SerialCableData + { + public bool ATNIN; + public bool ATNOUT; + public bool CLOCKIN; + public bool CLOCKOUT; + public bool DATAIN; + public bool DATAOUT; + } + + class SerialCable : DataPortConnector + { + private DataPortConnector connector; + + public SerialCable(DataPortConnector baseConnector) : base(baseConnector) + { + connector = baseConnector; + } + + new public byte Data + { + get + { + return base.Data; + } + set + { + base.Data = value; + } + } + + new public byte Direction + { + get + { + return base.Direction; + } + set + { + base.Direction = value; + } + } + + new public byte RemoteData + { + get + { + return base.RemoteData; + } + } + } + +} diff --git a/BizHawk.Emulation/Computers/Commodore64/Via.cs b/BizHawk.Emulation/Computers/Commodore64/Via.cs index 6d030b86bc..f4eed897ab 100644 --- a/BizHawk.Emulation/Computers/Commodore64/Via.cs +++ b/BizHawk.Emulation/Computers/Commodore64/Via.cs @@ -16,8 +16,8 @@ namespace BizHawk.Emulation.Computers.Commodore64 public int IFR; public int PCR; public int SR; - public int[] TC; - public int[] TL; + public int[] TC = new int[2]; + public int[] TL = new int[2]; public ViaRegs() { @@ -56,7 +56,7 @@ namespace BizHawk.Emulation.Computers.Commodore64 public class Via { - public ViaRegs regs; + private ViaRegs regs; public Via() { @@ -67,5 +67,25 @@ namespace BizHawk.Emulation.Computers.Commodore64 { regs = new ViaRegs(); } + + public byte Peek(int addr) + { + addr &= 0xF; + return 0; + } + + public void Poke(int addr, byte val) + { + addr &= 0xF; + } + + public byte Read(ushort addr) + { + return 0x00; + } + + public void Write(ushort addr, byte val) + { + } } }