From 63f74c7b23bd861c3873266ae7ba759ee30d8af6 Mon Sep 17 00:00:00 2001 From: Ian C Date: Wed, 11 Jul 2012 23:15:47 +0000 Subject: Added an opcode-level callback method for running the CPU. Added a simple mode to the clock. --- src/Noddybox.Emulation.EightBit/ICpu.cs | 2 +- src/Noddybox.Emulation/Clock.cs | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'src') 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. /// 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. - public delegate bool CpuCallback(object sender); + public delegate bool CpuCallback(ICpu sender); /// /// 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 /// - /// Defines a clock. + /// Defines a clock based on a raster display. /// /// The number of cycles per line. /// Cycles taken for the VBL at the end of the frame. @@ -189,6 +196,8 @@ namespace Noddybox.Emulation /// The number of raster lines before the VBL. 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(); } + /// + /// Defines a simple clock which is simply used to record ticks, must be manually reset and will not raise events. + /// + public Clock() + { + TotalCyclesPerFrame = 0; + this.simple = true; + Reset(); + } + #endregion } } -- cgit v1.2.3