diff --git a/Windows/Debugger/CtrlRegisterList.cpp b/Windows/Debugger/CtrlRegisterList.cpp index 563a2b47f..05be2dee2 100644 --- a/Windows/Debugger/CtrlRegisterList.cpp +++ b/Windows/Debugger/CtrlRegisterList.cpp @@ -19,8 +19,6 @@ #include "Windows/main.h" -static const int numCPUs = 1; - extern HMENU g_hPopupMenus; enum { REGISTER_PC = 32, REGISTER_HI, REGISTER_LO, REGISTERS_END }; @@ -520,9 +518,8 @@ void CtrlRegisterList::onMouseUp(WPARAM wParam, LPARAM lParam, int button) SendMessage(GetParent(wnd),WM_DEB_GOTOHEXEDIT,val,0); break; case ID_REGLIST_GOTOINDISASM: - for (int i=0; iGoto(val); + if (disasmWindow) + disasmWindow->Goto(val); break; case ID_REGLIST_COPYVALUE: copyRegisterValue(); diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index d519dffa7..e75a30783 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -31,12 +31,10 @@ #include #include -static const int numCPUs = 1; - // How long (max) to wait for Core to pause before clearing temp breakpoints. -const int TEMP_BREAKPOINT_WAIT_MS = 100; +static const int TEMP_BREAKPOINT_WAIT_MS = 100; -FAR WNDPROC DefGotoEditProc; +static FAR WNDPROC DefGotoEditProc; LRESULT CALLBACK GotoEditProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { @@ -66,7 +64,7 @@ LRESULT CALLBACK GotoEditProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa return (LRESULT)CallWindowProc((WNDPROC)DefGotoEditProc,hDlg,message,wParam,lParam); } -FAR WNDPROC DefFuncListProc; +static FAR WNDPROC DefFuncListProc; LRESULT CALLBACK FuncListProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { @@ -94,8 +92,6 @@ LRESULT CALLBACK FuncListProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Dialog((LPCSTR)IDD_DISASM, _hInstance, _hParent) { cpu = _cpu; lastTicks = PSP_IsInited() ? CoreTiming::GetTicks() : 0; - keepStatusBarText = false; - hideBottomTabs = false; SetWindowText(m_hDlg, ConvertUTF8ToWString(_cpu->GetName()).c_str()); @@ -113,8 +109,7 @@ CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Di // init status bar statusBarWnd = CreateWindowEx(0, STATUSCLASSNAME, L"", WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, m_hDlg, (HMENU)IDC_DISASMSTATUSBAR, _hInstance, NULL); - if (g_Config.bDisplayStatusBar == false) - { + if (g_Config.bDisplayStatusBar == false) { ShowWindow(statusBarWnd,SW_HIDE); } @@ -897,9 +892,8 @@ void CDisasm::UpdateDialog(bool _bComplete) SetDlgItemText(m_hDlg, IDC_DEBUG_COUNT, tempTicks); } // Update Register Dialog - for (int i=0; iUpdate(); + if (memoryWindow) + memoryWindow->Update(); // repaint windows at the bottom. only the memory view needs to be forced to // redraw. all others are updated manually diff --git a/Windows/Debugger/Debugger_Disasm.h b/Windows/Debugger/Debugger_Disasm.h index 5639b6e40..1dd8487d3 100644 --- a/Windows/Debugger/Debugger_Disasm.h +++ b/Windows/Debugger/Debugger_Disasm.h @@ -29,8 +29,8 @@ private: TabControl* bottomTabs; std::vector displayedBreakPoints_; std::vector displayedMemChecks_; - bool keepStatusBarText; - bool hideBottomTabs; + bool keepStatusBarText = false; + bool hideBottomTabs = false; BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam); void UpdateSize(WORD width, WORD height); @@ -40,17 +40,14 @@ private: void stepOver(); void stepOut(); void runToLine(); + public: - int index; //helper + int index; CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *cpu); ~CDisasm(); - // - // --- tools --- - // - - virtual void Update() - { + + virtual void Update() { UpdateDialog(true); SetDebugMode(Core_IsStepping(), false); breakpointList->reloadBreakpoints(); @@ -58,7 +55,7 @@ public: void UpdateDialog(bool _bComplete = false); // SetDebugMode void SetDebugMode(bool _bDebug, bool switchPC); - // show dialog + void Goto(u32 addr); void NotifyMapLoaded(); }; diff --git a/Windows/Debugger/Debugger_Lists.cpp b/Windows/Debugger/Debugger_Lists.cpp index 7d08b09ee..f6c5bd956 100644 --- a/Windows/Debugger/Debugger_Lists.cpp +++ b/Windows/Debugger/Debugger_Lists.cpp @@ -10,8 +10,6 @@ #include "../../Core/HLE/sceKernelThread.h" #include "util/text/utf8.h" -static const int numCPUs = 1; - enum { TL_NAME, TL_PROGRAMCOUNTER, TL_ENTRYPOINT, TL_PRIORITY, TL_STATE, TL_WAITTYPE, TL_COLUMNCOUNT }; enum { BPL_ENABLED, BPL_TYPE, BPL_OFFSET, BPL_SIZELABEL, BPL_OPCODE, BPL_CONDITION, BPL_HITS, BPL_COLUMNCOUNT }; enum { SF_ENTRY, SF_ENTRYNAME, SF_CURPC, SF_CUROPCODE, SF_CURSP, SF_FRAMESIZE, SF_COLUMNCOUNT }; @@ -375,22 +373,18 @@ void CtrlBreakpointList::toggleEnabled(int itemIndex) void CtrlBreakpointList::gotoBreakpointAddress(int itemIndex) { bool isMemory; - int index = getBreakpointIndex(itemIndex,isMemory); - if (index == -1) return; + int index = getBreakpointIndex(itemIndex, isMemory); + if (index == -1) + return; - if (isMemory) - { + if (isMemory) { u32 address = displayedMemChecks_[index].start; - - for (int i=0; iGoto(address); + if (memoryWindow) + memoryWindow->Goto(address); } else { u32 address = displayedBreakPoints_[index].addr; - - for (int i=0; iGoto(address); + if (disasmWindow) + disasmWindow->Goto(address); } } @@ -413,8 +407,7 @@ void CtrlBreakpointList::removeBreakpoint(int itemIndex) int CtrlBreakpointList::getTotalBreakpointCount() { int count = (int)CBreakPoints::GetMemChecks().size(); - for (size_t i = 0; i < CBreakPoints::GetBreakpoints().size(); i++) - { + for (size_t i = 0; i < CBreakPoints::GetBreakpoints().size(); i++) { if (!displayedBreakPoints_[i].temporary) count++; } diff --git a/Windows/GEDebugger/CtrlDisplayListView.cpp b/Windows/GEDebugger/CtrlDisplayListView.cpp index 07cc0490d..741ca4b3a 100644 --- a/Windows/GEDebugger/CtrlDisplayListView.cpp +++ b/Windows/GEDebugger/CtrlDisplayListView.cpp @@ -9,8 +9,6 @@ #include -static const int numCPUs = 1; - const PTCHAR CtrlDisplayListView::windowClass = _T("CtrlDisplayListView"); const int POPUP_SUBMENU_ID_DISPLAYLISTVIEW = 8; @@ -308,9 +306,8 @@ void CtrlDisplayListView::onMouseUp(WPARAM wParam, LPARAM lParam, int button) switch(TrackPopupMenuEx(GetSubMenu(g_hPopupMenus,POPUP_SUBMENU_ID_DISPLAYLISTVIEW),TPM_RIGHTBUTTON|TPM_RETURNCMD,pt.x,pt.y,wnd,0)) { case ID_DISASM_GOTOINMEMORYVIEW: - for (int i=0; iGoto(curAddress); + if (memoryWindow) + memoryWindow->Goto(curAddress); break; case ID_DISASM_TOGGLEBREAKPOINT: toggleBreakpoint(); diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index bc0c4fe54..57aa98397 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -536,23 +536,23 @@ namespace MainWindow } void CreateDebugWindows() { - disasmWindow[0] = new CDisasm(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS); - DialogManager::AddDlg(disasmWindow[0]); - disasmWindow[0]->Show(g_Config.bShowDebuggerOnLoad); + disasmWindow = new CDisasm(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS); + DialogManager::AddDlg(disasmWindow); + disasmWindow->Show(g_Config.bShowDebuggerOnLoad); #if PPSSPP_API(ANY_GL) geDebuggerWindow = new CGEDebugger(MainWindow::GetHInstance(), MainWindow::GetHWND()); DialogManager::AddDlg(geDebuggerWindow); #endif - memoryWindow[0] = new CMemoryDlg(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS); - DialogManager::AddDlg(memoryWindow[0]); + memoryWindow = new CMemoryDlg(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS); + DialogManager::AddDlg(memoryWindow); } void DestroyDebugWindows() { - DialogManager::RemoveDlg(disasmWindow[0]); - if (disasmWindow[0]) - delete disasmWindow[0]; - disasmWindow[0] = 0; + DialogManager::RemoveDlg(disasmWindow); + if (disasmWindow) + delete disasmWindow; + disasmWindow = 0; #if PPSSPP_API(ANY_GL) DialogManager::RemoveDlg(geDebuggerWindow); @@ -561,10 +561,10 @@ namespace MainWindow geDebuggerWindow = 0; #endif - DialogManager::RemoveDlg(memoryWindow[0]); - if (memoryWindow[0]) - delete memoryWindow[0]; - memoryWindow[0] = 0; + DialogManager::RemoveDlg(memoryWindow); + if (memoryWindow) + delete memoryWindow; + memoryWindow = 0; } LRESULT CALLBACK DisplayProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -678,10 +678,8 @@ namespace MainWindow break; case WM_TOUCH: - { - touchHandler.handleTouchEvent(hWnd, message, wParam, lParam); - return 0; - } + touchHandler.handleTouchEvent(hWnd, message, wParam, lParam); + return 0; default: return DefWindowProc(hWnd, message, wParam, lParam); @@ -725,8 +723,8 @@ namespace MainWindow } if (!noFocusPause && g_Config.bPauseOnLostFocus && GetUIState() == UISTATE_INGAME) { if (pause != Core_IsStepping()) { // != is xor for bools - if (disasmWindow[0]) - SendMessage(disasmWindow[0]->GetDlgHandle(), WM_COMMAND, IDC_STOPGO, 0); + if (disasmWindow) + SendMessage(disasmWindow->GetDlgHandle(), WM_COMMAND, IDC_STOPGO, 0); else Core_EnableStepping(pause); } @@ -928,13 +926,13 @@ namespace MainWindow break; case WM_USER + 1: - if (disasmWindow[0]) - disasmWindow[0]->NotifyMapLoaded(); - if (memoryWindow[0]) - memoryWindow[0]->NotifyMapLoaded(); + if (disasmWindow) + disasmWindow->NotifyMapLoaded(); + if (memoryWindow) + memoryWindow->NotifyMapLoaded(); - if (disasmWindow[0]) - disasmWindow[0]->UpdateDialog(); + if (disasmWindow) + disasmWindow->UpdateDialog(); SetForegroundWindow(hwndMain); break; diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index dc40b0b9c..ab80ec4ce 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -51,7 +51,6 @@ extern bool g_ShaderNameListChanged; namespace MainWindow { extern HINSTANCE hInst; - static const int numCPUs = 1; // what? extern bool noFocusPause; static W32Util::AsyncBrowseDialog *browseDialog; static W32Util::AsyncBrowseDialog *browseImageDialog; @@ -586,16 +585,16 @@ namespace MainWindow { // Causes hang //NativeMessageReceived("run", ""); - if (disasmWindow[0]) - SendMessage(disasmWindow[0]->GetDlgHandle(), WM_COMMAND, IDC_STOPGO, 0); + if (disasmWindow) + SendMessage(disasmWindow->GetDlgHandle(), WM_COMMAND, IDC_STOPGO, 0); } else if (Core_IsStepping()) { // It is paused, then continue to run. - if (disasmWindow[0]) - SendMessage(disasmWindow[0]->GetDlgHandle(), WM_COMMAND, IDC_STOPGO, 0); + if (disasmWindow) + SendMessage(disasmWindow->GetDlgHandle(), WM_COMMAND, IDC_STOPGO, 0); else Core_EnableStepping(false); } else { - if (disasmWindow[0]) - SendMessage(disasmWindow[0]->GetDlgHandle(), WM_COMMAND, IDC_STOPGO, 0); + if (disasmWindow) + SendMessage(disasmWindow->GetDlgHandle(), WM_COMMAND, IDC_STOPGO, 0); else Core_EnableStepping(true); } @@ -854,11 +853,11 @@ namespace MainWindow { if (W32Util::BrowseForFileName(true, hWnd, L"Load .ppmap", 0, L"Maps\0*.ppmap\0All files\0*.*\0\0", L"ppmap", fn)) { g_symbolMap->LoadSymbolMap(fn.c_str()); - if (disasmWindow[0]) - disasmWindow[0]->NotifyMapLoaded(); + if (disasmWindow) + disasmWindow->NotifyMapLoaded(); - if (memoryWindow[0]) - memoryWindow[0]->NotifyMapLoaded(); + if (memoryWindow) + memoryWindow->NotifyMapLoaded(); } break; @@ -871,11 +870,11 @@ namespace MainWindow { if (W32Util::BrowseForFileName(true, hWnd, L"Load .sym", 0, L"Symbols\0*.sym\0All files\0*.*\0\0", L"sym", fn)) { g_symbolMap->LoadNocashSym(fn.c_str()); - if (disasmWindow[0]) - disasmWindow[0]->NotifyMapLoaded(); + if (disasmWindow) + disasmWindow->NotifyMapLoaded(); - if (memoryWindow[0]) - memoryWindow[0]->NotifyMapLoaded(); + if (memoryWindow) + memoryWindow->NotifyMapLoaded(); } break; @@ -887,18 +886,16 @@ namespace MainWindow { case ID_DEBUG_RESETSYMBOLTABLE: g_symbolMap->Clear(); - for (int i = 0; i < numCPUs; i++) - if (disasmWindow[i]) - disasmWindow[i]->NotifyMapLoaded(); + if (disasmWindow) + disasmWindow->NotifyMapLoaded(); - for (int i = 0; i < numCPUs; i++) - if (memoryWindow[i]) - memoryWindow[i]->NotifyMapLoaded(); + if (memoryWindow) + memoryWindow->NotifyMapLoaded(); break; case ID_DEBUG_DISASSEMBLY: - if (disasmWindow[0]) - disasmWindow[0]->Show(true); + if (disasmWindow) + disasmWindow->Show(true); break; case ID_DEBUG_GEDEBUGGER: @@ -909,8 +906,8 @@ namespace MainWindow { break; case ID_DEBUG_MEMORYVIEW: - if (memoryWindow[0]) - memoryWindow[0]->Show(true); + if (memoryWindow) + memoryWindow->Show(true); break; case ID_DEBUG_EXTRACTFILE: diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index 48b79bde3..e34f744f3 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -72,8 +72,6 @@ #include "Windows/main.h" #include "UI/OnScreenDisplay.h" -static const int numCPUs = 1; - float g_mouseDeltaX = 0; float g_mouseDeltaY = 0; @@ -201,21 +199,18 @@ void WindowsHost::UpdateUI() { } void WindowsHost::UpdateMemView() { - for (int i = 0; i < numCPUs; i++) - if (memoryWindow[i]) - PostDialogMessage(memoryWindow[i], WM_DEB_UPDATE); + if (memoryWindow) + PostDialogMessage(memoryWindow, WM_DEB_UPDATE); } void WindowsHost::UpdateDisassembly() { - for (int i = 0; i < numCPUs; i++) - if (disasmWindow[i]) - PostDialogMessage(disasmWindow[i], WM_DEB_UPDATE); + if (disasmWindow) + PostDialogMessage(disasmWindow, WM_DEB_UPDATE); } void WindowsHost::SetDebugMode(bool mode) { - for (int i = 0; i < numCPUs; i++) - if (disasmWindow[i]) - PostDialogMessage(disasmWindow[i], WM_DEB_SETDEBUGLPARAM, 0, (LPARAM)mode); + if (disasmWindow) + PostDialogMessage(disasmWindow, WM_DEB_SETDEBUGLPARAM, 0, (LPARAM)mode); } void WindowsHost::PollControllers() { diff --git a/Windows/main.cpp b/Windows/main.cpp index f1617901c..bf2b74adc 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -88,11 +88,11 @@ extern "C" { __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; } #if PPSSPP_API(ANY_GL) -CGEDebugger* geDebuggerWindow = 0; +CGEDebugger* geDebuggerWindow = nullptr; #endif -CDisasm *disasmWindow[MAX_CPUCOUNT] = {0}; -CMemoryDlg *memoryWindow[MAX_CPUCOUNT] = {0}; +CDisasm *disasmWindow = nullptr; +CMemoryDlg *memoryWindow = nullptr; static std::string langRegion; static std::string osName; @@ -678,7 +678,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin accel = hAccelTable; break; case WINDOW_CPUDEBUGGER: - wnd = disasmWindow[0] ? disasmWindow[0]->GetDlgHandle() : 0; + wnd = disasmWindow ? disasmWindow->GetDlgHandle() : 0; accel = hDebugAccelTable; break; case WINDOW_GEDEBUGGER: diff --git a/Windows/main.h b/Windows/main.h index d25d8ed00..a47bc081b 100644 --- a/Windows/main.h +++ b/Windows/main.h @@ -22,10 +22,8 @@ #include "Debugger/Debugger_MemoryDlg.h" #include "Common/CommonWindows.h" -#define MAX_CPUCOUNT 1 - -extern CDisasm *disasmWindow[MAX_CPUCOUNT]; -extern CMemoryDlg *memoryWindow[MAX_CPUCOUNT]; +extern CDisasm *disasmWindow; +extern CMemoryDlg *memoryWindow; #if PPSSPP_API(ANY_GL) #include "Windows/GEDebugger/GEDebugger.h"