diff --git a/Core/Config.cpp b/Core/Config.cpp index 146f20e29f..a61c130592 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -154,6 +154,12 @@ void Config::Load(const char *iniFileName) pspConfig->Get("WlanPowerSave", &bWlanPowerSave, PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF); pspConfig->Get("EncryptSave", &bEncryptSave, true); + IniFile::Section *debugConfig = iniFile.GetOrCreateSection("Debugger"); + debugConfig->Get("DisasmWindowX", &iDisasmWindowX, -1); + debugConfig->Get("DisasmWindowY", &iDisasmWindowY, -1); + debugConfig->Get("DisasmWindowW", &iDisasmWindowW, -1); + debugConfig->Get("DisasmWindowH", &iDisasmWindowH, -1); + CleanRecent(); } @@ -250,6 +256,12 @@ void Config::Save() pspConfig->Set("WlanPowerSave", bWlanPowerSave); pspConfig->Set("EncryptSave", bEncryptSave); + IniFile::Section *debugConfig = iniFile.GetOrCreateSection("Debugger"); + debugConfig->Set("DisasmWindowX", iDisasmWindowX); + debugConfig->Set("DisasmWindowY", iDisasmWindowY); + debugConfig->Set("DisasmWindowW", iDisasmWindowW); + debugConfig->Set("DisasmWindowH", iDisasmWindowH); + if (!iniFile.Save(iniFilename_.c_str())) { ERROR_LOG(LOADER, "Error saving config - can't write ini %s", iniFilename_.c_str()); return; diff --git a/Core/Config.h b/Core/Config.h index 9881c582bc..8f0b829b80 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -127,6 +127,12 @@ public: int iWlanAdhocChannel; bool bWlanPowerSave; + // Debugger + int iDisasmWindowX; + int iDisasmWindowY; + int iDisasmWindowW; + int iDisasmWindowH; + std::string currentDirectory; std::string externalDirectory; std::string memCardDirectory; diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index 79fd177776..64e775ae7a 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -1,6 +1,7 @@ // NOTE: Apologies for the quality of this code, this is really from pre-opensource Dolphin - that is, 2003. -#include "../../Core/MemMap.h" +#include "Core/Config.h" +#include "Core/MemMap.h" #include "../Resource.h" #include "../InputBox.h" @@ -37,17 +38,24 @@ CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Di //if (WTL::CTheme::IsThemingSupported()) //EnableThemeDialogTexture(m_hDlg ,ETDT_ENABLETAB); #endif - SetWindowPos(m_hDlg,0,500,200,0,0,SWP_NOSIZE); + int x = g_Config.iDisasmWindowX == -1 ? 500 : g_Config.iDisasmWindowX; + int y = g_Config.iDisasmWindowY == -1 ? 200 : g_Config.iDisasmWindowY; + int w = g_Config.iDisasmWindowW; + int h = g_Config.iDisasmWindowH; + // Start with the initial size so we have the right minimum size from the rc. + SetWindowPos(m_hDlg, 0, x, y, 0, 0, SWP_NOSIZE); CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); ptr->setDebugger(cpu); ptr->gotoAddr(0x00000000); CtrlRegisterList *rl = CtrlRegisterList::getFrom(GetDlgItem(m_hDlg,IDC_REGLIST)); - - rl->setCPU(cpu); + rl->setCPU(cpu); GetWindowRect(m_hDlg,&minRect); + // Reduce the minimum size slightly, so they can size it however they like. + minRect.right -= 100; + minRect.bottom -= 100; //symbolMap.FillSymbolListBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION); symbolMap.FillSymbolComboBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION); @@ -83,6 +91,13 @@ CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Di // --- activate debug mode --- // + // Actually resize the window to the proper size (after the above setup.) + if (w != -1 && h != -1) + { + SetWindowPos(m_hDlg, 0, x, y, w, h, 0); + UpdateSize(w, h); + } + SetDebugMode(true); } @@ -335,19 +350,15 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) case WM_SIZE: { - HWND disasm = GetDlgItem(m_hDlg, IDC_DISASMVIEW); - HWND funclist = GetDlgItem(m_hDlg, IDC_FUNCTIONLIST); - HWND regList = GetDlgItem(m_hDlg, IDC_REGLIST); - int wf = regRect.right-regRect.left; - int top = 138; - MoveWindow(regList,8,top,wf,HIWORD(lParam)-top-8,TRUE); - MoveWindow(funclist,8,top,wf,HIWORD(lParam)-top-8,TRUE); - int w = LOWORD(lParam)-wf; - top = 25; - MoveWindow(disasm,wf+15,top, w-20,HIWORD(lParam)-top-8,TRUE); + UpdateSize(LOWORD(lParam), HIWORD(lParam)); + SavePosition(); return TRUE; } + case WM_MOVE: + SavePosition(); + break; + case WM_GETMINMAXINFO: { MINMAXINFO *m = (MINMAXINFO *)lParam; @@ -363,6 +374,32 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) return FALSE; } +void CDisasm::UpdateSize(WORD width, WORD height) +{ + HWND disasm = GetDlgItem(m_hDlg, IDC_DISASMVIEW); + HWND funclist = GetDlgItem(m_hDlg, IDC_FUNCTIONLIST); + HWND regList = GetDlgItem(m_hDlg, IDC_REGLIST); + int wf = regRect.right - regRect.left; + int top = 138; + MoveWindow(regList, 8, top, wf, height - top - 8, TRUE); + MoveWindow(funclist, 8, top, wf, height - top - 8, TRUE); + int w = width - wf; + top = 25; + MoveWindow(disasm, wf + 15,top, w - 20, height - top - 8, TRUE); +} + +void CDisasm::SavePosition() +{ + RECT rc; + if (GetWindowRect(m_hDlg, &rc)) + { + g_Config.iDisasmWindowX = rc.left; + g_Config.iDisasmWindowY = rc.top; + g_Config.iDisasmWindowW = rc.right - rc.left; + g_Config.iDisasmWindowH = rc.bottom - rc.top; + } +} + void CDisasm::SetDebugMode(bool _bDebug) { HWND hDlg = m_hDlg; diff --git a/Windows/Debugger/Debugger_Disasm.h b/Windows/Debugger/Debugger_Disasm.h index 6f0a398d72..398fea1a92 100644 --- a/Windows/Debugger/Debugger_Disasm.h +++ b/Windows/Debugger/Debugger_Disasm.h @@ -22,6 +22,8 @@ private: DebugInterface *cpu; BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam); + void UpdateSize(WORD width, WORD height); + void SavePosition(); public: int index; //helper