commodore64: add serial cable interface for CIA/VIA communication, also DriveLED

This commit is contained in:
saxxonpike 2012-11-15 21:40:01 +00:00
parent bd3912939a
commit 8196caf731
6 changed files with 120 additions and 11 deletions

View File

@ -94,6 +94,7 @@
<Compile Include="Computers\Commodore64\Input.cs" />
<Compile Include="Computers\Commodore64\PRGFile.cs" />
<Compile Include="Computers\Commodore64\MemBus.cs" />
<Compile Include="Computers\Commodore64\SerialCable.cs" />
<Compile Include="Computers\Commodore64\Sid.cs" />
<Compile Include="Computers\Commodore64\SidEnvelopeGenerator.cs" />
<Compile Include="Computers\Commodore64\SidSoundProvider.cs" />

View File

@ -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);
}
}
}

View File

@ -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

View File

@ -162,6 +162,15 @@ namespace BizHawk.Emulation.Computers.Commodore64
private Action<byte> WriteData;
private Action<byte> WriteDirection;
public DataPortConnector(DataPortConnector source)
{
ReadData = source.ReadData;
ReadDirection = source.ReadDirection;
ReadRemoteData = source.ReadRemoteData;
WriteData = source.WriteData;
WriteDirection = source.WriteDirection;
}
public DataPortConnector(Func<byte> newReadData, Func<byte> newReadDirection, Func<byte> newReadRemoteData, Action<byte> newWriteData, Action<byte> newWriteDirection)
{
ReadData = newReadData;

View File

@ -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;
}
}
}
}

View File

@ -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)
{
}
}
}