From 7baabe99d178b6f096909c71cd92af0cbcce1e43 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 14 May 2017 16:49:25 -0400 Subject: [PATCH] Host: Get rid of Host_SetStartupDebuggingParameters() This is something that should be the responsibility of the frontend booting the game. Making this part of the host 'interface' inherently requires frontends to leak internal details (much like the other UI-related functions in the interface). This also decouples more behavior from the debugger and the initialization process in the wx frontend. This also eliminates several usages of the parent menubar in the debugger code window. --- Source/Core/Core/BootManager.cpp | 4 --- Source/Core/Core/Host.h | 1 - Source/Core/DolphinNoGUI/MainNoGUI.cpp | 7 ----- Source/Core/DolphinQt2/Host.cpp | 3 -- Source/Core/DolphinWX/Debugger/CodeWindow.cpp | 28 +------------------ Source/Core/DolphinWX/Debugger/CodeWindow.h | 5 ---- Source/Core/DolphinWX/Frame.h | 4 ++- Source/Core/DolphinWX/FrameTools.cpp | 23 +++++++++++++++ Source/Core/DolphinWX/Main.cpp | 22 ++------------- 9 files changed, 30 insertions(+), 67 deletions(-) diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index a1ebc7ff4f..febea2441e 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -36,7 +36,6 @@ #include "Core/HW/SI/SI.h" #include "Core/HW/Sram.h" #include "Core/HW/WiimoteReal/WiimoteReal.h" -#include "Core/Host.h" #include "Core/Movie.h" #include "Core/NetPlayProto.h" @@ -223,9 +222,6 @@ bool BootCore(const std::string& _rFilename) { SConfig& StartUp = SConfig::GetInstance(); - // Use custom settings for debugging mode - Host_SetStartupDebuggingParameters(); - StartUp.m_BootType = SConfig::BOOT_ISO; StartUp.m_strFilename = _rFilename; StartUp.m_LastFilename = _rFilename; diff --git a/Source/Core/Core/Host.h b/Source/Core/Core/Host.h index 349d65f7a6..dc63e762ec 100644 --- a/Source/Core/Core/Host.h +++ b/Source/Core/Core/Host.h @@ -31,7 +31,6 @@ void Host_Message(int Id); void Host_NotifyMapLoaded(); void Host_RefreshDSPDebuggerWindow(); void Host_RequestRenderWindowSize(int width, int height); -void Host_SetStartupDebuggingParameters(); void Host_SetWiiMoteConnectionState(int _State); void Host_UpdateDisasmDialog(); void Host_UpdateMainFrame(); diff --git a/Source/Core/DolphinNoGUI/MainNoGUI.cpp b/Source/Core/DolphinNoGUI/MainNoGUI.cpp index 5c24b65a40..ce296251ed 100644 --- a/Source/Core/DolphinNoGUI/MainNoGUI.cpp +++ b/Source/Core/DolphinNoGUI/MainNoGUI.cpp @@ -115,13 +115,6 @@ void Host_RequestRenderWindowSize(int width, int height) { } -void Host_SetStartupDebuggingParameters() -{ - SConfig& StartUp = SConfig::GetInstance(); - StartUp.bEnableDebugging = false; - StartUp.bBootToPause = false; -} - bool Host_UIHasFocus() { return false; diff --git a/Source/Core/DolphinQt2/Host.cpp b/Source/Core/DolphinQt2/Host.cpp index 0797f4f39e..fdd3b5aecd 100644 --- a/Source/Core/DolphinQt2/Host.cpp +++ b/Source/Core/DolphinQt2/Host.cpp @@ -113,9 +113,6 @@ void Host_NotifyMapLoaded() void Host_UpdateDisasmDialog() { } -void Host_SetStartupDebuggingParameters() -{ -} void Host_SetWiiMoteConnectionState(int state) { } diff --git a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp index 75ff5c16dc..c1e10e248e 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp @@ -481,7 +481,7 @@ void CCodeWindow::OnCPUMode(wxCommandEvent& event) switch (event.GetId()) { case IDM_INTERPRETER: - PowerPC::SetMode(UseInterpreter() ? PowerPC::CoreMode::Interpreter : PowerPC::CoreMode::JIT); + PowerPC::SetMode(event.IsChecked() ? PowerPC::CoreMode::Interpreter : PowerPC::CoreMode::JIT); break; case IDM_BOOT_TO_PAUSE: SConfig::GetInstance().bBootToPause = event.IsChecked(); @@ -561,32 +561,6 @@ void CCodeWindow::OnJitMenu(wxCommandEvent& event) } } -// Shortcuts -bool CCodeWindow::UseInterpreter() -{ - return GetParentMenuBar()->IsChecked(IDM_INTERPRETER); -} - -bool CCodeWindow::BootToPause() -{ - return GetParentMenuBar()->IsChecked(IDM_BOOT_TO_PAUSE); -} - -bool CCodeWindow::AutomaticStart() -{ - return GetParentMenuBar()->IsChecked(IDM_AUTOMATIC_START); -} - -bool CCodeWindow::JITNoBlockCache() -{ - return GetParentMenuBar()->IsChecked(IDM_JIT_NO_BLOCK_CACHE); -} - -bool CCodeWindow::JITNoBlockLinking() -{ - return GetParentMenuBar()->IsChecked(IDM_JIT_NO_BLOCK_LINKING); -} - // Update GUI void CCodeWindow::Repopulate(bool refresh_codeview) { diff --git a/Source/Core/DolphinWX/Debugger/CodeWindow.h b/Source/Core/DolphinWX/Debugger/CodeWindow.h index a527ffa8f3..76024eb1d4 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindow.h +++ b/Source/Core/DolphinWX/Debugger/CodeWindow.h @@ -85,11 +85,6 @@ public: void Load(); void Save(); - bool UseInterpreter(); - bool BootToPause(); - bool AutomaticStart(); - bool JITNoBlockCache(); - bool JITNoBlockLinking(); bool JumpToAddress(u32 address); void Repopulate(bool refresh_codeview = true); diff --git a/Source/Core/DolphinWX/Frame.h b/Source/Core/DolphinWX/Frame.h index 279fba2536..b31a211152 100644 --- a/Source/Core/DolphinWX/Frame.h +++ b/Source/Core/DolphinWX/Frame.h @@ -183,6 +183,9 @@ private: void InitializeTASDialogs(); void InitializeCoreCallbacks(); + void StartGame(const std::string& filename); + void SetDebuggerStartupParameters() const; + // Utility wxWindow* GetNotebookPageFromId(wxWindowID Id); wxAuiNotebook* GetNotebookFromId(u32 NBId); @@ -338,7 +341,6 @@ private: void OnGameListCtrlItemActivated(wxListEvent& event); void OnRenderParentResize(wxSizeEvent& event); - void StartGame(const std::string& filename); void OnChangeColumnsVisible(wxCommandEvent& event); void OnSelectSlot(wxCommandEvent& event); diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index f8f99cdd81..7ae53545dd 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -707,6 +707,8 @@ void CFrame::StartGame(const std::string& filename) DoFullscreen(SConfig::GetInstance().bFullscreen); + SetDebuggerStartupParameters(); + if (!BootManager::BootCore(filename)) { DoFullscreen(false); @@ -745,6 +747,27 @@ void CFrame::StartGame(const std::string& filename) } } +void CFrame::SetDebuggerStartupParameters() const +{ + SConfig& config = SConfig::GetInstance(); + + if (m_use_debugger) + { + const wxMenuBar* const menu_bar = GetMenuBar(); + + config.bBootToPause = menu_bar->IsChecked(IDM_BOOT_TO_PAUSE); + config.bAutomaticStart = menu_bar->IsChecked(IDM_AUTOMATIC_START); + config.bJITNoBlockCache = menu_bar->IsChecked(IDM_JIT_NO_BLOCK_CACHE); + config.bJITNoBlockLinking = menu_bar->IsChecked(IDM_JIT_NO_BLOCK_LINKING); + config.bEnableDebugging = true; + } + else + { + config.bBootToPause = false; + config.bEnableDebugging = false; + } +} + void CFrame::OnBootDrive(wxCommandEvent& event) { const auto* menu = static_cast(event.GetEventObject()); diff --git a/Source/Core/DolphinWX/Main.cpp b/Source/Core/DolphinWX/Main.cpp index ab18e465a4..2f9ee6609f 100644 --- a/Source/Core/DolphinWX/Main.cpp +++ b/Source/Core/DolphinWX/Main.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -256,9 +257,9 @@ void DolphinApp::AfterInit() } // If we have selected Automatic Start, start the default ISO, // or if no default ISO exists, start the last loaded ISO - else if (main_frame->m_code_window) + else if (m_use_debugger) { - if (main_frame->m_code_window->AutomaticStart()) + if (main_frame->GetMenuBar()->IsChecked(IDM_AUTOMATIC_START)) { main_frame->BootGame(""); } @@ -456,23 +457,6 @@ void Host_RequestRenderWindowSize(int width, int height) main_frame->GetEventHandler()->AddPendingEvent(event); } -void Host_SetStartupDebuggingParameters() -{ - SConfig& StartUp = SConfig::GetInstance(); - if (main_frame->m_code_window) - { - StartUp.bBootToPause = main_frame->m_code_window->BootToPause(); - StartUp.bAutomaticStart = main_frame->m_code_window->AutomaticStart(); - StartUp.bJITNoBlockCache = main_frame->m_code_window->JITNoBlockCache(); - StartUp.bJITNoBlockLinking = main_frame->m_code_window->JITNoBlockLinking(); - } - else - { - StartUp.bBootToPause = false; - } - StartUp.bEnableDebugging = main_frame->m_code_window ? true : false; // RUNNING_DEBUG -} - void Host_SetWiiMoteConnectionState(int _State) { static int currentState = -1;