Commodore64: Removed a lot of functions in the motherboard glue to simplify things.

This commit is contained in:
saxxonpike 2013-08-14 05:33:10 +00:00
parent 5c37b64eec
commit 0a54f95b4f
8 changed files with 58 additions and 214 deletions

View File

@ -150,34 +150,34 @@ namespace BizHawk.Emulation.Computers.Commodore64
pla.PokeVic = vic.Poke; pla.PokeVic = vic.Poke;
pla.ReadAEC = vic.ReadAECBuffer; pla.ReadAEC = vic.ReadAECBuffer;
pla.ReadBA = vic.ReadBABuffer; pla.ReadBA = vic.ReadBABuffer;
pla.ReadBasicRom = Pla_ReadBasicRom; pla.ReadBasicRom = basicRom.Read;
pla.ReadCartridgeHi = Pla_ReadCartridgeHi; pla.ReadCartridgeHi = cartPort.ReadHiRom;
pla.ReadCartridgeLo = Pla_ReadCartridgeLo; pla.ReadCartridgeLo = cartPort.ReadLoRom;
pla.ReadCharen = Pla_ReadCharen; pla.ReadCharen = Pla_ReadCharen;
pla.ReadCharRom = Pla_ReadCharRom; pla.ReadCharRom = charRom.Read;
pla.ReadCia0 = Pla_ReadCia0; pla.ReadCia0 = Pla_ReadCia0;
pla.ReadCia1 = Pla_ReadCia1; pla.ReadCia1 = cia1.Read;
pla.ReadColorRam = Pla_ReadColorRam; pla.ReadColorRam = Pla_ReadColorRam;
pla.ReadExpansionHi = Pla_ReadExpansionHi; pla.ReadExpansionHi = cartPort.ReadHiExp;
pla.ReadExpansionLo = Pla_ReadExpansionLo; pla.ReadExpansionLo = cartPort.ReadLoExp;
pla.ReadExRom = cartPort.ReadExRom; pla.ReadExRom = cartPort.ReadExRom;
pla.ReadGame = cartPort.ReadGame; pla.ReadGame = cartPort.ReadGame;
pla.ReadHiRam = Pla_ReadHiRam; pla.ReadHiRam = Pla_ReadHiRam;
pla.ReadKernalRom = Pla_ReadKernalRom; pla.ReadKernalRom = kernalRom.Read;
pla.ReadLoRam = Pla_ReadLoRam; pla.ReadLoRam = Pla_ReadLoRam;
pla.ReadMemory = Pla_ReadMemory; pla.ReadMemory = ram.Read;
pla.ReadSid = Pla_ReadSid; pla.ReadSid = sid.Read;
pla.ReadVic = Pla_ReadVic; pla.ReadVic = vic.Read;
pla.WriteCartridgeHi = Pla_WriteCartridgeHi; pla.WriteCartridgeHi = cartPort.WriteHiRom;
pla.WriteCartridgeLo = Pla_WriteCartridgeLo; pla.WriteCartridgeLo = cartPort.WriteLoRom;
pla.WriteCia0 = Pla_WriteCia0; pla.WriteCia0 = cia0.Write;
pla.WriteCia1 = Pla_WriteCia1; pla.WriteCia1 = cia1.Write;
pla.WriteColorRam = Pla_WriteColorRam; pla.WriteColorRam = colorRam.Write;
pla.WriteExpansionHi = Pla_WriteExpansionHi; pla.WriteExpansionHi = cartPort.WriteHiExp;
pla.WriteExpansionLo = Pla_WriteExpansionLo; pla.WriteExpansionLo = cartPort.WriteLoExp;
pla.WriteMemory = Pla_WriteMemory; pla.WriteMemory = ram.Write;
pla.WriteSid = Pla_WriteSid; pla.WriteSid = sid.Write;
pla.WriteVic = Pla_WriteVic; pla.WriteVic = vic.Write;
serPort.ReadAtnOut = SerPort_ReadAtnOut; serPort.ReadAtnOut = SerPort_ReadAtnOut;
serPort.ReadClockOut = SerPort_ReadClockOut; serPort.ReadClockOut = SerPort_ReadClockOut;

View File

@ -9,8 +9,6 @@ namespace BizHawk.Emulation.Computers.Commodore64
{ {
public partial class Motherboard public partial class Motherboard
{ {
bool CassPort_ReadDataOutput() bool CassPort_ReadDataOutput()
{ {
return (cpu.PortData & 0x08) != 0; return (cpu.PortData & 0x08) != 0;
@ -64,6 +62,14 @@ namespace BizHawk.Emulation.Computers.Commodore64
return (userPort.ReadSerial2Buffer() && cia1.ReadSPBuffer()); return (userPort.ReadSerial2Buffer() && cia1.ReadSPBuffer());
} }
byte Cpu_ReadMemory(int addr)
{
byte result = pla.ReadMemory(addr);
address = addr;
bus = result;
return result;
}
byte Cpu_ReadPort() byte Cpu_ReadPort()
{ {
byte data = 0x1F; byte data = 0x1F;
@ -72,80 +78,36 @@ namespace BizHawk.Emulation.Computers.Commodore64
return data; return data;
} }
void Cpu_WriteMemory(int addr, byte val)
{
pla.WriteMemory(addr, val);
address = addr;
bus = val;
}
bool Glue_ReadIRQ() bool Glue_ReadIRQ()
{ {
return cia0.ReadIRQBuffer() & vic.ReadIRQBuffer() & cartPort.ReadIRQBuffer(); return cia0.ReadIRQBuffer() & vic.ReadIRQBuffer() & cartPort.ReadIRQBuffer();
} }
byte Pla_ReadBasicRom(int addr)
{
address = addr;
bus = basicRom.Read(addr);
return bus;
}
byte Pla_ReadCartridgeHi(int addr)
{
address = addr;
bus = cartPort.ReadHiRom(addr);
return bus;
}
byte Pla_ReadCartridgeLo(int addr)
{
address = addr;
bus = cartPort.ReadLoRom(addr);
return bus;
}
bool Pla_ReadCharen() bool Pla_ReadCharen()
{ {
return (cpu.PortData & 0x04) != 0; return (cpu.PortData & 0x04) != 0;
} }
byte Pla_ReadCharRom(int addr)
{
address = addr;
bus = charRom.Read(addr);
return bus;
}
byte Pla_ReadCia0(int addr) byte Pla_ReadCia0(int addr)
{ {
address = addr; if (addr == 0xDC00 || addr == 0xDC01)
bus = cia0.Read(addr);
if (!inputRead && (addr == 0xDC00 || addr == 0xDC01))
inputRead = true; inputRead = true;
return bus; return cia0.Read(addr);
}
byte Pla_ReadCia1(int addr)
{
address = addr;
bus = cia1.Read(addr);
return bus;
} }
byte Pla_ReadColorRam(int addr) byte Pla_ReadColorRam(int addr)
{ {
int result;
address = addr; address = addr;
bus &= 0xF0; result = colorRam.Read(addr) | (bus & 0xF0);
bus |= colorRam.Read(addr); return (byte)result;
return bus;
}
byte Pla_ReadExpansionHi(int addr)
{
address = addr;
bus = cartPort.ReadHiExp(addr);
return bus;
}
byte Pla_ReadExpansionLo(int addr)
{
address = addr;
bus = cartPort.ReadLoExp(addr);
return bus;
} }
bool Pla_ReadHiRam() bool Pla_ReadHiRam()
@ -153,109 +115,11 @@ namespace BizHawk.Emulation.Computers.Commodore64
return (cpu.PortData & 0x02) != 0; return (cpu.PortData & 0x02) != 0;
} }
byte Pla_ReadKernalRom(int addr)
{
address = addr;
bus = kernalRom.Read(addr);
return bus;
}
bool Pla_ReadLoRam() bool Pla_ReadLoRam()
{ {
return (cpu.PortData & 0x01) != 0; return (cpu.PortData & 0x01) != 0;
} }
byte Pla_ReadMemory(int addr)
{
address = addr;
bus = ram.Read(addr);
return bus;
}
byte Pla_ReadSid(int addr)
{
address = addr;
bus = sid.Read(addr);
return bus;
}
byte Pla_ReadVic(int addr)
{
address = addr;
bus = vic.Read(addr);
return bus;
}
void Pla_WriteCartridgeHi(int addr, byte val)
{
address = addr;
bus = val;
cartPort.WriteHiRom(addr, val);
}
void Pla_WriteCartridgeLo(int addr, byte val)
{
address = addr;
bus = val;
cartPort.WriteLoRom(addr, val);
}
void Pla_WriteCia0(int addr, byte val)
{
address = addr;
bus = val;
cia0.Write(addr, val);
}
void Pla_WriteCia1(int addr, byte val)
{
address = addr;
bus = val;
cia1.Write(addr, val);
}
void Pla_WriteColorRam(int addr, byte val)
{
address = addr;
bus = val;
colorRam.Write(addr, val);
}
void Pla_WriteExpansionHi(int addr, byte val)
{
address = addr;
bus = val;
cartPort.WriteHiExp(addr, val);
}
void Pla_WriteExpansionLo(int addr, byte val)
{
address = addr;
bus = val;
cartPort.WriteLoExp(addr, val);
}
void Pla_WriteMemory(int addr, byte val)
{
address = addr;
bus = val;
ram.Write(addr, val);
}
void Pla_WriteSid(int addr, byte val)
{
address = addr;
bus = val;
sid.Write(addr, val);
}
void Pla_WriteVic(int addr, byte val)
{
address = addr;
bus = val;
vic.Write(addr, val);
}
bool SerPort_ReadAtnOut() bool SerPort_ReadAtnOut()
{ {
return (cia1.PortBData & 0x08) == 0; return (cia1.PortBData & 0x08) == 0;

View File

@ -21,11 +21,6 @@
return ram[addr & 0x3FF]; return ram[addr & 0x3FF];
} }
public byte Peek(int addr, byte bus)
{
return (byte)(ram[addr & 0x3FF] | (bus & 0xF0));
}
public void Poke(int addr, byte val) public void Poke(int addr, byte val)
{ {
ram[addr & 0x3FF] = (byte)(val & 0xF); ram[addr & 0x3FF] = (byte)(val & 0xF);
@ -33,12 +28,7 @@
public byte Read(int addr) public byte Read(int addr)
{ {
return (byte)(ram[addr & 0x3FF]); return ram[addr & 0x3FF];
}
public byte Read(int addr, byte bus)
{
return (byte)(ram[addr & 0x3FF] | (bus & 0xF0));
} }
public void SyncState(Serializer ser) public void SyncState(Serializer ser)

View File

@ -46,11 +46,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
return rom[addr & addrMask]; return rom[addr & addrMask];
} }
public void Poke(int addr, byte val)
{
// do nothing (this is rom)
}
public byte Read(int addr) public byte Read(int addr)
{ {
return rom[addr & addrMask]; return rom[addr & addrMask];
@ -61,10 +56,5 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
ByteBuffer buffer = new ByteBuffer(rom); ByteBuffer buffer = new ByteBuffer(rom);
ser.Sync("rom", ref buffer); ser.Sync("rom", ref buffer);
} }
public void Write(int addr, byte val)
{
// do nothing (this is rom)
}
} }
} }

View File

@ -30,17 +30,17 @@
public byte Peek(int addr) public byte Peek(int addr)
{ {
return ram[addr]; return ram[addr & 0xFFFF];
} }
public void Poke(int addr, byte val) public void Poke(int addr, byte val)
{ {
ram[addr] = val; ram[addr & 0xFFFF] = val;
} }
public byte Read(int addr) public byte Read(int addr)
{ {
return ram[addr]; return ram[addr & 0xFFFF];
} }
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
@ -51,7 +51,7 @@
public void Write(int addr, byte val) public void Write(int addr, byte val)
{ {
ram[addr] = val; ram[addr & 0xFFFF] = val;
} }
} }
} }

View File

@ -365,7 +365,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
public byte Peek(int addr) public byte Peek(int addr)
{ {
return ReadRegister((addr & 0xF)); return ReadRegister(addr & 0xF);
} }
public void Poke(int addr, byte val) public void Poke(int addr, byte val)

View File

@ -630,8 +630,8 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
private bool filterSelectLoPass; private bool filterSelectLoPass;
private bool filterSelectHiPass; private bool filterSelectHiPass;
private int potCounter; private int potCounter;
private byte potX; private int potX;
private byte potY; private int potY;
private int[] voiceOutput; private int[] voiceOutput;
private Voice[] voices; private Voice[] voices;
private int volume; private int volume;

View File

@ -983,12 +983,12 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
break; break;
case 0x11: case 0x11:
result = (byte)( result = (byte)(
(byte)(yScroll & 0x7) | (yScroll & 0x7) |
(rowSelect ? (byte)0x08 : (byte)0x00) | (rowSelect ? 0x08 : 0x00) |
(displayEnable ? (byte)0x10 : (byte)0x00) | (displayEnable ? 0x10 : 0x00) |
(bitmapMode ? (byte)0x20 : (byte)0x00) | (bitmapMode ? 0x20 : 0x00) |
(extraColorMode ? (byte)0x40 : (byte)0x00) | (extraColorMode ? 0x40 : 0x00) |
(byte)((rasterLine & 0x100) >> 1) ((rasterLine & 0x100) >> 1)
); );
break; break;
case 0x12: case 0x12:
@ -1015,9 +1015,9 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
case 0x16: case 0x16:
result &= 0xC0; result &= 0xC0;
result |= (byte)( result |= (byte)(
(byte)(xScroll & 0x7) | (xScroll & 0x7) |
(columnSelect ? (byte)0x08 : (byte)0x00) | (columnSelect ? 0x08 : 0x00) |
(multicolorMode ? (byte)0x10 : (byte)0x00) (multicolorMode ? 0x10 : 0x00)
); );
break; break;
case 0x17: case 0x17: