Bug fix: Emulator now resets properly

This commit is contained in:
2026-04-24 13:27:42 +01:00
parent ed7c94dacc
commit 0e8462c8a5

View File

@@ -28,6 +28,7 @@ namespace Desktop
public double FrameTime = 0; public double FrameTime = 0;
public bool highSpeed = false; public bool highSpeed = false;
public bool tapeLoaded = false; public bool tapeLoaded = false;
private volatile bool _pendingReset = false;
public Form1() public Form1()
@@ -78,7 +79,21 @@ namespace Desktop
long audioSampleCount = 0; long audioSampleCount = 0;
while (_isRunning) 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) if (_isPaused)
{ {
@@ -277,6 +292,7 @@ namespace Desktop
private void btnReset_Click(object sender, EventArgs e) private void btnReset_Click(object sender, EventArgs e)
{ {
_pendingReset = true;
_isPaused = true; _isPaused = true;
_cpu.Reset(); _cpu.Reset();
_memoryBus.CleanRAMData(); _memoryBus.CleanRAMData();