Cycles count needs to be correct per clock tick

This commit is contained in:
Adrian Conlon committed 2026-06-10 20:12:24 +01:00
1 parent 39561437e9
commit b9b1b96c42
1 file changed
+8 -6
+8 -6
View File
@@ -19,14 +19,16 @@ namespace EightBit
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Tick(int extra = 1)
{
this.Cycles += extra;
var ticked = this.Ticked;
if (ticked is not null)
if (ticked is null)
{
for (var i = 0; i < extra; ++i)
{
ticked.Invoke(this, EventArgs.Empty);
}
this.Cycles += extra;
return;
}
for (var i = 0; i < extra; ++i)
{
++this.Cycles;
ticked.Invoke(this, EventArgs.Empty);
}
}