mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2024-12-23 17:31:33 +00:00
9a06b1743f
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
32 lines
650 B
C#
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;
|
|
}
|
|
}
|