EightBitNet/EightBit/ClockedChip.cs
Adrian Conlon 9a06b1743f Port of EightBit library to .Net (unworking!)
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
2019-02-02 15:12:51 +00:00

32 lines
650 B
C#

namespace EightBit
{
using System;
public class ClockedChip : Chip
{
private int cycles;
protected ClockedChip() { }
public int Cycles { get => cycles; protected set => cycles = value; }
public event EventHandler<EventArgs> Ticked;
public void Tick(int extra)
{
for (int i = 0; i < extra; ++i)
Tick();
}
public void Tick()
{
++Cycles;
OnTicked();
}
protected virtual void OnTicked() => Ticked?.Invoke(this, EventArgs.Empty);
protected void ResetCycles() => Cycles = 0;
}
}