mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2024-12-23 17:31:33 +00:00
03caba99dc
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
38 lines
791 B
C#
38 lines
791 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)
|
|
{
|
|
this.Tick();
|
|
}
|
|
}
|
|
|
|
public void Tick()
|
|
{
|
|
++this.Cycles;
|
|
this.OnTicked();
|
|
}
|
|
|
|
protected virtual void OnTicked() => this.Ticked?.Invoke(this, EventArgs.Empty);
|
|
|
|
protected void ResetCycles() => this.Cycles = 0;
|
|
}
|
|
}
|