Commodore64: Mobo glue for the experimental framework is complete.
This commit is contained in:
parent
9cc6936b89
commit
30174b9b9c
|
@ -104,6 +104,9 @@
|
|||
<Compile Include="Computers\Commodore64\Experimental\C64PAL.cs" />
|
||||
<Compile Include="Computers\Commodore64\Experimental\Chips\Internals\Cia.Interface.cs" />
|
||||
<Compile Include="Computers\Commodore64\Experimental\Chips\Internals\Cia.Internal.cs" />
|
||||
<Compile Include="Computers\Commodore64\Experimental\Chips\Internals\Sid.SoundProvider.cs" />
|
||||
<Compile Include="Computers\Commodore64\Experimental\Chips\Internals\Userport.cs" />
|
||||
<Compile Include="Computers\Commodore64\Experimental\Chips\Internals\Vic.VideoProvider.cs" />
|
||||
<Compile Include="Computers\Commodore64\Experimental\IMotherboard.cs" />
|
||||
<Compile Include="Computers\Commodore64\Experimental\Chips\Internals\Cpu.Interface.cs" />
|
||||
<Compile Include="Computers\Commodore64\Experimental\Chips\Internals\Cpu.Internal.cs" />
|
||||
|
|
|
@ -9,10 +9,104 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental
|
|||
{
|
||||
public void InitializeConnections()
|
||||
{
|
||||
|
||||
basicRom.InputAddress = ReadAddress;
|
||||
basicRom.InputData = ReadData;
|
||||
|
||||
characterRom.InputAddress = ReadAddress;
|
||||
characterRom.InputData = ReadData;
|
||||
|
||||
cia1.InputAddress = ReadAddress;
|
||||
cia1.InputClock = vic.OutputPHI0;
|
||||
cia1.InputCNT = user.OutputCNT1;
|
||||
cia1.InputData = ReadData;
|
||||
cia1.InputFlag = ReadCia1Flag;
|
||||
cia1.InputPortA = ReadCia1PortA;
|
||||
cia1.InputPortB = ReadCia1PortB;
|
||||
cia1.InputRead = cpu.OutputRead;
|
||||
cia1.InputReset = ReadReset;
|
||||
cia1.InputSP = user.OutputSP1;
|
||||
|
||||
cia2.InputAddress = ReadAddress;
|
||||
cia2.InputClock = vic.OutputPHI0;
|
||||
cia2.InputCNT = user.OutputCNT2;
|
||||
cia2.InputData = ReadData;
|
||||
cia2.InputFlag = user.OutputFLAG2;
|
||||
cia2.InputPortA = ReadCia2PortA;
|
||||
cia2.InputPortB = user.OutputData;
|
||||
cia2.InputRead = cpu.OutputRead;
|
||||
cia2.InputReset = ReadReset;
|
||||
cia2.InputSP = user.OutputSP2;
|
||||
|
||||
colorRam.InputAddress = ReadAddress;
|
||||
colorRam.InputData = ReadData;
|
||||
colorRam.InputRead = cpu.OutputRead;
|
||||
|
||||
cpu.InputAddress = ReadAddress;
|
||||
cpu.InputAEC = vic.OutputAEC;
|
||||
cpu.InputClock = vic.OutputPHI0;
|
||||
cpu.InputData = ReadData;
|
||||
cpu.InputIRQ = ReadIRQ;
|
||||
cpu.InputNMI = ReadNMI;
|
||||
cpu.InputPort = ReadCPUPort;
|
||||
cpu.InputRDY = vic.OutputBA;
|
||||
cpu.InputReset = ReadReset;
|
||||
|
||||
expansion.InputAddress = ReadAddress;
|
||||
expansion.InputBA = vic.OutputBA;
|
||||
expansion.InputData = ReadData;
|
||||
expansion.InputDotClock = vic.OutputPixelClock;
|
||||
expansion.InputHiExpansion = ReadHiExpansion;
|
||||
expansion.InputHiRom = pla.OutputRomHi;
|
||||
expansion.InputIRQ = ReadIRQ;
|
||||
expansion.InputLoExpansion = ReadLoExpansion;
|
||||
expansion.InputLoRom = pla.OutputRomLo;
|
||||
expansion.InputNMI = ReadNMI;
|
||||
expansion.InputRead = cpu.OutputRead;
|
||||
expansion.InputReset = ReadReset;
|
||||
|
||||
kernalRom.InputAddress = ReadAddress;
|
||||
kernalRom.InputData = ReadData;
|
||||
|
||||
memory.InputAddress = ReadAddress;
|
||||
memory.InputData = ReadData;
|
||||
memory.InputRead = cpu.OutputRead;
|
||||
|
||||
pla.InputAddress = ReadAddress;
|
||||
pla.InputAEC = vic.OutputAEC;
|
||||
pla.InputBA = vic.OutputBA;
|
||||
pla.InputCAS = vic.OutputCAS;
|
||||
pla.InputCharen = ReadCharen;
|
||||
pla.InputExRom = expansion.OutputExRom;
|
||||
pla.InputGame = expansion.OutputGame;
|
||||
pla.InputHiRam = ReadHiRam;
|
||||
pla.InputLoRam = ReadLoRam;
|
||||
pla.InputRead = cpu.OutputRead;
|
||||
pla.InputVA = ReadVicAddress;
|
||||
|
||||
serial.InputATN = ReadSerialATN;
|
||||
serial.InputClock = ReadSerialCLK;
|
||||
serial.InputData = ReadSerialDTA;
|
||||
serial.InputReset = ReadReset;
|
||||
|
||||
sid.InputAddress = ReadAddress;
|
||||
sid.InputData = ReadData;
|
||||
sid.InputRead = cpu.OutputRead;
|
||||
|
||||
user.InputCNT1 = cia1.OutputCNT;
|
||||
user.InputCNT2 = cia2.OutputCNT;
|
||||
user.InputData = cia2.OutputPortB;
|
||||
user.InputPA2 = ReadUserPA2;
|
||||
user.InputPC2 = cia2.OutputPC;
|
||||
user.InputReset = ReadReset;
|
||||
user.InputSP1 = cia1.OutputSP;
|
||||
user.InputSP2 = cia2.OutputSP;
|
||||
|
||||
vic.InputAddress = ReadAddress;
|
||||
vic.InputData = ReadData;
|
||||
vic.InputRead = cpu.OutputRead;
|
||||
}
|
||||
|
||||
public int ReadAddress()
|
||||
int ReadAddress()
|
||||
{
|
||||
int addr = 0xFFFF;
|
||||
addr &= cpu.Address;
|
||||
|
@ -21,7 +115,50 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental
|
|||
return addr;
|
||||
}
|
||||
|
||||
public int ReadData()
|
||||
bool ReadCharen()
|
||||
{
|
||||
return (cpu.Port & 0x4) != 0;
|
||||
}
|
||||
|
||||
bool ReadCia1Cnt()
|
||||
{
|
||||
// this pin is not connected
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReadCia1Flag()
|
||||
{
|
||||
return serial.SRQ && cassette.Data;
|
||||
}
|
||||
|
||||
int ReadCia1PortA()
|
||||
{
|
||||
return (joystickB.Data | 0xE0) & keyboard.Column;
|
||||
}
|
||||
|
||||
int ReadCia1PortB()
|
||||
{
|
||||
return (joystickA.Data | 0xE0) & keyboard.Row;
|
||||
}
|
||||
|
||||
int ReadCia2PortA()
|
||||
{
|
||||
int result = 0xFF;
|
||||
if (!user.PA2)
|
||||
result &= 0xFB;
|
||||
if (!serial.Clock)
|
||||
result &= 0xBF;
|
||||
if (!serial.Data)
|
||||
result &= 0x7F;
|
||||
return result;
|
||||
}
|
||||
|
||||
int ReadCPUPort()
|
||||
{
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
int ReadData()
|
||||
{
|
||||
int data = 0xFF;
|
||||
data &= expansion.Data;
|
||||
|
@ -33,13 +170,89 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental
|
|||
data &= colorRam.Data;
|
||||
if (pla.IO)
|
||||
{
|
||||
data &= cia1.Data;
|
||||
data &= cia2.Data;
|
||||
data &= sid.Data;
|
||||
data &= vic.Data;
|
||||
}
|
||||
data &= cpu.Data;
|
||||
data &= kernalRom.Data;
|
||||
data &= memory.Data;
|
||||
if (vic.BA)
|
||||
data &= cpu.Data;
|
||||
if (pla.Kernal)
|
||||
data &= kernalRom.Data;
|
||||
if (pla.CASRam)
|
||||
data &= memory.Data;
|
||||
return data;
|
||||
}
|
||||
|
||||
bool ReadHiExpansion()
|
||||
{
|
||||
int addr = ReadAddress();
|
||||
return (addr >= 0xDF00 && addr < 0xE000);
|
||||
}
|
||||
|
||||
bool ReadHiRam()
|
||||
{
|
||||
return (cpu.Port & 0x2) != 0;
|
||||
}
|
||||
|
||||
bool ReadIRQ()
|
||||
{
|
||||
return (
|
||||
cia1.IRQ &&
|
||||
vic.IRQ &&
|
||||
expansion.IRQ
|
||||
);
|
||||
}
|
||||
|
||||
bool ReadLoExpansion()
|
||||
{
|
||||
int addr = ReadAddress();
|
||||
return (addr >= 0xDE00 && addr < 0xDF00);
|
||||
}
|
||||
|
||||
bool ReadLoRam()
|
||||
{
|
||||
return (cpu.Port & 0x1) != 0;
|
||||
}
|
||||
|
||||
bool ReadNMI()
|
||||
{
|
||||
return (
|
||||
cia2.IRQ &&
|
||||
expansion.NMI
|
||||
);
|
||||
}
|
||||
|
||||
bool ReadReset()
|
||||
{
|
||||
return (
|
||||
expansion.Reset
|
||||
);
|
||||
}
|
||||
|
||||
bool ReadSerialATN()
|
||||
{
|
||||
return (cia2.PortA & 0x08) != 0;
|
||||
}
|
||||
|
||||
bool ReadSerialCLK()
|
||||
{
|
||||
return (cia2.PortA & 0x10) != 0;
|
||||
}
|
||||
|
||||
bool ReadSerialDTA()
|
||||
{
|
||||
return (cia2.PortA & 0x20) != 0;
|
||||
}
|
||||
|
||||
bool ReadUserPA2()
|
||||
{
|
||||
return (cia2.PortA & 0x04) != 0;
|
||||
}
|
||||
|
||||
int ReadVicAddress()
|
||||
{
|
||||
return (vic.Address | ((cia2.PortA & 0x3) << 14));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental
|
|||
Rom basicRom;
|
||||
Cassette cassette;
|
||||
Rom characterRom;
|
||||
Cia cia1;
|
||||
Cia cia2;
|
||||
Ram colorRam;
|
||||
Cpu cpu;
|
||||
Expansion expansion;
|
||||
|
@ -22,6 +24,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental
|
|||
Pla pla;
|
||||
Serial serial;
|
||||
Sid sid;
|
||||
Userport user;
|
||||
Vic vic;
|
||||
|
||||
public C64(C64Timing timing)
|
||||
|
|
|
@ -22,7 +22,9 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
|
|||
public int OutputAddress() { return Address; }
|
||||
public int OutputData() { return Data; }
|
||||
public int OutputPort() { return Port; }
|
||||
public bool OutputRead() { return Read; }
|
||||
virtual public int Port { get { return 0xFF; } }
|
||||
virtual public bool Read { get { return true; } }
|
||||
virtual public void Precache() { }
|
||||
virtual public void SyncState(Serializer ser) { }
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
|
|||
{
|
||||
public class Ram : Rom
|
||||
{
|
||||
public Func<bool> InputWrite;
|
||||
public Func<bool> InputRead;
|
||||
|
||||
public Ram(int size, int addressMask, int dataMask)
|
||||
: base(size, addressMask, dataMask)
|
||||
|
@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
|
|||
|
||||
virtual public void Execute()
|
||||
{
|
||||
if (InputWrite())
|
||||
if (!InputRead())
|
||||
memory[InputAddress() & addressMask] = InputData() & dataMask;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
|
||||
{
|
||||
public partial class Sid
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
|
||||
{
|
||||
public class Userport
|
||||
{
|
||||
public Func<bool> InputCNT1;
|
||||
public Func<bool> InputCNT2;
|
||||
public Func<int> InputData;
|
||||
public Func<bool> InputPA2;
|
||||
public Func<bool> InputPC2;
|
||||
public Func<bool> InputReset;
|
||||
public Func<bool> InputSP1;
|
||||
public Func<bool> InputSP2;
|
||||
|
||||
virtual public bool ATN { get { return true; } }
|
||||
virtual public bool CNT1 { get { return true; } }
|
||||
virtual public bool CNT2 { get { return true; } }
|
||||
virtual public int Data { get { return 0xFF; } }
|
||||
virtual public bool FLAG2 { get { return true; } }
|
||||
public bool OutputATN() { return ATN; }
|
||||
public bool OutputCNT1() { return CNT1; }
|
||||
public bool OutputCNT2() { return CNT2; }
|
||||
public int OutputData() { return Data; }
|
||||
public bool OutputFLAG2() { return FLAG2; }
|
||||
public bool OutputPA2() { return PA2; }
|
||||
public bool OutputReset() { return Reset; }
|
||||
public bool OutputSP1() { return SP1; }
|
||||
public bool OutputSP2() { return SP2; }
|
||||
virtual public bool PA2 { get { return true; } }
|
||||
virtual public bool Reset { get { return true; } }
|
||||
virtual public bool SP1 { get { return true; } }
|
||||
virtual public bool SP2 { get { return true; } }
|
||||
}
|
||||
}
|
|
@ -103,6 +103,11 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
|
|||
return PHI0;
|
||||
}
|
||||
|
||||
public bool OutputPixelClock()
|
||||
{
|
||||
return PixelClock;
|
||||
}
|
||||
|
||||
public bool OutputRAS()
|
||||
{
|
||||
return RAS;
|
||||
|
@ -116,6 +121,14 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
|
|||
}
|
||||
}
|
||||
|
||||
virtual public bool PixelClock
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
virtual public bool RAS
|
||||
{
|
||||
get
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
|
||||
{
|
||||
public abstract partial class Vic : IVideoProvider
|
||||
{
|
||||
protected int[] videoBuffer;
|
||||
|
||||
public int[] GetVideoBuffer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int VirtualWidth
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public int BufferWidth
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public int BufferHeight
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public int BackgroundColor
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue