Commodore64 CIA - registers implemented
This commit is contained in:
parent
2c25ae5701
commit
dbba216ec7
|
@ -8,13 +8,42 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
public class Cia
|
public class Cia
|
||||||
{
|
{
|
||||||
public int cycles;
|
public int cycles;
|
||||||
|
public bool flagPin;
|
||||||
|
public bool interrupt;
|
||||||
public byte[] regs;
|
public byte[] regs;
|
||||||
|
public bool serialData;
|
||||||
public Cia()
|
public bool serialReady;
|
||||||
|
public int shiftRegisterCycles;
|
||||||
|
public bool shiftRegisterInterrupt;
|
||||||
|
public bool shiftRegisterInterruptEnabled;
|
||||||
|
public bool shiftRegisterIsOutput;
|
||||||
|
public bool timeOfDayAlarmInterrupt;
|
||||||
|
public bool timeOfDayAlarmInterruptEnabled;
|
||||||
|
public bool underflowTimerAInterrupt;
|
||||||
|
public bool underflowTimerAInterruptEnabled;
|
||||||
|
public bool underflowTimerBInterrupt;
|
||||||
|
public bool underflowTimerBInterruptEnabled;
|
||||||
|
|
||||||
|
public Func<byte> ReadPortA;
|
||||||
|
public Func<byte> ReadPortB;
|
||||||
|
public Action<byte, byte> WritePortA;
|
||||||
|
public Action<byte, byte> WritePortB;
|
||||||
|
|
||||||
|
public Cia(Func<byte> funcReadPortA, Func<byte> funcReadPortB, Action<byte, byte> actWritePortA, Action<byte, byte> actWritePortB)
|
||||||
{
|
{
|
||||||
regs = new byte[0x10];
|
regs = new byte[0x10];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public byte DummyReadPort()
|
||||||
|
{
|
||||||
|
return 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
static public void DummyWritePort(byte val, byte direction)
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
public void PerformCycle()
|
public void PerformCycle()
|
||||||
{
|
{
|
||||||
unchecked
|
unchecked
|
||||||
|
@ -30,38 +59,21 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
switch (addr & 0x0F)
|
switch (addr & 0x0F)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
|
result = ReadPortA();
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
case 0x01:
|
||||||
break;
|
result = ReadPortB();
|
||||||
case 0x02:
|
|
||||||
break;
|
|
||||||
case 0x03:
|
|
||||||
break;
|
|
||||||
case 0x04:
|
|
||||||
break;
|
|
||||||
case 0x05:
|
|
||||||
break;
|
|
||||||
case 0x06:
|
|
||||||
break;
|
|
||||||
case 0x07:
|
|
||||||
break;
|
|
||||||
case 0x08:
|
|
||||||
break;
|
|
||||||
case 0x09:
|
|
||||||
break;
|
|
||||||
case 0x0A:
|
|
||||||
break;
|
|
||||||
case 0x0B:
|
|
||||||
break;
|
|
||||||
case 0x0C:
|
|
||||||
break;
|
break;
|
||||||
case 0x0D:
|
case 0x0D:
|
||||||
break;
|
result = regs[addr];
|
||||||
case 0x0E:
|
shiftRegisterInterrupt = false;
|
||||||
break;
|
timeOfDayAlarmInterrupt = false;
|
||||||
case 0x0F:
|
underflowTimerAInterrupt = false;
|
||||||
|
underflowTimerBInterrupt = false;
|
||||||
|
interrupt = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
result = regs[addr];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,8 +85,10 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
switch (addr & 0x0F)
|
switch (addr & 0x0F)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
|
WritePortA(val, regs[0x02]);
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
case 0x01:
|
||||||
|
WritePortB(val, regs[0x03]);
|
||||||
break;
|
break;
|
||||||
case 0x02:
|
case 0x02:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -266,7 +266,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
result = sid.Read(addr);
|
result = sid.Read(addr);
|
||||||
break;
|
break;
|
||||||
case MemoryBusDesignation.ColorRam:
|
case MemoryBusDesignation.ColorRam:
|
||||||
result = (byte)((busData & 0xF0) | (colorRam[addr & 0x03FF]));
|
result = ReadColorRam(addr);
|
||||||
break;
|
break;
|
||||||
case MemoryBusDesignation.Cia1:
|
case MemoryBusDesignation.Cia1:
|
||||||
result = cia1.Read(addr);
|
result = cia1.Read(addr);
|
||||||
|
@ -301,6 +301,11 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte ReadColorRam(ushort addr)
|
||||||
|
{
|
||||||
|
return (byte)((busData & 0xF0) | (colorRam[addr & 0x03FF]));
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateLayout()
|
public void UpdateLayout()
|
||||||
{
|
{
|
||||||
bool loRom = ((cpu01 & 0x01) != 0);
|
bool loRom = ((cpu01 & 0x01) != 0);
|
||||||
|
@ -390,6 +395,11 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte VicRead(ushort addr)
|
||||||
|
{
|
||||||
|
return Read(addr);
|
||||||
|
}
|
||||||
|
|
||||||
public void WipeMemory()
|
public void WipeMemory()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 0x10000; i += 0x80)
|
for (int i = 0; i < 0x10000; i += 0x80)
|
||||||
|
|
|
@ -153,8 +153,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
|
||||||
|
|
||||||
if (rasterInterruptEnabled && (rasterOffsetY == rasterInterruptLine) && (rasterOffsetX == 0))
|
if (rasterInterruptEnabled && (rasterOffsetY == rasterInterruptLine) && (rasterOffsetX == 0))
|
||||||
{
|
{
|
||||||
// removed for now
|
rasterInterrupt = true;
|
||||||
//rasterInterrupt = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interrupt =
|
interrupt =
|
||||||
|
|
Loading…
Reference in New Issue