Commodore64 CIA - registers implemented

This commit is contained in:
saxxonpike 2012-11-03 07:05:07 +00:00
parent 2c25ae5701
commit dbba216ec7
3 changed files with 54 additions and 31 deletions

View File

@ -8,13 +8,42 @@ namespace BizHawk.Emulation.Computers.Commodore64
public class Cia
{
public int cycles;
public bool flagPin;
public bool interrupt;
public byte[] regs;
public Cia()
public bool serialData;
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];
}
static public byte DummyReadPort()
{
return 0xFF;
}
static public void DummyWritePort(byte val, byte direction)
{
// do nothing
}
public void PerformCycle()
{
unchecked
@ -30,38 +59,21 @@ namespace BizHawk.Emulation.Computers.Commodore64
switch (addr & 0x0F)
{
case 0x00:
result = ReadPortA();
break;
case 0x01:
break;
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:
result = ReadPortB();
break;
case 0x0D:
break;
case 0x0E:
break;
case 0x0F:
result = regs[addr];
shiftRegisterInterrupt = false;
timeOfDayAlarmInterrupt = false;
underflowTimerAInterrupt = false;
underflowTimerBInterrupt = false;
interrupt = false;
break;
default:
result = regs[addr];
break;
}
@ -73,8 +85,10 @@ namespace BizHawk.Emulation.Computers.Commodore64
switch (addr & 0x0F)
{
case 0x00:
WritePortA(val, regs[0x02]);
break;
case 0x01:
WritePortB(val, regs[0x03]);
break;
case 0x02:
break;

View File

@ -266,7 +266,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
result = sid.Read(addr);
break;
case MemoryBusDesignation.ColorRam:
result = (byte)((busData & 0xF0) | (colorRam[addr & 0x03FF]));
result = ReadColorRam(addr);
break;
case MemoryBusDesignation.Cia1:
result = cia1.Read(addr);
@ -301,6 +301,11 @@ namespace BizHawk.Emulation.Computers.Commodore64
return result;
}
public byte ReadColorRam(ushort addr)
{
return (byte)((busData & 0xF0) | (colorRam[addr & 0x03FF]));
}
public void UpdateLayout()
{
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()
{
for (int i = 0; i < 0x10000; i += 0x80)

View File

@ -153,8 +153,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
if (rasterInterruptEnabled && (rasterOffsetY == rasterInterruptLine) && (rasterOffsetX == 0))
{
// removed for now
//rasterInterrupt = true;
rasterInterrupt = true;
}
interrupt =