diff options
-rw-r--r-- | src/Noddybox.Emulation.EightBit/ICpu.cs | 2 | ||||
-rw-r--r-- | src/Noddybox.Emulation/Clock.cs | 23 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/Noddybox.Emulation.EightBit/ICpu.cs b/src/Noddybox.Emulation.EightBit/ICpu.cs index 1ee7781..39e31cb 100644 --- a/src/Noddybox.Emulation.EightBit/ICpu.cs +++ b/src/Noddybox.Emulation.EightBit/ICpu.cs @@ -26,7 +26,7 @@ namespace Noddybox.Emulation.EightBit /// the callback.</param>
/// <returns>True if the CPU should continue executing, or false if not. Users should simply
/// return Clock.VBL if they need no other than clock control.</returns>
- public delegate bool CpuCallback(object sender);
+ public delegate bool CpuCallback(ICpu sender);
/// <summary>
/// Defines an 8-bit CPU.
diff --git a/src/Noddybox.Emulation/Clock.cs b/src/Noddybox.Emulation/Clock.cs index 4765086..263f15d 100644 --- a/src/Noddybox.Emulation/Clock.cs +++ b/src/Noddybox.Emulation/Clock.cs @@ -34,6 +34,8 @@ namespace Noddybox.Emulation private int line;
private uint cycles;
+ private bool simple;
+
#endregion
#region Private Members
@@ -120,6 +122,11 @@ namespace Noddybox.Emulation cycles += ticks;
CycleCount += ticks;
+ if (simple)
+ {
+ return;
+ }
+
// Check pre-frame end
//
if (line == -1 && cycles >= cyclesPreFrame)
@@ -173,7 +180,7 @@ namespace Noddybox.Emulation public void Reset()
{
line = -1;
- cycles = noLines;
+ cycles = 0;
}
#endregion
@@ -181,7 +188,7 @@ namespace Noddybox.Emulation #region Constructors
/// <summary>
- /// Defines a clock.
+ /// Defines a clock based on a raster display.
/// </summary>
/// <param name="cyclesPerLine">The number of cycles per line.</param>
/// <param name="cyclesPerVbl">Cycles taken for the VBL at the end of the frame.</param>
@@ -189,6 +196,8 @@ namespace Noddybox.Emulation /// <param name="noLines">The number of raster lines before the VBL.</param>
public Clock(uint cyclesPreFrame, uint cyclesPerLine, uint noLines, uint cyclesPerVbl)
{
+ this.simple = false;
+
this.cyclesPreFrame = cyclesPreFrame;
this.cyclesPerLine = cyclesPerLine;
this.noLines = noLines;
@@ -199,6 +208,16 @@ namespace Noddybox.Emulation Reset();
}
+ /// <summary>
+ /// Defines a simple clock which is simply used to record ticks, must be manually reset and will not raise events.
+ /// </summary>
+ public Clock()
+ {
+ TotalCyclesPerFrame = 0;
+ this.simple = true;
+ Reset();
+ }
+
#endregion
}
}
|