commodore64: implement Serial and Datassette interfaces (there are no devices to connect them to yet)

This commit is contained in:
saxxonpike 2012-12-06 04:29:08 +00:00
parent 747115962b
commit e449ab34fd
4 changed files with 84 additions and 2 deletions

View File

@ -35,6 +35,8 @@ namespace BizHawk.Emulation.Computers.Commodore64
public byte cia0DataB;
public byte cia0DirA;
public byte cia0DirB;
public bool cia0FlagCassette;
public bool cia0FlagSerial;
public byte cia1DataA;
public byte cia1DataB;
public byte cia1DirA;
@ -102,6 +104,8 @@ namespace BizHawk.Emulation.Computers.Commodore64
cia0DataB = 0xFF;
cia0DirA = 0xFF;
cia0DirB = 0xFF;
cia0FlagCassette = true;
cia0FlagSerial = true;
cia1DataA = 0xFF;
cia1DataB = 0xFF;
cia1DirA = 0xFF;
@ -128,6 +132,15 @@ namespace BizHawk.Emulation.Computers.Commodore64
public void Init()
{
cassPort.DeviceReadLevel = (() => { return cpu.CassetteOutputLevel; });
cassPort.DeviceReadMotor = (() => { return cpu.CassetteMotor; });
cassPort.DeviceWriteButton = ((bool val) => { cpu.CassetteButton = val; });
cassPort.DeviceWriteLevel = ((bool val) => { cia0FlagCassette = val; cia0.FLAG = cia0FlagCassette & cia0FlagSerial; });
cassPort.SystemReadButton = (() => { return true; });
cassPort.SystemReadLevel = (() => { return true; });
cassPort.SystemWriteLevel = ((bool val) => { });
cassPort.SystemWriteMotor = ((bool val) => { });
cia0.ReadDirA = (() => { return cia0DirA; });
cia0.ReadDirB = (() => { return cia0DirB; });
cia0.ReadPortA = (() => { return cia0DataA; });
@ -214,6 +227,22 @@ namespace BizHawk.Emulation.Computers.Commodore64
pla.WriteSid = ((ushort addr, byte val) => { address = addr; bus = val; sid.Write(addr, val); });
pla.WriteVic = ((ushort addr, byte val) => { address = addr; bus = val; vic.Write(addr, val); });
serPort.DeviceReadAtn = (() => { return (cia1DataA & 0x08) != 0; });
serPort.DeviceReadClock = (() => { return (cia1DataA & 0x10) != 0; });
serPort.DeviceReadData = (() => { return (cia1DataA & 0x20) != 0; });
serPort.DeviceReadReset = (() => { return true; }); // this triggers hard reset on ext device when low
serPort.DeviceWriteAtn = ((bool val) => { }); // currently not wired
serPort.DeviceWriteClock = ((bool val) => { cia1DataA = Port.ExternalWrite(cia1DataA, (byte)(cia1DataA | (val ? 0x40 : 0x00)), cia1DirA); });
serPort.DeviceWriteData = ((bool val) => { cia1DataA = Port.ExternalWrite(cia1DataA, (byte)(cia1DataA | (val ? 0x80 : 0x00)), cia1DirA); });
serPort.DeviceWriteSrq = ((bool val) => { cia0FlagSerial = val; cia0.FLAG = cia0FlagCassette & cia0FlagSerial; });
serPort.SystemReadAtn = (() => { return true; });
serPort.SystemReadClock = (() => { return true; });
serPort.SystemReadData = (() => { return true; });
serPort.SystemReadSrq = (() => { return true; });
serPort.SystemWriteAtn = ((bool val) => { });
serPort.SystemWriteClock = ((bool val) => { });
serPort.SystemWriteData = ((bool val) => { });
serPort.SystemWriteReset = ((bool val) => { });
sid.ReadPotX = (() => { return 0; });
sid.ReadPotY = (() => { return 0; });

View File

@ -7,6 +7,17 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
{
public class CassettePort
{
public Func<bool> DeviceReadLevel;
public Func<bool> DeviceReadMotor;
public Action<bool> DeviceWriteButton;
public Action<bool> DeviceWriteLevel;
public Func<bool> SystemReadButton;
public Func<bool> SystemReadLevel;
public Action<bool> SystemWriteLevel;
public Action<bool> SystemWriteMotor;
// Connect() needs to set System functions above
public void HardReset()
{
}

View File

@ -14,8 +14,8 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
private MOS6502X cpu;
private bool freezeCpu;
private bool pinCassetteButton;
private bool pinCassetteMotor;
private bool pinCassetteButton; // note: these are only
private bool pinCassetteMotor; // latches!
private bool pinCassetteOutput;
private bool pinCharen;
private bool pinLoram;
@ -31,10 +31,13 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
public Func<int, byte> PeekMemory;
public Action<int, byte> PokeMemory;
public Func<bool> ReadAEC;
public Func<bool> ReadCassetteButton;
public Func<bool> ReadIRQ;
public Func<bool> ReadNMI;
public Func<bool> ReadRDY;
public Func<ushort, byte> ReadMemory;
public Action<bool> WriteCassetteLevel;
public Action<bool> WriteCassetteMotor;
public Action<ushort, byte> WriteMemory;
// ------------------------------------
@ -154,6 +157,22 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
// ------------------------------------
public bool CassetteButton
{
get { return pinCassetteButton; }
set { pinCassetteButton = value; }
}
public bool CassetteMotor
{
get { return pinCassetteMotor; }
}
public bool CassetteOutputLevel
{
get { return pinCassetteOutput; }
}
public bool Charen
{
get { return pinCharen; }

View File

@ -5,8 +5,31 @@ using System.Text;
namespace BizHawk.Emulation.Computers.Commodore64.MOS
{
// the functions on this port are at the point of
// view of an external device.
public class SerialPort
{
public Func<bool> DeviceReadAtn;
public Func<bool> DeviceReadClock;
public Func<bool> DeviceReadData;
public Func<bool> DeviceReadReset;
public Action<bool> DeviceWriteAtn;
public Action<bool> DeviceWriteClock;
public Action<bool> DeviceWriteData;
public Action<bool> DeviceWriteSrq;
public Func<bool> SystemReadAtn;
public Func<bool> SystemReadClock;
public Func<bool> SystemReadData;
public Func<bool> SystemReadSrq;
public Action<bool> SystemWriteAtn;
public Action<bool> SystemWriteClock;
public Action<bool> SystemWriteData;
public Action<bool> SystemWriteReset;
// Connect() needs to set System functions above
public void HardReset()
{
}