//
// Copyright (c) Adrian Conlon. All rights reserved.
//
using System.Runtime.CompilerServices;
namespace EightBit
{
public class ClockedChip : Chip
{
protected ClockedChip()
{
}
public event EventHandler? Ticked;
public int Cycles { get; protected set; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Tick(int extra = 1)
{
this.Cycles += extra;
for (var i = 0; i < extra; ++i)
{
this.Ticked?.Invoke(this, EventArgs.Empty);
}
}
protected void ResetCycles() => this.Cycles = 0;
}
}