diff --git a/Core/CPU.cpp b/Core/CPU.cpp index 3671a2c9..7a2a99c6 100644 --- a/Core/CPU.cpp +++ b/Core/CPU.cpp @@ -86,7 +86,7 @@ void CPU::Reset(bool softReset, NesModel model) _spriteDmaOffset = 0; _needHalt = false; _dmcDmaRunning = false; - _warnOnCrash = true; + _lastCrashWarning = 0; //Used by NSF code to disable Frame Counter & DMC interrupts _irqMask = 0xFF; @@ -293,27 +293,26 @@ uint16_t CPU::FetchOperand() } #if !defined(LIBRETRO) && !defined(DUMMYCPU) - if(_warnOnCrash && _console->GetSettings()->CheckFlag(EmulationFlags::DeveloperMode)) { + if(_lastCrashWarning == 0 || _cycleCount - _lastCrashWarning > 5000000) { MessageManager::DisplayMessage("Error", "GameCrash", "Invalid OP code - CPU crashed."); - _warnOnCrash = false; + _lastCrashWarning = _cycleCount; } - _console->BreakIfDebugging(); + if(_console->GetSettings()->CheckFlag(EmulationFlags::BreakOnCrash)) { + //When "Break on Crash" is enabled, open the debugger and break immediately if a crash occurs + _console->GetDebugger(true)->BreakImmediately(BreakSource::BreakOnCpuCrash); + } if(_console->IsNsf()) { //Don't stop emulation on CPU crash when playing NSFs, reset cpu instead _console->Reset(true); return 0; - } else if(!_console->GetDebugger(false) && !_console->GetSettings()->CheckFlag(EmulationFlags::DeveloperMode)) { - //Throw an error and stop emulation core (if debugger is not enabled) - throw std::runtime_error("Invalid OP code - CPU crashed"); } else { return 0; } #else return 0; #endif - } void CPU::EndCpuCycle(bool forRead) diff --git a/Core/CPU.h b/Core/CPU.h index 1ea90e7f..2717e7de 100644 --- a/Core/CPU.h +++ b/Core/CPU.h @@ -59,7 +59,7 @@ private: bool _prevRunIrq = false; bool _runIrq = false; - bool _warnOnCrash = true; + uint64_t _lastCrashWarning = 0; #ifdef DUMMYCPU uint32_t _writeCounter = 0; diff --git a/Core/Console.cpp b/Core/Console.cpp index 2076026e..106b82e5 100644 --- a/Core/Console.cpp +++ b/Core/Console.cpp @@ -1071,18 +1071,6 @@ void Console::LoadState(uint8_t *buffer, uint32_t bufferSize) LoadState(stream); } -void Console::BreakIfDebugging() -{ - shared_ptr debugger = _debugger; - if(debugger) { - debugger->BreakImmediately(BreakSource::BreakOnCpuCrash); - } else if(_settings->CheckFlag(EmulationFlags::BreakOnCrash)) { - //When "Break on Crash" is enabled, open the debugger and break immediately if a crash occurs - debugger = GetDebugger(true); - debugger->BreakImmediately(BreakSource::BreakOnCpuCrash); - } -} - std::shared_ptr Console::GetDebugger(bool autoStart) { shared_ptr debugger = _debugger; diff --git a/Core/Console.h b/Core/Console.h index d1f39cd6..53f6c2c8 100644 --- a/Core/Console.h +++ b/Core/Console.h @@ -187,7 +187,6 @@ public: //Used to resume the emu loop after calling Pause() void Resume(); - void BreakIfDebugging(); shared_ptr GetDebugger(bool autoStart = true); void StopDebugger(); diff --git a/Core/RecordedRomTest.cpp b/Core/RecordedRomTest.cpp index edf5ba6f..6b6fcfd9 100644 --- a/Core/RecordedRomTest.cpp +++ b/Core/RecordedRomTest.cpp @@ -61,7 +61,6 @@ void RecordedRomTest::ValidateFrame(uint16_t* ppuFrameBuffer) if(memcmp(_screenshotHashes.front(), md5Hash, 16) != 0) { _badFrameCount++; - _console->BreakIfDebugging(); } if (_currentCount == 0 && _repetitionCount.empty()) {