Files
EightBitNet/EightBit/ClockedChip.cs
2024-10-09 20:05:37 +01:00

38 lines
767 B
C#

// <copyright file="ClockedChip.cs" company="Adrian Conlon">
// Copyright (c) Adrian Conlon. All rights reserved.
// </copyright>
namespace EightBit
{
using System;
public class ClockedChip : Chip
{
protected ClockedChip()
{
}
public event EventHandler<EventArgs>? Ticked;
public int Cycles { get; protected set; }
public void Tick(int extra)
{
for (var 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;
}
}