diff --git a/Desktop/Form1.cs b/Desktop/Form1.cs index 8d79c28..3f0f4c7 100644 --- a/Desktop/Form1.cs +++ b/Desktop/Form1.cs @@ -28,6 +28,7 @@ namespace Desktop public double FrameTime = 0; public bool highSpeed = false; public bool tapeLoaded = false; + private volatile bool _pendingReset = false; public Form1() @@ -78,7 +79,21 @@ namespace Desktop long audioSampleCount = 0; while (_isRunning) - { + { + if (_pendingReset) + { + _cpu.Reset(); + _memoryBus.CrapRAMData(); // Important! If RAM has garbage, the ROM boots instantly. If it has old data, it fails the RAM check! + + // Reset all local loop timing variables + TotalFrameCount = 0; + scanlineCount = 0; + audioSampleCount = 0; + nextScanlineTarget = TStatesPerFrame; + stopwatch.Restart(); + + _pendingReset = false; + } if (_isPaused) { @@ -277,6 +292,7 @@ namespace Desktop private void btnReset_Click(object sender, EventArgs e) { + _pendingReset = true; _isPaused = true; _cpu.Reset(); _memoryBus.CleanRAMData();