diff --git a/Core/Console.cpp b/Core/Console.cpp index a4ba43a9..4e9856e9 100644 --- a/Core/Console.cpp +++ b/Core/Console.cpp @@ -402,8 +402,6 @@ void Console::Run() _runLock.Acquire(); } - shared_ptr debugger = _debugger; - bool paused = EmulationSettings::IsPaused(); if(paused && !_stop) { MessageManager::SendNotification(ConsoleNotificationType::GamePaused); @@ -414,13 +412,13 @@ void Console::Run() _runLock.Release(); PlatformUtilities::EnableScreensaver(); - while(paused && !_stop && (!debugger || !debugger->CheckFlag(DebuggerFlags::DebuggerWindowEnabled))) { + while(paused && !_stop) { //Sleep until emulation is resumed std::this_thread::sleep_for(std::chrono::duration(30)); paused = EmulationSettings::IsPaused(); } - if(debugger && debugger->CheckFlag(DebuggerFlags::DebuggerWindowEnabled)) { + if(EmulationSettings::CheckFlag(EmulationFlags::DebuggerWindowEnabled)) { //Prevent pausing when debugger is active EmulationSettings::ClearFlags(EmulationFlags::Paused); } @@ -430,6 +428,7 @@ void Console::Run() MessageManager::SendNotification(ConsoleNotificationType::GameResumed); } + shared_ptr debugger = _debugger; if(debugger) { debugger->ProcessEvent(EventType::StartFrame); } diff --git a/Core/Debugger.cpp b/Core/Debugger.cpp index 8e79262e..c900e2b4 100644 --- a/Core/Debugger.cpp +++ b/Core/Debugger.cpp @@ -976,7 +976,7 @@ void Debugger::StopCodeRunner() //Break debugger when code has finished executing SetNextStatement(_returnToAddress); - if(CheckFlag(DebuggerFlags::DebuggerWindowEnabled)) { + if(EmulationSettings::CheckFlag(EmulationFlags::DebuggerWindowEnabled)) { Step(1); } else { Run(); diff --git a/Core/DebuggerTypes.h b/Core/DebuggerTypes.h index 8bfac4ea..40cc9f8e 100644 --- a/Core/DebuggerTypes.h +++ b/Core/DebuggerTypes.h @@ -12,7 +12,6 @@ enum class DebuggerFlags DisassembleEverythingButData = 0x20, BreakOnBrk = 0x40, BreakOnUnofficialOpCode = 0x80, - DebuggerWindowEnabled = 0x100, }; enum class AddressType diff --git a/Core/EmulationSettings.h b/Core/EmulationSettings.h index 95412c01..ae37d8a9 100644 --- a/Core/EmulationSettings.h +++ b/Core/EmulationSettings.h @@ -73,6 +73,8 @@ enum EmulationFlags : uint64_t IntegerFpsMode = 0x2000000000000, + DebuggerWindowEnabled = 0x4000000000000, + ForceMaxSpeed = 0x4000000000000000, ConsoleMode = 0x8000000000000000, }; @@ -602,7 +604,7 @@ public: static bool IsPaused() { - return CheckFlag(EmulationFlags::Paused) || (CheckFlag(EmulationFlags::InBackground) && CheckFlag(EmulationFlags::PauseWhenInBackground) && !GameClient::Connected()); + return (CheckFlag(EmulationFlags::Paused) || (CheckFlag(EmulationFlags::InBackground) && CheckFlag(EmulationFlags::PauseWhenInBackground) && !GameClient::Connected())) && !CheckFlag(EmulationFlags::DebuggerWindowEnabled); } static void SetNesModel(NesModel model) diff --git a/GUI.NET/Debugger/frmDebugger.cs b/GUI.NET/Debugger/frmDebugger.cs index 4f750bba..840d6df0 100644 --- a/GUI.NET/Debugger/frmDebugger.cs +++ b/GUI.NET/Debugger/frmDebugger.cs @@ -243,7 +243,8 @@ namespace Mesen.GUI.Debugger if(mnuBreakOnBrk.Checked) { flags |= DebuggerFlags.BreakOnBrk; } - InteropEmu.DebugSetFlags(flags | DebuggerFlags.DebuggerWindowEnabled); + InteropEmu.DebugSetFlags(flags); + InteropEmu.SetFlag(EmulationFlags.DebuggerWindowEnabled, true); } private void _notifListener_OnNotification(InteropEmu.NotificationEventArgs e) @@ -563,6 +564,7 @@ namespace Mesen.GUI.Debugger } InteropEmu.DebugSetFlags(0); + InteropEmu.SetFlag(EmulationFlags.DebuggerWindowEnabled, false); InteropEmu.DebugSetBreakpoints(new InteropBreakpoint[0], 0); InteropEmu.DebugRun(); diff --git a/GUI.NET/InteropEmu.cs b/GUI.NET/InteropEmu.cs index 8fd21574..8df87f4b 100644 --- a/GUI.NET/InteropEmu.cs +++ b/GUI.NET/InteropEmu.cs @@ -1316,6 +1316,8 @@ namespace Mesen.GUI IntegerFpsMode = 0x2000000000000, + DebuggerWindowEnabled = 0x4000000000000, + ForceMaxSpeed = 0x4000000000000000, ConsoleMode = 0x8000000000000000, } @@ -1332,7 +1334,6 @@ namespace Mesen.GUI DisassembleEverythingButData = 0x20, BreakOnBrk = 0x40, BreakOnUnofficialOpCode = 0x80, - DebuggerWindowEnabled = 0x100, } public struct InteropRomInfo diff --git a/Windows/Renderer.cpp b/Windows/Renderer.cpp index be0562f4..3d062845 100644 --- a/Windows/Renderer.cpp +++ b/Windows/Renderer.cpp @@ -457,7 +457,7 @@ namespace NES void Renderer::Render() { - bool paused = EmulationSettings::IsPaused(); + bool paused = EmulationSettings::IsPaused() && Console::IsRunning(); if(_noUpdateCount > 10 || _frameChanged || paused || IsMessageShown()) { _noUpdateCount = 0;