2012-11-27 05:11:40 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Emulation.Computers.Commodore64.MOS
|
|
|
|
|
{
|
|
|
|
|
// base class for MOS Technology timer chips
|
|
|
|
|
|
|
|
|
|
public abstract class Timer
|
|
|
|
|
{
|
|
|
|
|
protected bool pinIRQ;
|
|
|
|
|
protected uint[] timer;
|
|
|
|
|
protected uint[] timerLatch;
|
|
|
|
|
protected bool[] timerOn;
|
2012-11-28 17:26:40 +00:00
|
|
|
|
protected bool[] underflow;
|
2012-11-27 05:11:40 +00:00
|
|
|
|
|
2012-12-07 17:06:07 +00:00
|
|
|
|
public Func<byte> ReadDirA = (() => { return 0xFF; });
|
|
|
|
|
public Func<byte> ReadDirB = (() => { return 0xFF; });
|
|
|
|
|
public Func<byte> ReadPortA = (() => { return 0xFF; });
|
|
|
|
|
public Func<byte> ReadPortB = (() => { return 0xFF; });
|
|
|
|
|
public Action<byte> WriteDirA = ((byte val) => { });
|
|
|
|
|
public Action<byte> WriteDirB = ((byte val) => { });
|
|
|
|
|
public Action<byte> WritePortA = ((byte val) => { });
|
|
|
|
|
public Action<byte> WritePortB = ((byte val) => { });
|
2012-12-05 21:07:51 +00:00
|
|
|
|
|
2012-11-27 05:11:40 +00:00
|
|
|
|
public Timer()
|
|
|
|
|
{
|
|
|
|
|
timer = new uint[2];
|
|
|
|
|
timerLatch = new uint[2];
|
|
|
|
|
timerOn = new bool[2];
|
2012-11-28 17:26:40 +00:00
|
|
|
|
underflow = new bool[2];
|
2012-11-27 05:11:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void HardResetInternal()
|
|
|
|
|
{
|
2012-12-07 17:06:07 +00:00
|
|
|
|
WriteDirA(0x00);
|
|
|
|
|
WriteDirB(0x00);
|
2012-11-27 05:11:40 +00:00
|
|
|
|
timer[0] = 0xFFFF;
|
|
|
|
|
timer[1] = 0xFFFF;
|
|
|
|
|
timerLatch[0] = timer[0];
|
|
|
|
|
timerLatch[1] = timer[1];
|
|
|
|
|
pinIRQ = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IRQ
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return pinIRQ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void SyncInternal(Serializer ser)
|
|
|
|
|
{
|
2012-12-03 07:43:11 +00:00
|
|
|
|
ser.Sync("pinIRQ", ref pinIRQ);
|
|
|
|
|
ser.Sync("timer0", ref timer[0]);
|
|
|
|
|
ser.Sync("timer1", ref timer[1]);
|
|
|
|
|
ser.Sync("timerLatch0", ref timerLatch[0]);
|
|
|
|
|
ser.Sync("timerLatch1", ref timerLatch[1]);
|
|
|
|
|
ser.Sync("timerOn0", ref timerOn[0]);
|
|
|
|
|
ser.Sync("timerOn1", ref timerOn[1]);
|
|
|
|
|
ser.Sync("underflow0", ref underflow[0]);
|
|
|
|
|
ser.Sync("underflow1", ref underflow[1]);
|
2012-11-27 05:11:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|