diff --git a/Core/CPU.cpp b/Core/CPU.cpp index 7a391b6d..317dbb8e 100644 --- a/Core/CPU.cpp +++ b/Core/CPU.cpp @@ -83,6 +83,7 @@ void CPU::Reset(bool softReset, NesModel model) _dmcCounter = -1; _dmcDmaRunning = false; + _warnOnCrash = true; //Used by NSF code to disable Frame Counter & DMC interrupts _irqMask = 0xFF; @@ -232,13 +233,18 @@ uint16_t CPU::FetchOperand() } #ifndef LIBRETRO + if(_warnOnCrash && _console->GetSettings()->CheckFlag(EmulationFlags::DeveloperMode)) { + MessageManager::DisplayMessage("Error", "GameCrash", "Invalid OP code - CPU crashed."); + _warnOnCrash = false; + } + _console->BreakIfDebugging(); if(NsfMapper::GetInstance()) { //Don't stop emulation on CPU crash when playing NSFs, reset cpu instead _console->Reset(true); return 0; - } else if(!_console->GetDebugger(false)) { + } 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 { diff --git a/Core/CPU.h b/Core/CPU.h index 9a2e06dc..4d610073 100644 --- a/Core/CPU.h +++ b/Core/CPU.h @@ -60,6 +60,8 @@ private: bool _prevRunIrq = false; bool _runIrq = false; + bool _warnOnCrash = true; + void IncCycleCount(); uint16_t FetchOperand(); void IRQ(); diff --git a/Core/EmulationSettings.h b/Core/EmulationSettings.h index bf24b56f..a2fc9391 100644 --- a/Core/EmulationSettings.h +++ b/Core/EmulationSettings.h @@ -22,6 +22,9 @@ enum EmulationFlags : uint64_t DisableDynamicSampleRate = 0x80, PauseOnMovieEnd = 0x0100, + + DeveloperMode = 0x0200, + AllowBackgroundInput = 0x0400, ReduceSoundInBackground = 0x0800, MuteSoundInBackground = 0x1000, diff --git a/GUI.NET/Config/PreferenceInfo.cs b/GUI.NET/Config/PreferenceInfo.cs index 1892a334..64f70794 100644 --- a/GUI.NET/Config/PreferenceInfo.cs +++ b/GUI.NET/Config/PreferenceInfo.cs @@ -180,6 +180,8 @@ namespace Mesen.GUI.Config InteropEmu.SetOsdState(!preferenceInfo.DisableOsd); InteropEmu.SetGameDatabaseState(!preferenceInfo.DisableGameDatabase); + InteropEmu.SetFlag(EmulationFlags.DeveloperMode, preferenceInfo.DeveloperMode); + InteropEmu.SetFlag(EmulationFlags.AllowInvalidInput, preferenceInfo.AllowInvalidInput); InteropEmu.SetFlag(EmulationFlags.RemoveSpriteLimit, preferenceInfo.RemoveSpriteLimit); InteropEmu.SetFlag(EmulationFlags.FdsAutoLoadDisk, preferenceInfo.FdsAutoLoadDisk); diff --git a/GUI.NET/InteropEmu.cs b/GUI.NET/InteropEmu.cs index 2c332874..4a38ab42 100644 --- a/GUI.NET/InteropEmu.cs +++ b/GUI.NET/InteropEmu.cs @@ -1559,6 +1559,9 @@ namespace Mesen.GUI DisableDynamicSampleRate = 0x80, PauseOnMovieEnd = 0x0100, + + DeveloperMode = 0x0200, + AllowBackgroundInput = 0x0400, ReduceSoundInBackground = 0x0800, MuteSoundInBackground = 0x1000,