From a65086579fa7fbfa9a69391cfbabfc78d5c93821 Mon Sep 17 00:00:00 2001 From: zilmar Date: Wed, 21 Sep 2022 14:46:07 +0930 Subject: [PATCH] Project64: Code clean up --- Source/Project64/Plugins/PluginList.cpp | 9 +- Source/Project64/Settings/GuiSettings.cpp | 10 +- Source/Project64/Settings/UISettings.cpp | 17 +- Source/Project64/UserInterface/About.cpp | 14 +- Source/Project64/UserInterface/CheatUI.cpp | 85 +- .../UserInterface/Debugger/Assembler.cpp | 104 +- .../UserInterface/Debugger/Breakpoints.cpp | 8 +- .../UserInterface/Debugger/CPULog.cpp | 21 +- .../Project64/UserInterface/Debugger/CPULog.h | 2 - .../UserInterface/Debugger/DMALog.cpp | 19 +- .../Project64/UserInterface/Debugger/DMALog.h | 2 - .../UserInterface/Debugger/DebugMMU.cpp | 202 ++-- .../UserInterface/Debugger/DebugMMU.h | 1 - .../Debugger/Debugger-AddBreakpoint.cpp | 6 +- .../Debugger/Debugger-AddSymbol.cpp | 22 +- .../Debugger/Debugger-CPULogView.cpp | 51 +- .../Debugger/Debugger-CPULogView.h | 2 - .../Debugger/Debugger-Commands.cpp | 186 ++-- .../Debugger/Debugger-DMALogView.cpp | 84 +- .../Debugger/Debugger-DMALogView.h | 2 - .../Debugger-ExceptionBreakpoints.cpp | 91 +- .../Debugger/Debugger-ExceptionBreakpoints.h | 2 - .../Debugger/Debugger-MemoryDump.cpp | 20 +- .../Debugger/Debugger-MemorySearch.cpp | 425 +++++---- .../Debugger/Debugger-RegisterTabData.h | 1 - .../Debugger/Debugger-RegisterTabs.cpp | 214 ++--- .../Debugger/Debugger-Scripts.cpp | 100 +- .../Debugger/Debugger-ScriptsAutorun.cpp | 40 +- .../Debugger/Debugger-StackTrace.cpp | 24 +- .../Debugger/Debugger-StackView.cpp | 9 +- .../Debugger/Debugger-Symbols.cpp | 109 +-- .../UserInterface/Debugger/Debugger-TLB.cpp | 8 +- .../Debugger/Debugger-ViewMemory.cpp | 129 ++- .../UserInterface/Debugger/Debugger.cpp | 37 +- .../UserInterface/Debugger/MemoryScanner.cpp | 267 +++--- .../UserInterface/Debugger/MemoryScanner.h | 2 - .../Project64/UserInterface/Debugger/OpInfo.h | 2 - .../Debugger/ScriptAPI/JSIntervalWorker.cpp | 9 +- .../Debugger/ScriptAPI/JSServerWorker.cpp | 29 +- .../Debugger/ScriptAPI/JSSocketWorker.cpp | 103 +- .../Debugger/ScriptAPI/N64Image.cpp | 116 +-- .../Debugger/ScriptAPI/N64Image.h | 1 - .../Debugger/ScriptAPI/N64Image_PNG.cpp | 32 +- .../Debugger/ScriptAPI/ScriptAPI.cpp | 580 ++++++------ .../ScriptAPI/ScriptAPI_AddressRange.cpp | 71 +- .../Debugger/ScriptAPI/ScriptAPI_N64Image.cpp | 87 +- .../ScriptAPI/ScriptAPI_Number_hex.cpp | 9 +- .../Debugger/ScriptAPI/ScriptAPI_Server.cpp | 72 +- .../Debugger/ScriptAPI/ScriptAPI_Socket.cpp | 137 ++- .../Debugger/ScriptAPI/ScriptAPI_alert.cpp | 17 +- .../Debugger/ScriptAPI/ScriptAPI_asm.cpp | 29 +- .../Debugger/ScriptAPI/ScriptAPI_console.cpp | 39 +- .../Debugger/ScriptAPI/ScriptAPI_cpu.cpp | 157 +-- .../Debugger/ScriptAPI/ScriptAPI_debug.cpp | 41 +- .../Debugger/ScriptAPI/ScriptAPI_events.cpp | 368 ++++---- .../Debugger/ScriptAPI/ScriptAPI_exec.cpp | 31 +- .../Debugger/ScriptAPI/ScriptAPI_interval.cpp | 49 +- .../Debugger/ScriptAPI/ScriptAPI_mem.cpp | 178 ++-- .../Debugger/ScriptAPI/ScriptAPI_pj64.cpp | 115 +-- .../UserInterface/Debugger/ScriptInstance.cpp | 77 +- .../UserInterface/Debugger/ScriptSystem.cpp | 143 +-- .../UserInterface/Debugger/ScriptWorker.cpp | 16 +- .../UserInterface/Debugger/Symbols.cpp | 114 +-- .../UserInterface/Debugger/Symbols.h | 1 - Source/Project64/UserInterface/DiscordRPC.cpp | 99 +- .../Project64/UserInterface/EnhancementUI.cpp | 1 + Source/Project64/UserInterface/LoggingUI.cpp | 5 +- Source/Project64/UserInterface/MainMenu.cpp | 27 +- Source/Project64/UserInterface/MainWindow.cpp | 891 +++++++++--------- .../Project64/UserInterface/MenuShortCuts.cpp | 24 +- .../Project64/UserInterface/Notification.cpp | 1 + .../UserInterface/ProjectSupport.cpp | 9 +- Source/Project64/UserInterface/RomBrowser.cpp | 1 + .../UserInterface/RomInformation.cpp | 1 + .../Settings/SettingsPage-AdvancedOptions.cpp | 7 +- .../Settings/SettingsPage-Defaults.cpp | 6 +- .../Settings/SettingsPage-Directories.cpp | 77 +- .../Settings/SettingsPage-DiskDrive.cpp | 20 +- .../Settings/SettingsPage-Game-DiskDrive.cpp | 9 +- .../Settings/SettingsPage-Game-DiskDrive.h | 3 +- .../Settings/SettingsPage-Game-General.cpp | 15 +- .../Settings/SettingsPage-Game-General.h | 3 +- .../Settings/SettingsPage-Game-Plugin.cpp | 17 +- .../Settings/SettingsPage-Game-Plugin.h | 1 + .../Settings/SettingsPage-Game-Recompiler.cpp | 7 +- .../Settings/SettingsPage-Game-Recompiler.h | 1 + .../Settings/SettingsPage-Game-Status.cpp | 19 +- .../Settings/SettingsPage-Game-Status.h | 1 + .../Settings/SettingsPage-GameBrowser.cpp | 24 +- .../SettingsPage-KeyboardShortcuts.cpp | 50 +- .../Settings/SettingsPage-Options.cpp | 9 +- .../Settings/SettingsPage-Plugin.cpp | 7 +- .../UserInterface/Settings/SettingsPage.cpp | 26 +- .../UserInterface/SettingsConfig.cpp | 2 +- .../UserInterface/SupportEnterCode.cpp | 3 +- .../Project64/UserInterface/SupportWindow.cpp | 35 +- .../UserInterface/WTLControls/EditConInput.h | 2 - .../WTLControls/EditNumber32.cpp | 23 +- .../WTLControls/GetCWindowText.cpp | 1 + .../UserInterface/WTLControls/HexEditCtrl.cpp | 144 +-- .../UserInterface/WTLControls/HexEditCtrl.h | 1 - .../WTLControls/ModifiedEditBox.cpp | 14 +- .../WTLControls/PartialGroupBox.cpp | 154 +-- .../UserInterface/WTLControls/TooltipDialog.h | 2 - .../WTLControls/wtl-BitmapPicture.cpp | 95 +- .../Project64/UserInterface/WelcomeScreen.cpp | 10 +- Source/Project64/main.cpp | 14 +- Source/Project64/stdafx.cpp | 2 +- 108 files changed, 3500 insertions(+), 3311 deletions(-) diff --git a/Source/Project64/Plugins/PluginList.cpp b/Source/Project64/Plugins/PluginList.cpp index 893afb274..9b9753add 100644 --- a/Source/Project64/Plugins/PluginList.cpp +++ b/Source/Project64/Plugins/PluginList.cpp @@ -1,10 +1,11 @@ #include "stdafx.h" -#include + #include "PluginList.h" #include +#include CPluginList::CPluginList(bool bAutoFill /* = true */) : -m_PluginDir(g_Settings->LoadStringVal(Directory_Plugin), "") + m_PluginDir(g_Settings->LoadStringVal(Directory_Plugin), "") { if (bAutoFill) { @@ -75,14 +76,14 @@ void CPluginList::AddPluginFromDir(CPath Dir) continue; } - void(CALL *GetDllInfo) (PLUGIN_INFO * PluginInfo); + void(CALL * GetDllInfo)(PLUGIN_INFO * PluginInfo); GetDllInfo = (void(CALL *)(PLUGIN_INFO *))GetProcAddress(hLib, "GetDllInfo"); if (GetDllInfo == nullptr) { continue; } - PLUGIN Plugin = { 0 }; + PLUGIN Plugin = {0}; Plugin.Info.Reserved2 = true; GetDllInfo(&Plugin.Info); if (!CPlugin::ValidPluginVersion(Plugin.Info)) diff --git a/Source/Project64/Settings/GuiSettings.cpp b/Source/Project64/Settings/GuiSettings.cpp index 3cb962d93..a826c7d0e 100644 --- a/Source/Project64/Settings/GuiSettings.cpp +++ b/Source/Project64/Settings/GuiSettings.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" -int CGuiSettings::m_RefCount = 0; +int CGuiSettings::m_RefCount = 0; bool CGuiSettings::m_bCPURunning; bool CGuiSettings::m_bAutoSleep; @@ -9,8 +9,8 @@ CGuiSettings::CGuiSettings() m_RefCount += 1; if (m_RefCount == 1) { - g_Settings->RegisterChangeCB(GameRunning_CPU_Running,nullptr,RefreshSettings); - g_Settings->RegisterChangeCB((SettingID)Setting_AutoSleep,nullptr,RefreshSettings); + g_Settings->RegisterChangeCB(GameRunning_CPU_Running, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB((SettingID)Setting_AutoSleep, nullptr, RefreshSettings); RefreshSettings(nullptr); } } @@ -20,8 +20,8 @@ CGuiSettings::~CGuiSettings() m_RefCount -= 1; if (m_RefCount == 0) { - g_Settings->UnregisterChangeCB(GameRunning_CPU_Running,nullptr,RefreshSettings); - g_Settings->UnregisterChangeCB((SettingID)Setting_AutoSleep,nullptr,RefreshSettings); + g_Settings->UnregisterChangeCB(GameRunning_CPU_Running, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB((SettingID)Setting_AutoSleep, nullptr, RefreshSettings); } } diff --git a/Source/Project64/Settings/UISettings.cpp b/Source/Project64/Settings/UISettings.cpp index 9f75b6481..443a96170 100644 --- a/Source/Project64/Settings/UISettings.cpp +++ b/Source/Project64/Settings/UISettings.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "UISettings.h" #include #include @@ -13,7 +14,7 @@ void AddUISetting(UISettingID TypeID, CSettingType * Handler) g_Settings->AddHandler((SettingID)TypeID, Handler); } -void RegisterUISettings (void) +void RegisterUISettings(void) { // Information - temporary keys AddUISetting(Info_ShortCutsChanged, new CSettingTypeTempBool(false)); @@ -24,10 +25,10 @@ void RegisterUISettings (void) // Settings location AddUISetting(Setting_PluginPageFirst, new CSettingTypeApplication("Settings", "Plugin Page First", false)); - AddUISetting(Setting_DisableScrSaver, new CSettingTypeApplication("Settings", "Disable Screen Saver", (uint32_t)true)); + AddUISetting(Setting_DisableScrSaver, new CSettingTypeApplication("Settings", "Disable Screen Saver", (uint32_t) true)); AddUISetting(Setting_EnableDiscordRPC, new CSettingTypeApplication("Settings", "Enable Discord RPC", true)); - AddUISetting(Setting_AutoSleep, new CSettingTypeApplication("Settings", "Auto Sleep", (uint32_t)true)); - AddUISetting(Setting_AutoFullscreen, new CSettingTypeApplication("Settings", "Auto Full Screen", (uint32_t)false)); + AddUISetting(Setting_AutoSleep, new CSettingTypeApplication("Settings", "Auto Sleep", (uint32_t) true)); + AddUISetting(Setting_AutoFullscreen, new CSettingTypeApplication("Settings", "Auto Full Screen", (uint32_t) false)); // RDB settings AddUISetting(Rdb_Status, new CSettingTypeRomDatabase("Status", "Unknown")); @@ -38,7 +39,7 @@ void RegisterUISettings (void) AddUISetting(UserInterface_InFullScreen, new CSettingTypeTempBool(false)); AddUISetting(UserInterface_MainWindowTop, new CSettingTypeApplication("Main Window", "Top", Default_None)); AddUISetting(UserInterface_MainWindowLeft, new CSettingTypeApplication("Main Window", "Left", Default_None)); - AddUISetting(UserInterface_AlwaysOnTop, new CSettingTypeApplication("Settings", "Always on top", (uint32_t)false)); + AddUISetting(UserInterface_AlwaysOnTop, new CSettingTypeApplication("Settings", "Always on top", (uint32_t) false)); AddUISetting(UserInterface_ShowStatusBar, new CSettingTypeApplication("Settings", "Show Status Bar", true)); AddUISetting(UserInterface_ExitFullscreenOnLoseFocus, new CSettingTypeApplication("Settings", "Exit Full Screen On Lose Focus", false)); AddUISetting(UserInterface_ShowingNagWindow, new CSettingTypeTempBool(false)); @@ -77,7 +78,7 @@ void RegisterUISettings (void) AddUISetting(DebuggerUI_ExceptionBPPos, new CSettingTypeApplication("Debugger UI", "Exception BP Pos", Default_None)); } -float DPIScale(void) +float DPIScale(void) { return CClientDC(0).GetDeviceCaps(LOGPIXELSX) / 96.0f; } @@ -124,7 +125,7 @@ bool UISettingsLoadBool(UISettingID Type) bool UISettingsLoadBoolIndex(UISettingID Type, int32_t index) { - return g_Settings->LoadBoolIndex((SettingID)Type,index); + return g_Settings->LoadBoolIndex((SettingID)Type, index); } uint32_t UISettingsLoadDword(UISettingID Type) @@ -162,5 +163,5 @@ std::string UISettingsLoadStringVal(UISettingID Type) bool UISettingsLoadStringVal(UISettingID Type, char * Buffer, int32_t BufferSize) { - return g_Settings->LoadStringVal((SettingID)Type,Buffer,BufferSize); + return g_Settings->LoadStringVal((SettingID)Type, Buffer, BufferSize); } diff --git a/Source/Project64/UserInterface/About.cpp b/Source/Project64/UserInterface/About.cpp index 184aabb5c..2af772b26 100644 --- a/Source/Project64/UserInterface/About.cpp +++ b/Source/Project64/UserInterface/About.cpp @@ -1,4 +1,5 @@ -#include +#include "stdafx.h" + #include CAboutDlg::CAboutDlg(CProjectSupport & Support) : @@ -20,7 +21,7 @@ LRESULT CAboutDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPara CDC hDC = GetDC(); float DPIScale = hDC.GetDeviceCaps(LOGPIXELSX) / 96.0f; - LOGFONT lf = { 0 }; + LOGFONT lf = {0}; CFontHandle(GetDlgItem(IDC_VERSION).GetFont()).GetLogFont(&lf); lf.lfHeight = (int)(16 * DPIScale); m_TextFont.CreateFontIndirect(&lf); @@ -38,7 +39,7 @@ LRESULT CAboutDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPara return TRUE; } -void CAboutDlg::SetWindowDetais(int nIDDlgItem, int nAboveIDDlgItem, const wchar_t * Text, const HFONT &font) +void CAboutDlg::SetWindowDetais(int nIDDlgItem, int nAboveIDDlgItem, const wchar_t * Text, const HFONT & font) { CWindow Wnd = GetDlgItem(nIDDlgItem); Wnd.SetWindowText(Text); @@ -55,7 +56,7 @@ void CAboutDlg::SetWindowDetais(int nIDDlgItem, int nAboveIDDlgItem, const wchar { Wnd.SetWindowPos(nullptr, 0, 0, rcWin.Width(), rcWin.Height(), SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER); } - + CWindow AboveWnd = GetDlgItem(nAboveIDDlgItem); AboveWnd.GetWindowRect(&rcWin); ::MapWindowPoints(nullptr, m_hWnd, (LPPOINT)&rcWin, 2); @@ -66,8 +67,7 @@ void CAboutDlg::SetWindowDetais(int nIDDlgItem, int nAboveIDDlgItem, const wchar Wnd.SetWindowPos(nullptr, rcWin.left, Top, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOOWNERZORDER); } - -LRESULT CAboutDlg::OnColorStatic(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CAboutDlg::OnColorStatic(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL & /*bHandled*/) { HDC hdcStatic = (HDC)wParam; SetTextColor(hdcStatic, RGB(0, 0, 0)); @@ -75,7 +75,7 @@ LRESULT CAboutDlg::OnColorStatic(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/ return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH)); } -LRESULT CAboutDlg::OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CAboutDlg::OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL & /*bHandled*/) { static HPEN outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF); static HBRUSH fill = CreateSolidBrush(0x00FFFFFF); diff --git a/Source/Project64/UserInterface/CheatUI.cpp b/Source/Project64/UserInterface/CheatUI.cpp index c7319bec8..21eb52b7e 100644 --- a/Source/Project64/UserInterface/CheatUI.cpp +++ b/Source/Project64/UserInterface/CheatUI.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include CCheatsUI::CCheatsUI(void) : @@ -36,7 +37,7 @@ void CCheatsUI::Display(HWND hParent, bool BlockExecution) } } -LRESULT CCheatsUI::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CCheatsUI::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { bool inBasicMode = g_Settings->LoadBool(UserInterface_BasicMode); m_StateBtn.Attach(GetDlgItem(IDC_STATE)); @@ -96,13 +97,13 @@ LRESULT CCheatsUI::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPara return 0; } -LRESULT CCheatsUI::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CCheatsUI::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { m_StateBtn.Detach(); return 0; } -LRESULT CCheatsUI::OnCloseCmd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CCheatsUI::OnCloseCmd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { if (m_EditCheat.ValuesChanged()) { @@ -124,7 +125,7 @@ LRESULT CCheatsUI::OnCloseCmd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl return 0; } -LRESULT CCheatsUI::OnStateChange(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CCheatsUI::OnStateChange(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { WINDOWPLACEMENT WndPlac; WndPlac.length = sizeof(WndPlac); @@ -169,7 +170,7 @@ CCheatList::~CCheatList() { } -LRESULT CCheatList::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CCheatList::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { GetDlgItem(IDC_NOTESFRAME).SetWindowText(wGS(CHEAT_NOTES_FRAME).c_str()); GetDlgItem(IDC_UNMARK).SetWindowText(wGS(CHEAT_MARK_NONE).c_str()); @@ -180,8 +181,8 @@ LRESULT CCheatList::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPar CRect hCheatTreeRect(6, 4, rcList.right - rcList.left - 13, rcButton.top - rcList.top - 8); m_hCheatTree.Create(m_hWnd, &hCheatTreeRect, L"", - WS_CHILD | WS_VISIBLE | WS_VSCROLL | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_DISABLEDRAGDROP | WS_TABSTOP | TVS_FULLROWSELECT, - WS_EX_CLIENTEDGE, (HMENU)IDC_MYTREE); + WS_CHILD | WS_VISIBLE | WS_VSCROLL | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_DISABLEDRAGDROP | WS_TABSTOP | TVS_FULLROWSELECT, + WS_EX_CLIENTEDGE, (HMENU)IDC_MYTREE); m_hCheatTree.SetWindowLong(GWL_STYLE, TVS_CHECKBOXES | TVS_SHOWSELALWAYS | m_hCheatTree.GetWindowLong(GWL_STYLE)); CImageList hImageList; @@ -193,17 +194,17 @@ LRESULT CCheatList::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPar return true; } -LRESULT CCheatList::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CCheatList::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { m_hCheatTree.Detach(); return 0; } -LRESULT CCheatList::OnChangeCodeExtension(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) +LRESULT CCheatList::OnChangeCodeExtension(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL & /*bHandled*/) { m_hSelectedItem = (HTREEITEM)lParam; - TVITEM item = { 0 }; + TVITEM item = {0}; item.mask = TVIF_PARAM; item.hItem = m_hSelectedItem; if (!m_hCheatTree.GetItem(&item) || item.lParam == NULL) @@ -232,7 +233,7 @@ LRESULT CCheatList::OnChangeCodeExtension(UINT /*uMsg*/, WPARAM /*wParam*/, LPAR return 0; } -LRESULT CCheatList::OnPopupDelete(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CCheatList::OnPopupDelete(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { int Response = MessageBox(wGS(MSG_DEL_SURE).c_str(), wGS(MSG_DEL_TITLE).c_str(), MB_YESNO | MB_ICONQUESTION); if (Response != IDYES) @@ -240,7 +241,7 @@ LRESULT CCheatList::OnPopupDelete(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWn return 0; } - TVITEM item = { 0 }; + TVITEM item = {0}; item.hItem = m_hSelectedItem; item.mask = TVIF_PARAM; m_hCheatTree.GetItem(&item); @@ -251,7 +252,7 @@ LRESULT CCheatList::OnPopupDelete(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWn return 0; } -LRESULT CCheatList::OnUnmark(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CCheatList::OnUnmark(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { ChangeChildrenStatus(TVI_ROOT, false); if (g_Enhancements != nullptr) @@ -261,10 +262,10 @@ LRESULT CCheatList::OnUnmark(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl* return 0; } -LRESULT CCheatList::OnTreeClicked(NMHDR* lpnmh) +LRESULT CCheatList::OnTreeClicked(NMHDR * lpnmh) { uint32_t dwpos = GetMessagePos(); - TVHITTESTINFO ht = { 0 }; + TVHITTESTINFO ht = {0}; ht.pt.x = GET_X_LPARAM(dwpos); ht.pt.y = GET_Y_LPARAM(dwpos); ::MapWindowPoints(HWND_DESKTOP, lpnmh->hwndFrom, &ht.pt, 1); @@ -279,10 +280,10 @@ LRESULT CCheatList::OnTreeClicked(NMHDR* lpnmh) case TV_STATE_INDETERMINATE: if (m_hCheatTree.GetChildItem(ht.hItem) == nullptr) { - TVITEM item = { 0 }; + TVITEM item = {0}; item.mask = TVIF_PARAM; item.hItem = ht.hItem; - m_hCheatTree.GetItem(&item); + m_hCheatTree.GetItem(&item); if (item.lParam != NULL) { CEnhancement * Enhancement = (CEnhancement *)item.lParam; @@ -310,7 +311,7 @@ LRESULT CCheatList::OnTreeClicked(NMHDR* lpnmh) case TV_STATE_CLEAR: TV_SetCheckState(ht.hItem, TV_STATE_CHECKED); break; case TV_STATE_INDETERMINATE: TV_SetCheckState(ht.hItem, TV_STATE_CLEAR); break; } - + if (g_Enhancements != nullptr) { g_Enhancements->UpdateCheats(); @@ -319,12 +320,12 @@ LRESULT CCheatList::OnTreeClicked(NMHDR* lpnmh) return 0; } -LRESULT CCheatList::OnTreeRClicked(NMHDR* lpnmh) +LRESULT CCheatList::OnTreeRClicked(NMHDR * lpnmh) { if (g_Settings->LoadBool(UserInterface_BasicMode)) { return true; } // Work out what item is selected - TVHITTESTINFO ht = { 0 }; + TVHITTESTINFO ht = {0}; uint32_t dwpos = GetMessagePos(); // Include and header files @@ -354,10 +355,10 @@ LRESULT CCheatList::OnTreeRClicked(NMHDR* lpnmh) return true; } -LRESULT CCheatList::OnTreeDClicked(NMHDR* lpnmh) +LRESULT CCheatList::OnTreeDClicked(NMHDR * lpnmh) { uint32_t dwpos = GetMessagePos(); - TVHITTESTINFO ht = { 0 }; + TVHITTESTINFO ht = {0}; ht.pt.x = GET_X_LPARAM(dwpos); ht.pt.y = GET_Y_LPARAM(dwpos); ::MapWindowPoints(HWND_DESKTOP, lpnmh->hwndFrom, &ht.pt, 1); @@ -377,7 +378,7 @@ LRESULT CCheatList::OnTreeSelChanged(NMHDR * /*lpnmh*/) GetDlgItem(IDC_NOTES).SetWindowText(L""); if (m_hCheatTree.GetChildItem(hItem) == nullptr) { - TVITEM item = { 0 }; + TVITEM item = {0}; item.mask = TVIF_PARAM; item.hItem = hItem; m_hCheatTree.GetItem(&item); @@ -405,15 +406,15 @@ void CCheatList::RefreshItems() for (CEnhancementList::iterator itr = m_Cheats.begin(); itr != m_Cheats.end(); itr++) { std::string Name = itr->second.GetNameAndExtension(); - if (Name.length() == 0) - { - continue; + if (Name.length() == 0) + { + continue; } AddCodeLayers((LPARAM)&itr->second, stdstr(Name).ToUTF16(), TVI_ROOT, itr->second.Active()); } } -void CCheatList::AddCodeLayers(LPARAM Enhancement, const std::wstring &Name, HTREEITEM hParent, bool CheatActive) +void CCheatList::AddCodeLayers(LPARAM Enhancement, const std::wstring & Name, HTREEITEM hParent, bool CheatActive) { TV_INSERTSTRUCT tv; @@ -551,7 +552,7 @@ void CCheatList::DeleteCheat(LPARAM Enhancement) CCheatList::TV_CHECK_STATE CCheatList::TV_GetCheckState(HTREEITEM hItem) { - TVITEM tvItem = { 0 }; + TVITEM tvItem = {0}; tvItem.mask = TVIF_HANDLE | TVIF_STATE; tvItem.hItem = hItem; tvItem.stateMask = TVIS_STATEIMAGEMASK; @@ -569,7 +570,7 @@ CCheatList::TV_CHECK_STATE CCheatList::TV_GetCheckState(HTREEITEM hItem) bool CCheatList::TV_SetCheckState(HTREEITEM hItem, TV_CHECK_STATE state) { - TVITEM tvItem = { 0 }; + TVITEM tvItem = {0}; tvItem.mask = TVIF_HANDLE | TVIF_STATE; tvItem.hItem = (HTREEITEM)hItem; tvItem.stateMask = TVIS_STATEIMAGEMASK; @@ -591,7 +592,7 @@ void CCheatList::MenuSetText(HMENU hMenu, int MenuPos, const wchar_t * Title, co return; } - MENUITEMINFO MenuInfo = { 0 }; + MENUITEMINFO MenuInfo = {0}; wchar_t String[256]; MenuInfo.cbSize = sizeof(MENUITEMINFO); MenuInfo.fMask = MIIM_TYPE; @@ -618,7 +619,7 @@ CEditCheat::~CEditCheat() { } -LRESULT CEditCheat::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CEditCheat::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { GetDlgItem(IDC_NAME).SetWindowText(wGS(CHEAT_ADDCHEAT_NAME).c_str()); GetDlgItem(IDC_CODE).SetWindowText(wGS(CHEAT_ADDCHEAT_CODE).c_str()); @@ -632,7 +633,7 @@ LRESULT CEditCheat::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPar return 0; } -LRESULT CEditCheat::OnEditCheat(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CEditCheat::OnEditCheat(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL & /*bHandled*/) { if (ValuesChanged()) { @@ -679,7 +680,7 @@ LRESULT CEditCheat::OnEditCheat(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, return 0; } -LRESULT CEditCheat::OnAddCheat(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CEditCheat::OnAddCheat(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { std::string NewCheatName = GetCWindowText(GetDlgItem(IDC_CODE_NAME)); for (CEnhancementList::const_iterator itr = m_Cheats.begin(); itr != m_Cheats.end(); itr++) @@ -722,7 +723,7 @@ LRESULT CEditCheat::OnAddCheat(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCt return 0; } -LRESULT CEditCheat::OnNewCheat(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CEditCheat::OnNewCheat(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { if (ValuesChanged()) { @@ -740,19 +741,19 @@ LRESULT CEditCheat::OnNewCheat(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCt return 0; } -LRESULT CEditCheat::OnCodeNameChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CEditCheat::OnCodeNameChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { DetailsChanged(); return 0; } -LRESULT CEditCheat::OnCheatCodeChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CEditCheat::OnCheatCodeChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { DetailsChanged(); return 0; } -LRESULT CEditCheat::OnCheatOptionsChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CEditCheat::OnCheatOptionsChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { DetailsChanged(); return 0; @@ -902,7 +903,7 @@ CEnhancementCodeEx::CEnhancementCodeEx(CEnhancement * Enhancement) : { } -LRESULT CEnhancementCodeEx::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CEnhancementCodeEx::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { SetWindowText(wGS(CHEAT_CODE_EXT_TITLE).c_str()); GetDlgItem(IDC_NOTE).SetWindowText(wGS(CHEAT_CODE_EXT_TXT).c_str()); @@ -910,7 +911,7 @@ LRESULT CEnhancementCodeEx::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA GetDlgItem(IDCANCEL).SetWindowText(wGS(CHEAT_CANCEL).c_str()); GetDlgItem(IDC_CHEAT_NAME).SetWindowText(stdstr(m_Enhancement->GetName()).ToUTF16().c_str()); - + CListBox CheatList = GetDlgItem(IDC_CHEAT_LIST); CEnhancement::CodeOptions Options = m_Enhancement->GetOptions(); bool OptionSelected = m_Enhancement->OptionSelected(); @@ -931,13 +932,13 @@ LRESULT CEnhancementCodeEx::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA return 0; } -LRESULT CEnhancementCodeEx::OnListDblClick(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CEnhancementCodeEx::OnListDblClick(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { PostMessage(WM_COMMAND, IDOK, 0); return 0; } -LRESULT CEnhancementCodeEx::OnOkCmd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CEnhancementCodeEx::OnOkCmd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { CListBox CheatList = GetDlgItem(IDC_CHEAT_LIST); int index = CheatList.GetCurSel(); @@ -955,7 +956,7 @@ LRESULT CEnhancementCodeEx::OnOkCmd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*h return 0; } -LRESULT CEnhancementCodeEx::OnCloseCmd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CEnhancementCodeEx::OnCloseCmd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { EndDialog(0); return 0; diff --git a/Source/Project64/UserInterface/Debugger/Assembler.cpp b/Source/Project64/UserInterface/Debugger/Assembler.cpp index 947e2ead3..c01909a03 100644 --- a/Source/Project64/UserInterface/Debugger/Assembler.cpp +++ b/Source/Project64/UserInterface/Debugger/Assembler.cpp @@ -1,39 +1,39 @@ -#include -#include -#include -#include - #include "stdafx.h" +#include +#include +#include +#include + #include "Assembler.h" #include "Project64-core/N64System/Mips/R4300iOpcode.h" ASM_PARSE_ERROR CAssembler::m_ParseError = ERR_NONE; uint32_t CAssembler::m_Address = 0; -char* CAssembler::m_TokContext = nullptr; +char * CAssembler::m_TokContext = nullptr; -const ASM_SYNTAX_FN CAssembler::syn_jump[] = { arg_jump, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_loadstore[] = { arg_reg_t, arg_imm16, arg_reg_s, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_arith[] = { arg_reg_d, arg_reg_s, arg_reg_t, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_arith2[] = { arg_reg_s, arg_reg_t, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_shiftv[] = { arg_reg_d, arg_reg_t, arg_reg_s, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_arith_i[] = { arg_reg_t, arg_reg_s, arg_imm16, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_load_i[] = { arg_reg_t, arg_imm16, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_branch_z[] = { arg_reg_s, arg_bra_target, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_branch[] = { arg_reg_s, arg_reg_t, arg_bra_target, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_branch_unc[] = { arg_bra_target, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_trap_i[] = { arg_reg_s, arg_imm16, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_shift[] = { arg_reg_d, arg_reg_t, arg_shamt, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_mf[] = { arg_reg_d, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_jr[] = { arg_reg_s, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_jalr[] = { arg_reg_d, arg_reg_s, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_cop1_arith[] = { arg_reg_fd, arg_reg_fs, arg_reg_ft, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_cop1[] = { arg_reg_fd, arg_reg_fs, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_cop1_cmp[] = { arg_reg_fs, arg_reg_ft, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_cop_mv[] = { arg_reg_t, arg_reg_d, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_cache[] = { arg_cache_op, arg_imm16, arg_reg_s, nullptr }; -const ASM_SYNTAX_FN CAssembler::syn_syscall[] = { arg_syscall_code, nullptr }; +const ASM_SYNTAX_FN CAssembler::syn_jump[] = {arg_jump, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_loadstore[] = {arg_reg_t, arg_imm16, arg_reg_s, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_arith[] = {arg_reg_d, arg_reg_s, arg_reg_t, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_arith2[] = {arg_reg_s, arg_reg_t, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_shiftv[] = {arg_reg_d, arg_reg_t, arg_reg_s, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_arith_i[] = {arg_reg_t, arg_reg_s, arg_imm16, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_load_i[] = {arg_reg_t, arg_imm16, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_branch_z[] = {arg_reg_s, arg_bra_target, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_branch[] = {arg_reg_s, arg_reg_t, arg_bra_target, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_branch_unc[] = {arg_bra_target, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_trap_i[] = {arg_reg_s, arg_imm16, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_shift[] = {arg_reg_d, arg_reg_t, arg_shamt, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_mf[] = {arg_reg_d, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_jr[] = {arg_reg_s, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_jalr[] = {arg_reg_d, arg_reg_s, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_cop1_arith[] = {arg_reg_fd, arg_reg_fs, arg_reg_ft, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_cop1[] = {arg_reg_fd, arg_reg_fs, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_cop1_cmp[] = {arg_reg_fs, arg_reg_ft, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_cop_mv[] = {arg_reg_t, arg_reg_d, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_cache[] = {arg_cache_op, arg_imm16, arg_reg_s, nullptr}; +const ASM_SYNTAX_FN CAssembler::syn_syscall[] = {arg_syscall_code, nullptr}; const ASM_INSTRUCTION CAssembler::m_Instructions[] = { @@ -293,7 +293,7 @@ const ASM_REGISTER CAssembler::m_Registers[] = { nullptr } }; -bool CAssembler::AssembleLine(const char* line, uint32_t* opcode, uint32_t address) +bool CAssembler::AssembleLine(const char * line, uint32_t * opcode, uint32_t address) { m_ParseError = ERR_NONE; m_Address = address; @@ -308,21 +308,21 @@ bool CAssembler::AssembleLine(const char* line, uint32_t* opcode, uint32_t addre return true; } - char* name = strtok_s(line_c, " \t", &m_TokContext); - + char * name = strtok_s(line_c, " \t", &m_TokContext); + // Attempt to assemble the line // If a syntax error occurs, check if the command has alternative syntax forms and retry - for(int nFallback = 0;; nFallback++) + for (int nFallback = 0;; nFallback++) { - const ASM_INSTRUCTION* instruction = LookupInstruction(name, nFallback); + const ASM_INSTRUCTION * instruction = LookupInstruction(name, nFallback); if (instruction == nullptr) { m_ParseError = ERR_UNKNOWN_CMD; return false; } - + m_ParseError = ERR_NONE; if (nFallback > 0) @@ -358,7 +358,7 @@ bool CAssembler::AssembleLine(const char* line, uint32_t* opcode, uint32_t addre } } -const ASM_INSTRUCTION* CAssembler::LookupInstruction(char* name, int nFallback) +const ASM_INSTRUCTION * CAssembler::LookupInstruction(char * name, int nFallback) { for (int i = 0; m_Instructions[i].name != nullptr; i++) { @@ -375,7 +375,7 @@ const ASM_INSTRUCTION* CAssembler::LookupInstruction(char* name, int nFallback) return nullptr; } -const ASM_REGISTER* CAssembler::LookupRegister(char* name) +const ASM_REGISTER * CAssembler::LookupRegister(char * name) { for (int i = 0; m_Registers[i].name != nullptr; i++) { @@ -387,7 +387,7 @@ const ASM_REGISTER* CAssembler::LookupRegister(char* name) return nullptr; } -void CAssembler::StrToLower(char* str) +void CAssembler::StrToLower(char * str) { while (*str) { @@ -401,7 +401,7 @@ void CAssembler::StrToLower(char* str) uint32_t CAssembler::pop_reg() { - char* r = strtok_s(nullptr, " \t,()", &m_TokContext); + char * r = strtok_s(nullptr, " \t,()", &m_TokContext); if (r == nullptr) { @@ -409,7 +409,7 @@ uint32_t CAssembler::pop_reg() return 0; } - const ASM_REGISTER* reg = LookupRegister(r); + const ASM_REGISTER * reg = LookupRegister(r); if (reg == nullptr) { @@ -422,7 +422,7 @@ uint32_t CAssembler::pop_reg() uint32_t CAssembler::pop_val() { - char* v = strtok_s(nullptr, " \t,()", &m_TokContext); + char * v = strtok_s(nullptr, " \t,()", &m_TokContext); if (v == nullptr) { @@ -444,7 +444,7 @@ uint32_t CAssembler::pop_val() v++; } - char* endptr; + char * endptr; uint32_t val = strtoul(v, &endptr, base); @@ -517,63 +517,63 @@ uint32_t CAssembler::base_cop1_bc(uint32_t val) return (R4300i_CP1 << 26) | (R4300i_COP1_BC << 21) | (val << 16); } -void CAssembler::arg_reg_t(uint32_t* opcode) +void CAssembler::arg_reg_t(uint32_t * opcode) { *opcode |= pop_reg() << 16; } -void CAssembler::arg_reg_s(uint32_t* opcode) +void CAssembler::arg_reg_s(uint32_t * opcode) { *opcode |= pop_reg() << 21; } -void CAssembler::arg_reg_d(uint32_t* opcode) +void CAssembler::arg_reg_d(uint32_t * opcode) { *opcode |= pop_reg() << 11; } -void CAssembler::arg_reg_ft(uint32_t* opcode) +void CAssembler::arg_reg_ft(uint32_t * opcode) { *opcode |= pop_reg() << 16; } -void CAssembler::arg_reg_fs(uint32_t* opcode) +void CAssembler::arg_reg_fs(uint32_t * opcode) { *opcode |= pop_reg() << 11; } -void CAssembler::arg_reg_fd(uint32_t* opcode) +void CAssembler::arg_reg_fd(uint32_t * opcode) { *opcode |= pop_reg() << 6; } -void CAssembler::arg_jump(uint32_t* opcode) +void CAssembler::arg_jump(uint32_t * opcode) { *opcode |= (pop_val() / 4) & 0x3FFFFFF; } -void CAssembler::arg_imm16(uint32_t* opcode) +void CAssembler::arg_imm16(uint32_t * opcode) { *opcode |= (pop_val() & 0xFFFF); } -void CAssembler::arg_bra_target(uint32_t* opcode) +void CAssembler::arg_bra_target(uint32_t * opcode) { uint16_t relTarget = (((pop_val() - m_Address) / 4) & 0xFFFF) - 1; *opcode |= relTarget; } -void CAssembler::arg_shamt(uint32_t* opcode) +void CAssembler::arg_shamt(uint32_t * opcode) { *opcode |= (pop_val() & 0x1F) << 6; } -void CAssembler::arg_cache_op(uint32_t* opcode) +void CAssembler::arg_cache_op(uint32_t * opcode) { *opcode |= (pop_val() & 0x1F) << 16; } -void CAssembler::arg_syscall_code(uint32_t* opcode) +void CAssembler::arg_syscall_code(uint32_t * opcode) { *opcode |= (pop_val() & 0xFFFFF) << 6; } diff --git a/Source/Project64/UserInterface/Debugger/Breakpoints.cpp b/Source/Project64/UserInterface/Debugger/Breakpoints.cpp index 447c2e8cb..86488cd26 100644 --- a/Source/Project64/UserInterface/Debugger/Breakpoints.cpp +++ b/Source/Project64/UserInterface/Debugger/Breakpoints.cpp @@ -1,10 +1,10 @@ #include "stdafx.h" -#include "Breakpoints.h" -#include -#include +#include "Breakpoints.h" #include +#include #include +#include CBreakpoints::CBreakpoints() : m_bHaveRegBP(false), @@ -259,7 +259,7 @@ CBreakpoints::BPSTATE CBreakpoints::WriteBPExists64(uint32_t address) CBreakpoints::BPSTATE CBreakpoints::WriteBPExistsInChunk(uint32_t address, uint32_t nBytes) { uint32_t endAddr = address + nBytes; - + for (breakpoints_t::iterator breakpoint = m_WriteMem.begin(); breakpoint != m_WriteMem.end(); breakpoint++) { uint32_t wbpAddr = breakpoint->first; diff --git a/Source/Project64/UserInterface/Debugger/CPULog.cpp b/Source/Project64/UserInterface/Debugger/CPULog.cpp index 1fad66899..13f4099ac 100644 --- a/Source/Project64/UserInterface/Debugger/CPULog.cpp +++ b/Source/Project64/UserInterface/Debugger/CPULog.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "CPULog.h" #include @@ -24,7 +25,7 @@ CCPULog::CCPULog(size_t size) : m_Array = nullptr; return; } - + m_Array = new CPUState[m_Size]; } @@ -50,7 +51,7 @@ void CCPULog::PushState() m_bMaxed = true; } - CPUState* state = &m_Array[m_Index++]; + CPUState * state = &m_Array[m_Index++]; state->pc = g_Reg->m_PROGRAM_COUNTER; state->opcode = R4300iOp::m_Opcode; @@ -81,7 +82,7 @@ size_t CCPULog::GetSize(void) return m_Size; } -CPUState* CCPULog::GetEntry(size_t index) +CPUState * CCPULog::GetEntry(size_t index) { if (m_Array == nullptr) { @@ -108,7 +109,7 @@ CPUState* CCPULog::GetEntry(size_t index) void CCPULog::Reset() { size_t newSize; - + if (!g_Settings->LoadBool(Debugger_CPULoggingEnabled)) { newSize = 0; @@ -130,7 +131,7 @@ void CCPULog::Reset() delete[] m_Array; m_Array = nullptr; } - + if (m_Size != 0) { m_Array = new CPUState[m_Size]; @@ -138,23 +139,23 @@ void CCPULog::Reset() } } -CCPULog* CCPULog::Clone(void) +CCPULog * CCPULog::Clone(void) { if (m_Array == nullptr) { return nullptr; } - CCPULog *clone = new CCPULog(m_Size); + CCPULog * clone = new CCPULog(m_Size); clone->m_bMaxed = m_bMaxed; clone->m_Index = m_Index; memcpy(clone->m_Array, m_Array, sizeof(CPUState) * m_Size); return clone; } -void CCPULog::DumpToFile(const char* path) +void CCPULog::DumpToFile(const char * path) { - FILE* fp = fopen(path, "wb"); + FILE * fp = fopen(path, "wb"); if (fp == nullptr) { @@ -165,7 +166,7 @@ void CCPULog::DumpToFile(const char* path) for (size_t i = 0; i < count; i++) { - CPUState* state = GetEntry(i); + CPUState * state = GetEntry(i); R4300iInstruction Instruction(state->pc, state->opcode.Value); fprintf(fp, "%08X: %08X %s %s\n", state->pc, state->opcode.Value, Instruction.Name(), Instruction.Param()); } diff --git a/Source/Project64/UserInterface/Debugger/CPULog.h b/Source/Project64/UserInterface/Debugger/CPULog.h index a242401ce..7fdb36807 100644 --- a/Source/Project64/UserInterface/Debugger/CPULog.h +++ b/Source/Project64/UserInterface/Debugger/CPULog.h @@ -1,7 +1,5 @@ #pragma once -#include - typedef struct { uint32_t pc; diff --git a/Source/Project64/UserInterface/Debugger/DMALog.cpp b/Source/Project64/UserInterface/Debugger/DMALog.cpp index f44343e86..a9668381b 100644 --- a/Source/Project64/UserInterface/Debugger/DMALog.cpp +++ b/Source/Project64/UserInterface/Debugger/DMALog.cpp @@ -1,9 +1,10 @@ #include "stdafx.h" + #include "DMALog.h" void CDMALog::AddEntry(uint32_t romAddr, uint32_t ramAddr, uint32_t length) { - DMALOGENTRY entry = { romAddr, ramAddr, length }; + DMALOGENTRY entry = {romAddr, ramAddr, length}; m_Log.push_back(entry); } @@ -17,7 +18,7 @@ size_t CDMALog::GetNumEntries() return m_Log.size(); } -DMALOGENTRY* CDMALog::GetEntryByIndex(uint32_t index) +DMALOGENTRY * CDMALog::GetEntryByIndex(uint32_t index) { if (index < m_Log.size()) { @@ -26,7 +27,7 @@ DMALOGENTRY* CDMALog::GetEntryByIndex(uint32_t index) return nullptr; } -DMALOGENTRY* CDMALog::GetEntryByRamAddress(uint32_t ramAddr) +DMALOGENTRY * CDMALog::GetEntryByRamAddress(uint32_t ramAddr) { uint32_t nEntries = GetNumEntries(); @@ -48,9 +49,9 @@ DMALOGENTRY* CDMALog::GetEntryByRamAddress(uint32_t ramAddr) return nullptr; } -DMALOGENTRY* CDMALog::GetEntryByRamAddress(uint32_t ramAddr, uint32_t* lpRomAddr, uint32_t* lpOffset) +DMALOGENTRY * CDMALog::GetEntryByRamAddress(uint32_t ramAddr, uint32_t * lpRomAddr, uint32_t * lpOffset) { - DMALOGENTRY* lpEntry = GetEntryByRamAddress(ramAddr); + DMALOGENTRY * lpEntry = GetEntryByRamAddress(ramAddr); if (lpEntry == nullptr) { @@ -63,7 +64,7 @@ DMALOGENTRY* CDMALog::GetEntryByRamAddress(uint32_t ramAddr, uint32_t* lpRomAddr return lpEntry; } -DMALOGENTRY* CDMALog::GetEntryByRomAddress(uint32_t romAddr) +DMALOGENTRY * CDMALog::GetEntryByRomAddress(uint32_t romAddr) { uint32_t nEntries = GetNumEntries(); @@ -72,7 +73,7 @@ DMALOGENTRY* CDMALog::GetEntryByRomAddress(uint32_t romAddr) return nullptr; } - for (uint32_t i = nEntries - 1; i-- > 0; ) + for (uint32_t i = nEntries - 1; i-- > 0;) { uint32_t min = m_Log[i].romAddr; uint32_t max = min + m_Log[i].length - 1; @@ -85,9 +86,9 @@ DMALOGENTRY* CDMALog::GetEntryByRomAddress(uint32_t romAddr) return nullptr; } -DMALOGENTRY* CDMALog::GetEntryByRomAddress(uint32_t romAddr, uint32_t* lpRamAddr, uint32_t* lpOffset) +DMALOGENTRY * CDMALog::GetEntryByRomAddress(uint32_t romAddr, uint32_t * lpRamAddr, uint32_t * lpOffset) { - DMALOGENTRY* lpEntry = GetEntryByRomAddress(romAddr); + DMALOGENTRY * lpEntry = GetEntryByRomAddress(romAddr); if (lpEntry == nullptr) { diff --git a/Source/Project64/UserInterface/Debugger/DMALog.h b/Source/Project64/UserInterface/Debugger/DMALog.h index 0d404d2ae..180b1737d 100644 --- a/Source/Project64/UserInterface/Debugger/DMALog.h +++ b/Source/Project64/UserInterface/Debugger/DMALog.h @@ -1,7 +1,5 @@ #pragma once -#include - struct DMALOGENTRY { uint32_t romAddr; diff --git a/Source/Project64/UserInterface/Debugger/DebugMMU.cpp b/Source/Project64/UserInterface/Debugger/DebugMMU.cpp index 6a0bb5ffe..8038fa0dd 100644 --- a/Source/Project64/UserInterface/Debugger/DebugMMU.cpp +++ b/Source/Project64/UserInterface/Debugger/DebugMMU.cpp @@ -1,36 +1,36 @@ -#include +#include "stdafx.h" #include "DebugMMU.h" #include #include -#define PJMEM_CARTROM 1 +#define PJMEM_CARTROM 1 -uint8_t* CDebugMMU::GetPhysicalPtr(uint32_t paddr, WORD* flags) +uint8_t * CDebugMMU::GetPhysicalPtr(uint32_t paddr, WORD * flags) { if (g_MMU == nullptr) { return nullptr; } - uint8_t* ptr = nullptr; + uint8_t * ptr = nullptr; int nbyte = paddr & 3; paddr = paddr & ~3; - + bool bBigEndian = false; bool bCartRom = false; - if (paddr < g_MMU->RdramSize()) + if (paddr < g_MMU->RdramSize()) { - ptr = (uint8_t*)(g_MMU->Rdram() + paddr); + ptr = (uint8_t *)(g_MMU->Rdram() + paddr); } else if (paddr >= 0x04000000 && paddr <= 0x04000FFF) { - ptr = (uint8_t*)(g_MMU->Dmem() + paddr - 0x04000000); + ptr = (uint8_t *)(g_MMU->Dmem() + paddr - 0x04000000); } else if (paddr >= 0x04001000 && paddr <= 0x04001FFF) { - ptr = (uint8_t*)(g_MMU->Imem() + paddr - 0x04001000); + ptr = (uint8_t *)(g_MMU->Imem() + paddr - 0x04001000); } else if (paddr >= 0x05000000 && paddr <= 0x050004FF) // 64DD buffer { @@ -42,7 +42,7 @@ uint8_t* CDebugMMU::GetPhysicalPtr(uint32_t paddr, WORD* flags) if (g_DDRom != nullptr && iplRomOffset < g_DDRom->GetRomSize()) { - ptr = (uint8_t*)(g_MMU->Rdram() + paddr); + ptr = (uint8_t *)(g_MMU->Rdram() + paddr); } } else if (paddr >= 0x10000000 && paddr <= 0x1FBFFFFF) // Cartridge ROM @@ -50,14 +50,14 @@ uint8_t* CDebugMMU::GetPhysicalPtr(uint32_t paddr, WORD* flags) uint32_t cartRomOffset = paddr - 0x10000000; if (g_Rom != nullptr && cartRomOffset < g_Rom->GetRomSize()) { - ptr = (uint8_t*)(g_Rom->GetRomAddress() + cartRomOffset); + ptr = (uint8_t *)(g_Rom->GetRomAddress() + cartRomOffset); bCartRom = true; } } else if (paddr >= 0x1FC007C0 && paddr <= 0x1FC007FF) // PIF RAM { uint32_t pifRamOffset = paddr - 0x1FC007C0; - ptr = (uint8_t*)(g_MMU->PifRam() + pifRamOffset); + ptr = (uint8_t *)(g_MMU->PifRam() + pifRamOffset); bBigEndian = true; } else @@ -65,85 +65,85 @@ uint8_t* CDebugMMU::GetPhysicalPtr(uint32_t paddr, WORD* flags) // Note: write-only registers are excluded switch (paddr) { - case 0x03F00000: ptr = (uint8_t*)&g_Reg->RDRAM_CONFIG_REG; break; - case 0x03F00004: ptr = (uint8_t*)&g_Reg->RDRAM_DEVICE_ID_REG; break; - case 0x03F00008: ptr = (uint8_t*)&g_Reg->RDRAM_DELAY_REG; break; - case 0x03F0000C: ptr = (uint8_t*)&g_Reg->RDRAM_MODE_REG; break; - case 0x03F00010: ptr = (uint8_t*)&g_Reg->RDRAM_REF_INTERVAL_REG; break; - case 0x03F00014: ptr = (uint8_t*)&g_Reg->RDRAM_REF_ROW_REG; break; - case 0x03F00018: ptr = (uint8_t*)&g_Reg->RDRAM_RAS_INTERVAL_REG; break; - case 0x03F0001C: ptr = (uint8_t*)&g_Reg->RDRAM_MIN_INTERVAL_REG; break; - case 0x03F00020: ptr = (uint8_t*)&g_Reg->RDRAM_ADDR_SELECT_REG; break; - case 0x03F00024: ptr = (uint8_t*)&g_Reg->RDRAM_DEVICE_MANUF_REG; break; - case 0x04040010: ptr = (uint8_t*)&g_Reg->SP_STATUS_REG; break; - case 0x04040014: ptr = (uint8_t*)&g_Reg->SP_DMA_FULL_REG; break; - case 0x04040018: ptr = (uint8_t*)&g_Reg->SP_DMA_BUSY_REG; break; - case 0x0404001C: ptr = (uint8_t*)&g_Reg->SP_SEMAPHORE_REG; break; - case 0x04080000: ptr = (uint8_t*)&g_Reg->SP_PC_REG; break; - case 0x0410000C: ptr = (uint8_t*)&g_Reg->DPC_STATUS_REG; break; - case 0x04100010: ptr = (uint8_t*)&g_Reg->DPC_CLOCK_REG; break; - case 0x04100014: ptr = (uint8_t*)&g_Reg->DPC_BUFBUSY_REG; break; - case 0x04100018: ptr = (uint8_t*)&g_Reg->DPC_PIPEBUSY_REG; break; - case 0x0410001C: ptr = (uint8_t*)&g_Reg->DPC_TMEM_REG; break; - case 0x04300000: ptr = (uint8_t*)&g_Reg->MI_MODE_REG; break; - case 0x04300004: ptr = (uint8_t*)&g_Reg->MI_VERSION_REG; break; - case 0x04300008: ptr = (uint8_t*)&g_Reg->MI_INTR_REG; break; - case 0x0430000C: ptr = (uint8_t*)&g_Reg->MI_INTR_MASK_REG; break; - case 0x04400000: ptr = (uint8_t*)&g_Reg->VI_STATUS_REG; break; - case 0x04400004: ptr = (uint8_t*)&g_Reg->VI_ORIGIN_REG; break; - case 0x04400008: ptr = (uint8_t*)&g_Reg->VI_WIDTH_REG; break; - case 0x0440000C: ptr = (uint8_t*)&g_Reg->VI_INTR_REG; break; - case 0x04400010: ptr = (uint8_t*)&g_Reg->VI_V_CURRENT_LINE_REG; break; - case 0x04400014: ptr = (uint8_t*)&g_Reg->VI_BURST_REG; break; - case 0x04400018: ptr = (uint8_t*)&g_Reg->VI_V_SYNC_REG; break; - case 0x0440001C: ptr = (uint8_t*)&g_Reg->VI_H_SYNC_REG; break; - case 0x04400020: ptr = (uint8_t*)&g_Reg->VI_LEAP_REG; break; - case 0x04400024: ptr = (uint8_t*)&g_Reg->VI_H_START_REG; break; - case 0x04400028: ptr = (uint8_t*)&g_Reg->VI_V_START_REG; break; - case 0x0440002C: ptr = (uint8_t*)&g_Reg->VI_V_BURST_REG; break; - case 0x04400030: ptr = (uint8_t*)&g_Reg->VI_X_SCALE_REG; break; - case 0x04400034: ptr = (uint8_t*)&g_Reg->VI_Y_SCALE_REG; break; - case 0x04600000: ptr = (uint8_t*)&g_Reg->PI_DRAM_ADDR_REG; break; - case 0x04600004: ptr = (uint8_t*)&g_Reg->PI_CART_ADDR_REG; break; - case 0x04600008: ptr = (uint8_t*)&g_Reg->PI_RD_LEN_REG; break; - case 0x0460000C: ptr = (uint8_t*)&g_Reg->PI_WR_LEN_REG; break; - case 0x04600010: ptr = (uint8_t*)&g_Reg->PI_STATUS_REG; break; - case 0x04600014: ptr = (uint8_t*)&g_Reg->PI_DOMAIN1_REG; break; - case 0x04600018: ptr = (uint8_t*)&g_Reg->PI_BSD_DOM1_PWD_REG; break; - case 0x0460001C: ptr = (uint8_t*)&g_Reg->PI_BSD_DOM1_PGS_REG; break; - case 0x04600020: ptr = (uint8_t*)&g_Reg->PI_BSD_DOM1_RLS_REG; break; - case 0x04600024: ptr = (uint8_t*)&g_Reg->PI_DOMAIN2_REG; break; - case 0x04600028: ptr = (uint8_t*)&g_Reg->PI_BSD_DOM2_PWD_REG; break; - case 0x0460002C: ptr = (uint8_t*)&g_Reg->PI_BSD_DOM2_PGS_REG; break; - case 0x04600030: ptr = (uint8_t*)&g_Reg->PI_BSD_DOM2_RLS_REG; break; - case 0x04700000: ptr = (uint8_t*)&g_Reg->RI_MODE_REG; break; - case 0x04700004: ptr = (uint8_t*)&g_Reg->RI_CONFIG_REG; break; - case 0x04700008: ptr = (uint8_t*)&g_Reg->RI_CURRENT_LOAD_REG; break; - case 0x0470000C: ptr = (uint8_t*)&g_Reg->RI_SELECT_REG; break; - case 0x04700010: ptr = (uint8_t*)&g_Reg->RI_REFRESH_REG; break; - case 0x04700014: ptr = (uint8_t*)&g_Reg->RI_LATENCY_REG; break; - case 0x04700018: ptr = (uint8_t*)&g_Reg->RI_RERROR_REG; break; - case 0x0470001C: ptr = (uint8_t*)&g_Reg->RI_WERROR_REG; break; - case 0x04800018: ptr = (uint8_t*)&g_Reg->SI_STATUS_REG; break; - case 0x05000500: ptr = (uint8_t*)&g_Reg->ASIC_DATA; break; - case 0x05000504: ptr = (uint8_t*)&g_Reg->ASIC_MISC_REG; break; - case 0x05000508: ptr = (uint8_t*)&g_Reg->ASIC_STATUS; break; - case 0x0500050C: ptr = (uint8_t*)&g_Reg->ASIC_CUR_TK; break; - case 0x05000510: ptr = (uint8_t*)&g_Reg->ASIC_BM_STATUS; break; - case 0x05000514: ptr = (uint8_t*)&g_Reg->ASIC_ERR_SECTOR; break; - case 0x05000518: ptr = (uint8_t*)&g_Reg->ASIC_SEQ_STATUS; break; - case 0x0500051C: ptr = (uint8_t*)&g_Reg->ASIC_CUR_SECTOR; break; - case 0x05000520: ptr = (uint8_t*)&g_Reg->ASIC_HARD_RESET; break; - case 0x05000524: ptr = (uint8_t*)&g_Reg->ASIC_C1_S0; break; - case 0x05000528: ptr = (uint8_t*)&g_Reg->ASIC_HOST_SECBYTE; break; - case 0x0500052C: ptr = (uint8_t*)&g_Reg->ASIC_C1_S2; break; - case 0x05000530: ptr = (uint8_t*)&g_Reg->ASIC_SEC_BYTE; break; - case 0x05000534: ptr = (uint8_t*)&g_Reg->ASIC_C1_S4; break; - case 0x05000538: ptr = (uint8_t*)&g_Reg->ASIC_C1_S6; break; - case 0x0500053C: ptr = (uint8_t*)&g_Reg->ASIC_CUR_ADDR; break; - case 0x05000540: ptr = (uint8_t*)&g_Reg->ASIC_ID_REG; break; - case 0x05000544: ptr = (uint8_t*)&g_Reg->ASIC_TEST_REG; break; - case 0x05000548: ptr = (uint8_t*)&g_Reg->ASIC_TEST_PIN_SEL; break; + case 0x03F00000: ptr = (uint8_t *)&g_Reg->RDRAM_CONFIG_REG; break; + case 0x03F00004: ptr = (uint8_t *)&g_Reg->RDRAM_DEVICE_ID_REG; break; + case 0x03F00008: ptr = (uint8_t *)&g_Reg->RDRAM_DELAY_REG; break; + case 0x03F0000C: ptr = (uint8_t *)&g_Reg->RDRAM_MODE_REG; break; + case 0x03F00010: ptr = (uint8_t *)&g_Reg->RDRAM_REF_INTERVAL_REG; break; + case 0x03F00014: ptr = (uint8_t *)&g_Reg->RDRAM_REF_ROW_REG; break; + case 0x03F00018: ptr = (uint8_t *)&g_Reg->RDRAM_RAS_INTERVAL_REG; break; + case 0x03F0001C: ptr = (uint8_t *)&g_Reg->RDRAM_MIN_INTERVAL_REG; break; + case 0x03F00020: ptr = (uint8_t *)&g_Reg->RDRAM_ADDR_SELECT_REG; break; + case 0x03F00024: ptr = (uint8_t *)&g_Reg->RDRAM_DEVICE_MANUF_REG; break; + case 0x04040010: ptr = (uint8_t *)&g_Reg->SP_STATUS_REG; break; + case 0x04040014: ptr = (uint8_t *)&g_Reg->SP_DMA_FULL_REG; break; + case 0x04040018: ptr = (uint8_t *)&g_Reg->SP_DMA_BUSY_REG; break; + case 0x0404001C: ptr = (uint8_t *)&g_Reg->SP_SEMAPHORE_REG; break; + case 0x04080000: ptr = (uint8_t *)&g_Reg->SP_PC_REG; break; + case 0x0410000C: ptr = (uint8_t *)&g_Reg->DPC_STATUS_REG; break; + case 0x04100010: ptr = (uint8_t *)&g_Reg->DPC_CLOCK_REG; break; + case 0x04100014: ptr = (uint8_t *)&g_Reg->DPC_BUFBUSY_REG; break; + case 0x04100018: ptr = (uint8_t *)&g_Reg->DPC_PIPEBUSY_REG; break; + case 0x0410001C: ptr = (uint8_t *)&g_Reg->DPC_TMEM_REG; break; + case 0x04300000: ptr = (uint8_t *)&g_Reg->MI_MODE_REG; break; + case 0x04300004: ptr = (uint8_t *)&g_Reg->MI_VERSION_REG; break; + case 0x04300008: ptr = (uint8_t *)&g_Reg->MI_INTR_REG; break; + case 0x0430000C: ptr = (uint8_t *)&g_Reg->MI_INTR_MASK_REG; break; + case 0x04400000: ptr = (uint8_t *)&g_Reg->VI_STATUS_REG; break; + case 0x04400004: ptr = (uint8_t *)&g_Reg->VI_ORIGIN_REG; break; + case 0x04400008: ptr = (uint8_t *)&g_Reg->VI_WIDTH_REG; break; + case 0x0440000C: ptr = (uint8_t *)&g_Reg->VI_INTR_REG; break; + case 0x04400010: ptr = (uint8_t *)&g_Reg->VI_V_CURRENT_LINE_REG; break; + case 0x04400014: ptr = (uint8_t *)&g_Reg->VI_BURST_REG; break; + case 0x04400018: ptr = (uint8_t *)&g_Reg->VI_V_SYNC_REG; break; + case 0x0440001C: ptr = (uint8_t *)&g_Reg->VI_H_SYNC_REG; break; + case 0x04400020: ptr = (uint8_t *)&g_Reg->VI_LEAP_REG; break; + case 0x04400024: ptr = (uint8_t *)&g_Reg->VI_H_START_REG; break; + case 0x04400028: ptr = (uint8_t *)&g_Reg->VI_V_START_REG; break; + case 0x0440002C: ptr = (uint8_t *)&g_Reg->VI_V_BURST_REG; break; + case 0x04400030: ptr = (uint8_t *)&g_Reg->VI_X_SCALE_REG; break; + case 0x04400034: ptr = (uint8_t *)&g_Reg->VI_Y_SCALE_REG; break; + case 0x04600000: ptr = (uint8_t *)&g_Reg->PI_DRAM_ADDR_REG; break; + case 0x04600004: ptr = (uint8_t *)&g_Reg->PI_CART_ADDR_REG; break; + case 0x04600008: ptr = (uint8_t *)&g_Reg->PI_RD_LEN_REG; break; + case 0x0460000C: ptr = (uint8_t *)&g_Reg->PI_WR_LEN_REG; break; + case 0x04600010: ptr = (uint8_t *)&g_Reg->PI_STATUS_REG; break; + case 0x04600014: ptr = (uint8_t *)&g_Reg->PI_DOMAIN1_REG; break; + case 0x04600018: ptr = (uint8_t *)&g_Reg->PI_BSD_DOM1_PWD_REG; break; + case 0x0460001C: ptr = (uint8_t *)&g_Reg->PI_BSD_DOM1_PGS_REG; break; + case 0x04600020: ptr = (uint8_t *)&g_Reg->PI_BSD_DOM1_RLS_REG; break; + case 0x04600024: ptr = (uint8_t *)&g_Reg->PI_DOMAIN2_REG; break; + case 0x04600028: ptr = (uint8_t *)&g_Reg->PI_BSD_DOM2_PWD_REG; break; + case 0x0460002C: ptr = (uint8_t *)&g_Reg->PI_BSD_DOM2_PGS_REG; break; + case 0x04600030: ptr = (uint8_t *)&g_Reg->PI_BSD_DOM2_RLS_REG; break; + case 0x04700000: ptr = (uint8_t *)&g_Reg->RI_MODE_REG; break; + case 0x04700004: ptr = (uint8_t *)&g_Reg->RI_CONFIG_REG; break; + case 0x04700008: ptr = (uint8_t *)&g_Reg->RI_CURRENT_LOAD_REG; break; + case 0x0470000C: ptr = (uint8_t *)&g_Reg->RI_SELECT_REG; break; + case 0x04700010: ptr = (uint8_t *)&g_Reg->RI_REFRESH_REG; break; + case 0x04700014: ptr = (uint8_t *)&g_Reg->RI_LATENCY_REG; break; + case 0x04700018: ptr = (uint8_t *)&g_Reg->RI_RERROR_REG; break; + case 0x0470001C: ptr = (uint8_t *)&g_Reg->RI_WERROR_REG; break; + case 0x04800018: ptr = (uint8_t *)&g_Reg->SI_STATUS_REG; break; + case 0x05000500: ptr = (uint8_t *)&g_Reg->ASIC_DATA; break; + case 0x05000504: ptr = (uint8_t *)&g_Reg->ASIC_MISC_REG; break; + case 0x05000508: ptr = (uint8_t *)&g_Reg->ASIC_STATUS; break; + case 0x0500050C: ptr = (uint8_t *)&g_Reg->ASIC_CUR_TK; break; + case 0x05000510: ptr = (uint8_t *)&g_Reg->ASIC_BM_STATUS; break; + case 0x05000514: ptr = (uint8_t *)&g_Reg->ASIC_ERR_SECTOR; break; + case 0x05000518: ptr = (uint8_t *)&g_Reg->ASIC_SEQ_STATUS; break; + case 0x0500051C: ptr = (uint8_t *)&g_Reg->ASIC_CUR_SECTOR; break; + case 0x05000520: ptr = (uint8_t *)&g_Reg->ASIC_HARD_RESET; break; + case 0x05000524: ptr = (uint8_t *)&g_Reg->ASIC_C1_S0; break; + case 0x05000528: ptr = (uint8_t *)&g_Reg->ASIC_HOST_SECBYTE; break; + case 0x0500052C: ptr = (uint8_t *)&g_Reg->ASIC_C1_S2; break; + case 0x05000530: ptr = (uint8_t *)&g_Reg->ASIC_SEC_BYTE; break; + case 0x05000534: ptr = (uint8_t *)&g_Reg->ASIC_C1_S4; break; + case 0x05000538: ptr = (uint8_t *)&g_Reg->ASIC_C1_S6; break; + case 0x0500053C: ptr = (uint8_t *)&g_Reg->ASIC_CUR_ADDR; break; + case 0x05000540: ptr = (uint8_t *)&g_Reg->ASIC_ID_REG; break; + case 0x05000544: ptr = (uint8_t *)&g_Reg->ASIC_TEST_REG; break; + case 0x05000548: ptr = (uint8_t *)&g_Reg->ASIC_TEST_PIN_SEL; break; } } @@ -167,9 +167,9 @@ uint8_t* CDebugMMU::GetPhysicalPtr(uint32_t paddr, WORD* flags) } } -bool CDebugMMU::GetPhysicalByte(uint32_t paddr, uint8_t* value) +bool CDebugMMU::GetPhysicalByte(uint32_t paddr, uint8_t * value) { - uint8_t* ptr = GetPhysicalPtr(paddr, nullptr); + uint8_t * ptr = GetPhysicalPtr(paddr, nullptr); if (ptr != nullptr) { @@ -201,7 +201,7 @@ bool CDebugMMU::GetPhysicalByte(uint32_t paddr, uint8_t* value) return true; } } - + if (paddr >= 0x04500004 && paddr <= 0x04500007) { uint32_t audioLength; @@ -212,7 +212,7 @@ bool CDebugMMU::GetPhysicalByte(uint32_t paddr, uint8_t* value) } else { - CAudioPlugin* audioPlg = g_Plugins->Audio(); + CAudioPlugin * audioPlg = g_Plugins->Audio(); audioLength = audioPlg->AiReadLength != nullptr ? audioPlg->AiReadLength() : 0; } @@ -233,7 +233,7 @@ bool CDebugMMU::GetPhysicalByte(uint32_t paddr, uint8_t* value) bool CDebugMMU::SetPhysicalByte(uint32_t paddr, uint8_t value) { WORD flags; - uint8_t* ptr = GetPhysicalPtr(paddr, &flags); + uint8_t * ptr = GetPhysicalPtr(paddr, &flags); bool bCartRom = flags & PJMEM_CARTROM; if (ptr != nullptr) @@ -246,7 +246,7 @@ bool CDebugMMU::SetPhysicalByte(uint32_t paddr, uint8_t value) { ProtectMemory(g_Rom->GetRomAddress(), g_Rom->GetRomSize(), MEM_READWRITE); *ptr = value; - ProtectMemory(g_Rom->GetRomAddress(), g_Rom->GetRomSize(), MEM_READONLY); + ProtectMemory(g_Rom->GetRomAddress(), g_Rom->GetRomSize(), MEM_READONLY); } return true; } @@ -273,7 +273,7 @@ bool CDebugMMU::SetPhysicalByte(uint32_t paddr, uint8_t value) return false; } -size_t CDebugMMU::ReadPhysical(uint32_t paddr, size_t length, uint8_t* buffer) +size_t CDebugMMU::ReadPhysical(uint32_t paddr, size_t length, uint8_t * buffer) { size_t nByte; for (nByte = 0; nByte < length; nByte++) @@ -286,7 +286,7 @@ size_t CDebugMMU::ReadPhysical(uint32_t paddr, size_t length, uint8_t* buffer) return nByte; } -size_t CDebugMMU::ReadVirtual(uint32_t vaddr, size_t length, uint8_t* buffer) +size_t CDebugMMU::ReadVirtual(uint32_t vaddr, size_t length, uint8_t * buffer) { size_t nByte; for (nByte = 0; nByte < length; nByte++) @@ -304,7 +304,7 @@ size_t CDebugMMU::ReadVirtual(uint32_t vaddr, size_t length, uint8_t* buffer) return nByte; } -size_t CDebugMMU::WritePhysical(uint32_t paddr, size_t length, uint8_t* buffer) +size_t CDebugMMU::WritePhysical(uint32_t paddr, size_t length, uint8_t * buffer) { size_t nByte; for (nByte = 0; nByte < length; nByte++) @@ -317,7 +317,7 @@ size_t CDebugMMU::WritePhysical(uint32_t paddr, size_t length, uint8_t* buffer) return nByte; } -size_t CDebugMMU::WriteVirtual(uint32_t vaddr, size_t length, uint8_t* buffer) +size_t CDebugMMU::WriteVirtual(uint32_t vaddr, size_t length, uint8_t * buffer) { size_t nByte; for (nByte = 0; nByte < length; nByte++) diff --git a/Source/Project64/UserInterface/Debugger/DebugMMU.h b/Source/Project64/UserInterface/Debugger/DebugMMU.h index 72a7691af..fe543bffb 100644 --- a/Source/Project64/UserInterface/Debugger/DebugMMU.h +++ b/Source/Project64/UserInterface/Debugger/DebugMMU.h @@ -1,5 +1,4 @@ #pragma once -#include class CDebugMMU { diff --git a/Source/Project64/UserInterface/Debugger/Debugger-AddBreakpoint.cpp b/Source/Project64/UserInterface/Debugger/Debugger-AddBreakpoint.cpp index 03829a816..000cc57d4 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-AddBreakpoint.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-AddBreakpoint.cpp @@ -2,7 +2,7 @@ #include "DebuggerUI.h" -LRESULT CAddBreakpointDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CAddBreakpointDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { CenterWindow(); m_AddressEdit.Attach(GetDlgItem(IDC_ADDR_EDIT)); @@ -12,7 +12,7 @@ LRESULT CAddBreakpointDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM return FALSE; } -LRESULT CAddBreakpointDlg::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/) +LRESULT CAddBreakpointDlg::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL & /*bHandled*/) { switch (wID) { @@ -21,7 +21,7 @@ LRESULT CAddBreakpointDlg::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& std::string addrStr = GetCWindowText(m_AddressEdit); uint32_t address = stoul(addrStr.c_str(), nullptr, 16); - CBreakpoints* breakpoints = m_Debugger->Breakpoints(); + CBreakpoints * breakpoints = m_Debugger->Breakpoints(); if (m_ReadCheck.GetCheck()) { diff --git a/Source/Project64/UserInterface/Debugger/Debugger-AddSymbol.cpp b/Source/Project64/UserInterface/Debugger/Debugger-AddSymbol.cpp index 9c33b8d18..5a499a2ec 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-AddSymbol.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-AddSymbol.cpp @@ -3,7 +3,7 @@ #include "DebuggerUI.h" #include "Symbols.h" -LRESULT CAddSymbolDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CAddSymbolDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { CenterWindow(); @@ -15,14 +15,14 @@ LRESULT CAddSymbolDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*l for (int i = 0;; i++) { - const char* typeName = CSymbolTable::m_SymbolTypes[i].name; + const char * typeName = CSymbolTable::m_SymbolTypes[i].name; if (typeName == nullptr) { break; } m_TypeComboBox.AddString(stdstr(typeName).ToUTF16().c_str()); } - + m_AddressEdit.SetWindowText(L""); m_AddressEdit.SetFocus(); @@ -32,7 +32,7 @@ LRESULT CAddSymbolDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*l m_TypeComboBox.SetFocus(); } - if(m_bHaveType) + if (m_bHaveType) { m_TypeComboBox.SetCurSel(m_InitType); m_NameEdit.SetFocus(); @@ -41,11 +41,11 @@ LRESULT CAddSymbolDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*l { m_TypeComboBox.SetCurSel(SYM_DATA); } - + return FALSE; } -LRESULT CAddSymbolDlg::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CAddSymbolDlg::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { switch (wID) { @@ -66,13 +66,13 @@ LRESULT CAddSymbolDlg::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl* int nameLen = m_NameEdit.GetWindowTextLength(); int descLen = m_DescriptionEdit.GetWindowTextLength(); - + if (!nameLen && !descLen) { MessageBox(L"Name and/or description required", L"Error", MB_OK); return 0; } - + m_Debugger->SymbolTable()->AddSymbol(type, address, GetCWindowText(m_NameEdit).c_str(), GetCWindowText(m_DescriptionEdit).c_str()); m_Debugger->SymbolTable()->Save(); @@ -84,7 +84,7 @@ LRESULT CAddSymbolDlg::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl* return 0; } -INT_PTR CAddSymbolDlg::DoModal(CDebuggerUI* debugger) +INT_PTR CAddSymbolDlg::DoModal(CDebuggerUI * debugger) { m_Debugger = debugger; m_bHaveAddress = false; @@ -92,7 +92,7 @@ INT_PTR CAddSymbolDlg::DoModal(CDebuggerUI* debugger) return CDialogImpl::DoModal(); } -INT_PTR CAddSymbolDlg::DoModal(CDebuggerUI* debugger, uint32_t initAddress) +INT_PTR CAddSymbolDlg::DoModal(CDebuggerUI * debugger, uint32_t initAddress) { m_Debugger = debugger; m_bHaveAddress = true; @@ -101,7 +101,7 @@ INT_PTR CAddSymbolDlg::DoModal(CDebuggerUI* debugger, uint32_t initAddress) return CDialogImpl::DoModal(); } -INT_PTR CAddSymbolDlg::DoModal(CDebuggerUI* debugger, uint32_t initAddress, int initType) +INT_PTR CAddSymbolDlg::DoModal(CDebuggerUI * debugger, uint32_t initAddress, int initType) { m_Debugger = debugger; m_bHaveAddress = true; diff --git a/Source/Project64/UserInterface/Debugger/Debugger-CPULogView.cpp b/Source/Project64/UserInterface/Debugger/Debugger-CPULogView.cpp index 022f5e0b5..56867b171 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-CPULogView.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-CPULogView.cpp @@ -1,14 +1,15 @@ #include "stdafx.h" -#include "DebuggerUI.h" + #include "CPULog.h" +#include "DebuggerUI.h" #include "Debugger-CPULogView.h" #include -CDebugCPULogView* CDebugCPULogView::_this = nullptr; +CDebugCPULogView * CDebugCPULogView::_this = nullptr; HHOOK CDebugCPULogView::hWinMessageHook = nullptr; -CDebugCPULogView::CDebugCPULogView(CDebuggerUI* debugger) : +CDebugCPULogView::CDebugCPULogView(CDebuggerUI * debugger) : CDebugDialog(debugger), m_CPULogCopy(nullptr), m_LogStartIndex(0), @@ -24,7 +25,7 @@ CDebugCPULogView::~CDebugCPULogView() } } -LRESULT CDebugCPULogView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugCPULogView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { DlgResize_Init(false, true); DlgToolTip_Init(); @@ -45,7 +46,7 @@ LRESULT CDebugCPULogView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM m_CPUListView.SetColumnWidth(0, 65); m_CPUListView.SetColumnWidth(1, 60); m_CPUListView.SetColumnWidth(2, 120); - + bool bLoggingEnabled = g_Settings->LoadBool(Debugger_CPULoggingEnabled); uint32_t bufferSize = g_Settings->LoadDword(Debugger_CPULogBufferSize); @@ -54,7 +55,7 @@ LRESULT CDebugCPULogView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM m_BuffSizeEdit.SetDisplayType(CEditNumber32::DisplayDec); m_BuffSizeEdit.SetValue(bufferSize); m_BuffSizeEdit.EnableWindow(!bLoggingEnabled); - + RefreshList(true); m_ExportBtn.EnableWindow(false); @@ -94,7 +95,7 @@ LRESULT CDebugCPULogView::OnDestroy(void) LRESULT CALLBACK CDebugCPULogView::HookProc(int nCode, WPARAM wParam, LPARAM lParam) { - MSG *pMsg = (MSG*)lParam; + MSG * pMsg = (MSG *)lParam; switch (pMsg->message) { @@ -111,7 +112,7 @@ LRESULT CALLBACK CDebugCPULogView::HookProc(int nCode, WPARAM wParam, LPARAM lPa return 0; } -LRESULT CDebugCPULogView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/) +LRESULT CDebugCPULogView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL & /*bHandled*/) { switch (wID) { @@ -128,18 +129,18 @@ LRESULT CDebugCPULogView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& Export(); break; } - + return FALSE; } -LRESULT CDebugCPULogView::OnActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugCPULogView::OnActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { return FALSE; } -LRESULT CDebugCPULogView::OnListItemChanged(NMHDR* pNMHDR) +LRESULT CDebugCPULogView::OnListItemChanged(NMHDR * pNMHDR) { - NMITEMACTIVATE* pIA = reinterpret_cast(pNMHDR); + NMITEMACTIVATE * pIA = reinterpret_cast(pNMHDR); int nItem = pIA->iItem; ShowRegStates(m_LogStartIndex + nItem); @@ -147,12 +148,12 @@ LRESULT CDebugCPULogView::OnListItemChanged(NMHDR* pNMHDR) return FALSE; } -LRESULT CDebugCPULogView::OnListDblClicked(NMHDR* pNMHDR) +LRESULT CDebugCPULogView::OnListDblClicked(NMHDR * pNMHDR) { - NMITEMACTIVATE* pIA = reinterpret_cast(pNMHDR); + NMITEMACTIVATE * pIA = reinterpret_cast(pNMHDR); int nItem = pIA->iItem; - CPUState* state = m_CPULogCopy->GetEntry(m_LogStartIndex + nItem); + CPUState * state = m_CPULogCopy->GetEntry(m_LogStartIndex + nItem); if (state == nullptr) { @@ -164,7 +165,7 @@ LRESULT CDebugCPULogView::OnListDblClicked(NMHDR* pNMHDR) return FALSE; } -LRESULT CDebugCPULogView::OnMeasureItem(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) +LRESULT CDebugCPULogView::OnMeasureItem(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL & /*bHandled*/) { if (wParam == IDC_CPU_LIST) { @@ -175,13 +176,13 @@ LRESULT CDebugCPULogView::OnMeasureItem(UINT /*uMsg*/, WPARAM wParam, LPARAM lPa m_RowHeight = tm.tmHeight + tm.tmExternalLeading; - MEASUREITEMSTRUCT* lpMeasureItem = (MEASUREITEMSTRUCT*)lParam; + MEASUREITEMSTRUCT * lpMeasureItem = (MEASUREITEMSTRUCT *)lParam; lpMeasureItem->itemHeight = m_RowHeight; } return FALSE; } -LRESULT CDebugCPULogView::OnScroll(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) +LRESULT CDebugCPULogView::OnScroll(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL & /*bHandled*/) { WORD type = LOWORD(wParam); HWND hScrollbar = (HWND)lParam; @@ -318,7 +319,7 @@ void CDebugCPULogView::RefreshList(bool bUpdateBuffer) for (size_t i = start; i < end; i++) { - CPUState* state = m_CPULogCopy->GetEntry(i); + CPUState * state = m_CPULogCopy->GetEntry(i); if (state == nullptr) { @@ -340,7 +341,7 @@ void CDebugCPULogView::RefreshList(bool bUpdateBuffer) void CDebugCPULogView::ShowRegStates(size_t stateIndex) { - CPUState* state = m_CPULogCopy->GetEntry(stateIndex); + CPUState * state = m_CPULogCopy->GetEntry(stateIndex); if (state == nullptr) { @@ -348,7 +349,7 @@ void CDebugCPULogView::ShowRegStates(size_t stateIndex) } char szRegStates[2048]; - char* out = szRegStates; + char * out = szRegStates; out += sprintf(out, "PC: %08X\r\n\r\n", state->pc); @@ -368,8 +369,8 @@ void CDebugCPULogView::ShowRegStates(size_t stateIndex) { int regl = i, regr = i + 16; out += sprintf(out, "%-3s: %08X %-3s: %08X\r\n", - CRegName::FPR[regl], *(uint32_t*)&state->fpr[regl], - CRegName::FPR[regr], *(uint32_t*)&state->fpr[regr]); + CRegName::FPR[regl], *(uint32_t *)&state->fpr[regl], + CRegName::FPR[regr], *(uint32_t *)&state->fpr[regr]); } out += sprintf(out, "FPCR: %08X\r\n", state->fpcr); @@ -386,7 +387,7 @@ void CDebugCPULogView::Export(void) OPENFILENAMEA openfilename; char filePath[255]; - + memset(&filePath, 0, sizeof(filePath)); memset(&openfilename, 0, sizeof(openfilename)); @@ -408,7 +409,7 @@ void CDebugCPULogView::Export(void) // Utility -int CDebugCPULogView::GetNumVisibleRows(CListViewCtrl& list) +int CDebugCPULogView::GetNumVisibleRows(CListViewCtrl & list) { CHeaderCtrl header = list.GetHeader(); CRect listRect, headRect; diff --git a/Source/Project64/UserInterface/Debugger/Debugger-CPULogView.h b/Source/Project64/UserInterface/Debugger/Debugger-CPULogView.h index f54d449ae..b8edf1ceb 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-CPULogView.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-CPULogView.h @@ -1,6 +1,4 @@ #pragma once - -#include #include "DebuggerUI.h" class CDebugCPULogView : diff --git a/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp b/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp index eddc6325b..7ba60aa2a 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp @@ -1,10 +1,11 @@ #include "stdafx.h" + #include "DebuggerUI.h" -#include "Symbols.h" -#include "Breakpoints.h" #include "Assembler.h" +#include "Breakpoints.h" #include "OpInfo.h" +#include "Symbols.h" #include @@ -31,10 +32,10 @@ void CCommandList::Attach(HWND hWndNew) SetColumnWidth(COL_SYMBOL, 180); } -CDebugCommandsView* CDebugCommandsView::_this = nullptr; +CDebugCommandsView * CDebugCommandsView::_this = nullptr; HHOOK CDebugCommandsView::hWinMessageHook = nullptr; -CDebugCommandsView::CDebugCommandsView(CDebuggerUI * debugger, SyncEvent &StepEvent) : +CDebugCommandsView::CDebugCommandsView(CDebuggerUI * debugger, SyncEvent & StepEvent) : CDebugDialog(debugger), CToolTipDialog(), m_StepEvent(StepEvent), @@ -56,7 +57,7 @@ CDebugCommandsView::~CDebugCommandsView() g_Settings->UnregisterChangeCB(GameRunning_CPU_Running, this, (CSettings::SettingChangedFunc)GameCpuRunningChanged); } -LRESULT CDebugCommandsView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { m_StartAddress = g_Reg ? g_Reg->m_PROGRAM_COUNTER : 0x80000000; @@ -164,11 +165,11 @@ void CDebugCommandsView::RecompilerCheck(void) !g_Settings->LoadBool(Setting_ForceInterpreterCPU) && (CPU_TYPE)g_Settings->LoadDword(Game_CpuType) != CPU_Interpreter) { - // TODO: Remove this or fix? + // TODO: Remove this or fix? MessageBox(L"Debugger support for the recompiler core is experimental.\n\n" - L"For optimal experience, enable \"Always use interpreter core\" " - L"in advanced settings and restart the emulator.", - L"Warning", MB_ICONWARNING | MB_OK); + L"For optimal experience, enable \"Always use interpreter core\" " + L"in advanced settings and restart the emulator.", + L"Warning", MB_ICONWARNING | MB_OK); } } @@ -206,7 +207,7 @@ void CDebugCommandsView::InterceptKeyDown(WPARAM wParam, LPARAM /*lParam*/) switch (wParam) { case VK_F1: CPUSkip(); break; - case VK_F2: + case VK_F2: if (WaitingForStep()) { m_StepEvent.Trigger(); @@ -228,7 +229,7 @@ void CDebugCommandsView::InterceptMouseWheel(WPARAM wParam, LPARAM /*lParam*/) LRESULT CALLBACK CDebugCommandsView::HookProc(int nCode, WPARAM wParam, LPARAM lParam) { - MSG *pMsg = (MSG*)lParam; + MSG * pMsg = (MSG *)lParam; if (pMsg->message == WM_KEYDOWN) { @@ -294,7 +295,7 @@ void CDebugCommandsView::AddBranchArrow(int startPos, int endPos) } } - m_BranchArrows.push_back({ startPos, endPos, startMargin, endMargin, margin }); + m_BranchArrows.push_back({startPos, endPos, startMargin, endMargin, margin}); } void CDebugCommandsView::HistoryPushState() @@ -304,7 +305,7 @@ void CDebugCommandsView::HistoryPushState() ToggleHistoryButtons(); } -const char* CDebugCommandsView::GetDataAddressNotes(uint32_t vAddr) +const char * CDebugCommandsView::GetDataAddressNotes(uint32_t vAddr) { switch (vAddr) { @@ -424,7 +425,7 @@ const char* CDebugCommandsView::GetDataAddressNotes(uint32_t vAddr) return nullptr; } -const char* CDebugCommandsView::GetCodeAddressNotes(uint32_t vAddr) +const char * CDebugCommandsView::GetCodeAddressNotes(uint32_t vAddr) { switch (vAddr) { @@ -447,8 +448,8 @@ const char* CDebugCommandsView::GetCodeAddressNotes(uint32_t vAddr) return nullptr; } - uint8_t* rom = g_Rom->GetRomAddress(); - uint32_t gameEntryPoint = *(uint32_t*)&rom[0x08]; + uint8_t * rom = g_Rom->GetRomAddress(); + uint32_t gameEntryPoint = *(uint32_t *)&rom[0x08]; if (vAddr == gameEntryPoint) { @@ -485,7 +486,7 @@ void CDebugCommandsView::ShowAddress(uint32_t address, bool top, bool bUserInput else { bool bOutOfView = address < m_StartAddress || - address > m_StartAddress + (m_CommandListRows - 1) * 4; + address > m_StartAddress + (m_CommandListRows - 1) * 4; if (bOutOfView) { @@ -531,7 +532,7 @@ void CDebugCommandsView::ShowAddress(uint32_t address, bool top, bool bUserInput m_CommandList.AddItem(i, CCommandList::COL_ADDRESS, stdstr(addrStr).ToUTF16().c_str()); COpInfo OpInfo; - R4300iOpcode& OpCode = OpInfo.m_OpCode; + R4300iOpcode & OpCode = OpInfo.m_OpCode; if (!m_Debugger->DebugLoad_VAddr(opAddr, OpCode.Value)) { @@ -557,7 +558,7 @@ void CDebugCommandsView::ShowAddress(uint32_t address, bool top, bool bUserInput } // Detect reads and writes to mapped registers, cart header data, etc. - const char* annotation = nullptr; + const char * annotation = nullptr; bool bLoadStoreAnnotation = false; CSymbol memSymbol; @@ -618,7 +619,7 @@ void CDebugCommandsView::ShowAddress(uint32_t address, bool top, bool bUserInput } else if (annotation != nullptr) { - const char* annotationFormat = bLoadStoreAnnotation ? "// (%s)" : "// %s"; + const char * annotationFormat = bLoadStoreAnnotation ? "// (%s)" : "// %s"; m_CommandList.AddItem(i, CCommandList::COL_SYMBOL, stdstr_f(annotationFormat, annotation).ToUTF16().c_str()); m_bvAnnotatedLines.push_back(true); } @@ -661,9 +662,9 @@ void CDebugCommandsView::ShowAddress(uint32_t address, bool top, bool bUserInput } // Highlight command list items and draw branch arrows -LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR) +LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR * pNMHDR) { - NMLVCUSTOMDRAW* pLVCD = reinterpret_cast(pNMHDR); + NMLVCUSTOMDRAW * pLVCD = reinterpret_cast(pNMHDR); DWORD drawStage = pLVCD->nmcd.dwDrawStage; switch (drawStage) @@ -734,49 +735,50 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR) // Command and arguments COpInfo OpInfo; - R4300iOpcode& OpCode = OpInfo.m_OpCode; + R4300iOpcode & OpCode = OpInfo.m_OpCode; bool bAddrOkay = m_Debugger->DebugLoad_VAddr(address, OpCode.Value); - struct { + struct + { COLORREF bg; COLORREF fg; } colors; if (!bAddrOkay) { - colors = { 0xFFFFFF, 0xFF0000 }; + colors = {0xFFFFFF, 0xFF0000}; } else if (address == pc && isStepping()) { - colors = { 0xFFFFAA, 0x222200 }; + colors = {0xFFFFAA, 0x222200}; } else if (IsOpEdited(address)) { - colors = { 0xFFEEFF, 0xFF00FF }; + colors = {0xFFEEFF, 0xFF00FF}; } else if (OpInfo.IsStackAlloc()) { - colors = { 0xCCDDFF, 0x001144 }; + colors = {0xCCDDFF, 0x001144}; } else if (OpInfo.IsStackFree()) { - colors = { 0xFFDDDD, 0x440000 }; + colors = {0xFFDDDD, 0x440000}; } else if (OpInfo.IsNOP()) { - colors = { 0xFFFFFF, 0x888888 }; + colors = {0xFFFFFF, 0x888888}; } else if (OpInfo.IsJump()) { - colors = { 0xEEFFEE, 0x006600 }; + colors = {0xEEFFEE, 0x006600}; } else if (OpInfo.IsBranch()) { - colors = { 0xFFFFFF, 0x337700 }; + colors = {0xFFFFFF, 0x337700}; } else { - colors = { 0xFFFFFF, 0x0000000 }; + colors = {0xFFFFFF, 0x0000000}; } // Gray annotations @@ -798,7 +800,7 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR) // Color register usage // TODO: localize to temporary register context (don't look before/after jumps and frame shifts) - COLORREF clrUsedRegister = RGB(0xF5, 0xF0, 0xFF); // Light purple + COLORREF clrUsedRegister = RGB(0xF5, 0xF0, 0xFF); // Light purple COLORREF clrAffectedRegister = RGB(0xFF, 0xF0, 0xFF); // Light pink int pcUsedRegA = 0, pcUsedRegB = 0, pcChangedReg = 0; @@ -845,7 +847,7 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR) return CDRF_DODEFAULT; } -LRESULT CDebugCommandsView::OnMeasureItem(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnMeasureItem(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL & /*bHandled*/) { if (wParam == IDC_CMD_LIST) { @@ -856,7 +858,7 @@ LRESULT CDebugCommandsView::OnMeasureItem(UINT /*uMsg*/, WPARAM wParam, LPARAM l m_RowHeight = tm.tmHeight + tm.tmExternalLeading; - MEASUREITEMSTRUCT* lpMeasureItem = (MEASUREITEMSTRUCT*)lParam; + MEASUREITEMSTRUCT * lpMeasureItem = (MEASUREITEMSTRUCT *)lParam; lpMeasureItem->itemHeight = m_RowHeight; } return FALSE; @@ -866,18 +868,18 @@ LRESULT CDebugCommandsView::OnMeasureItem(UINT /*uMsg*/, WPARAM wParam, LPARAM l void CDebugCommandsView::DrawBranchArrows(HDC listDC) { COLORREF colors[] = - { - RGB(240, 240, 240), // White - RGB(30, 135, 255), // Blue - RGB(255, 0, 200), // Pink - RGB(215, 155, 0), // Yellow - RGB(100, 180, 0), // Green - RGB(200, 100, 255), // Purple - RGB(120, 120, 120), // Gray - RGB(0, 220, 160), // Cyan - RGB(255, 100, 0), // Orange - RGB(255, 255, 0), // Yellow - }; + { + RGB(240, 240, 240), // White + RGB(30, 135, 255), // Blue + RGB(255, 0, 200), // Pink + RGB(215, 155, 0), // Yellow + RGB(100, 180, 0), // Green + RGB(200, 100, 255), // Purple + RGB(120, 120, 120), // Gray + RGB(0, 220, 160), // Cyan + RGB(255, 100, 0), // Orange + RGB(255, 255, 0), // Yellow + }; int nColors = sizeof(colors) / sizeof(COLORREF); @@ -1077,7 +1079,7 @@ void CDebugCommandsView::CPUStepOver() } } -LRESULT CDebugCommandsView::OnBackButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnBackButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { if (m_HistoryIndex > 0) { @@ -1088,7 +1090,7 @@ LRESULT CDebugCommandsView::OnBackButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWN return FALSE; } -LRESULT CDebugCommandsView::OnForwardButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnForwardButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { if (m_History.size() > 0 && m_HistoryIndex < (int)m_History.size() - 1) { @@ -1099,7 +1101,7 @@ LRESULT CDebugCommandsView::OnForwardButton(WORD /*wNotifyCode*/, WORD /*wID*/, return FALSE; } -LRESULT CDebugCommandsView::OnViewPCButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnViewPCButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { if (g_Reg != nullptr && isStepping()) { @@ -1108,27 +1110,27 @@ LRESULT CDebugCommandsView::OnViewPCButton(WORD /*wNotifyCode*/, WORD /*wID*/, H return FALSE; } -LRESULT CDebugCommandsView::OnSymbolsButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnSymbolsButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { m_Debugger->OpenSymbolsWindow(); return FALSE; } -LRESULT CDebugCommandsView::OnPopupmenuRunTo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnPopupmenuRunTo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { // Add temp breakpoints and resume m_Breakpoints->AddExecution(m_SelectedAddress, true); return FALSE; } -LRESULT CDebugCommandsView::OnGoButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnGoButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { CPUResume(); m_AddressEdit.SetFocus(); return FALSE; } -LRESULT CDebugCommandsView::OnStepButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnStepButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { if (WaitingForStep()) { @@ -1137,20 +1139,20 @@ LRESULT CDebugCommandsView::OnStepButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWN return FALSE; } -LRESULT CDebugCommandsView::OnStepOverButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnStepOverButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { CPUStepOver(); return FALSE; } -LRESULT CDebugCommandsView::OnSkipButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnSkipButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { CPUSkip(); m_AddressEdit.SetFocus(); return FALSE; } -LRESULT CDebugCommandsView::OnClearBPButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnClearBPButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { m_Breakpoints->BPClear(); RefreshBreakpointList(); @@ -1158,7 +1160,7 @@ LRESULT CDebugCommandsView::OnClearBPButton(WORD /*wNotifyCode*/, WORD /*wID*/, return FALSE; } -LRESULT CDebugCommandsView::OnAddBPButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnAddBPButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { m_AddBreakpointDlg.DoModal(m_Debugger); RefreshBreakpointList(); @@ -1166,65 +1168,65 @@ LRESULT CDebugCommandsView::OnAddBPButton(WORD /*wNotifyCode*/, WORD /*wID*/, HW return FALSE; } -LRESULT CDebugCommandsView::OnRemoveBPButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnRemoveBPButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { RemoveSelectedBreakpoints(); ShowAddress(m_StartAddress, TRUE); return FALSE; } -LRESULT CDebugCommandsView::OnCopyTabRegistersButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnCopyTabRegistersButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { m_RegisterTabs.CopyTabRegisters(); return FALSE; } -LRESULT CDebugCommandsView::OnCopyAllRegistersButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnCopyAllRegistersButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { m_RegisterTabs.CopyAllRegisters(); return FALSE; } -LRESULT CDebugCommandsView::OnCancel(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnCancel(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { EndDialog(0); return FALSE; } -LRESULT CDebugCommandsView::OnPopupmenuEdit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnPopupmenuEdit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { BeginOpEdit(m_SelectedAddress); return FALSE; } -LRESULT CDebugCommandsView::OnPopupmenuInsertNOP(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnPopupmenuInsertNOP(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { EditOp(m_SelectedAddress, 0x00000000); ShowAddress(m_StartAddress, TRUE); return FALSE; } -LRESULT CDebugCommandsView::OnPopupmenuRestore(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnPopupmenuRestore(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { RestoreOp(m_SelectedAddress); ShowAddress(m_StartAddress, TRUE); return FALSE; } -LRESULT CDebugCommandsView::OnPopupmenuRestoreAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnPopupmenuRestoreAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { RestoreAllOps(); ShowAddress(m_StartAddress, TRUE); return FALSE; } -LRESULT CDebugCommandsView::OnPopupmenuAddSymbol(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnPopupmenuAddSymbol(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { m_AddSymbolDlg.DoModal(m_Debugger, m_SelectedAddress, SYM_CODE); return FALSE; } -LRESULT CDebugCommandsView::OnPopupmenuFollowJump(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnPopupmenuFollowJump(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { HistoryPushState(); ShowAddress(m_FollowAddress, TRUE); @@ -1232,13 +1234,13 @@ LRESULT CDebugCommandsView::OnPopupmenuFollowJump(WORD /*wNotifyCode*/, WORD /*w return FALSE; } -LRESULT CDebugCommandsView::OnPopupmenuViewMemory(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnPopupmenuViewMemory(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { m_Debugger->Debug_ShowMemoryLocation(m_FollowAddress, true); return FALSE; } -LRESULT CDebugCommandsView::OnPopupmenuToggleBP(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnPopupmenuToggleBP(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { if (m_Breakpoints->ExecutionBPExists(m_SelectedAddress)) { @@ -1252,7 +1254,7 @@ LRESULT CDebugCommandsView::OnPopupmenuToggleBP(WORD /*wNotifyCode*/, WORD /*wID return FALSE; } -LRESULT CDebugCommandsView::OnPopupmenuClearBP(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnPopupmenuClearBP(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { m_Breakpoints->EBPClear(); ShowAddress(m_StartAddress, TRUE); @@ -1280,7 +1282,7 @@ void CDebugCommandsView::BeginOpEdit(uint32_t address) //itemRect.bottom += 0; itemRect.left += listRect.left + 3; itemRect.right += 100; - + m_OpEdit.ShowWindow(SW_SHOW); m_OpEdit.MoveWindow(&itemRect); m_OpEdit.BringWindowToTop(); @@ -1299,7 +1301,7 @@ void CDebugCommandsView::EndOpEdit() m_OpEdit.ShowWindow(SW_HIDE); } -LRESULT CDebugCommandsView::OnAddrChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnAddrChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { if (!m_Attached) { @@ -1317,7 +1319,7 @@ LRESULT CDebugCommandsView::OnAddrChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HW return 0; } -LRESULT CDebugCommandsView::OnPCChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnPCChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { if (!m_Attached) { @@ -1335,16 +1337,16 @@ LRESULT CDebugCommandsView::OnPCChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND return 0; } -LRESULT CDebugCommandsView::OnCommandListClicked(NMHDR* /*pNMHDR*/) +LRESULT CDebugCommandsView::OnCommandListClicked(NMHDR * /*pNMHDR*/) { EndOpEdit(); return 0; } -LRESULT CDebugCommandsView::OnCommandListDblClicked(NMHDR* pNMHDR) +LRESULT CDebugCommandsView::OnCommandListDblClicked(NMHDR * pNMHDR) { // Set PC breakpoint - NMITEMACTIVATE* pIA = reinterpret_cast(pNMHDR); + NMITEMACTIVATE * pIA = reinterpret_cast(pNMHDR); int nItem = pIA->iItem; uint32_t address = m_StartAddress + nItem * 4; @@ -1363,11 +1365,11 @@ LRESULT CDebugCommandsView::OnCommandListDblClicked(NMHDR* pNMHDR) return 0; } -LRESULT CDebugCommandsView::OnCommandListRightClicked(NMHDR* pNMHDR) +LRESULT CDebugCommandsView::OnCommandListRightClicked(NMHDR * pNMHDR) { EndOpEdit(); - NMITEMACTIVATE* pIA = reinterpret_cast(pNMHDR); + NMITEMACTIVATE * pIA = reinterpret_cast(pNMHDR); int nItem = pIA->iItem; uint32_t address = m_StartAddress + nItem * 4; @@ -1380,7 +1382,7 @@ LRESULT CDebugCommandsView::OnCommandListRightClicked(NMHDR* pNMHDR) HMENU hMenu = LoadMenu(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDR_OP_POPUP)); HMENU hPopupMenu = GetSubMenu(hMenu, 0); - + if (m_SelectedOpInfo.IsStaticJump()) { m_FollowAddress = (m_SelectedAddress & 0xF0000000) | (m_SelectedOpCode.target * 4); @@ -1433,7 +1435,7 @@ LRESULT CDebugCommandsView::OnCommandListRightClicked(NMHDR* pNMHDR) return 0; } -LRESULT CDebugCommandsView::OnListBoxClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnListBoxClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { if (wID == IDC_BP_LIST) { @@ -1456,7 +1458,7 @@ LRESULT CDebugCommandsView::OnListBoxClicked(WORD /*wNotifyCode*/, WORD wID, HWN return FALSE; } -LRESULT CDebugCommandsView::OnActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnActivate(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL & /*bHandled*/) { if (!m_Attached) { @@ -1495,13 +1497,13 @@ void CDebugCommandsView::RedrawCommandsAndRegisters() listHead.ResizeClient(listRect.Width(), headRect.Height()); } -LRESULT CDebugCommandsView::OnSizing(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnSizing(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { RedrawCommandsAndRegisters(); return FALSE; } -LRESULT CDebugCommandsView::OnScroll(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnScroll(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL & /*bHandled*/) { WORD type = LOWORD(wParam); @@ -1597,7 +1599,7 @@ void CDebugCommandsView::EditOp(uint32_t address, uint32_t op, bool bRefresh) if (!IsOpEdited(address)) { - m_EditedOps.push_back({ address, currentOp }); + m_EditedOps.push_back({address, currentOp}); } if (bRefresh) @@ -1635,7 +1637,7 @@ void CDebugCommandsView::ShowPIRegTab() m_RegisterTabs.ShowTab(2); } -LRESULT CDebugCommandsView::OnRegisterTabChange(NMHDR* /*pNMHDR*/) +LRESULT CDebugCommandsView::OnRegisterTabChange(NMHDR * /*pNMHDR*/) { int nPage = m_RegisterTabs.GetCurSel(); m_RegisterTabs.ShowTab(nPage); @@ -1659,7 +1661,7 @@ void CDebugCommandsView::ToggleHistoryButtons() // Opcode editor -LRESULT CDebugCommandsView::OnOpEditKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) +LRESULT CDebugCommandsView::OnOpEditKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL & bHandled) { if (wParam == VK_UP) { @@ -1694,7 +1696,7 @@ LRESULT CDebugCommandsView::OnOpEditKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM return 1; } -LRESULT CDebugCommandsView::OnOpEditChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugCommandsView::OnOpEditChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { // Handle multiline input std::string text = GetCWindowText(m_OpEdit); @@ -1705,7 +1707,7 @@ LRESULT CDebugCommandsView::OnOpEditChanged(WORD /*wNotifyCode*/, WORD /*wID*/, EndOpEdit(); - for (size_t i = 0 , n = text.size(); i < n; i++) + for (size_t i = 0, n = text.size(); i < n; i++) { if (text[i] == '\r') { @@ -1745,7 +1747,7 @@ LRESULT CDebugCommandsView::OnOpEditChanged(WORD /*wNotifyCode*/, WORD /*wID*/, return FALSE; } -LRESULT CEditOp::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +LRESULT CEditOp::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled) { if (m_CommandsWindow == nullptr) { @@ -1754,7 +1756,7 @@ LRESULT CEditOp::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandl return m_CommandsWindow->OnOpEditKeyDown(uMsg, wParam, lParam, bHandled); } -void CEditOp::SetCommandsWindow(CDebugCommandsView* commandsWindow) +void CEditOp::SetCommandsWindow(CDebugCommandsView * commandsWindow) { m_CommandsWindow = commandsWindow; } diff --git a/Source/Project64/UserInterface/Debugger/Debugger-DMALogView.cpp b/Source/Project64/UserInterface/Debugger/Debugger-DMALogView.cpp index 1035aeca7..bf49952a0 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-DMALogView.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-DMALogView.cpp @@ -1,10 +1,11 @@ #include "stdafx.h" -#include "DebuggerUI.h" + #include "DMALog.h" +#include "DebuggerUI.h" #include -CDebugDMALogView::CDebugDMALogView(CDebuggerUI* debugger) : -CDebugDialog(debugger) +CDebugDMALogView::CDebugDMALogView(CDebuggerUI * debugger) : + CDebugDialog(debugger) { m_DMALog = debugger->DMALog(); m_bFilterChanged = false; @@ -42,9 +43,9 @@ void CDebugDMALogView::RefreshList() { return; } - - uint8_t* rom = g_Rom->GetRomAddress(); - + + uint8_t * rom = g_Rom->GetRomAddress(); + // Get scrollbar state SCROLLINFO scroll; scroll.cbSize = sizeof(SCROLLINFO); @@ -60,7 +61,7 @@ void CDebugDMALogView::RefreshList() int startIndex; int dmaLogSize = m_Debugger->DMALog()->GetNumEntries(); - + HWND hWndExportBtn = GetDlgItem(IDC_EXPORT_BTN); if (dmaLogSize == 0) @@ -77,51 +78,51 @@ void CDebugDMALogView::RefreshList() startIndex = m_nLastStartIndex; ::EnableWindow(hWndExportBtn, TRUE); } - + m_DMAList.SetRedraw(FALSE); int itemIndex = m_DMAList.GetItemCount(); - + for (int i = startIndex; i < dmaLogSize; i++) { - DMALOGENTRY* lpEntry = m_DMALog->GetEntryByIndex(i); + DMALOGENTRY * lpEntry = m_DMALog->GetEntryByIndex(i); //if (!FilterEntry(i)) //{ // continue; //} - + m_DMAList.AddItem(itemIndex, 0, stdstr_f("%08X", lpEntry->romAddr).ToUTF16().c_str()); m_DMAList.AddItem(itemIndex, 1, stdstr_f("%08X", lpEntry->ramAddr).ToUTF16().c_str()); m_DMAList.AddItem(itemIndex, 2, stdstr_f("%08X (%d)", lpEntry->length, lpEntry->length).ToUTF16().c_str()); - + union { uint32_t u32; uint8_t sz[5]; - } sig = { 0 }; + } sig = {0}; if (lpEntry->romAddr < g_Rom->GetRomSize()) { - sig.u32 = _byteswap_ulong(*(uint32_t*)&rom[lpEntry->romAddr]); + sig.u32 = _byteswap_ulong(*(uint32_t *)&rom[lpEntry->romAddr]); } // TODO: checkbox to display all in hex if (isalnum(sig.sz[0]) && isalnum(sig.sz[1]) && isalnum(sig.sz[2]) && isalnum(sig.sz[3])) { - m_DMAList.AddItem(itemIndex, 4, stdstr((char*)sig.sz).ToUTF16().c_str()); + m_DMAList.AddItem(itemIndex, 4, stdstr((char *)sig.sz).ToUTF16().c_str()); } itemIndex++; } - + if (bScrolledDown) { m_DMAList.EnsureVisible(m_DMAList.GetItemCount() - 1, FALSE); } m_DMAList.SetRedraw(TRUE); - + m_nLastStartIndex = dmaLogSize; } @@ -132,15 +133,15 @@ void CDebugDMALogView::Export(void) memset(&filePath, 0, sizeof(filePath)); memset(&openfilename, 0, sizeof(openfilename)); - + wsprintf(filePath, L"*.csv"); - const TCHAR* filters = ( + const TCHAR * filters = ( /*1*/ L"Comma separated values (*.csv)\0*.csv;\0" /*2*/ L"Plain text (*.txt)\0*.txt;\0" ); - const char *extensions[] = { "", ".csv", ".txt" }; + const char * extensions[] = {"", ".csv", ".txt"}; openfilename.lStructSize = sizeof(openfilename); openfilename.hwndOwner = (HWND)m_hWnd; @@ -174,23 +175,23 @@ void CDebugDMALogView::Export(void) for (size_t nEntry = 0; nEntry < numEntries; nEntry++) { - DMALOGENTRY* entry = m_DMALog->GetEntryByIndex(nEntry); + DMALOGENTRY * entry = m_DMALog->GetEntryByIndex(nEntry); file << stdstr_f("0x%08X,0x%08X,0x%08X\r\n", - entry->romAddr, entry->ramAddr, entry->length); + entry->romAddr, entry->ramAddr, entry->length); } file.close(); } } -LRESULT CDebugDMALogView::OnActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugDMALogView::OnActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { //RefreshList(); return FALSE; } -LRESULT CDebugDMALogView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugDMALogView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { DlgResize_Init(false, true); DlgSavePos_Init(DebuggerUI_DMALogPos); @@ -219,7 +220,7 @@ LRESULT CDebugDMALogView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM //m_DMAList.SetColumnWidth(3, 50); //m_DMAList.SetColumnWidth(4, 50); //m_DMAList.SetColumnWidth(5, 50); - + m_DMARamEdit.SetLimitText(8); m_DMARomEdit.SetLimitText(8); @@ -245,7 +246,7 @@ void CDebugDMALogView::RefreshDMALogWindow(bool bReset) PostMessage(WM_REFRESH, bReset); } -LRESULT CDebugDMALogView::OnRefresh(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugDMALogView::OnRefresh(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL & /*bHandled*/) { bool bReset = (wParam != 0); @@ -273,7 +274,7 @@ LRESULT CDebugDMALogView::OnDestroy(void) return 0; } -LRESULT CDebugDMALogView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/) +LRESULT CDebugDMALogView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL & /*bHandled*/) { switch (wID) { @@ -294,7 +295,7 @@ LRESULT CDebugDMALogView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& return FALSE; } -LRESULT CDebugDMALogView::OnRamAddrChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CDebugDMALogView::OnRamAddrChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { if (m_bConvertingAddress) { @@ -317,14 +318,14 @@ LRESULT CDebugDMALogView::OnRamAddrChanged(WORD /*wNotifyCode*/, WORD /*wID*/, H szRomAddr = "????????"; m_BlockInfo.SetWindowText(L"Block: ?"); } - + m_bConvertingAddress = true; m_DMARomEdit.SetWindowText(szRomAddr.ToUTF16().c_str()); m_bConvertingAddress = false; return FALSE; } -LRESULT CDebugDMALogView::OnRomAddrChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CDebugDMALogView::OnRomAddrChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { if (m_bConvertingAddress) { @@ -334,7 +335,7 @@ LRESULT CDebugDMALogView::OnRomAddrChanged(WORD /*wNotifyCode*/, WORD /*wID*/, H stdstr szRamAddr = GetCWindowText(m_DMARomEdit); uint32_t romAddr = strtoul(szRamAddr.c_str(), nullptr, 16); uint32_t ramAddr, offset; - DMALOGENTRY* lpEntry = m_DMALog->GetEntryByRomAddress(romAddr, &ramAddr, &offset); + DMALOGENTRY * lpEntry = m_DMALog->GetEntryByRomAddress(romAddr, &ramAddr, &offset); if (lpEntry != nullptr) { @@ -354,10 +355,9 @@ LRESULT CDebugDMALogView::OnRomAddrChanged(WORD /*wNotifyCode*/, WORD /*wID*/, H return FALSE; } - -LRESULT CDebugDMALogView::OnCustomDrawList(NMHDR* pNMHDR) +LRESULT CDebugDMALogView::OnCustomDrawList(NMHDR * pNMHDR) { - NMLVCUSTOMDRAW* pLVCD = reinterpret_cast(pNMHDR); + NMLVCUSTOMDRAW * pLVCD = reinterpret_cast(pNMHDR); DWORD drawStage = pLVCD->nmcd.dwDrawStage; switch (drawStage) @@ -367,7 +367,7 @@ LRESULT CDebugDMALogView::OnCustomDrawList(NMHDR* pNMHDR) case (CDDS_ITEMPREPAINT | CDDS_SUBITEM): break; default: return CDRF_DODEFAULT; } - + DWORD nItem = pLVCD->nmcd.dwItemSpec; DWORD nSubItem = pLVCD->iSubItem; @@ -375,19 +375,19 @@ LRESULT CDebugDMALogView::OnCustomDrawList(NMHDR* pNMHDR) { return CDRF_DODEFAULT; } - + size_t nEntries = m_DMALog->GetNumEntries(); if (nEntries == 0) { return CDRF_DODEFAULT; } - - DMALOGENTRY* lpEntry = m_DMALog->GetEntryByIndex(nItem); - + + DMALOGENTRY * lpEntry = m_DMALog->GetEntryByIndex(nItem); + if (nItem >= 1) // Continuation { - DMALOGENTRY* lpPrevEntry = m_DMALog->GetEntryByIndex(nItem - 1); + DMALOGENTRY * lpPrevEntry = m_DMALog->GetEntryByIndex(nItem - 1); if (lpEntry->romAddr == lpPrevEntry->romAddr + lpPrevEntry->length) { @@ -398,7 +398,7 @@ LRESULT CDebugDMALogView::OnCustomDrawList(NMHDR* pNMHDR) if (nEntries >= 2 && nItem <= nEntries - 2) // Head { - DMALOGENTRY* lpNextEntry = m_DMALog->GetEntryByIndex(nItem + 1); + DMALOGENTRY * lpNextEntry = m_DMALog->GetEntryByIndex(nItem + 1); if (lpNextEntry->romAddr == lpEntry->romAddr + lpEntry->length) { @@ -406,6 +406,6 @@ LRESULT CDebugDMALogView::OnCustomDrawList(NMHDR* pNMHDR) return CDRF_DODEFAULT; } } - + return CDRF_DODEFAULT; } diff --git a/Source/Project64/UserInterface/Debugger/Debugger-DMALogView.h b/Source/Project64/UserInterface/Debugger/Debugger-DMALogView.h index 5aa558d17..933e8dab3 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-DMALogView.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-DMALogView.h @@ -1,6 +1,4 @@ #pragma once - -#include #include "DebuggerUI.h" class CDebugDMALogView : diff --git a/Source/Project64/UserInterface/Debugger/Debugger-ExceptionBreakpoints.cpp b/Source/Project64/UserInterface/Debugger/Debugger-ExceptionBreakpoints.cpp index dd406d348..a08cb1396 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-ExceptionBreakpoints.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-ExceptionBreakpoints.cpp @@ -1,61 +1,62 @@ #include "stdafx.h" + #include "DebuggerUI.h" CDebugExcBreakpoints::ExcCheckboxMeta CDebugExcBreakpoints::ExcCheckboxMap[] = { - { IDC_CHK_INT, 0 }, - { IDC_CHK_MOD, 1 }, - { IDC_CHK_RMISS, 2 }, - { IDC_CHK_WMISS, 3 }, - { IDC_CHK_RADE, 4 }, - { IDC_CHK_WADE, 5 }, - { IDC_CHK_IBE, 6 }, - { IDC_CHK_DBE, 7 }, - { IDC_CHK_SYSCALL, 8 }, - { IDC_CHK_BREAK, 9 }, - { IDC_CHK_II, 10 }, - { IDC_CHK_CPU, 11 }, - { IDC_CHK_OV, 12 }, - { IDC_CHK_TRAP, 13 }, - { IDC_CHK_VCEI, 14 }, - { IDC_CHK_FPE, 15 }, - { IDC_CHK_WATCH, 23 }, - { IDC_CHK_VCED, 31 }, + {IDC_CHK_INT, 0}, + {IDC_CHK_MOD, 1}, + {IDC_CHK_RMISS, 2}, + {IDC_CHK_WMISS, 3}, + {IDC_CHK_RADE, 4}, + {IDC_CHK_WADE, 5}, + {IDC_CHK_IBE, 6}, + {IDC_CHK_DBE, 7}, + {IDC_CHK_SYSCALL, 8}, + {IDC_CHK_BREAK, 9}, + {IDC_CHK_II, 10}, + {IDC_CHK_CPU, 11}, + {IDC_CHK_OV, 12}, + {IDC_CHK_TRAP, 13}, + {IDC_CHK_VCEI, 14}, + {IDC_CHK_FPE, 15}, + {IDC_CHK_WATCH, 23}, + {IDC_CHK_VCED, 31}, { 0, 0 } }; CDebugExcBreakpoints::ExcCheckboxMeta CDebugExcBreakpoints::FpExcCheckboxMap[] = { - { IDC_CHK_FP_CI, (1 << 0) }, - { IDC_CHK_FP_CU, (1 << 1) }, - { IDC_CHK_FP_CO, (1 << 2) }, - { IDC_CHK_FP_CZ, (1 << 3) }, - { IDC_CHK_FP_CV, (1 << 4) }, - { IDC_CHK_FP_CE, (1 << 5) }, + {IDC_CHK_FP_CI, (1 << 0)}, + {IDC_CHK_FP_CU, (1 << 1)}, + {IDC_CHK_FP_CO, (1 << 2)}, + {IDC_CHK_FP_CZ, (1 << 3)}, + {IDC_CHK_FP_CV, (1 << 4)}, + {IDC_CHK_FP_CE, (1 << 5)}, { 0, 0 } }; CDebugExcBreakpoints::ExcCheckboxMeta CDebugExcBreakpoints::IntrCheckboxMap[] = { - { IDC_CHK_INTR_IP0, (1 << 0) }, - { IDC_CHK_INTR_IP1, (1 << 1) }, - { IDC_CHK_INTR_IP2, (1 << 2) }, - { IDC_CHK_INTR_IP3, (1 << 3) }, - { IDC_CHK_INTR_IP4, (1 << 4) }, - { IDC_CHK_INTR_IP5, (1 << 5) }, - { IDC_CHK_INTR_IP6, (1 << 6) }, - { IDC_CHK_INTR_IP7, (1 << 7) }, + {IDC_CHK_INTR_IP0, (1 << 0)}, + {IDC_CHK_INTR_IP1, (1 << 1)}, + {IDC_CHK_INTR_IP2, (1 << 2)}, + {IDC_CHK_INTR_IP3, (1 << 3)}, + {IDC_CHK_INTR_IP4, (1 << 4)}, + {IDC_CHK_INTR_IP5, (1 << 5)}, + {IDC_CHK_INTR_IP6, (1 << 6)}, + {IDC_CHK_INTR_IP7, (1 << 7)}, { 0, 0 } }; CDebugExcBreakpoints::ExcCheckboxMeta CDebugExcBreakpoints::RcpIntrCheckboxMap[] = { - { IDC_CHK_INTR_SP, (1 << 0) }, - { IDC_CHK_INTR_SI, (1 << 1) }, - { IDC_CHK_INTR_AI, (1 << 2) }, - { IDC_CHK_INTR_VI, (1 << 3) }, - { IDC_CHK_INTR_PI, (1 << 4) }, - { IDC_CHK_INTR_DP, (1 << 5) }, + {IDC_CHK_INTR_SP, (1 << 0)}, + {IDC_CHK_INTR_SI, (1 << 1)}, + {IDC_CHK_INTR_AI, (1 << 2)}, + {IDC_CHK_INTR_VI, (1 << 3)}, + {IDC_CHK_INTR_PI, (1 << 4)}, + {IDC_CHK_INTR_DP, (1 << 5)}, { 0, 0 } }; -CDebugExcBreakpoints::CDebugExcBreakpoints(CDebuggerUI* debugger) : +CDebugExcBreakpoints::CDebugExcBreakpoints(CDebuggerUI * debugger) : CDebugDialog(debugger) { } @@ -64,7 +65,7 @@ CDebugExcBreakpoints::~CDebugExcBreakpoints() { } -LRESULT CDebugExcBreakpoints::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugExcBreakpoints::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { DlgSavePos_Init(DebuggerUI_ExceptionBPPos); @@ -94,7 +95,7 @@ LRESULT CDebugExcBreakpoints::OnDestroy(void) return 0; } -LRESULT CDebugExcBreakpoints::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/) +LRESULT CDebugExcBreakpoints::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL & /*bHandled*/) { switch (wID) { @@ -112,7 +113,7 @@ LRESULT CDebugExcBreakpoints::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BO bool toggleRcpIntr = bChecked && (g_Settings->LoadDword(Debugger_IntrBreakpoints) & 0x04); EnableCheckboxes(RcpIntrCheckboxMap, toggleRcpIntr); } - + if (wID == IDC_CHK_FPE) { EnableCheckboxes(FpExcCheckboxMap, bChecked); @@ -136,7 +137,7 @@ void CDebugExcBreakpoints::OnExitSizeMove(void) SaveWindowPos(0); } -void CDebugExcBreakpoints::InitCheckboxes(ExcCheckboxMeta* checkboxMap, SettingID settingID, bool bShift) +void CDebugExcBreakpoints::InitCheckboxes(ExcCheckboxMeta * checkboxMap, SettingID settingID, bool bShift) { uint32_t excBits = g_Settings->LoadDword(settingID); @@ -151,7 +152,7 @@ void CDebugExcBreakpoints::InitCheckboxes(ExcCheckboxMeta* checkboxMap, SettingI } } -void CDebugExcBreakpoints::UpdateBpSetting(ExcCheckboxMeta* checkboxMap, SettingID settingID, WORD wID, bool bChecked, bool bShift) +void CDebugExcBreakpoints::UpdateBpSetting(ExcCheckboxMeta * checkboxMap, SettingID settingID, WORD wID, bool bChecked, bool bShift) { for (int i = 0; checkboxMap[i].ctrlId != 0; i++) { @@ -175,7 +176,7 @@ void CDebugExcBreakpoints::UpdateBpSetting(ExcCheckboxMeta* checkboxMap, Setting } } -void CDebugExcBreakpoints::EnableCheckboxes(ExcCheckboxMeta* checkboxMap, bool bEnable) +void CDebugExcBreakpoints::EnableCheckboxes(ExcCheckboxMeta * checkboxMap, bool bEnable) { for (int i = 0; checkboxMap[i].ctrlId != 0; i++) { diff --git a/Source/Project64/UserInterface/Debugger/Debugger-ExceptionBreakpoints.h b/Source/Project64/UserInterface/Debugger/Debugger-ExceptionBreakpoints.h index 66b820b5a..56e213ff0 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-ExceptionBreakpoints.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-ExceptionBreakpoints.h @@ -1,6 +1,4 @@ #pragma once - -#include #include "DebuggerUI.h" diff --git a/Source/Project64/UserInterface/Debugger/Debugger-MemoryDump.cpp b/Source/Project64/UserInterface/Debugger/Debugger-MemoryDump.cpp index fd43ada73..205de0585 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-MemoryDump.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-MemoryDump.cpp @@ -5,7 +5,7 @@ #include CDumpMemory::CDumpMemory(CDebuggerUI * debugger) : -CDebugDialog(debugger) + CDebugDialog(debugger) { } @@ -13,7 +13,7 @@ CDumpMemory::~CDumpMemory() { } -LRESULT CDumpMemory::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDumpMemory::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { DlgSavePos_Init(DebuggerUI_MemoryDumpPos); @@ -33,7 +33,7 @@ LRESULT CDumpMemory::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPa m_StartAddress.SetValue(startAddress, DisplayMode::AllHex); m_EndAddress.SetValue(endAddress, DisplayMode::AllHex); m_PC.SetValue(startAddress); - + int nIndex = m_FormatList.AddString(L"TEXT - Disassembly + PC"); m_FormatList.SetItemData(nIndex, (DWORD_PTR)DisassemblyWithPC); @@ -52,7 +52,7 @@ void CDumpMemory::OnExitSizeMove(void) SaveWindowPos(0); } -LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { switch (wID) { @@ -66,7 +66,7 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, int CurrentFormatSel = m_FormatList.GetCurSel(); DumpFormat Format = (DumpFormat)m_FormatList.GetItemData(CurrentFormatSel); - const char* FileFilter = "All files (*.*)\0*.*\0"; + const char * FileFilter = "All files (*.*)\0*.*\0"; if (Format == RawBigEndian) { @@ -78,7 +78,7 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, } CPath FileName; - + if (FileName.SelectFile(m_hWnd, CPath(CPath::MODULE_DIRECTORY), FileFilter, false)) { if (FileName.GetExtension().length() == 0) @@ -94,8 +94,8 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, { TCHAR FileName[MAX_PATH]; int CurrentFormatSel = m_FormatList.GetCurSel(); - DumpFormat Format = (DumpFormat) m_FormatList.GetItemData(CurrentFormatSel); - + DumpFormat Format = (DumpFormat)m_FormatList.GetItemData(CurrentFormatSel); + DWORD StartPC = m_StartAddress.GetValue(); DWORD EndPC = m_EndAddress.GetValue(); DWORD DumpPC = m_PC.GetValue(); @@ -129,8 +129,8 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, } g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); } - EndDialog(0); - break; + EndDialog(0); + break; } return FALSE; } diff --git a/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.cpp b/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.cpp index dbbaefb4e..3f5af8eb8 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.cpp @@ -1,22 +1,23 @@ #include "stdafx.h" + #include "DebuggerUI.h" #include "MemoryScanner.h" -CDebugMemorySearch* CDebugMemorySearch::_this = nullptr; +CDebugMemorySearch * CDebugMemorySearch::_this = nullptr; HHOOK CDebugMemorySearch::hWinMessageHook = nullptr; const CSetValueDlg::ComboItem CDebugMemorySearch::ModalChangeTypeItems[] = { - { "uint8", ValueType_uint8 }, - { "int8", ValueType_int8 }, - { "uint16", ValueType_uint16 }, - { "int16", ValueType_int16 }, - { "uint32", ValueType_uint32 }, - { "int32", ValueType_int32 }, - { "uint64", ValueType_uint64 }, - { "int64", ValueType_int64 }, - { "float", ValueType_float }, - { "double", ValueType_double }, - { "string", ValueType_string }, + {"uint8", ValueType_uint8}, + {"int8", ValueType_int8}, + {"uint16", ValueType_uint16}, + {"int16", ValueType_int16}, + {"uint32", ValueType_uint32}, + {"int32", ValueType_int32}, + {"uint64", ValueType_uint64}, + {"int64", ValueType_int64}, + {"float", ValueType_float}, + {"double", ValueType_double}, + {"string", ValueType_string}, { nullptr, 0 } }; @@ -29,7 +30,7 @@ CDebugMemorySearch::~CDebugMemorySearch() { } -LRESULT CDebugMemorySearch::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { DlgSavePos_Init(DebuggerUI_MemorySearchPos); DlgResize_Init(false, true); @@ -156,7 +157,7 @@ void CDebugMemorySearch::GameReset(void) SendMessage(WM_GAMERESET); } -LRESULT CDebugMemorySearch::OnGameReset(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnGameReset(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { ReloadWatchList(); return FALSE; @@ -186,7 +187,7 @@ void CDebugMemorySearch::OnTimer(UINT_PTR nIDEvent) LRESULT CALLBACK CDebugMemorySearch::HookProc(int nCode, WPARAM wParam, LPARAM lParam) { - MSG *pMsg = (MSG*)lParam; + MSG * pMsg = (MSG *)lParam; switch (pMsg->message) { @@ -219,20 +220,20 @@ void CDebugMemorySearch::OnSizing(UINT /*fwSide*/, LPRECT /*pRect*/) SetMsgHandled(FALSE); } -LRESULT CDebugMemorySearch::OnCancel(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnCancel(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { EndDialog(0); return FALSE; } -LRESULT CDebugMemorySearch::OnHexCheckbox(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnHexCheckbox(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { bool bChecked = (m_HexCheckbox.GetCheck() == BST_CHECKED); m_SearchValue.SetDisplayFormat(bChecked ? DisplayHex : DisplayDefault); return FALSE; } -LRESULT CDebugMemorySearch::OnSearchButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnSearchButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory); Search(); @@ -242,13 +243,13 @@ LRESULT CDebugMemorySearch::OnSearchButton(WORD /*wNotifyCode*/, WORD /*wID*/, H return FALSE; } -LRESULT CDebugMemorySearch::OnResetButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnResetButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { ResetResults(); return FALSE; } -LRESULT CDebugMemorySearch::OnScanTypeChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnScanTypeChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { SearchType searchType = (SearchType)m_SearchTypeOptions.GetItemData(m_SearchTypeOptions.GetCurSel()); @@ -273,7 +274,7 @@ LRESULT CDebugMemorySearch::OnScanTypeChanged(WORD /*wNotifyCode*/, WORD /*wID*/ m_UnsignedCheckbox.SetCheck(BST_CHECKED); m_UnsignedCheckbox.EnableWindow(FALSE); } - else if(m_bJalSelected) + else if (m_bJalSelected) { m_bJalSelected = false; m_SearchValue.SetDisplayFormat(m_bJalHexWasChecked ? DisplayHex : DisplayDefault); @@ -304,7 +305,7 @@ LRESULT CDebugMemorySearch::OnScanTypeChanged(WORD /*wNotifyCode*/, WORD /*wID*/ return FALSE; } -LRESULT CDebugMemorySearch::OnValueTypeChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnValueTypeChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { ValueType valueType = (ValueType)m_ValueTypeOptions.GetItemData(m_ValueTypeOptions.GetCurSel()); @@ -332,7 +333,7 @@ LRESULT CDebugMemorySearch::OnValueTypeChanged(WORD /*wNotifyCode*/, WORD /*wID* return FALSE; } -LRESULT CDebugMemorySearch::OnRdramButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnRdramButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { bool bPhysicalChecked = (m_PhysicalCheckbox.GetCheck() == BST_CHECKED); uint32_t addrStart = bPhysicalChecked ? 0 : 0x80000000; @@ -342,7 +343,7 @@ LRESULT CDebugMemorySearch::OnRdramButton(WORD /*wNotifyCode*/, WORD /*wID*/, HW return FALSE; } -LRESULT CDebugMemorySearch::OnRomButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnRomButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { bool bPhysicalChecked = (m_PhysicalCheckbox.GetCheck() == BST_CHECKED); uint32_t addrStart = bPhysicalChecked ? 0x10000000 : 0xB0000000; @@ -351,7 +352,7 @@ LRESULT CDebugMemorySearch::OnRomButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND return FALSE; } -LRESULT CDebugMemorySearch::OnSpmemButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnSpmemButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { bool bPhysicalChecked = (m_PhysicalCheckbox.GetCheck() == BST_CHECKED); uint32_t addrStart = bPhysicalChecked ? 0x04000000 : 0xA4000000; @@ -362,7 +363,7 @@ LRESULT CDebugMemorySearch::OnSpmemButton(WORD /*wNotifyCode*/, WORD /*wID*/, HW LRESULT CDebugMemorySearch::OnResultsCustomDraw(LPNMHDR lpnmh) { - NMLVCUSTOMDRAW* pLVCD = reinterpret_cast(lpnmh); + NMLVCUSTOMDRAW * pLVCD = reinterpret_cast(lpnmh); DWORD drawStage = pLVCD->nmcd.dwDrawStage; switch (drawStage) @@ -376,7 +377,7 @@ LRESULT CDebugMemorySearch::OnResultsCustomDraw(LPNMHDR lpnmh) uint32_t nItem = (uint32_t)pLVCD->nmcd.dwItemSpec; uint32_t nSubItem = pLVCD->iSubItem; size_t index = m_ResultsListCtrl.GetItemData(nItem); - CScanResult *presult = m_MemoryScanner.GetResult(index); + CScanResult * presult = m_MemoryScanner.GetResult(index); switch (nSubItem) { @@ -388,28 +389,28 @@ LRESULT CDebugMemorySearch::OnResultsCustomDraw(LPNMHDR lpnmh) } break; case ResultsListCtrl_Col_Value: + { + pLVCD->clrText = RGB(0, 0, 0); + char szCurrentValue[1024], szOldValue[1024]; + presult->GetMemoryValueString(szCurrentValue, 1024); + presult->GetValueString(szOldValue, 1024); + + if (presult->IsStringType()) { pLVCD->clrText = RGB(0, 0, 0); - char szCurrentValue[1024], szOldValue[1024]; - presult->GetMemoryValueString(szCurrentValue, 1024); - presult->GetValueString(szOldValue, 1024); - - if (presult->IsStringType()) + if (presult->m_DisplayFormat == DisplayHex) { - pLVCD->clrText = RGB(0, 0, 0); - if (presult->m_DisplayFormat == DisplayHex) - { - // Blue if hex string - pLVCD->clrText = RGB(0, 0, 255); - } - } - else if (strcmp(szCurrentValue, szOldValue) != 0) - { - // Red if value has changed - pLVCD->clrText = RGB(255, 0, 0); + // Blue if hex string + pLVCD->clrText = RGB(0, 0, 255); } } - break; + else if (strcmp(szCurrentValue, szOldValue) != 0) + { + // Red if value has changed + pLVCD->clrText = RGB(255, 0, 0); + } + } + break; case ResultsListCtrl_Col_Previous: pLVCD->clrText = RGB(0, 0, 0); break; @@ -456,9 +457,9 @@ LRESULT CDebugMemorySearch::OnResultsRClick(LPNMHDR /*lpnmh*/) return true; } -LRESULT CDebugMemorySearch::OnResultsPopupViewMemory(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnResultsPopupViewMemory(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { - CScanResult* presult = GetFirstSelectedScanResult(); + CScanResult * presult = GetFirstSelectedScanResult(); if (presult == nullptr) { @@ -470,7 +471,7 @@ LRESULT CDebugMemorySearch::OnResultsPopupViewMemory(WORD /*wNotifyCode*/, WORD return FALSE; } -LRESULT CDebugMemorySearch::OnResultsPopupAddToWatchList(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnResultsPopupAddToWatchList(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { LONG iItem = -1; @@ -485,7 +486,7 @@ LRESULT CDebugMemorySearch::OnResultsPopupAddToWatchList(WORD /*wNotifyCode*/, W return FALSE; } -LRESULT CDebugMemorySearch::OnResultsPopupAddAllToWatchList(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnResultsPopupAddAllToWatchList(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { size_t numResults = m_MemoryScanner.GetNumResults(); @@ -499,9 +500,9 @@ LRESULT CDebugMemorySearch::OnResultsPopupAddAllToWatchList(WORD /*wNotifyCode*/ return FALSE; } -LRESULT CDebugMemorySearch::OnResultsPopupSetValue(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnResultsPopupSetValue(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { - CScanResult* pFirstResult = GetFirstSelectedScanResult(); + CScanResult * pFirstResult = GetFirstSelectedScanResult(); if (pFirstResult == nullptr) { @@ -522,7 +523,7 @@ LRESULT CDebugMemorySearch::OnResultsPopupSetValue(WORD /*wNotifyCode*/, WORD /* if (bSelected) { int index = m_ResultsListCtrl.GetItemData(iItem); - CScanResult* presult = m_MemoryScanner.GetResult(index); + CScanResult * presult = m_MemoryScanner.GetResult(index); const std::string & enteredString = m_SetValueDlg.GetEnteredString(); presult->SetMemoryValueFromString(enteredString.c_str()); m_ResultsListCtrl.SetItemText(iItem, ResultsListCtrl_Col_Value, stdstr(enteredString).ToUTF16().c_str()); @@ -532,7 +533,7 @@ LRESULT CDebugMemorySearch::OnResultsPopupSetValue(WORD /*wNotifyCode*/, WORD /* return FALSE; } -LRESULT CDebugMemorySearch::OnResultsPopupRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnResultsPopupRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { int nItems = m_ResultsListCtrl.GetItemCount(); @@ -576,7 +577,7 @@ LRESULT CDebugMemorySearch::OnWatchListItemChanged(LPNMHDR /*lpnmh*/) LRESULT CDebugMemorySearch::OnWatchListCustomDraw(LPNMHDR lpnmh) { - NMLVCUSTOMDRAW* pLVCD = reinterpret_cast(lpnmh); + NMLVCUSTOMDRAW * pLVCD = reinterpret_cast(lpnmh); DWORD drawStage = pLVCD->nmcd.dwDrawStage; switch (drawStage) @@ -590,7 +591,7 @@ LRESULT CDebugMemorySearch::OnWatchListCustomDraw(LPNMHDR lpnmh) uint32_t nItem = (uint32_t)pLVCD->nmcd.dwItemSpec; uint32_t nSubItem = pLVCD->iSubItem; size_t index = m_WatchListCtrl.GetItemData(nItem); - CScanResult *presult = &m_WatchList[index]; + CScanResult * presult = &m_WatchList[index]; switch (nSubItem) { @@ -629,7 +630,7 @@ LRESULT CDebugMemorySearch::OnWatchListDblClick(LPNMHDR /*lpnmh*/) } int index = m_WatchListCtrl.GetItemData(iItem); - CScanResult *presult = &m_WatchList[index]; + CScanResult * presult = &m_WatchList[index]; int nSelectedCol = -1; @@ -659,61 +660,61 @@ LRESULT CDebugMemorySearch::OnWatchListDblClick(LPNMHDR /*lpnmh*/) m_Debugger->Breakpoints()->ToggleMemLock(presult->m_Address); break; case WatchListCtrl_Col_Address: + { + if (m_SetValueDlg.DoModal("Change address", "New address:", stdstr_f("0x%08X", presult->m_Address).c_str())) { - if (m_SetValueDlg.DoModal("Change address", "New address:", stdstr_f("0x%08X", presult->m_Address).c_str())) + uint32_t newAddr = strtoul(m_SetValueDlg.GetEnteredString().c_str(), nullptr, 0); + if (presult->SetAddressSafe(newAddr)) { - uint32_t newAddr = strtoul(m_SetValueDlg.GetEnteredString().c_str(), nullptr, 0); - if (presult->SetAddressSafe(newAddr)) - { - m_WatchListCtrl.SetItemText(iItem, WatchListCtrl_Col_Address, stdstr_f("0x%08X", newAddr).ToUTF16().c_str()); - } + m_WatchListCtrl.SetItemText(iItem, WatchListCtrl_Col_Address, stdstr_f("0x%08X", newAddr).ToUTF16().c_str()); } } - break; + } + break; case WatchListCtrl_Col_Value: + { + char szInitialValue[1024]; + presult->GetMemoryValueString(szInitialValue, 1024); + if (m_SetValueDlg.DoModal("Change value", "New value:", szInitialValue)) { - char szInitialValue[1024]; - presult->GetMemoryValueString(szInitialValue, 1024); - if (m_SetValueDlg.DoModal("Change value", "New value:", szInitialValue)) - { - presult->SetMemoryValueFromString(m_SetValueDlg.GetEnteredString().c_str()); - } + presult->SetMemoryValueFromString(m_SetValueDlg.GetEnteredString().c_str()); } - break; + } + break; case WatchListCtrl_Col_Description: + { + if (m_SetValueDlg.DoModal("Set description", "New description:", presult->GetDescription())) { - if (m_SetValueDlg.DoModal("Set description", "New description:", presult->GetDescription())) - { - stdstr EnteredString = m_SetValueDlg.GetEnteredString(); - presult->SetDescription(EnteredString.c_str()); - m_WatchListCtrl.SetItemText(iItem, WatchListCtrl_Col_Description, EnteredString.ToUTF16().c_str()); - } + stdstr EnteredString = m_SetValueDlg.GetEnteredString(); + presult->SetDescription(EnteredString.c_str()); + m_WatchListCtrl.SetItemText(iItem, WatchListCtrl_Col_Description, EnteredString.ToUTF16().c_str()); } - break; + } + break; case WatchListCtrl_Col_Type: + { + if (m_SetValueDlg.DoModal("Change type", "New type:", presult->GetType(), ModalChangeTypeItems)) { - if (m_SetValueDlg.DoModal("Change type", "New type:", presult->GetType(), ModalChangeTypeItems)) + ValueType t = (ValueType)m_SetValueDlg.GetEnteredData(); + presult->SetType(t); + + if (t == ValueType_string) { - ValueType t = (ValueType) m_SetValueDlg.GetEnteredData(); - presult->SetType(t); - - if (t == ValueType_string) + if (m_SetValueDlg.DoModal("String length", "New string length:", stdstr_f("%d", presult->GetStrLength()).c_str())) { - if (m_SetValueDlg.DoModal("String length", "New string length:", stdstr_f("%d", presult->GetStrLength()).c_str())) - { - int length = atoi(m_SetValueDlg.GetEnteredString().c_str()); - presult->SetStrLengthSafe(length); - } + int length = atoi(m_SetValueDlg.GetEnteredString().c_str()); + presult->SetStrLengthSafe(length); + } - m_WatchListCtrl.SetItemText(iItem, WatchListCtrl_Col_Type, stdstr_f("char[%d]", presult->GetStrLength()).ToUTF16().c_str()); - } - else - { - m_WatchListCtrl.SetItemText(iItem, WatchListCtrl_Col_Type, stdstr(presult->GetTypeName()).ToUTF16().c_str()); - } + m_WatchListCtrl.SetItemText(iItem, WatchListCtrl_Col_Type, stdstr_f("char[%d]", presult->GetStrLength()).ToUTF16().c_str()); + } + else + { + m_WatchListCtrl.SetItemText(iItem, WatchListCtrl_Col_Type, stdstr(presult->GetTypeName()).ToUTF16().c_str()); } } - break; + } + break; } return true; @@ -728,7 +729,7 @@ LRESULT CDebugMemorySearch::OnWatchListRClick(LPNMHDR /*lpnmh*/) } int index = m_WatchListCtrl.GetItemData(iItem); - CScanResult *presult = &m_WatchList[index]; + CScanResult * presult = &m_WatchList[index]; // Load the menu HMENU hMenu = LoadMenu(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDR_MEM_WATCHLIST)); @@ -738,7 +739,7 @@ LRESULT CDebugMemorySearch::OnWatchListRClick(LPNMHDR /*lpnmh*/) POINT Mouse; GetCursorPos(&Mouse); - CBreakpoints* breakpoints = m_Debugger->Breakpoints(); + CBreakpoints * breakpoints = m_Debugger->Breakpoints(); bool bHaveLock = breakpoints->MemLockExists(presult->m_Address, 1); bool bHaveReadBP = (breakpoints->ReadBPExists8(presult->m_Address) != CBreakpoints::BPSTATE::BP_NOT_SET); @@ -756,9 +757,9 @@ LRESULT CDebugMemorySearch::OnWatchListRClick(LPNMHDR /*lpnmh*/) return true; } -LRESULT CDebugMemorySearch::OnWatchListPopupViewMemory(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnWatchListPopupViewMemory(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { - CScanResult* presult = GetFirstSelectedWatchListResult(); + CScanResult * presult = GetFirstSelectedWatchListResult(); if (presult == nullptr) { @@ -770,7 +771,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupViewMemory(WORD /*wNotifyCode*/, WOR return FALSE; } -LRESULT CDebugMemorySearch::OnWatchListPopupLock(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnWatchListPopupLock(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { int nItems = m_WatchListCtrl.GetItemCount(); for (int iItem = nItems - 1; iItem >= 0; iItem--) @@ -780,7 +781,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupLock(WORD /*wNotifyCode*/, WORD /*wI if (bSelected) { int index = m_WatchListCtrl.GetItemData(iItem); - CScanResult* presult = &m_WatchList[index]; + CScanResult * presult = &m_WatchList[index]; m_Debugger->Breakpoints()->ToggleMemLock(presult->m_Address); } } @@ -788,9 +789,9 @@ LRESULT CDebugMemorySearch::OnWatchListPopupLock(WORD /*wNotifyCode*/, WORD /*wI return FALSE; } -LRESULT CDebugMemorySearch::OnWatchListPopupReadBP(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnWatchListPopupReadBP(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { - CScanResult* presult = GetFirstSelectedWatchListResult(); + CScanResult * presult = GetFirstSelectedWatchListResult(); if (presult == nullptr) { @@ -801,9 +802,9 @@ LRESULT CDebugMemorySearch::OnWatchListPopupReadBP(WORD /*wNotifyCode*/, WORD /* return FALSE; } -LRESULT CDebugMemorySearch::OnWatchListPopupWriteBP(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnWatchListPopupWriteBP(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { - CScanResult* presult = GetFirstSelectedWatchListResult(); + CScanResult * presult = GetFirstSelectedWatchListResult(); if (presult == nullptr) { @@ -814,9 +815,9 @@ LRESULT CDebugMemorySearch::OnWatchListPopupWriteBP(WORD /*wNotifyCode*/, WORD / return FALSE; } -LRESULT CDebugMemorySearch::OnWatchListPopupAddSymbol(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnWatchListPopupAddSymbol(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { - CScanResult* presult = GetFirstSelectedWatchListResult(); + CScanResult * presult = GetFirstSelectedWatchListResult(); if (presult == nullptr) { @@ -845,7 +846,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupAddSymbol(WORD /*wNotifyCode*/, WORD return FALSE; } -LRESULT CDebugMemorySearch::OnWatchListPopupHexadecimal(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnWatchListPopupHexadecimal(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { int nItems = m_WatchListCtrl.GetItemCount(); for (int iItem = 0; iItem < nItems; iItem++) @@ -855,7 +856,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupHexadecimal(WORD /*wNotifyCode*/, WO if (bSelected) { int index = m_WatchListCtrl.GetItemData(iItem); - CScanResult* presult = &m_WatchList[index]; + CScanResult * presult = &m_WatchList[index]; if (presult->m_DisplayFormat == DisplayDefault) { @@ -871,9 +872,9 @@ LRESULT CDebugMemorySearch::OnWatchListPopupHexadecimal(WORD /*wNotifyCode*/, WO return FALSE; } -LRESULT CDebugMemorySearch::OnWatchListPopupChangeValue(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnWatchListPopupChangeValue(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { - CScanResult* pFirstResult = GetFirstSelectedWatchListResult(); + CScanResult * pFirstResult = GetFirstSelectedWatchListResult(); if (pFirstResult == nullptr) { @@ -893,7 +894,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupChangeValue(WORD /*wNotifyCode*/, WO if (bSelected) { int index = m_WatchListCtrl.GetItemData(iItem); - CScanResult* presult = &m_WatchList[index]; + CScanResult * presult = &m_WatchList[index]; // TODO: prompt for size change if string is too long presult->SetMemoryValueFromString(m_SetValueDlg.GetEnteredString().c_str()); m_WatchListCtrl.SetItemText(iItem, WatchListCtrl_Col_Value, stdstr(m_SetValueDlg.GetEnteredString()).ToUTF16().c_str()); @@ -904,9 +905,9 @@ LRESULT CDebugMemorySearch::OnWatchListPopupChangeValue(WORD /*wNotifyCode*/, WO return FALSE; } -LRESULT CDebugMemorySearch::OnWatchListPopupChangeDescription(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnWatchListPopupChangeDescription(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { - CScanResult* pFirstResult = GetFirstSelectedWatchListResult(); + CScanResult * pFirstResult = GetFirstSelectedWatchListResult(); if (pFirstResult == nullptr) { @@ -923,7 +924,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupChangeDescription(WORD /*wNotifyCode if (bSelected) { int index = m_WatchListCtrl.GetItemData(iItem); - CScanResult* presult = &m_WatchList[index]; + CScanResult * presult = &m_WatchList[index]; stdstr description = m_SetValueDlg.GetEnteredString(); presult->SetDescription(description.c_str()); m_WatchListCtrl.SetItemText(iItem, WatchListCtrl_Col_Description, description.ToUTF16().c_str()); @@ -934,9 +935,9 @@ LRESULT CDebugMemorySearch::OnWatchListPopupChangeDescription(WORD /*wNotifyCode return FALSE; } -LRESULT CDebugMemorySearch::OnWatchListPopupChangeType(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnWatchListPopupChangeType(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { - CScanResult* pFirstResult = GetFirstSelectedWatchListResult(); + CScanResult * pFirstResult = GetFirstSelectedWatchListResult(); if (pFirstResult == nullptr) { @@ -951,7 +952,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupChangeType(WORD /*wNotifyCode*/, WOR if (t == ValueType_string) { if (m_SetValueDlg.DoModal("String length", "New string length:", - stdstr_f("%d", pFirstResult->GetStrLength()).c_str())) + stdstr_f("%d", pFirstResult->GetStrLength()).c_str())) { length = atoi(m_SetValueDlg.GetEnteredString().c_str()); @@ -970,14 +971,14 @@ LRESULT CDebugMemorySearch::OnWatchListPopupChangeType(WORD /*wNotifyCode*/, WOR if (bSelected) { int index = m_WatchListCtrl.GetItemData(iItem); - CScanResult* presult = &m_WatchList[index]; + CScanResult * presult = &m_WatchList[index]; if (presult->IsStringType()) { presult->SetStrLengthSafe(length); m_WatchListCtrl.SetItemText(iItem, WatchListCtrl_Col_Type, - stdstr_f("char[%d]", presult->GetStrLength()).ToUTF16().c_str()); + stdstr_f("char[%d]", presult->GetStrLength()).ToUTF16().c_str()); } else { @@ -990,9 +991,9 @@ LRESULT CDebugMemorySearch::OnWatchListPopupChangeType(WORD /*wNotifyCode*/, WOR return FALSE; } -LRESULT CDebugMemorySearch::OnWatchListPopupChangeAddress(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnWatchListPopupChangeAddress(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { - CScanResult* pFirstResult = GetFirstSelectedWatchListResult(); + CScanResult * pFirstResult = GetFirstSelectedWatchListResult(); if (pFirstResult == nullptr) { @@ -1012,7 +1013,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupChangeAddress(WORD /*wNotifyCode*/, if (bSelected) { int index = m_WatchListCtrl.GetItemData(iItem); - CScanResult* presult = &m_WatchList[index]; + CScanResult * presult = &m_WatchList[index]; presult->SetAddressSafe(newAddr); m_WatchListCtrl.SetItemText(iItem, WatchListCtrl_Col_Address, newAddrStr.ToUTF16().c_str()); } @@ -1022,9 +1023,9 @@ LRESULT CDebugMemorySearch::OnWatchListPopupChangeAddress(WORD /*wNotifyCode*/, return FALSE; } -LRESULT CDebugMemorySearch::OnWatchListPopupChangeAddressBy(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnWatchListPopupChangeAddressBy(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { - CScanResult* pFirstResult = GetFirstSelectedWatchListResult(); + CScanResult * pFirstResult = GetFirstSelectedWatchListResult(); if (pFirstResult == nullptr) { @@ -1043,7 +1044,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupChangeAddressBy(WORD /*wNotifyCode*/ if (bSelected) { int index = m_WatchListCtrl.GetItemData(iItem); - CScanResult* presult = &m_WatchList[index]; + CScanResult * presult = &m_WatchList[index]; uint32_t newAddr = presult->m_Address + offset; if (presult->SetAddressSafe(newAddr)) { @@ -1057,19 +1058,19 @@ LRESULT CDebugMemorySearch::OnWatchListPopupChangeAddressBy(WORD /*wNotifyCode*/ return FALSE; } -LRESULT CDebugMemorySearch::OnWatchListPopupRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnWatchListPopupRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { RemoveSelectedWatchListItems(); return FALSE; } -LRESULT CDebugMemorySearch::OnWatchListPopupRemoveAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnWatchListPopupRemoveAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { ClearWatchList(); return FALSE; } -LRESULT CDebugMemorySearch::OnWatchListPopupCopyGamesharkCode(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnWatchListPopupCopyGamesharkCode(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { int numWatchListItems = m_WatchListCtrl.GetItemCount(); @@ -1083,7 +1084,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupCopyGamesharkCode(WORD /*wNotifyCode } size_t index = m_WatchListCtrl.GetItemData(i); - CScanResult* presult = &m_WatchList[index]; + CScanResult * presult = &m_WatchList[index]; uint32_t vaddr = presult->GetVirtualAddress(); @@ -1152,7 +1153,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupCopyGamesharkCode(WORD /*wNotifyCode } HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, strGSCode.length()); - strncpy((char*)GlobalLock(hMem), strGSCode.c_str(), strGSCode.length() - 1); + strncpy((char *)GlobalLock(hMem), strGSCode.c_str(), strGSCode.length() - 1); GlobalUnlock(hMem); OpenClipboard(); EmptyClipboard(); @@ -1162,7 +1163,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupCopyGamesharkCode(WORD /*wNotifyCode return FALSE; } -LRESULT CDebugMemorySearch::OnWatchListPopupCopyAddressAndDescription(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnWatchListPopupCopyAddressAndDescription(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { int numWatchListItems = m_WatchListCtrl.GetItemCount(); @@ -1176,7 +1177,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupCopyAddressAndDescription(WORD /*wNo } size_t index = m_WatchListCtrl.GetItemData(i); - CScanResult* presult = &m_WatchList[index]; + CScanResult * presult = &m_WatchList[index]; str += stdstr_f("%08X %s\n", presult->m_Address, presult->GetDescription()); } @@ -1188,7 +1189,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupCopyAddressAndDescription(WORD /*wNo HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, str.length()); - strncpy((char*)GlobalLock(hMem), str.c_str(), str.length() - 1); + strncpy((char *)GlobalLock(hMem), str.c_str(), str.length() - 1); GlobalUnlock(hMem); OpenClipboard(); EmptyClipboard(); @@ -1198,7 +1199,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupCopyAddressAndDescription(WORD /*wNo return FALSE; } -LRESULT CDebugMemorySearch::OnSetFont(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnSetFont(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL & /*bHandled*/) { // Set row height for the results list and watch list CClientDC dc(m_hWnd); @@ -1209,17 +1210,17 @@ LRESULT CDebugMemorySearch::OnSetFont(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lPa return FALSE; } -LRESULT CDebugMemorySearch::OnMeasureItem(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnMeasureItem(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL & /*bHandled*/) { if (wParam == IDC_LST_RESULTS || wParam == IDC_LST_WATCHLIST) { - MEASUREITEMSTRUCT* lpMeasureItem = (MEASUREITEMSTRUCT*)lParam; + MEASUREITEMSTRUCT * lpMeasureItem = (MEASUREITEMSTRUCT *)lParam; lpMeasureItem->itemHeight = m_ListCtrlRowHeight; } return FALSE; } -LRESULT CDebugMemorySearch::OnScroll(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnScroll(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL & /*bHandled*/) { WORD type = LOWORD(wParam); HWND hScrollbar = (HWND)lParam; @@ -1262,7 +1263,7 @@ LRESULT CDebugMemorySearch::OnScroll(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam return 0; } -LRESULT CDebugMemorySearch::OnMouseDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnMouseDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { if (MouseHovering(IDC_SEPARATOR, 0, 1)) { @@ -1273,7 +1274,7 @@ LRESULT CDebugMemorySearch::OnMouseDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM return 0; } -LRESULT CDebugMemorySearch::OnMouseUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugMemorySearch::OnMouseUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { if (m_bDraggingSeparator) { @@ -1305,7 +1306,7 @@ void CDebugMemorySearch::OnInterceptMouseMove(WPARAM /*wParam*/, LPARAM /*lParam ::GetWindowRect(hSeparator, &sepRect); ScreenToClient(&sepRect); ::SetWindowPos(hSeparator, nullptr, sepRect.left, cursorPos.y, 0, 0, - SWP_NOSIZE | SWP_NOZORDER); + SWP_NOSIZE | SWP_NOZORDER); ::InvalidateRect(hSeparator, nullptr, true); // Move and resize controls @@ -1388,7 +1389,7 @@ void CDebugMemorySearch::AddResultToWatchList(int resultIndex) m_WatchList.push_back(result); } -CScanResult* CDebugMemorySearch::GetFirstSelectedScanResult(void) +CScanResult * CDebugMemorySearch::GetFirstSelectedScanResult(void) { LONG iItem = m_ResultsListCtrl.GetNextItem(-1, LVNI_SELECTED); @@ -1398,11 +1399,11 @@ CScanResult* CDebugMemorySearch::GetFirstSelectedScanResult(void) } int index = m_ResultsListCtrl.GetItemData(iItem); - CScanResult *presult = m_MemoryScanner.GetResult(index); + CScanResult * presult = m_MemoryScanner.GetResult(index); return presult; } -CScanResult* CDebugMemorySearch::GetFirstSelectedWatchListResult(void) +CScanResult * CDebugMemorySearch::GetFirstSelectedWatchListResult(void) { LONG iItem = m_WatchListCtrl.GetNextItem(-1, LVNI_SELECTED); @@ -1412,11 +1413,11 @@ CScanResult* CDebugMemorySearch::GetFirstSelectedWatchListResult(void) } int index = m_WatchListCtrl.GetItemData(iItem); - CScanResult *presult = &m_WatchList[index]; + CScanResult * presult = &m_WatchList[index]; return presult; } -void CDebugMemorySearch::SetComboBoxSelByData(CComboBox& cb, DWORD_PTR data) +void CDebugMemorySearch::SetComboBoxSelByData(CComboBox & cb, DWORD_PTR data) { int numOptions = cb.GetCount(); @@ -1463,18 +1464,18 @@ void CDebugMemorySearch::SeparatorMoveCtrl(WORD ctrlId, int yChange, bool bResiz if (bResize) // Resize control { ::SetWindowPos(hControl, nullptr, 0, 0, rect.Width(), rect.Height() + yChange, - SWP_NOMOVE | SWP_NOZORDER); + SWP_NOMOVE | SWP_NOZORDER); } else // Move control { ::SetWindowPos(hControl, nullptr, rect.left, rect.top + yChange, 0, 0, - SWP_NOSIZE | SWP_NOZORDER); + SWP_NOSIZE | SWP_NOZORDER); } ::InvalidateRect(hControl, nullptr, true); } -int CDebugMemorySearch::GetNumVisibleRows(CListViewCtrl& list) +int CDebugMemorySearch::GetNumVisibleRows(CListViewCtrl & list) { CHeaderCtrl header = list.GetHeader(); CRect listRect, headRect; @@ -1494,8 +1495,8 @@ void CDebugMemorySearch::ResetResults(void) void CDebugMemorySearch::Search(void) { - ValueType valueType = (ValueType) m_ValueTypeOptions.GetItemData(m_ValueTypeOptions.GetCurSel()); - SearchType searchType = (SearchType) m_SearchTypeOptions.GetItemData(m_SearchTypeOptions.GetCurSel()); + ValueType valueType = (ValueType)m_ValueTypeOptions.GetItemData(m_ValueTypeOptions.GetCurSel()); + SearchType searchType = (SearchType)m_SearchTypeOptions.GetItemData(m_SearchTypeOptions.GetCurSel()); DWORD startAddress = m_AddrStart.GetValue(); DWORD endAddress = m_AddrEnd.GetValue(); @@ -1521,7 +1522,7 @@ void CDebugMemorySearch::Search(void) { switch (valueType) { - case ValueType_int8: valueType = ValueType_uint8; break; + case ValueType_int8: valueType = ValueType_uint8; break; case ValueType_int16: valueType = ValueType_uint16; break; case ValueType_int32: valueType = ValueType_uint32; break; case ValueType_int64: valueType = ValueType_uint64; break; @@ -1635,7 +1636,7 @@ void CDebugMemorySearch::Search(void) goto value_parse_error; } } - m_MemoryScanner.SetValue(value._string); + m_MemoryScanner.SetValue(value._string); m_MemoryScanner.SetStringValueLength(stringValueLength); break; case ValueType_unkstring: @@ -1645,7 +1646,7 @@ void CDebugMemorySearch::Search(void) goto value_parse_error; } - m_MemoryScanner.SetValue(value._string); + m_MemoryScanner.SetValue(value._string); m_MemoryScanner.SetStringValueLength(stringValueLength); break; default: @@ -1812,7 +1813,7 @@ void CDebugMemorySearch::UpdateResultsList(bool bUpdateScrollbar, bool bResetScr char szCurrentValue[1024]; char szValue[1024]; - CScanResult *presult = m_MemoryScanner.GetResult(index); + CScanResult * presult = m_MemoryScanner.GetResult(index); presult->GetAddressString(szAddress); presult->GetMemoryValueString(szCurrentValue, 1024); @@ -1863,19 +1864,19 @@ void CDebugMemorySearch::UpdateWatchList(bool bUpdateScrollbar) for (size_t index = start; index < end; index++) { - CScanResult *presult = &m_WatchList[index]; + CScanResult * presult = &m_WatchList[index]; char szAddress[16]; char szValue[1024]; char szValueType[32]; - const char* pSzValueType; - const char* pSzDescription; + const char * pSzValueType; + const char * pSzDescription; presult->GetAddressString(szAddress); presult->GetMemoryValueString(szValue, 1024); pSzValueType = presult->GetTypeName(); pSzDescription = presult->GetDescription(); - switch(presult->GetType()) + switch (presult->GetType()) { case ValueType_string: case ValueType_istring: @@ -1920,7 +1921,7 @@ void CDebugMemorySearch::RefreshResultsListValues(void) for (int nItem = 0; nItem < numShownResults; nItem++) { size_t index = m_ResultsListCtrl.GetItemData(nItem); - CScanResult *presult = m_MemoryScanner.GetResult(index); + CScanResult * presult = m_MemoryScanner.GetResult(index); if (presult == nullptr) { @@ -1954,9 +1955,9 @@ void CDebugMemorySearch::RefreshWatchListValues(void) for (int nItem = 0; nItem < numShownWatchListEntries; nItem++) { size_t index = m_WatchListCtrl.GetItemData(nItem); - CScanResult *presult = &m_WatchList[index]; + CScanResult * presult = &m_WatchList[index]; - CBreakpoints *breakpoints = m_Debugger->Breakpoints(); + CBreakpoints * breakpoints = m_Debugger->Breakpoints(); bool bHaveLock = breakpoints->MemLockExists(presult->m_Address, 1); bool bHaveReadBP = (breakpoints->ReadBPExists8(presult->m_Address) != CBreakpoints::BPSTATE::BP_NOT_SET); @@ -1965,9 +1966,9 @@ void CDebugMemorySearch::RefreshWatchListValues(void) char szBPStates[4]; sprintf(szBPStates, "%s%s%s", - bHaveReadBP ? "R" : "", - bHaveWriteBP ? "W" : "", - bHaveExecBP ? "E" : ""); + bHaveReadBP ? "R" : "", + bHaveWriteBP ? "W" : "", + bHaveExecBP ? "E" : ""); char szCurrentValue[1024]; presult->GetMemoryValueString(szCurrentValue, 1024); @@ -2000,10 +2001,10 @@ void CDebugMemorySearch::FlushWatchList(void) for (size_t i = 0; i < numWatchListEntries; i++) { - CScanResult* presult = &m_WatchList[i]; + CScanResult * presult = &m_WatchList[i]; char szValueType[32]; - const char* pSzValueType; + const char * pSzValueType; pSzValueType = presult->GetTypeName(); @@ -2018,10 +2019,10 @@ void CDebugMemorySearch::FlushWatchList(void) } char cAddrType = (presult->m_AddressType == AddressType_Physical) ? 'p' : 'v'; - const char* szDisplayFormat = (presult->m_DisplayFormat == DisplayDefault) ? "def" : "hex"; + const char * szDisplayFormat = (presult->m_DisplayFormat == DisplayDefault) ? "def" : "hex"; stdstr line = stdstr_f("%c,%08X,%s,%s,%s\n", - cAddrType, presult->m_Address, pSzValueType, szDisplayFormat, presult->GetDescription()); + cAddrType, presult->m_Address, pSzValueType, szDisplayFormat, presult->GetDescription()); m_WatchListFile.Write(line.c_str(), line.length()); } @@ -2047,7 +2048,7 @@ void CDebugMemorySearch::LoadWatchList(void) } uint32_t length = m_WatchListFile.GetLength(); - char* szWlFile = new char[length + 1]; + char * szWlFile = new char[length + 1]; m_WatchListFile.SeekToBegin(); m_WatchListFile.Read(szWlFile, length); @@ -2055,19 +2056,29 @@ void CDebugMemorySearch::LoadWatchList(void) m_WatchListFile.Close(); - char* p = szWlFile; + char * p = szWlFile; while (*p) { CScanResult result(AddressType_Virtual, DisplayDefault); - char* szAddrType, *szAddress, *szValueType, *szDisplayFormat, *szDescription; + char *szAddrType, *szAddress, *szValueType, *szDisplayFormat, *szDescription; - szAddrType = p; p = strchr(p, ','); *p++ = '\0'; - szAddress = p; p = strchr(p, ','); *p++ = '\0'; - szValueType = p; p = strchr(p, ','); *p++ = '\0'; - szDisplayFormat = p; p = strchr(p, ','); *p++ = '\0'; - szDescription = p; p = strchr(p, '\n'); *p++ = '\0'; + szAddrType = p; + p = strchr(p, ','); + *p++ = '\0'; + szAddress = p; + p = strchr(p, ','); + *p++ = '\0'; + szValueType = p; + p = strchr(p, ','); + *p++ = '\0'; + szDisplayFormat = p; + p = strchr(p, ','); + *p++ = '\0'; + szDescription = p; + p = strchr(p, '\n'); + *p++ = '\0'; switch (szAddrType[0]) { @@ -2120,12 +2131,11 @@ void CDebugMemorySearch::LoadWatchList(void) UpdateWatchList(); - parse_error: +parse_error: delete[] szWlFile; - } -void CDebugMemorySearch::FixListHeader(CListViewCtrl& listCtrl) +void CDebugMemorySearch::FixListHeader(CListViewCtrl & listCtrl) { CRect listRect, headRect; CHeaderCtrl listHead = listCtrl.GetHeader(); @@ -2160,7 +2170,7 @@ CPath CDebugMemorySearch::GetWatchListPath(void) return wlFilePath; } -INT_PTR CSetValueDlg::DoModal(const char* caption, const char* label, const char* initialText) +INT_PTR CSetValueDlg::DoModal(const char * caption, const char * label, const char * initialText) { m_Mode = Mode_TextBox; m_Caption = caption; @@ -2169,7 +2179,7 @@ INT_PTR CSetValueDlg::DoModal(const char* caption, const char* label, const char return CDialogImpl::DoModal(); } -INT_PTR CSetValueDlg::DoModal(const char* caption, const char* label, DWORD_PTR initialData, const ComboItem items[]) +INT_PTR CSetValueDlg::DoModal(const char * caption, const char * label, DWORD_PTR initialData, const ComboItem items[]) { m_Mode = Mode_ComboBox; m_Caption = caption; @@ -2194,7 +2204,7 @@ DWORD_PTR CSetValueDlg::GetEnteredData(void) return m_EnteredData; } -LRESULT CSetValueDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CSetValueDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { SetWindowText(stdstr(m_Caption).ToUTF16().c_str()); CenterWindow(); @@ -2237,7 +2247,7 @@ LRESULT CSetValueDlg::OnDestroy(void) return 0; } -LRESULT CSetValueDlg::OnOK(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CSetValueDlg::OnOK(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { m_EnteredString.clear(); if (m_Mode == Mode_TextBox) @@ -2254,7 +2264,7 @@ LRESULT CSetValueDlg::OnOK(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BO return FALSE; } -LRESULT CSetValueDlg::OnCancel(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CSetValueDlg::OnCancel(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { EndDialog(FALSE); return FALSE; @@ -2304,7 +2314,7 @@ BOOL CEditMixed::Attach(HWND hWndNew) return SubclassWindow(hWndNew); } -bool CEditMixed::GetValue(uint8_t& value) +bool CEditMixed::GetValue(uint8_t & value) { uint64_t valueU64; bool bValid = GetValue(valueU64); @@ -2318,11 +2328,11 @@ bool CEditMixed::GetValue(uint8_t& value) return true; } -bool CEditMixed::GetValue(int8_t& value) +bool CEditMixed::GetValue(int8_t & value) { if (m_DisplayFormat == DisplayHex) { - return GetValue((uint8_t&)value); + return GetValue((uint8_t &)value); } int64_t valueS64; @@ -2337,7 +2347,7 @@ bool CEditMixed::GetValue(int8_t& value) return true; } -bool CEditMixed::GetValue(uint16_t& value) +bool CEditMixed::GetValue(uint16_t & value) { uint64_t valueU64; bool bValid = GetValue(valueU64); @@ -2351,11 +2361,11 @@ bool CEditMixed::GetValue(uint16_t& value) return true; } -bool CEditMixed::GetValue(int16_t& value) +bool CEditMixed::GetValue(int16_t & value) { if (m_DisplayFormat == DisplayHex) { - return GetValue((uint16_t&)value); + return GetValue((uint16_t &)value); } int64_t valueS64; @@ -2370,7 +2380,7 @@ bool CEditMixed::GetValue(int16_t& value) return true; } -bool CEditMixed::GetValue(uint32_t& value) +bool CEditMixed::GetValue(uint32_t & value) { uint64_t valueU64; bool bValid = GetValue(valueU64); @@ -2384,11 +2394,11 @@ bool CEditMixed::GetValue(uint32_t& value) return true; } -bool CEditMixed::GetValue(int32_t& value) +bool CEditMixed::GetValue(int32_t & value) { if (m_DisplayFormat == DisplayHex) { - return GetValue((uint32_t&)value); + return GetValue((uint32_t &)value); } int64_t valueS64; @@ -2403,11 +2413,11 @@ bool CEditMixed::GetValue(int32_t& value) return true; } -bool CEditMixed::GetValue(uint64_t& value) +bool CEditMixed::GetValue(uint64_t & value) { ReloadString(); - char *end; + char * end; uint64_t res = strtoull(stdstr().FromUTF16(m_String).c_str(), &end, m_DisplayFormat == DisplayHex ? 16 : 10); if (*end != '\0') @@ -2419,16 +2429,16 @@ bool CEditMixed::GetValue(uint64_t& value) return true; } -bool CEditMixed::GetValue(int64_t& value) +bool CEditMixed::GetValue(int64_t & value) { if (m_DisplayFormat == DisplayHex) { - return GetValue((uint64_t&)value); + return GetValue((uint64_t &)value); } ReloadString(); - char *end; + char * end; uint64_t res = strtoll(stdstr().FromUTF16(m_String).c_str(), &end, m_DisplayFormat == DisplayHex ? 16 : 10); if (*end != '\0') @@ -2440,17 +2450,17 @@ bool CEditMixed::GetValue(int64_t& value) return true; } -bool CEditMixed::GetValue(float& value) +bool CEditMixed::GetValue(float & value) { if (m_DisplayFormat == DisplayHex) { - return GetValue((uint32_t&)value); + return GetValue((uint32_t &)value); } ReloadString(); float valueF32; - char *end; + char * end; valueF32 = strtof(stdstr().FromUTF16(m_String).c_str(), &end); @@ -2463,17 +2473,17 @@ bool CEditMixed::GetValue(float& value) return true; } -bool CEditMixed::GetValue(double& value) +bool CEditMixed::GetValue(double & value) { if (m_DisplayFormat == DisplayHex) { - return GetValue((uint64_t&)value); + return GetValue((uint64_t &)value); } ReloadString(); double valueF64; - char *end; + char * end; valueF64 = strtod(stdstr().FromUTF16(m_String).c_str(), &end); @@ -2486,7 +2496,7 @@ bool CEditMixed::GetValue(double& value) return true; } -bool CEditMixed::GetValueString(const wchar_t*& value, int& length) +bool CEditMixed::GetValueString(const wchar_t *& value, int & length) { ReloadString(); @@ -2500,7 +2510,7 @@ bool CEditMixed::GetValueString(const wchar_t*& value, int& length) return true; } -bool CEditMixed::GetValueHexString(const wchar_t*& value, int& length) +bool CEditMixed::GetValueHexString(const wchar_t *& value, int & length) { ReloadString(); @@ -2517,9 +2527,8 @@ bool CEditMixed::GetValueHexString(const wchar_t*& value, int& length) return false; } - - char *hexString = new char[numBytes]; - wchar_t *wchexString = new wchar_t[numBytes]; + char * hexString = new char[numBytes]; + wchar_t * wchexString = new wchar_t[numBytes]; CMemoryScanner::ParseHexString(hexString, string.c_str()); wcscpy(wchexString, stdstr(hexString).ToUTF16().c_str()); diff --git a/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabData.h b/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabData.h index 155f30d1e..4e0627755 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabData.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabData.h @@ -1,5 +1,4 @@ #pragma once -#include "stdafx.h" struct FieldPair { diff --git a/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.cpp b/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.cpp index 49d4ee8cc..fe418c6e7 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.cpp @@ -4,7 +4,7 @@ #include "OpInfo.h" bool CRegisterTabs::m_bColorsEnabled = false; -CDebuggerUI* CRegisterTabs::m_Debugger = nullptr; +CDebuggerUI * CRegisterTabs::m_Debugger = nullptr; CRegisterTabs::CRegisterTabs() : m_attached(false) @@ -15,7 +15,7 @@ CRegisterTabs::~CRegisterTabs() { } -void CRegisterTabs::Attach(HWND hWndNew, CDebuggerUI* debugger) +void CRegisterTabs::Attach(HWND hWndNew, CDebuggerUI * debugger) { m_Debugger = debugger; CTabCtrl::Attach(hWndNew); @@ -154,7 +154,7 @@ void CRegisterTabs::RefreshEdits() CAUSE cause; cause.intval = (uint32_t)g_Reg->CAUSE_REGISTER; - const char* szExceptionCode = ExceptionCodes[cause.exceptionCode]; + const char * szExceptionCode = ExceptionCodes[cause.exceptionCode]; m_CauseTip.SetWindowText(stdstr(szExceptionCode).ToUTF16().c_str()); m_RDRAMEdits[0].SetValue(g_Reg->RDRAM_CONFIG_REG, DisplayMode::ZeroExtend); // or device type @@ -305,22 +305,22 @@ void CRegisterTabs::RegisterChanged(HWND hDlg, TAB_ID srcTabId, WPARAM wParam) } int nReg = TabData::FPR.GetEditIndex(ctrlId); - *(uint32_t*)g_Reg->m_FPR_S[nReg] = value; + *(uint32_t *)g_Reg->m_FPR_S[nReg] = value; return; } switch (ctrlId) { - case IDC_COP0_0_EDIT: g_Reg->INDEX_REGISTER = value; break; - case IDC_COP0_1_EDIT: g_Reg->RANDOM_REGISTER = value; break; - case IDC_COP0_2_EDIT: g_Reg->ENTRYLO0_REGISTER = value; break; - case IDC_COP0_3_EDIT: g_Reg->ENTRYLO1_REGISTER = value; break; - case IDC_COP0_4_EDIT: g_Reg->CONTEXT_REGISTER.Value = value; break; - case IDC_COP0_5_EDIT: g_Reg->PAGE_MASK_REGISTER = value; break; - case IDC_COP0_6_EDIT: g_Reg->WIRED_REGISTER = value; break; - case IDC_COP0_7_EDIT: g_Reg->BAD_VADDR_REGISTER = value; break; - case IDC_COP0_8_EDIT: g_Reg->COUNT_REGISTER = value; break; - case IDC_COP0_9_EDIT: g_Reg->ENTRYHI_REGISTER = value; break; + case IDC_COP0_0_EDIT: g_Reg->INDEX_REGISTER = value; break; + case IDC_COP0_1_EDIT: g_Reg->RANDOM_REGISTER = value; break; + case IDC_COP0_2_EDIT: g_Reg->ENTRYLO0_REGISTER = value; break; + case IDC_COP0_3_EDIT: g_Reg->ENTRYLO1_REGISTER = value; break; + case IDC_COP0_4_EDIT: g_Reg->CONTEXT_REGISTER.Value = value; break; + case IDC_COP0_5_EDIT: g_Reg->PAGE_MASK_REGISTER = value; break; + case IDC_COP0_6_EDIT: g_Reg->WIRED_REGISTER = value; break; + case IDC_COP0_7_EDIT: g_Reg->BAD_VADDR_REGISTER = value; break; + case IDC_COP0_8_EDIT: g_Reg->COUNT_REGISTER = value; break; + case IDC_COP0_9_EDIT: g_Reg->ENTRYHI_REGISTER = value; break; case IDC_COP0_10_EDIT: g_Reg->COMPARE_REGISTER = value; break; case IDC_COP0_11_EDIT: g_Reg->STATUS_REGISTER = value; break; case IDC_COP0_12_EDIT: g_Reg->CAUSE_REGISTER = value; break; @@ -342,14 +342,14 @@ void CRegisterTabs::RegisterChanged(HWND hDlg, TAB_ID srcTabId, WPARAM wParam) case IDC_RDRAM20_EDIT: g_Reg->RDRAM_ADDR_SELECT_REG = value; break; case IDC_RDRAM24_EDIT: g_Reg->RDRAM_DEVICE_MANUF_REG = value; break; - case IDC_SP00_EDIT: g_Reg->SP_MEM_ADDR_REG = value; break; - case IDC_SP04_EDIT: g_Reg->SP_DRAM_ADDR_REG = value; break; - case IDC_SP08_EDIT: g_Reg->SP_RD_LEN_REG = value; break; - case IDC_SP0C_EDIT: g_Reg->SP_WR_LEN_REG = value; break; - case IDC_SP10_EDIT: g_Reg->SP_STATUS_REG = value; break; - case IDC_SP14_EDIT: g_Reg->SP_DMA_FULL_REG = value; break; - case IDC_SP18_EDIT: g_Reg->SP_DMA_BUSY_REG = value; break; - case IDC_SP1C_EDIT: g_Reg->SP_SEMAPHORE_REG = value; break; + case IDC_SP00_EDIT: g_Reg->SP_MEM_ADDR_REG = value; break; + case IDC_SP04_EDIT: g_Reg->SP_DRAM_ADDR_REG = value; break; + case IDC_SP08_EDIT: g_Reg->SP_RD_LEN_REG = value; break; + case IDC_SP0C_EDIT: g_Reg->SP_WR_LEN_REG = value; break; + case IDC_SP10_EDIT: g_Reg->SP_STATUS_REG = value; break; + case IDC_SP14_EDIT: g_Reg->SP_DMA_FULL_REG = value; break; + case IDC_SP18_EDIT: g_Reg->SP_DMA_BUSY_REG = value; break; + case IDC_SP1C_EDIT: g_Reg->SP_SEMAPHORE_REG = value; break; case IDC_SP_PC_EDIT: g_Reg->SP_PC_REG = value; break; case IDC_DPC00_EDIT: g_Reg->DPC_START_REG = value; break; @@ -362,8 +362,8 @@ void CRegisterTabs::RegisterChanged(HWND hDlg, TAB_ID srcTabId, WPARAM wParam) case IDC_DPC1C_EDIT: g_Reg->DPC_TMEM_REG = value; break; case IDC_MI00_EDIT: g_Reg->MI_INIT_MODE_REG = value; break; // or MI_MODE ? - case IDC_MI04_EDIT: g_Reg->MI_VERSION_REG = value; break; // or MI_NOOP ? - case IDC_MI08_EDIT: g_Reg->MI_INTR_REG = value; break; // or MI_INTR ? + case IDC_MI04_EDIT: g_Reg->MI_VERSION_REG = value; break; // or MI_NOOP ? + case IDC_MI08_EDIT: g_Reg->MI_INTR_REG = value; break; // or MI_INTR ? case IDC_MI0C_EDIT: g_Reg->MI_INTR_MASK_REG = value; break; // or MI_INTR_MASK ? case IDC_VI00_EDIT: g_Reg->VI_STATUS_REG = value; break; @@ -481,7 +481,7 @@ INT_PTR CALLBACK CRegisterTabs::TabProcGPR(HWND hDlg, UINT msg, WPARAM wParam, L } HWND hWnd = (HWND)lParam; - WORD ctrlId = (WORD) ::GetWindowLong(hWnd, GWL_ID); + WORD ctrlId = (WORD)::GetWindowLong(hWnd, GWL_ID); COpInfo opInfo; m_Debugger->DebugLoad_VAddr(g_Reg->m_PROGRAM_COUNTER, opInfo.m_OpCode.Value); @@ -555,9 +555,9 @@ INT_PTR CALLBACK CRegisterTabs::TabProcGPR(HWND hDlg, UINT msg, WPARAM wParam, L } HWND hWnd = (HWND)wParam; - WORD ctrlId = (WORD) ::GetWindowLong(hWnd, GWL_ID); + WORD ctrlId = (WORD)::GetWindowLong(hWnd, GWL_ID); - CBreakpoints* breakpoints = m_Debugger->Breakpoints(); + CBreakpoints * breakpoints = m_Debugger->Breakpoints(); if (ctrlId == IDC_HI_LBL) { @@ -594,7 +594,7 @@ INT_PTR CALLBACK CRegisterTabs::TabProcGPR(HWND hDlg, UINT msg, WPARAM wParam, L HWND hWnd = (HWND)lParam; WORD ctrlId = LOWORD(wParam); - CBreakpoints* breakpoints = m_Debugger->Breakpoints(); + CBreakpoints * breakpoints = m_Debugger->Breakpoints(); if (ctrlId == IDC_HI_LBL) { @@ -629,8 +629,7 @@ INT_PTR CALLBACK CRegisterTabs::TabProcGPR(HWND hDlg, UINT msg, WPARAM wParam, L } HWND hWnd = (HWND)lParam; - WORD ctrlId = (WORD) ::GetWindowLong(hWnd, GWL_ID); - + WORD ctrlId = (WORD)::GetWindowLong(hWnd, GWL_ID); HDC hdc = (HDC)wParam; @@ -638,8 +637,8 @@ INT_PTR CALLBACK CRegisterTabs::TabProcGPR(HWND hDlg, UINT msg, WPARAM wParam, L COLORREF colorWrite = RGB(255, 200, 200); COLORREF colorBoth = RGB(220, 170, 255); - CBreakpoints* breakpoints = m_Debugger->Breakpoints(); - + CBreakpoints * breakpoints = m_Debugger->Breakpoints(); + bool haveRead, haveWrite; if (ctrlId == IDC_HI_LBL) @@ -669,11 +668,11 @@ INT_PTR CALLBACK CRegisterTabs::TabProcGPR(HWND hDlg, UINT msg, WPARAM wParam, L { SetBkColor(hdc, colorBoth); } - else if(haveRead) + else if (haveRead) { SetBkColor(hdc, colorRead); } - else if(haveWrite) + else if (haveWrite) { SetBkColor(hdc, colorWrite); } @@ -684,7 +683,7 @@ INT_PTR CALLBACK CRegisterTabs::TabProcGPR(HWND hDlg, UINT msg, WPARAM wParam, L return (LRESULT)GetStockObject(DC_BRUSH); } - + return FALSE; } @@ -716,7 +715,7 @@ CRect CRegisterTabs::GetPageRect() return pageRect; } -CWindow CRegisterTabs::AddTab(char* caption, int dialogId, DLGPROC dlgProc) +CWindow CRegisterTabs::AddTab(char * caption, int dialogId, DLGPROC dlgProc) { AddItem(stdstr(caption).ToUTF16().c_str()); @@ -774,13 +773,13 @@ void CRegisterTabs::SetColorsEnabled(bool bColorsEnabled) m_bColorsEnabled = bColorsEnabled; } -void CRegisterTabs::InitRegisterEdit(CWindow& tab, CEditNumber32& edit, FieldPair ctrl) +void CRegisterTabs::InitRegisterEdit(CWindow & tab, CEditNumber32 & edit, FieldPair ctrl) { edit.Attach(tab.GetDlgItem(ctrl.EditId)); edit.SetDisplayType(CEditNumber32::DisplayHex); } -void CRegisterTabs::InitRegisterEdits(CWindow& tab, CEditNumber32* edits, const TabRecord* ctrlIds) +void CRegisterTabs::InitRegisterEdits(CWindow & tab, CEditNumber32 * edits, const TabRecord * ctrlIds) { for (int i = 0, n = ctrlIds->FieldCount; i < n; i++) { @@ -788,12 +787,12 @@ void CRegisterTabs::InitRegisterEdits(CWindow& tab, CEditNumber32* edits, const } } -void CRegisterTabs::InitRegisterEdit64(CWindow& tab, CEditReg64& edit, FieldPair ctrl) +void CRegisterTabs::InitRegisterEdit64(CWindow & tab, CEditReg64 & edit, FieldPair ctrl) { edit.Attach(tab.GetDlgItem(ctrl.EditId)); } -void CRegisterTabs::InitRegisterEdits64(CWindow& tab, CEditReg64* edits, const TabRecord* ctrlIds) +void CRegisterTabs::InitRegisterEdits64(CWindow & tab, CEditReg64 * edits, const TabRecord * ctrlIds) { for (int i = 0, n = ctrlIds->FieldCount; i < n; i++) { @@ -801,12 +800,12 @@ void CRegisterTabs::InitRegisterEdits64(CWindow& tab, CEditReg64* edits, const T } } -void CRegisterTabs::ZeroRegisterEdit(CEditNumber32& edit) +void CRegisterTabs::ZeroRegisterEdit(CEditNumber32 & edit) { edit.SetValue(0, DisplayMode::ZeroExtend); } -void CRegisterTabs::ZeroRegisterEdits(CEditNumber32* edits, uint32_t ctrlIdsCount) +void CRegisterTabs::ZeroRegisterEdits(CEditNumber32 * edits, uint32_t ctrlIdsCount) { for (int i = 0, n = ctrlIdsCount; i < n; i++) { @@ -814,12 +813,12 @@ void CRegisterTabs::ZeroRegisterEdits(CEditNumber32* edits, uint32_t ctrlIdsCoun } } -void CRegisterTabs::ZeroRegisterEdit64(CEditReg64& edit) +void CRegisterTabs::ZeroRegisterEdit64(CEditReg64 & edit) { edit.SetValue(0); } -void CRegisterTabs::ZeroRegisterEdits64(CEditReg64* edits, uint32_t ctrlIdsCount) +void CRegisterTabs::ZeroRegisterEdits64(CEditReg64 * edits, uint32_t ctrlIdsCount) { for (uint32_t i = 0, n = ctrlIdsCount; i < n; i++) { @@ -827,12 +826,13 @@ void CRegisterTabs::ZeroRegisterEdits64(CEditReg64* edits, uint32_t ctrlIdsCount } } -void CRegisterTabs::CopyTabRegisters() { +void CRegisterTabs::CopyTabRegisters() +{ int nPage = GetCurSel(); stdstr str = CopyTabRegisters(nPage); HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, str.length() + 1); - strncpy((char*)GlobalLock(hMem), str.c_str(), str.length()); + strncpy((char *)GlobalLock(hMem), str.c_str(), str.length()); GlobalUnlock(hMem); OpenClipboard(); EmptyClipboard(); @@ -840,15 +840,17 @@ void CRegisterTabs::CopyTabRegisters() { CloseClipboard(); } -void CRegisterTabs::CopyAllRegisters() { +void CRegisterTabs::CopyAllRegisters() +{ stdstr str; - for (int i = 0; i <= 12; i++) { + for (int i = 0; i <= 12; i++) + { if (!str.empty()) str += "\r\n"; str += CopyTabRegisters(i); } HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, str.length() + 1); - strncpy((char*)GlobalLock(hMem), str.c_str(), str.length()); + strncpy((char *)GlobalLock(hMem), str.c_str(), str.length()); GlobalUnlock(hMem); OpenClipboard(); EmptyClipboard(); @@ -870,52 +872,52 @@ stdstr CRegisterTabs::CopyTabRegisters(int id) str += stdstr().FromUTF16(item.pszText); - const TabRecord *record = nullptr; + const TabRecord * record = nullptr; switch (id) { - case 0: record = &TabData::GPR; break; - case 1: record = &TabData::FPR; break; - case 2: record = &TabData::COP0; break; - case 3: - record = &TabData::RDRAM; - str += " (A3F00000)"; - break; - case 4: - record = &TabData::SP; - str += " (A4040000)"; - break; - case 5: - record = &TabData::DPC; - str += " (A4100000)"; - break; - case 6: - record = &TabData::MI; - str += " (A4300000)"; - break; - case 7: - record = &TabData::VI; - str += " (A4400000)"; - break; - case 8: - record = &TabData::AI; - str += " (A4500000)"; - break; - case 9: - record = &TabData::PI; - str += " (A4600000)"; - break; - case 10: - record = &TabData::RI; - str += " (A4700000)"; - break; - case 11: - record = &TabData::SI; - str += " (A4800000)"; - break; - case 12: - record = &TabData::DD; - str += " (A5000500)"; - break; + case 0: record = &TabData::GPR; break; + case 1: record = &TabData::FPR; break; + case 2: record = &TabData::COP0; break; + case 3: + record = &TabData::RDRAM; + str += " (A3F00000)"; + break; + case 4: + record = &TabData::SP; + str += " (A4040000)"; + break; + case 5: + record = &TabData::DPC; + str += " (A4100000)"; + break; + case 6: + record = &TabData::MI; + str += " (A4300000)"; + break; + case 7: + record = &TabData::VI; + str += " (A4400000)"; + break; + case 8: + record = &TabData::AI; + str += " (A4500000)"; + break; + case 9: + record = &TabData::PI; + str += " (A4600000)"; + break; + case 10: + record = &TabData::RI; + str += " (A4700000)"; + break; + case 11: + record = &TabData::SI; + str += " (A4800000)"; + break; + case 12: + record = &TabData::DD; + str += " (A5000500)"; + break; } record->Iterate(tab, [&str](const CWindow & label, const CWindow & edit) @@ -925,16 +927,16 @@ stdstr CRegisterTabs::CopyTabRegisters(int id) switch (id) { - case 0: - str += stdstr_f("\r\nHI %s", GetCWindowText(m_HIEdit).c_str()); - str += stdstr_f("\r\nLO %s", GetCWindowText(m_LOEdit).c_str()); - break; - case 1: - str += stdstr_f("\r\nFCSR %s", GetCWindowText(m_FCSREdit).c_str()); - break; - case 4: - str += stdstr_f("\r\nSP (A4080000)\r\n00 SP_PC %s", GetCWindowText(m_SPPCEdit).c_str()); - break; + case 0: + str += stdstr_f("\r\nHI %s", GetCWindowText(m_HIEdit).c_str()); + str += stdstr_f("\r\nLO %s", GetCWindowText(m_LOEdit).c_str()); + break; + case 1: + str += stdstr_f("\r\nFCSR %s", GetCWindowText(m_FCSREdit).c_str()); + break; + case 4: + str += stdstr_f("\r\nSP (A4080000)\r\n00 SP_PC %s", GetCWindowText(m_SPPCEdit).c_str()); + break; } str += "\r\n"; @@ -942,7 +944,7 @@ stdstr CRegisterTabs::CopyTabRegisters(int id) } // CEditReg64 for GPR -uint64_t CEditReg64::ParseValue(const char* wordPair) +uint64_t CEditReg64::ParseValue(const char * wordPair) { uint32_t a, b; uint64_t ret; @@ -964,7 +966,7 @@ BOOL CEditReg64::Attach(HWND hWndNew) return SubclassWindow(hWndNew); } -LRESULT CEditReg64::OnChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +LRESULT CEditReg64::OnChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled) { bHandled = TRUE; if (!isStepping()) @@ -1015,7 +1017,7 @@ uint64_t CEditReg64::GetValue() return ParseValue(GetCWindowText(*this).c_str()); } -LRESULT CEditReg64::OnLostFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) +LRESULT CEditReg64::OnLostFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & bHandled) { SetValue(GetValue()); bHandled = FALSE; diff --git a/Source/Project64/UserInterface/Debugger/Debugger-Scripts.cpp b/Source/Project64/UserInterface/Debugger/Debugger-Scripts.cpp index aed1bd722..380af7e5e 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-Scripts.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-Scripts.cpp @@ -1,7 +1,8 @@ #include "stdafx.h" + #include "DebuggerUI.h" -CDebugScripts::CDebugScripts(CDebuggerUI* debugger) : +CDebugScripts::CDebugScripts(CDebuggerUI * debugger) : CDebugDialog(debugger), CToolTipDialog(), m_hQuitScriptDirWatchEvent(nullptr), @@ -21,21 +22,21 @@ CDebugScripts::~CDebugScripts(void) m_InputHistory.clear(); } -LRESULT CDebugScripts::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugScripts::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { DlgResize_Init(false, true); DlgSavePos_Init(DebuggerUI_ScriptsPos); DlgToolTip_Init(); m_MonoFont = CreateFont(-12, 0, 0, 0, - FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, - OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, - CLEARTYPE_QUALITY, FF_DONTCARE, L"Consolas"); + FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, + OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, + CLEARTYPE_QUALITY, FF_DONTCARE, L"Consolas"); m_MonoBoldFont = CreateFont(-13, 0, 0, 0, - FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET, - OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, - CLEARTYPE_QUALITY, FF_DONTCARE, L"Consolas"); + FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET, + OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, + CLEARTYPE_QUALITY, FF_DONTCARE, L"Consolas"); m_ScriptList.Attach(GetDlgItem(IDC_SCRIPT_LIST)); m_ScriptList.AddColumn(L"Status", 0); @@ -55,7 +56,7 @@ LRESULT CDebugScripts::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*l ::SendMessage(GetDlgItem(IDC_EVAL_LBL), WM_SETFONT, (WPARAM)m_MonoBoldFont, 0); - int statusPaneWidths[] = { -1 }; + int statusPaneWidths[] = {-1}; m_StatusBar.Attach(GetDlgItem(IDC_STATUSBAR)); m_StatusBar.SetParts(1, statusPaneWidths); @@ -69,7 +70,7 @@ LRESULT CDebugScripts::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*l SetTimer(CONFLUSH_TIMER_ID, CONFLUSH_TIMER_INTERVAL, nullptr); m_hQuitScriptDirWatchEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr); - m_hScriptDirWatchThread = CreateThread(nullptr, 0, ScriptDirWatchProc, (void*)this, 0, nullptr); + m_hScriptDirWatchThread = CreateThread(nullptr, 0, ScriptDirWatchProc, (void *)this, 0, nullptr); m_ConOutputEdit.SetWindowText(m_Debugger->ScriptSystem()->GetConsoleBuffer().ToUTF16().c_str()); @@ -93,11 +94,11 @@ LRESULT CDebugScripts::OnDestroy(void) return 0; } -LRESULT CDebugScripts::OnCtlColorStatic(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) +LRESULT CDebugScripts::OnCtlColorStatic(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL & /*bHandled*/) { HDC hDC = (HDC)wParam; HWND hCtrl = (HWND)lParam; - WORD ctrlId = (WORD) ::GetWindowLong(hCtrl, GWL_ID); + WORD ctrlId = (WORD)::GetWindowLong(hCtrl, GWL_ID); if (ctrlId == IDC_CONSOLE_EDIT) { @@ -110,11 +111,11 @@ LRESULT CDebugScripts::OnCtlColorStatic(UINT /*uMsg*/, WPARAM wParam, LPARAM lPa return FALSE; } -LRESULT CDebugScripts::OnCtlColorEdit(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) +LRESULT CDebugScripts::OnCtlColorEdit(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL & /*bHandled*/) { HDC hDC = (HDC)wParam; HWND hCtrl = (HWND)lParam; - WORD ctrlId = (WORD) ::GetWindowLong(hCtrl, GWL_ID); + WORD ctrlId = (WORD)::GetWindowLong(hCtrl, GWL_ID); if (ctrlId == IDC_EVAL_EDIT) { @@ -127,9 +128,9 @@ LRESULT CDebugScripts::OnCtlColorEdit(UINT /*uMsg*/, WPARAM wParam, LPARAM lPara return FALSE; } -DWORD WINAPI CDebugScripts::ScriptDirWatchProc(void* ctx) +DWORD WINAPI CDebugScripts::ScriptDirWatchProc(void * ctx) { - CDebugScripts* _this = (CDebugScripts*)ctx; + CDebugScripts * _this = (CDebugScripts *)ctx; HANDLE hEvents[2]; @@ -161,7 +162,7 @@ DWORD WINAPI CDebugScripts::ScriptDirWatchProc(void* ctx) } } - done: +done: FindCloseChangeNotification(hEvents[0]); return 0; } @@ -189,7 +190,7 @@ void CDebugScripts::ConsoleCopy() return; } - wchar_t* memBuf = (wchar_t*)GlobalLock(hMem); + wchar_t * memBuf = (wchar_t *)GlobalLock(hMem); if (memBuf == nullptr) { @@ -207,12 +208,12 @@ void CDebugScripts::ConsoleCopy() CloseClipboard(); } -void CDebugScripts::ConsolePrint(const char* text) +void CDebugScripts::ConsolePrint(const char * text) { if (m_hWnd != nullptr) { // OnConsolePrint will free this - char* textCopy = _strdup(text); + char * textCopy = _strdup(text); PostMessage(WM_CONSOLE_PRINT, (WPARAM)textCopy); } } @@ -233,7 +234,7 @@ void CDebugScripts::RefreshList() } } -LRESULT CDebugScripts::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CDebugScripts::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { switch (wID) { @@ -269,9 +270,9 @@ LRESULT CDebugScripts::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl* return FALSE; } -LRESULT CDebugScripts::OnScriptListDblClicked(NMHDR* pNMHDR) +LRESULT CDebugScripts::OnScriptListDblClicked(NMHDR * pNMHDR) { - NMITEMACTIVATE* pIA = reinterpret_cast(pNMHDR); + NMITEMACTIVATE * pIA = reinterpret_cast(pNMHDR); int nItem = pIA->iItem; if (nItem == -1) @@ -304,13 +305,13 @@ void CDebugScripts::RefreshStatus() } m_ConInputEdit.EnableWindow(FALSE); } - + m_StatusBar.SetText(0, statusText.ToUTF16().c_str()); } -LRESULT CDebugScripts::OnScriptListRClicked(NMHDR* pNMHDR) +LRESULT CDebugScripts::OnScriptListRClicked(NMHDR * pNMHDR) { - NMITEMACTIVATE* pIA = reinterpret_cast(pNMHDR); + NMITEMACTIVATE * pIA = reinterpret_cast(pNMHDR); int nItem = pIA->iItem; if (nItem == -1) @@ -331,7 +332,7 @@ LRESULT CDebugScripts::OnScriptListRClicked(NMHDR* pNMHDR) { EnableMenuItem(hPopupMenu, ID_POPUP_STOP, MF_DISABLED | MF_GRAYED); } - + POINT mouse; GetCursorPos(&mouse); TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN, mouse.x, mouse.y, 0, m_hWnd, nullptr); @@ -340,9 +341,9 @@ LRESULT CDebugScripts::OnScriptListRClicked(NMHDR* pNMHDR) return 0; } -LRESULT CDebugScripts::OnScriptListCustomDraw(NMHDR* pNMHDR) +LRESULT CDebugScripts::OnScriptListCustomDraw(NMHDR * pNMHDR) { - NMLVCUSTOMDRAW* pLVCD = reinterpret_cast(pNMHDR); + NMLVCUSTOMDRAW * pLVCD = reinterpret_cast(pNMHDR); DWORD drawStage = pLVCD->nmcd.dwDrawStage; switch (drawStage) @@ -381,10 +382,10 @@ LRESULT CDebugScripts::OnScriptListCustomDraw(NMHDR* pNMHDR) return CDRF_DODEFAULT; } -LRESULT CDebugScripts::OnScriptListItemChanged(NMHDR* pNMHDR) +LRESULT CDebugScripts::OnScriptListItemChanged(NMHDR * pNMHDR) { - NMLISTVIEW* lpStateChange = reinterpret_cast(pNMHDR); - if ((lpStateChange->uNewState ^ lpStateChange->uOldState) & LVIS_SELECTED) + NMLISTVIEW * lpStateChange = reinterpret_cast(pNMHDR); + if ((lpStateChange->uNewState ^ lpStateChange->uOldState) & LVIS_SELECTED) { if (lpStateChange->iItem == -1) { @@ -405,22 +406,22 @@ LRESULT CDebugScripts::OnScriptListItemChanged(NMHDR* pNMHDR) return FALSE; } -LRESULT CDebugScripts::OnConsolePrint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugScripts::OnConsolePrint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL & /*bHandled*/) { - char *text = (char*)wParam; + char * text = (char *)wParam; m_ConOutputBuffer += text; free(text); return FALSE; } -LRESULT CDebugScripts::OnConsoleClear(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugScripts::OnConsoleClear(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { m_ConOutputBuffer = ""; m_ConOutputEdit.SetWindowText(L""); return FALSE; } -LRESULT CDebugScripts::OnRefreshList(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugScripts::OnRefreshList(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { int nIndex = m_ScriptList.GetSelectedIndex(); CPath searchPath(m_ScriptsDir.c_str(), "*"); @@ -439,19 +440,18 @@ LRESULT CDebugScripts::OnRefreshList(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /* fileNames.push_back(searchPath.GetNameExtension()); } } while (searchPath.FindNext()); - - fileNames.sort([](stdstr a, stdstr b) { - return a.ToLower() < b.ToLower(); - }); + + fileNames.sort([](stdstr a, stdstr b) + { return a.ToLower() < b.ToLower(); }); m_ScriptList.SetRedraw(false); m_ScriptList.DeleteAllItems(); int nItem = 0; - for (const stdstr& fileName : fileNames) + for (const stdstr & fileName : fileNames) { JSInstanceStatus status = m_Debugger->ScriptSystem()->GetStatus(fileName.c_str()); - const wchar_t* statusIcon = L""; + const wchar_t * statusIcon = L""; switch (status) { @@ -482,7 +482,7 @@ LRESULT CDebugScripts::OnRefreshList(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /* return FALSE; } -void CDebugScripts::SendInput(const char* name, const char* code) +void CDebugScripts::SendInput(const char * name, const char * code) { m_Debugger->ScriptSystem()->Input(name, code); } @@ -524,15 +524,15 @@ void CDebugScripts::EditSelected() ShellExecuteA(nullptr, "edit", scriptPath.c_str(), nullptr, m_InstallDir.c_str(), SW_SHOWNORMAL); } -LRESULT CDebugScripts::OnInputSpecialKey(NMHDR* pNMHDR) +LRESULT CDebugScripts::OnInputSpecialKey(NMHDR * pNMHDR) { - NMCISPECIALKEY* pnmsk = (NMCISPECIALKEY*)pNMHDR; + NMCISPECIALKEY * pnmsk = (NMCISPECIALKEY *)pNMHDR; if (pnmsk->vkey == VK_UP) { if (m_InputHistoryIndex > 0) { - wchar_t* code = m_InputHistory[--m_InputHistoryIndex]; + wchar_t * code = m_InputHistory[--m_InputHistoryIndex]; m_ConInputEdit.SetWindowText(code); int selEnd = wcslen(code); m_ConInputEdit.SetSel(selEnd, selEnd); @@ -552,7 +552,7 @@ LRESULT CDebugScripts::OnInputSpecialKey(NMHDR* pNMHDR) if (m_InputHistoryIndex < size) { - wchar_t* code = m_InputHistory[m_InputHistoryIndex]; + wchar_t * code = m_InputHistory[m_InputHistoryIndex]; m_ConInputEdit.SetWindowText(code); int selEnd = wcslen(code); m_ConInputEdit.SetSel(selEnd, selEnd); @@ -574,7 +574,7 @@ LRESULT CDebugScripts::OnInputSpecialKey(NMHDR* pNMHDR) return 0; } - wchar_t* code = new wchar_t[codeLength + 1]; + wchar_t * code = new wchar_t[codeLength + 1]; m_ConInputEdit.GetWindowText(code, codeLength + 1); m_ConInputEdit.SetWindowText(L""); @@ -585,7 +585,7 @@ LRESULT CDebugScripts::OnInputSpecialKey(NMHDR* pNMHDR) { if (wcscmp(code, m_InputHistory[i]) == 0) { - wchar_t* str = m_InputHistory[i]; + wchar_t * str = m_InputHistory[i]; m_InputHistory.erase(m_InputHistory.begin() + i); m_InputHistory.push_back(str); m_InputHistoryIndex = m_InputHistory.size(); @@ -615,7 +615,7 @@ void CDebugScripts::OnTimer(UINT_PTR nIDEvent) scroll.cbSize = sizeof(SCROLLINFO); scroll.fMask = SIF_ALL; m_ConOutputEdit.GetScrollInfo(SB_VERT, &scroll); - + m_ConOutputEdit.SetRedraw(FALSE); m_ConOutputEdit.AppendText(m_ConOutputBuffer.ToUTF16().c_str()); m_ConOutputEdit.SetRedraw(TRUE); diff --git a/Source/Project64/UserInterface/Debugger/Debugger-ScriptsAutorun.cpp b/Source/Project64/UserInterface/Debugger/Debugger-ScriptsAutorun.cpp index d398b6a6e..280741a61 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-ScriptsAutorun.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-ScriptsAutorun.cpp @@ -1,4 +1,5 @@ -#include +#include "stdafx.h" + #include "DebuggerUI.h" #include @@ -17,7 +18,7 @@ CScriptsAutorunDlg::~CScriptsAutorunDlg() { } -INT_PTR CScriptsAutorunDlg::DoModal(CDebuggerUI* debugger, stdstr selectedScriptName) +INT_PTR CScriptsAutorunDlg::DoModal(CDebuggerUI * debugger, stdstr selectedScriptName) { m_Debugger = debugger; m_ScriptSystem = debugger->ScriptSystem(); @@ -25,7 +26,7 @@ INT_PTR CScriptsAutorunDlg::DoModal(CDebuggerUI* debugger, stdstr selectedScript return CDialogImpl::DoModal(); } -LRESULT CScriptsAutorunDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CScriptsAutorunDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { CenterWindow(); @@ -35,13 +36,13 @@ LRESULT CScriptsAutorunDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA m_ScriptListView.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER); m_ScriptListView.AddColumn(L"Script", 0); m_ScriptListView.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER); - + m_AutorunListView.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER); m_AutorunListView.AddColumn(L"Script", 0); m_AutorunListView.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER); m_hQuitScriptDirWatchEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr); - m_hScriptDirWatchThread = CreateThread(nullptr, 0, ScriptDirWatchProc, (void*)this, 0, nullptr); + m_hScriptDirWatchThread = CreateThread(nullptr, 0, ScriptDirWatchProc, (void *)this, 0, nullptr); m_ScriptSystem->LoadAutorunList(); @@ -63,38 +64,37 @@ LRESULT CScriptsAutorunDlg::OnDestroy(void) return 0; } -LRESULT CScriptsAutorunDlg::OnOKCancel(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CScriptsAutorunDlg::OnOKCancel(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { EndDialog(0); return 0; } - -LRESULT CScriptsAutorunDlg::OnAdd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CScriptsAutorunDlg::OnAdd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { m_bScriptListNeedsRefocus = true; AddSelected(); return 0; } -LRESULT CScriptsAutorunDlg::OnRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +LRESULT CScriptsAutorunDlg::OnRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL & /*bHandled*/) { m_bAutorunListNeedsRefocus = true; RemoveSelected(); return 0; } -LRESULT CScriptsAutorunDlg::OnScriptListDblClicked(NMHDR* /*pNMHDR*/) +LRESULT CScriptsAutorunDlg::OnScriptListDblClicked(NMHDR * /*pNMHDR*/) { AddSelected(); return 0; } -LRESULT CScriptsAutorunDlg::OnCtrlSetFocus(NMHDR* pNMHDR) +LRESULT CScriptsAutorunDlg::OnCtrlSetFocus(NMHDR * pNMHDR) { bool bEnableScriptButtons = false; bool bEnableAutorunButtons = false; - + switch (pNMHDR->idFrom) { case IDC_SCRIPT_LIST: @@ -108,20 +108,20 @@ LRESULT CScriptsAutorunDlg::OnCtrlSetFocus(NMHDR* pNMHDR) bEnableScriptButtons = false; break; } - + ::EnableWindow(GetDlgItem(IDC_ADD_BTN), bEnableScriptButtons); ::EnableWindow(GetDlgItem(IDC_REMOVE_BTN), bEnableAutorunButtons); return 0; } -LRESULT CScriptsAutorunDlg::OnAutorunListDblClicked(NMHDR* /*pNMHDR*/) +LRESULT CScriptsAutorunDlg::OnAutorunListDblClicked(NMHDR * /*pNMHDR*/) { RemoveSelected(); return 0; } -LRESULT CScriptsAutorunDlg::OnRefreshScriptList(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CScriptsAutorunDlg::OnRefreshScriptList(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { int nSelectedItem = m_ScriptListView.GetSelectedIndex(); @@ -152,7 +152,7 @@ LRESULT CScriptsAutorunDlg::OnRefreshScriptList(UINT /*uMsg*/, WPARAM /*wParam*/ m_ScriptListView.DeleteAllItems(); int nItem = 0; - for (const stdstr& fileName : fileNames) + for (const stdstr & fileName : fileNames) { m_ScriptListView.AddItem(nItem, 0, fileName.ToUTF16().c_str()); if (fileName == m_InitSelectedScriptName) @@ -183,7 +183,7 @@ LRESULT CScriptsAutorunDlg::OnRefreshScriptList(UINT /*uMsg*/, WPARAM /*wParam*/ return 0; } -LRESULT CScriptsAutorunDlg::OnRefreshAutorunList(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CScriptsAutorunDlg::OnRefreshAutorunList(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { int nSelectedItem = m_AutorunListView.GetSelectedIndex(); @@ -196,7 +196,7 @@ LRESULT CScriptsAutorunDlg::OnRefreshAutorunList(UINT /*uMsg*/, WPARAM /*wParam* m_AutorunListView.DeleteAllItems(); int nItem = 0; - for (const stdstr& fileName : fileNames) + for (const stdstr & fileName : fileNames) { m_AutorunListView.AddItem(nItem, 0, fileName.ToUTF16().c_str()); if (fileName == m_InitSelectedScriptName) @@ -225,9 +225,9 @@ LRESULT CScriptsAutorunDlg::OnRefreshAutorunList(UINT /*uMsg*/, WPARAM /*wParam* return 0; } -DWORD WINAPI CScriptsAutorunDlg::ScriptDirWatchProc(void* ctx) +DWORD WINAPI CScriptsAutorunDlg::ScriptDirWatchProc(void * ctx) { - CScriptsAutorunDlg* _this = (CScriptsAutorunDlg*)ctx; + CScriptsAutorunDlg * _this = (CScriptsAutorunDlg *)ctx; stdstr scriptsDir = _this->m_ScriptSystem->ScriptsDirPath(); diff --git a/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.cpp b/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.cpp index dda703b5e..1f592bd4a 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.cpp @@ -3,9 +3,9 @@ #include "DebuggerUI.h" #include "Symbols.h" -CDebugStackTrace::CDebugStackTrace(CDebuggerUI* debugger) : -CDebugDialog(debugger), -m_EntriesIndex(0) +CDebugStackTrace::CDebugStackTrace(CDebuggerUI * debugger) : + CDebugDialog(debugger), + m_EntriesIndex(0) { } @@ -13,15 +13,15 @@ CDebugStackTrace::~CDebugStackTrace() { } -LRESULT CDebugStackTrace::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugStackTrace::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { DlgResize_Init(); DlgSavePos_Init(DebuggerUI_StackTracePos); - + m_List.Attach(GetDlgItem(IDC_STACKTRACE_LIST)); m_List.AddColumn(L"Caller", 0); m_List.AddColumn(L"Routine", 1); - m_List.AddColumn(L"Name", 2); + m_List.AddColumn(L"Name", 2); m_List.SetColumnWidth(0, 70); m_List.SetColumnWidth(1, 70); @@ -39,7 +39,7 @@ void CDebugStackTrace::OnExitSizeMove(void) SaveWindowPos(true); } -LRESULT CDebugStackTrace::OnActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugStackTrace::OnActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { Refresh(); return FALSE; @@ -51,7 +51,7 @@ LRESULT CDebugStackTrace::OnDestroy(void) return FALSE; } -LRESULT CDebugStackTrace::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CDebugStackTrace::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { switch (wID) { @@ -62,9 +62,9 @@ LRESULT CDebugStackTrace::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndC return FALSE; } -LRESULT CDebugStackTrace::OnListDblClicked(NMHDR* pNMHDR) +LRESULT CDebugStackTrace::OnListDblClicked(NMHDR * pNMHDR) { - NMITEMACTIVATE* pIA = reinterpret_cast(pNMHDR); + NMITEMACTIVATE * pIA = reinterpret_cast(pNMHDR); int nItem = pIA->iItem; uint32_t address = m_List.GetItemData(nItem); @@ -90,7 +90,7 @@ void CDebugStackTrace::Refresh() { uint32_t routineAddress = m_Entries[i].routineAddress; uint32_t callingAddress = m_Entries[i].callingAddress; - + m_List.AddItem(i, 0, stdstr_f("%08X", callingAddress).ToUTF16().c_str()); m_List.AddItem(i, 1, stdstr_f("%08X", routineAddress).ToUTF16().c_str()); @@ -103,7 +103,7 @@ void CDebugStackTrace::Refresh() { m_List.AddItem(i, 2, L""); } - + m_List.SetItemData(i, routineAddress); } diff --git a/Source/Project64/UserInterface/Debugger/Debugger-StackView.cpp b/Source/Project64/UserInterface/Debugger/Debugger-StackView.cpp index da539bb26..dd6386f9e 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-StackView.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-StackView.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "DebuggerUI.h" #include "Symbols.h" @@ -11,7 +12,7 @@ CDebugStackView::~CDebugStackView(void) { } -LRESULT CDebugStackView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugStackView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { DlgResize_Init(false, true); DlgSavePos_Init(DebuggerUI_StackPos); @@ -32,8 +33,8 @@ LRESULT CDebugStackView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM / m_SPStatic.Attach(GetDlgItem(IDC_SP_STATIC)); - LoadWindowPos(); - WindowCreated(); + LoadWindowPos(); + WindowCreated(); return 0; } @@ -50,7 +51,7 @@ LRESULT CDebugStackView::OnDestroy(void) return 0; } -LRESULT CDebugStackView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CDebugStackView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { switch (wID) { diff --git a/Source/Project64/UserInterface/Debugger/Debugger-Symbols.cpp b/Source/Project64/UserInterface/Debugger/Debugger-Symbols.cpp index c306db7d2..18c960bd8 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-Symbols.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-Symbols.cpp @@ -1,27 +1,28 @@ #include "stdafx.h" + #include "DebuggerUI.h" -#include #include +#include #include "Symbols.h" const CSetValueDlg::ComboItem CDebugSymbols::ModalChangeTypeItems[] = { - { "code", SYM_CODE }, - { "data", SYM_DATA }, - { "uint8", SYM_U8 }, - { "int8", SYM_S8 }, - { "uint16", SYM_U16 }, - { "int16", SYM_S16 }, - { "uint32", SYM_U32 }, - { "int32", SYM_S32 }, - { "uint64", SYM_U64 }, - { "int64", SYM_S64 }, - { "float", SYM_FLOAT }, - { "double", SYM_DOUBLE }, - { "v2", SYM_VECTOR2 }, - { "v3", SYM_VECTOR3 }, - { "v4", SYM_VECTOR4 }, + {"code", SYM_CODE}, + {"data", SYM_DATA}, + {"uint8", SYM_U8}, + {"int8", SYM_S8}, + {"uint16", SYM_U16}, + {"int16", SYM_S16}, + {"uint32", SYM_U32}, + {"int32", SYM_S32}, + {"uint64", SYM_U64}, + {"int64", SYM_S64}, + {"float", SYM_FLOAT}, + {"double", SYM_DOUBLE}, + {"v2", SYM_VECTOR2}, + {"v3", SYM_VECTOR3}, + {"v4", SYM_VECTOR4}, { nullptr, 0 } }; @@ -34,7 +35,7 @@ CDebugSymbols::CDebugSymbols(CDebuggerUI * debugger) : memset(m_FilterText, 0, sizeof(m_FilterText)); } -LRESULT CDebugSymbols::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugSymbols::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { DlgResize_Init(false, true); DlgSavePos_Init(DebuggerUI_SymbolsPos); @@ -85,7 +86,7 @@ void CDebugSymbols::OnTimer(UINT_PTR nIDEvent) } } -LRESULT CDebugSymbols::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CDebugSymbols::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { switch (wID) { @@ -96,35 +97,35 @@ LRESULT CDebugSymbols::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl* m_AddSymbolDlg.DoModal(m_Debugger); break; case IDC_REMOVESYMBOL_BTN: + { + int nItem = m_SymbolsListView.GetSelectedIndex(); + int id = -1; + if (m_bFiltering) { - int nItem = m_SymbolsListView.GetSelectedIndex(); - int id = -1; - if (m_bFiltering) - { - id = m_FilteredSymbols[nItem].m_Id; - } - else - { - CSymbol symbol; - m_SymbolTable->GetSymbolByIndex(nItem, &symbol); - id = symbol.m_Id; - } - - if (id != -1) - { - m_SymbolTable->RemoveSymbolById(id); - m_SymbolTable->Save(); - Refresh(); - } + id = m_FilteredSymbols[nItem].m_Id; } - break; + else + { + CSymbol symbol; + m_SymbolTable->GetSymbolByIndex(nItem, &symbol); + id = symbol.m_Id; + } + + if (id != -1) + { + m_SymbolTable->RemoveSymbolById(id); + m_SymbolTable->Save(); + Refresh(); + } + } + break; } return FALSE; } -LRESULT CDebugSymbols::OnListDblClicked(NMHDR* pNMHDR) +LRESULT CDebugSymbols::OnListDblClicked(NMHDR * pNMHDR) { - NMITEMACTIVATE* pIA = reinterpret_cast(pNMHDR); + NMITEMACTIVATE * pIA = reinterpret_cast(pNMHDR); if (pIA->iItem == -1) { @@ -175,8 +176,8 @@ LRESULT CDebugSymbols::OnListDblClicked(NMHDR* pNMHDR) break; case SymbolsListView_Col_Value: char szValue[256]; - const char* x; - const char* y; + const char * x; + const char * y; m_SymbolTable->GetValueString(szValue, &symbol); if (m_SetValueDlg.DoModal("Change value", "New value:", szValue)) { @@ -269,7 +270,7 @@ LRESULT CDebugSymbols::OnListDblClicked(NMHDR* pNMHDR) m_SymbolTable->AddSymbol(symbol.m_Type, symbol.m_Address, symbol.m_Name, m_SetValueDlg.GetEnteredString().c_str()); } break; - } + } m_SymbolTable->Save(); Refresh(); @@ -277,10 +278,10 @@ LRESULT CDebugSymbols::OnListDblClicked(NMHDR* pNMHDR) return 0; } -LRESULT CDebugSymbols::OnListGetDispInfo(NMHDR* pNMHDR) +LRESULT CDebugSymbols::OnListGetDispInfo(NMHDR * pNMHDR) { - NMLVDISPINFO* plvdi = (NMLVDISPINFO*)pNMHDR; - + NMLVDISPINFO * plvdi = (NMLVDISPINFO *)pNMHDR; + int index = plvdi->item.iItem; if (index == -1) @@ -288,7 +289,7 @@ LRESULT CDebugSymbols::OnListGetDispInfo(NMHDR* pNMHDR) return TRUE; } - std::vector& cache = m_bFiltering ? m_FilteredSymbols : m_SymbolCache; + std::vector & cache = m_bFiltering ? m_FilteredSymbols : m_SymbolCache; if (!m_bFiltering) { @@ -319,8 +320,8 @@ LRESULT CDebugSymbols::OnListGetDispInfo(NMHDR* pNMHDR) LRESULT CDebugSymbols::OnListCacheHint(NMHDR * pNMHDR) { - NMLVCACHEHINT* plvch = (NMLVCACHEHINT*)pNMHDR; - + NMLVCACHEHINT * plvch = (NMLVCACHEHINT *)pNMHDR; + if (m_bFiltering) { return 0; @@ -344,7 +345,7 @@ LRESULT CDebugSymbols::OnListCacheHint(NMHDR * pNMHDR) return 0; } -LRESULT CDebugSymbols::OnFilterChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CDebugSymbols::OnFilterChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { if (::GetWindowTextLength(GetDlgItem(IDC_FILTER_EDIT)) == 0) { @@ -352,17 +353,17 @@ LRESULT CDebugSymbols::OnFilterChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND Refresh(); return FALSE; } - + m_bFiltering = true; ::GetWindowText(GetDlgItem(IDC_FILTER_EDIT), m_FilterText, sizeof(m_FilterText) / sizeof(wchar_t)); - + UpdateFilteredSymbols(); - + m_SymbolsListView.SetItemCount(m_FilteredSymbols.size()); return FALSE; } -int CDebugSymbols::ColumnHitTest(POINT& pt) +int CDebugSymbols::ColumnHitTest(POINT & pt) { int nHitCol = -1; RECT listRect; diff --git a/Source/Project64/UserInterface/Debugger/Debugger-TLB.cpp b/Source/Project64/UserInterface/Debugger/Debugger-TLB.cpp index f64e5f80c..eccfccf86 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-TLB.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-TLB.cpp @@ -11,7 +11,7 @@ CDebugTlb::~CDebugTlb() { } -LRESULT CDebugTlb::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugTlb::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { DlgSavePos_Init(DebuggerUI_TLBPos); @@ -79,7 +79,7 @@ void CDebugTlb::OnExitSizeMove(void) SaveWindowPos(0); } -LRESULT CDebugTlb::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/) +LRESULT CDebugTlb::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL & /*bHandled*/) { switch (wID) { @@ -202,7 +202,7 @@ void CDebugTlb::RefreshTLBWindow(void) } } - CTLB::FASTTLB * FastTlb = g_TLB->m_FastTlb; + CTLB::FASTTLB * FastTlb = g_TLB->m_FastTlb; hList = GetDlgItem(IDC_LIST2); for (count = 0; count < 64; count++) { @@ -266,7 +266,7 @@ void CDebugTlb::RefreshTLBWindow(void) if (FastTlb[count].ValidEntry && FastTlb[count].VALID) { swprintf(Output, sizeof(Output), L"%08X:%08X -> %08X:%08X", FastTlb[count].VSTART, FastTlb[count].VEND, - FastTlb[count].PHYSSTART, FastTlb[count].PHYSEND); + FastTlb[count].PHYSSTART, FastTlb[count].PHYSEND); } else { diff --git a/Source/Project64/UserInterface/Debugger/Debugger-ViewMemory.cpp b/Source/Project64/UserInterface/Debugger/Debugger-ViewMemory.cpp index 370220957..f904ab763 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-ViewMemory.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-ViewMemory.cpp @@ -1,32 +1,33 @@ #include "stdafx.h" -#include + #include +#include #include +#include "DMALog.h" #include "DebuggerUI.h" #include "Symbols.h" -#include "DMALog.h" CDebugMemoryView::jump_item_t CDebugMemoryView::JumpItems[] = { - { 0x80000000, 0x00000000, 0x0800000, "RDRAM" }, - { 0xA3F00000, 0x03F00000, 0x0000028, "RDRAM registers" }, - { 0xA4000000, 0x04000000, 0x0001000, "SP DMEM" }, - { 0xA4001000, 0x04001000, 0x0001000, "SP IMEM" }, - { 0xA4040000, 0x04040000, 0x0000020, "SP registers" }, - { 0xA4080000, 0x04080000, 0x0000004, "SP PC register" }, - { 0xA4100000, 0x04100000, 0x0000020, "DP control registers" }, - { 0xA4300000, 0x04300000, 0x0000010, "MI registers" }, - { 0xA4400000, 0x04400000, 0x0000038, "VI registers" }, - { 0xA4500000, 0x04500000, 0x0000018, "AI registers" }, - { 0xA4600000, 0x04600000, 0x0000034, "PI registers" }, - { 0xA4700000, 0x04700000, 0x0000020, "RI registers" }, - { 0xA4800000, 0x04800000, 0x0000010, "SI registers" }, - { 0xA5000500, 0x05000500, 0x000004C, "DD registers" }, - { 0xA8000000, 0x08000000, 0x1000000, "Cartridge save data" }, - { 0xB0000000, 0x10000000, 0xFC00000, "Cartridge ROM" }, - { 0xBFC00000, 0x1FC00000, 0x00007C0, "PIF ROM" }, - { 0xBFC007C0, 0x1FC007C0, 0x0000040, "PIF RAM" }, + {0x80000000, 0x00000000, 0x0800000, "RDRAM"}, + {0xA3F00000, 0x03F00000, 0x0000028, "RDRAM registers"}, + {0xA4000000, 0x04000000, 0x0001000, "SP DMEM"}, + {0xA4001000, 0x04001000, 0x0001000, "SP IMEM"}, + {0xA4040000, 0x04040000, 0x0000020, "SP registers"}, + {0xA4080000, 0x04080000, 0x0000004, "SP PC register"}, + {0xA4100000, 0x04100000, 0x0000020, "DP control registers"}, + {0xA4300000, 0x04300000, 0x0000010, "MI registers"}, + {0xA4400000, 0x04400000, 0x0000038, "VI registers"}, + {0xA4500000, 0x04500000, 0x0000018, "AI registers"}, + {0xA4600000, 0x04600000, 0x0000034, "PI registers"}, + {0xA4700000, 0x04700000, 0x0000020, "RI registers"}, + {0xA4800000, 0x04800000, 0x0000010, "SI registers"}, + {0xA5000500, 0x05000500, 0x000004C, "DD registers"}, + {0xA8000000, 0x08000000, 0x1000000, "Cartridge save data"}, + {0xB0000000, 0x10000000, 0xFC00000, "Cartridge ROM"}, + {0xBFC00000, 0x1FC00000, 0x00007C0, "PIF ROM"}, + {0xBFC007C0, 0x1FC007C0, 0x0000040, "PIF RAM"}, { 0, NULL} }; @@ -62,7 +63,7 @@ void CDebugMemoryView::ShowAddress(uint32_t address, bool bVirtual) SendMessage(WM_SHOWADDRESS, (WPARAM)address, (LPARAM)bVirtual); } -bool CDebugMemoryView::GetByte(uint32_t address, uint8_t* value) +bool CDebugMemoryView::GetByte(uint32_t address, uint8_t * value) { if (m_bVirtualMemory) { @@ -86,11 +87,11 @@ bool CDebugMemoryView::SetByte(uint32_t address, uint8_t value) } } -void CDebugMemoryView::CopyTextToClipboard(const char* text) +void CDebugMemoryView::CopyTextToClipboard(const char * text) { size_t length = strlen(text); HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, length + 1); - strcpy((char*)GlobalLock(hMem), text); + strcpy((char *)GlobalLock(hMem), text); GlobalUnlock(hMem); OpenClipboard(); EmptyClipboard(); @@ -113,7 +114,7 @@ void CDebugMemoryView::CopyBytesToClipboard(uint32_t startAddress, uint32_t endA uint8_t value; GetByte(address, &value); - + if (bIncludeAddresses) { if ((bRowAddresses && offsetFromBase % rowSize == 0) || @@ -157,7 +158,7 @@ void CDebugMemoryView::CopyGameSharkCodeToClipboard(uint32_t startAddress, uint3 str += stdstr_f("%08X %04X\r\n", startAddress, value); startAddress++; } - + for (uint32_t address = startAddress; address < endAddress; address += 2) { uint8_t value0 = 0, value1 = 0; @@ -217,7 +218,6 @@ void CDebugMemoryView::FollowPointer(bool bContextMenuAddress) } } - void CDebugMemoryView::JumpToSelection(void) { uint32_t startAddress, endAddress; @@ -226,14 +226,14 @@ void CDebugMemoryView::JumpToSelection(void) m_MemAddr.SetValue(targetAddress, DisplayMode::ZeroExtend); } -bool CDebugMemoryView::GetSafeEditValue(uint32_t address, uint8_t* value) +bool CDebugMemoryView::GetSafeEditValue(uint32_t address, uint8_t * value) { if (m_SafeEditQueue.size() == 0) { return false; } - for(size_t i = m_SafeEditQueue.size(); i-- > 0;) + for (size_t i = m_SafeEditQueue.size(); i-- > 0;) { edit_t edit = m_SafeEditQueue[i]; if (address >= edit.startAddress && address <= edit.endAddress) @@ -266,7 +266,7 @@ void CDebugMemoryView::SetupJumpMenu(bool bVirtual) for (int i = 0;; i++) { - jump_item_t* item = &JumpItems[i]; + jump_item_t * item = &JumpItems[i]; if (item->caption == nullptr) { @@ -299,7 +299,7 @@ int CDebugMemoryView::GetJumpItemIndex(uint32_t address, bool bVirtual) return -1; } -LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { DlgResize_Init(false, true); DlgSavePos_Init(DebuggerUI_MemoryPos); @@ -348,7 +348,7 @@ LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM SetupJumpMenu(true); m_CmbJump.SetCurSel(0); - + m_TabData.clear(); AddTab(0x80000000, true, 4); @@ -520,7 +520,7 @@ void CDebugMemoryView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar) m_MemAddr.SetValue(address < 0xFFFFFEFF ? address + numVisibleBytes : 0xFFFFFFFF, DisplayMode::ZeroExtend); break; case SB_PAGEUP: - m_MemAddr.SetValue(address >(uint32_t)numVisibleBytes ? address - numVisibleBytes : 0, DisplayMode::ZeroExtend); + m_MemAddr.SetValue(address > (uint32_t)numVisibleBytes ? address - numVisibleBytes : 0, DisplayMode::ZeroExtend); break; case SB_THUMBPOSITION: m_MemAddr.SetValue((DWORD)nPos << 0x10, DisplayMode::ZeroExtend); @@ -534,7 +534,7 @@ void CDebugMemoryView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar) LRESULT CDebugMemoryView::OnHxCtrlKeyPressed(LPNMHDR lpNMHDR) { - NMHXCTRLKEYPRESSED* nmck = reinterpret_cast(lpNMHDR); + NMHXCTRLKEYPRESSED * nmck = reinterpret_cast(lpNMHDR); uint32_t address = m_HexEditCtrl.GetCaretAddress(); if (nmck->nChar >= '1' && nmck->nChar <= '9') @@ -611,7 +611,7 @@ LRESULT CDebugMemoryView::OnHxSetNibble(LPNMHDR lpNMHDR) return FALSE; } - NMHXSETNIBBLE* nmsn = reinterpret_cast(lpNMHDR); + NMHXSETNIBBLE * nmsn = reinterpret_cast(lpNMHDR); uint8_t curValue; bool bValid = GetByte(nmsn->address, &curValue); @@ -631,7 +631,7 @@ LRESULT CDebugMemoryView::OnHxSetNibble(LPNMHDR lpNMHDR) newValue = (curValue & mask) | (nmsn->value << (nmsn->bLoNibble ? 0 : 4)); } - m_SafeEditQueue.push_back({ SE_FILL, nmsn->address, nmsn->address, newValue }); + m_SafeEditQueue.push_back({SE_FILL, nmsn->address, nmsn->address, newValue}); } else { @@ -643,7 +643,7 @@ LRESULT CDebugMemoryView::OnHxSetNibble(LPNMHDR lpNMHDR) LRESULT CDebugMemoryView::OnHxSetByte(LPNMHDR lpNMHDR) { - NMHXSETBYTE* nmsb = reinterpret_cast(lpNMHDR); + NMHXSETBYTE * nmsb = reinterpret_cast(lpNMHDR); if (g_MMU == nullptr) { @@ -652,7 +652,7 @@ LRESULT CDebugMemoryView::OnHxSetByte(LPNMHDR lpNMHDR) if (nmsb->bInsert) { - m_SafeEditQueue.push_back({ SE_FILL, nmsb->address, nmsb->address, nmsb->value }); + m_SafeEditQueue.push_back({SE_FILL, nmsb->address, nmsb->address, nmsb->value}); } else { @@ -663,11 +663,11 @@ LRESULT CDebugMemoryView::OnHxSetByte(LPNMHDR lpNMHDR) LRESULT CDebugMemoryView::OnHxFillRange(LPNMHDR lpNMHDR) { - NMHXFILLRANGE* nmfr = reinterpret_cast(lpNMHDR); + NMHXFILLRANGE * nmfr = reinterpret_cast(lpNMHDR); if (nmfr->bInsert) { - m_SafeEditQueue.push_back({ SE_FILL, nmfr->startAddress, nmfr->endAddress, nmfr->value }); + m_SafeEditQueue.push_back({SE_FILL, nmfr->startAddress, nmfr->endAddress, nmfr->value}); return FALSE; } @@ -705,7 +705,7 @@ LRESULT CDebugMemoryView::OnHxSelectionChanged(LPNMHDR /*lpNMHDR*/) } uint32_t romAddr, offset; - DMALOGENTRY* entry = m_Debugger->DMALog()->GetEntryByRamAddress(startAddress, &romAddr, &offset); + DMALOGENTRY * entry = m_Debugger->DMALog()->GetEntryByRamAddress(startAddress, &romAddr, &offset); m_StatusBar.SetText(MEMSB_DMAINFO, entry != nullptr ? L"Have DMA" : L""); return FALSE; @@ -740,7 +740,7 @@ LRESULT CDebugMemoryView::OnHxRedrawStarted(LPNMHDR /*lpNMHDR*/) LRESULT CDebugMemoryView::OnHxGetByteInfo(LPNMHDR lpNMHDR) { - NMHXGETBYTEINFO *nmgbi = reinterpret_cast(lpNMHDR); + NMHXGETBYTEINFO * nmgbi = reinterpret_cast(lpNMHDR); bool bHaveWriteTarget = false, bHaveReadTarget = false; uint32_t cpuReadWriteAddress = 0; @@ -767,8 +767,8 @@ LRESULT CDebugMemoryView::OnHxGetByteInfo(LPNMHDR lpNMHDR) { uint32_t address = nmgbi->address + i; uint32_t paddress = address; - HXBYTEINFO* oldByte = &nmgbi->oldBytes[i]; - HXBYTEINFO* newByte = &nmgbi->newBytes[i]; + HXBYTEINFO * oldByte = &nmgbi->oldBytes[i]; + HXBYTEINFO * newByte = &nmgbi->newBytes[i]; newByte->bkColor = BKCOLOR_DEFAULT; newByte->color = COLOR_DEFAULT; @@ -885,7 +885,7 @@ LRESULT CDebugMemoryView::OnHxGetByteInfo(LPNMHDR lpNMHDR) LRESULT CDebugMemoryView::OnHxRightClick(LPNMHDR lpNMHDR) { - NMHXRCLICK *nmrc = reinterpret_cast(lpNMHDR); + NMHXRCLICK * nmrc = reinterpret_cast(lpNMHDR); m_ContextMenuAddress = nmrc->address; @@ -958,7 +958,7 @@ LRESULT CDebugMemoryView::OnHxCopy(LPNMHDR /*lpNMHDR*/) LRESULT CDebugMemoryView::OnHxPaste(LPNMHDR lpNMHDR) { - NMHXPASTE *nmp = reinterpret_cast(lpNMHDR); + NMHXPASTE * nmp = reinterpret_cast(lpNMHDR); if (g_MMU == nullptr) { @@ -967,7 +967,7 @@ LRESULT CDebugMemoryView::OnHxPaste(LPNMHDR lpNMHDR) OpenClipboard(); HANDLE hData = GetClipboardData(CF_TEXT); - char* text = (char*)GlobalLock(hData); + char * text = (char *)GlobalLock(hData); int retDataLength = 0; if (nmp->column == HX_COL_HEXDATA) @@ -1005,7 +1005,6 @@ LRESULT CDebugMemoryView::OnHxPaste(LPNMHDR lpNMHDR) return retDataLength; } - LRESULT CDebugMemoryView::OnTabSelChange(LPNMHDR /*lpNMHDR*/) { TabSelChanged(); @@ -1014,16 +1013,16 @@ LRESULT CDebugMemoryView::OnTabSelChange(LPNMHDR /*lpNMHDR*/) void CDebugMemoryView::TabSelChanged(void) { - TCITEM item = { 0 }; + TCITEM item = {0}; item.mask = TCIF_PARAM; - + int nItem = m_TabCtrl.GetCurSel(); - + if (m_TabCtrl.GetItem(nItem, &item)) { tab_info_t tabInfo = m_TabData[nItem]; uint32_t address = tabInfo.address; - + m_MemAddr.SetValue(address, DisplayMode::ZeroExtend); if (m_bVirtualMemory != tabInfo.bVirtual) @@ -1042,13 +1041,13 @@ int CDebugMemoryView::AddTab(uint32_t address, bool bVirtual, int numBytesPerGro { stdstr szAddress; szAddress.Format("%08X", address); - m_TabData.push_back({ address, bVirtual, numBytesPerGroup }); + m_TabData.push_back({address, bVirtual, numBytesPerGroup}); return m_TabCtrl.AddItem(TCIF_TEXT | TCIF_PARAM, szAddress.ToUTF16().c_str(), 0, (LPARAM)address); } int CDebugMemoryView::InsertTab(int nItem, uint32_t address, bool bVirtual, int numBytesPerGroup) { - m_TabData.insert(m_TabData.begin() + nItem + 1, { address, bVirtual, numBytesPerGroup }); + m_TabData.insert(m_TabData.begin() + nItem + 1, {address, bVirtual, numBytesPerGroup}); m_TabCtrl.SetRedraw(FALSE); m_TabCtrl.DeleteAllItems(); for (size_t i = 0; i < m_TabData.size(); i++) @@ -1069,13 +1068,13 @@ void CDebugMemoryView::UpdateCurrentTab(uint32_t address) { std::wstring szAddress = stdstr_f("%08X", address).ToUTF16(); int nItem = m_TabCtrl.GetCurSel(); - + if (nItem == -1) { return; } - TCITEM item = { 0 }; + TCITEM item = {0}; item.mask = TCIF_TEXT; item.pszText = (LPWSTR)szAddress.c_str(); @@ -1102,7 +1101,7 @@ void CDebugMemoryView::OpenNewTab(uint32_t address, bool bVirtual, int numBytesP } } } - + if (bInsert) { int nCurSelItem = m_TabCtrl.GetCurSel(); @@ -1119,7 +1118,7 @@ void CDebugMemoryView::OpenNewTab(uint32_t address, bool bVirtual, int numBytesP void CDebugMemoryView::OpenDuplicateTab(void) { - int nItem = m_TabCtrl.GetCurSel(); + int nItem = m_TabCtrl.GetCurSel(); tab_info_t tabInfo = m_TabData[nItem]; int nItemNew = InsertTab(nItem, tabInfo.address, tabInfo.bVirtual, tabInfo.numBytesPerGroup); m_TabCtrl.SetCurSel(nItemNew); @@ -1130,12 +1129,12 @@ void CDebugMemoryView::CloseTab(int nItem) { int itemCount = m_TabCtrl.GetItemCount(); int nSelItem = m_TabCtrl.GetCurSel(); - + if (itemCount < 2 || nItem == -1) { return; } - + if (nItem == nSelItem) { if (nItem == m_TabCtrl.GetItemCount() - 1) @@ -1151,7 +1150,7 @@ void CDebugMemoryView::CloseTab(int nItem) TabSelChanged(); } - DeleteTab(nItem); + DeleteTab(nItem); } void CDebugMemoryView::CloseCurrentTab(void) @@ -1167,14 +1166,14 @@ LRESULT CDebugMemoryView::OnTabDblClick(LPNMHDR /*lpNMHDR*/) LRESULT CDebugMemoryView::OnTabRClick(LPNMHDR lpNMHDR) { - NMMTRCLICK *nmrc = reinterpret_cast(lpNMHDR); + NMMTRCLICK * nmrc = reinterpret_cast(lpNMHDR); CloseTab(nmrc->nItem); return FALSE; } LRESULT CDebugMemoryView::OnStatusBarClick(LPNMHDR lpNMHDR) { - NMMOUSE *nmm = reinterpret_cast(lpNMHDR); + NMMOUSE * nmm = reinterpret_cast(lpNMHDR); uint32_t startAddress, endAddress; bool bHaveSelection = m_HexEditCtrl.GetSelectionRange(&startAddress, &endAddress); @@ -1182,7 +1181,7 @@ LRESULT CDebugMemoryView::OnStatusBarClick(LPNMHDR lpNMHDR) if (nmm->dwItemSpec == MEMSB_DMAINFO) { uint32_t romAddress, blockOffset; - DMALOGENTRY* entry = m_Debugger->DMALog()->GetEntryByRamAddress(startAddress, &romAddress, &blockOffset); + DMALOGENTRY * entry = m_Debugger->DMALog()->GetEntryByRamAddress(startAddress, &romAddress, &blockOffset); if (entry == nullptr) { @@ -1191,7 +1190,7 @@ LRESULT CDebugMemoryView::OnStatusBarClick(LPNMHDR lpNMHDR) stdstr strDmaTitle = stdstr_f("DMA information for 0x%08X", startAddress); stdstr strDmaInfo = stdstr_f("Block:\nROM 0x%08X -> RAM 0x%08X ( 0x%X bytes )\n\nROM address of byte:\n0x%08X ( 0x%08X + 0x%08X )", - entry->romAddr, entry->ramAddr, entry->length, romAddress, entry->romAddr, blockOffset); + entry->romAddr, entry->ramAddr, entry->length, romAddress, entry->romAddr, blockOffset); MessageBox(strDmaInfo.ToUTF16().c_str(), strDmaTitle.ToUTF16().c_str(), MB_OK); } else if (nmm->dwItemSpec == MEMSB_BLOCK) @@ -1226,7 +1225,7 @@ void CDebugMemoryView::OnJumpComboSelChange(UINT /*uNotifyCode*/, int /*nID*/, C { address = JumpItems[nItem].paddr; } - + m_MemAddr.SetValue(address, DisplayMode::ZeroExtend); m_HexEditCtrl.SetFocus(); } diff --git a/Source/Project64/UserInterface/Debugger/Debugger.cpp b/Source/Project64/UserInterface/Debugger/Debugger.cpp index c4f3f264d..903ec7f48 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "DebuggerUI.h" #include "CPULog.h" @@ -112,7 +113,7 @@ void CDebuggerUI::GamePausedChanged(CDebuggerUI * _this) _this->m_ScriptSystem->InvokeAppCallbacks(JS_HOOK_EMUSTATECHANGE, &env); } -void CDebuggerUI::WaitingForStepChanged(CDebuggerUI* _this) +void CDebuggerUI::WaitingForStepChanged(CDebuggerUI * _this) { if (g_Settings->LoadBool(Debugger_WaitingForStep)) { @@ -360,7 +361,7 @@ void CDebuggerUI::Debug_RefreshScriptsWindow() } } -void CDebuggerUI::Debug_LogScriptsWindow(const char* text) +void CDebuggerUI::Debug_LogScriptsWindow(const char * text) { if (m_Scripts != nullptr) { @@ -462,37 +463,37 @@ void CDebuggerUI::Debug_RefreshCPULogWindow(void) } } -CBreakpoints* CDebuggerUI::Breakpoints() +CBreakpoints * CDebuggerUI::Breakpoints() { return m_Breakpoints; } -CScriptSystem* CDebuggerUI::ScriptSystem() +CScriptSystem * CDebuggerUI::ScriptSystem() { return m_ScriptSystem; } -CDebugScripts* CDebuggerUI::ScriptConsole() +CDebugScripts * CDebuggerUI::ScriptConsole() { return m_Scripts; } -CDMALog* CDebuggerUI::DMALog() +CDMALog * CDebuggerUI::DMALog() { return m_DMALog; } -CCPULog* CDebuggerUI::CPULog() +CCPULog * CDebuggerUI::CPULog() { return m_CPULog; } -CSymbolTable* CDebuggerUI::SymbolTable() +CSymbolTable * CDebuggerUI::SymbolTable() { return m_SymbolTable; } -SyncEvent& CDebuggerUI::StepEvent() +SyncEvent & CDebuggerUI::StepEvent() { return m_StepEvent; } @@ -511,7 +512,7 @@ void CDebuggerUI::HandleCPUException(void) int intr = (g_Reg->CAUSE_REGISTER >> 8) & 0xFF; int fpExc = (g_Reg->m_FPCR[31] >> 12) & 0x3F; int rcpIntr = g_Reg->MI_INTR_REG & 0x2F; - + if ((ExceptionBreakpoints() & (1 << exc))) { if (exc == 15) // Floating-point exception @@ -568,7 +569,7 @@ void CDebuggerUI::HandleCartToRamDMA(void) m_DMALog->AddEntry(dmaRomAddr, dmaRamAddr, dmaLen); Debug_RefreshDMALogWindow(); - + // Break if write breakpoint exists anywhere in target buffer if (m_Breakpoints->WriteBPExistsInChunk(dmaRamAddr, dmaLen)) { @@ -584,7 +585,7 @@ void CDebuggerUI::CPUStepStarted() Debug_RefreshCPULogWindow(); } - if(m_Breakpoints->NumMemLocks() > 0) + if (m_Breakpoints->NumMemLocks() > 0) { COpInfo opInfo(R4300iOp::m_Opcode); bool bStoreOp = opInfo.IsStoreCommand(); @@ -607,20 +608,20 @@ void CDebuggerUI::CPUStepStarted() hookEnv.pc = g_Reg->m_PROGRAM_COUNTER; hookEnv.opInfo = COpInfo(R4300iOp::m_Opcode); - if(m_ScriptSystem->HaveCpuExecCallbacks(hookEnv.pc)) + if (m_ScriptSystem->HaveCpuExecCallbacks(hookEnv.pc)) { - m_ScriptSystem->InvokeAppCallbacks(JS_HOOK_CPU_EXEC, (void*)&hookEnv); + m_ScriptSystem->InvokeAppCallbacks(JS_HOOK_CPU_EXEC, (void *)&hookEnv); } if (hookEnv.opInfo.IsLoadCommand() && m_ScriptSystem->HaveCpuReadCallbacks(hookEnv.opInfo.GetLoadStoreAddress())) { - m_ScriptSystem->InvokeAppCallbacks(JS_HOOK_CPU_READ, (void*)&hookEnv); + m_ScriptSystem->InvokeAppCallbacks(JS_HOOK_CPU_READ, (void *)&hookEnv); } else if (hookEnv.opInfo.IsStoreCommand() && - m_ScriptSystem->HaveCpuWriteCallbacks(hookEnv.opInfo.GetLoadStoreAddress())) + m_ScriptSystem->HaveCpuWriteCallbacks(hookEnv.opInfo.GetLoadStoreAddress())) { - m_ScriptSystem->InvokeAppCallbacks(JS_HOOK_CPU_WRITE, (void*)&hookEnv); + m_ScriptSystem->InvokeAppCallbacks(JS_HOOK_CPU_WRITE, (void *)&hookEnv); } } @@ -691,7 +692,7 @@ void CDebuggerUI::CPUStepEnded() { return; } - + R4300iOpcode Opcode = R4300iOp::m_Opcode; uint32_t op = Opcode.op; uint32_t funct = Opcode.funct; diff --git a/Source/Project64/UserInterface/Debugger/MemoryScanner.cpp b/Source/Project64/UserInterface/Debugger/MemoryScanner.cpp index 01358552f..1404599e5 100644 --- a/Source/Project64/UserInterface/Debugger/MemoryScanner.cpp +++ b/Source/Project64/UserInterface/Debugger/MemoryScanner.cpp @@ -1,36 +1,37 @@ #include "stdafx.h" + #include "MemoryScanner.h" CMixed::TypeNameEntry CMixed::TypeNames[] = { - { "uint8", ValueType_uint8 }, - { "int8", ValueType_int8 }, - { "uint16", ValueType_uint16 }, - { "int16", ValueType_int16 }, - { "uint32", ValueType_uint32 }, - { "int32", ValueType_int32 }, - { "uint64", ValueType_uint64 }, - { "int64", ValueType_int64 }, - { "float", ValueType_float }, - { "double", ValueType_double }, - { "char", ValueType_string }, - { "char", ValueType_unkstring }, - { "char", ValueType_unkstring }, + {"uint8", ValueType_uint8}, + {"int8", ValueType_int8}, + {"uint16", ValueType_uint16}, + {"int16", ValueType_int16}, + {"uint32", ValueType_uint32}, + {"int32", ValueType_int32}, + {"uint64", ValueType_uint64}, + {"int64", ValueType_int64}, + {"float", ValueType_float}, + {"double", ValueType_double}, + {"char", ValueType_string}, + {"char", ValueType_unkstring}, + {"char", ValueType_unkstring}, { nullptr, ValueType_invalid} }; -const char* CMixed::GetTypeName(void) +const char * CMixed::GetTypeName(void) { switch (m_Type) { - case ValueType_uint8: return "uint8"; - case ValueType_int8: return "int8"; + case ValueType_uint8: return "uint8"; + case ValueType_int8: return "int8"; case ValueType_uint16: return "uint16"; - case ValueType_int16: return "int16"; + case ValueType_int16: return "int16"; case ValueType_uint32: return "uint32"; - case ValueType_int32: return "int32"; + case ValueType_int32: return "int32"; case ValueType_uint64: return "uint64"; - case ValueType_int64: return "int64"; - case ValueType_float: return "float"; + case ValueType_int64: return "int64"; + case ValueType_float: return "float"; case ValueType_double: return "double"; case ValueType_string: case ValueType_istring: @@ -41,7 +42,7 @@ const char* CMixed::GetTypeName(void) return nullptr; } -ValueType CMixed::GetTypeFromString(const char* name, int* charArrayLength) +ValueType CMixed::GetTypeFromString(const char * name, int * charArrayLength) { for (int i = 0; TypeNames[i].name != nullptr; i++) { @@ -64,15 +65,15 @@ int CMixed::GetTypeSize(void) { switch (m_Type) { - case ValueType_uint8: return sizeof(uint8_t); - case ValueType_int8: return sizeof(int8_t); + case ValueType_uint8: return sizeof(uint8_t); + case ValueType_int8: return sizeof(int8_t); case ValueType_uint16: return sizeof(uint16_t); - case ValueType_int16: return sizeof(int16_t); + case ValueType_int16: return sizeof(int16_t); case ValueType_uint32: return sizeof(uint32_t); - case ValueType_int32: return sizeof(int32_t); + case ValueType_int32: return sizeof(int32_t); case ValueType_uint64: return sizeof(uint64_t); - case ValueType_int64: return sizeof(int64_t); - case ValueType_float: return sizeof(float); + case ValueType_int64: return sizeof(int64_t); + case ValueType_float: return sizeof(float); case ValueType_double: return sizeof(double); case ValueType_string: case ValueType_istring: @@ -96,7 +97,7 @@ bool CMixed::IsStringType(void) return false; } -int CMixed::ToString(char* buffer, bool bHex, size_t size) +int CMixed::ToString(char * buffer, bool bHex, size_t size) { if (bHex) { @@ -123,15 +124,15 @@ int CMixed::ToString(char* buffer, bool bHex, size_t size) switch (m_Type) { - case ValueType_uint8: return snprintf(buffer, size, "%d", m_Value._uint8); - case ValueType_int8: return snprintf(buffer, size, "%d", m_Value._sint8); + case ValueType_uint8: return snprintf(buffer, size, "%d", m_Value._uint8); + case ValueType_int8: return snprintf(buffer, size, "%d", m_Value._sint8); case ValueType_uint16: return snprintf(buffer, size, "%d", m_Value._uint16); - case ValueType_int16: return snprintf(buffer, size, "%d", m_Value._sint16); + case ValueType_int16: return snprintf(buffer, size, "%d", m_Value._sint16); case ValueType_uint32: return snprintf(buffer, size, "%lu", m_Value._uint32); - case ValueType_int32: return snprintf(buffer, size, "%d", m_Value._sint32); + case ValueType_int32: return snprintf(buffer, size, "%d", m_Value._sint32); case ValueType_uint64: return snprintf(buffer, size, "%llu", m_Value._uint64); - case ValueType_int64: return snprintf(buffer, size, "%lld", m_Value._sint64); - case ValueType_float: return snprintf(buffer, size, "%f", m_Value._float); + case ValueType_int64: return snprintf(buffer, size, "%lld", m_Value._sint64); + case ValueType_float: return snprintf(buffer, size, "%f", m_Value._float); case ValueType_double: return snprintf(buffer, size, "%f", m_Value._double); default: return snprintf(buffer, size, "?"); } @@ -149,7 +150,7 @@ CScanResult::~CScanResult(void) { } -void CScanResult::SetDescription(const char* str) +void CScanResult::SetDescription(const char * str) { m_Description = str; } @@ -159,18 +160,18 @@ void CScanResult::DeleteDescription(void) m_Description.clear(); } -const char* CScanResult::GetDescription(void) +const char * CScanResult::GetDescription(void) { return m_Description.c_str(); } -int CScanResult::GetValueString(char *buffer, size_t size) +int CScanResult::GetValueString(char * buffer, size_t size) { bool bHex = (m_DisplayFormat == DisplayHex); return ToString(buffer, bHex, size); } -bool CScanResult::GetMemoryValue(CMixed* v) +bool CScanResult::GetMemoryValue(CMixed * v) { if (g_MMU == nullptr) { @@ -184,41 +185,41 @@ bool CScanResult::GetMemoryValue(CMixed* v) return false; } - uint8_t* mem = CMemoryScanner::GetMemoryPool(paddr); + uint8_t * mem = CMemoryScanner::GetMemoryPool(paddr); uint64_t raw64 = 0; if (GetTypeSize() == 8) { - raw64 = ((uint64_t)*(uint32_t*)&mem[paddr] << 32) | *(uint32_t*)&mem[paddr + 4]; + raw64 = ((uint64_t) * (uint32_t *)&mem[paddr] << 32) | *(uint32_t *)&mem[paddr + 4]; } switch (m_Type) { - case ValueType_uint8: v->Set(*(uint8_t*) &mem[paddr ^ 3]); break; - case ValueType_int8: v->Set(*(int8_t*) &mem[paddr ^ 3]); break; - case ValueType_uint16: v->Set(*(uint16_t*)&mem[paddr ^ 2]); break; - case ValueType_int16: v->Set(*(int16_t*) &mem[paddr ^ 2]); break; - case ValueType_uint32: v->Set(*(uint32_t*)&mem[paddr]); break; - case ValueType_int32: v->Set(*(int32_t*)&mem[paddr]); break; - case ValueType_uint64: v->Set(*(uint64_t*)&raw64); break; - case ValueType_int64: v->Set(*(int64_t*)&raw64); break; - case ValueType_float: v->Set(*(float*)&mem[paddr]); break; - case ValueType_double: v->Set(*(double*)&raw64); break; + case ValueType_uint8: v->Set(*(uint8_t *)&mem[paddr ^ 3]); break; + case ValueType_int8: v->Set(*(int8_t *)&mem[paddr ^ 3]); break; + case ValueType_uint16: v->Set(*(uint16_t *)&mem[paddr ^ 2]); break; + case ValueType_int16: v->Set(*(int16_t *)&mem[paddr ^ 2]); break; + case ValueType_uint32: v->Set(*(uint32_t *)&mem[paddr]); break; + case ValueType_int32: v->Set(*(int32_t *)&mem[paddr]); break; + case ValueType_uint64: v->Set(*(uint64_t *)&raw64); break; + case ValueType_int64: v->Set(*(int64_t *)&raw64); break; + case ValueType_float: v->Set(*(float *)&mem[paddr]); break; + case ValueType_double: v->Set(*(double *)&raw64); break; default: return false; // (primitives only) } return true; } -int CScanResult::GetMemoryValueString(char* buffer, size_t size, bool bIgnoreHex) +int CScanResult::GetMemoryValueString(char * buffer, size_t size, bool bIgnoreHex) { if (g_MMU == nullptr) { sprintf(buffer, "?"); return 1; } - + bool bHex = (m_DisplayFormat == DisplayHex) && !bIgnoreHex; uint32_t paddr = m_Address & 0x1FFFFFFF; @@ -228,15 +229,15 @@ int CScanResult::GetMemoryValueString(char* buffer, size_t size, bool bIgnoreHex return sprintf(buffer, "?"); } - uint8_t* mem = CMemoryScanner::GetMemoryPool(paddr); + uint8_t * mem = CMemoryScanner::GetMemoryPool(paddr); if (m_Type == ValueType_istring || - m_Type == ValueType_string || + m_Type == ValueType_string || m_Type == ValueType_unkstring) { if (bHex) { - char* out = buffer; + char * out = buffer; for (int i = 0; i < m_StrLength; i++) { @@ -268,7 +269,7 @@ int CScanResult::GetMemoryValueString(char* buffer, size_t size, bool bIgnoreHex return memVal.ToString(buffer, bHex, size); } -int CScanResult::GetAddressString(char *buffer) +int CScanResult::GetAddressString(char * buffer) { return sprintf(buffer, "0x%08X", m_Address); } @@ -286,7 +287,7 @@ uint32_t CScanResult::GetVirtualAddress(void) } } -bool CScanResult::SetMemoryValueFromString(const char* str) +bool CScanResult::SetMemoryValueFromString(const char * str) { if (g_MMU == nullptr) { @@ -303,9 +304,9 @@ bool CScanResult::SetMemoryValueFromString(const char* str) return false; } - uint8_t* mem = CMemoryScanner::GetMemoryPool(m_Address & 0x1FFFFFFF); + uint8_t * mem = CMemoryScanner::GetMemoryPool(m_Address & 0x1FFFFFFF); - char* endptr; + char * endptr; uint64_t intVal = strtoull(str, &endptr, 0); double doubleVal = strtod(str, &endptr); @@ -317,32 +318,32 @@ bool CScanResult::SetMemoryValueFromString(const char* str) break; case ValueType_uint16: case ValueType_int16: - *(uint16_t*)&mem[paddr ^ 2] = intVal & 0xFFFF; + *(uint16_t *)&mem[paddr ^ 2] = intVal & 0xFFFF; break; case ValueType_uint32: case ValueType_int32: - *(uint32_t*)&mem[paddr] = intVal & 0xFFFFFFFF; + *(uint32_t *)&mem[paddr] = intVal & 0xFFFFFFFF; break; case ValueType_uint64: case ValueType_int64: - *(uint64_t*)&mem[paddr] = (intVal << 32) | (intVal >> 32); + *(uint64_t *)&mem[paddr] = (intVal << 32) | (intVal >> 32); break; case ValueType_float: if (bHex) { - *(uint32_t*)&mem[paddr] = intVal & 0xFFFFFFFF; + *(uint32_t *)&mem[paddr] = intVal & 0xFFFFFFFF; break; } - *(float*)&mem[paddr] = (float)doubleVal; + *(float *)&mem[paddr] = (float)doubleVal; break; case ValueType_double: if (bHex) { - *(uint64_t*)&mem[paddr] = (intVal << 32) | (intVal >> 32); + *(uint64_t *)&mem[paddr] = (intVal << 32) | (intVal >> 32); break; } - intVal = *(uint64_t*)&doubleVal; - *(uint64_t*)&mem[paddr] = (intVal << 32) | (intVal >> 32); + intVal = *(uint64_t *)&doubleVal; + *(uint64_t *)&mem[paddr] = (intVal << 32) | (intVal >> 32); break; case ValueType_string: case ValueType_istring: @@ -355,7 +356,7 @@ bool CScanResult::SetMemoryValueFromString(const char* str) return false; } - char* buff = new char[size]; + char * buff = new char[size]; CMemoryScanner::ParseHexString(buff, str); for (int i = 0; i < m_StrLength; i++) @@ -488,15 +489,15 @@ bool CMemoryScanner::PAddrValid(uint32_t physAddr) uint32_t romSize = g_Rom->GetRomSize(); return (AddrCheck(physAddr, 0x00000000, 0x00000000 + ramSize - 1) || - AddrCheck(physAddr, 0x10000000, 0x10000000 + romSize - 1) || - AddrCheck(physAddr, 0x04000000, 0x04001FFF)); + AddrCheck(physAddr, 0x10000000, 0x10000000 + romSize - 1) || + AddrCheck(physAddr, 0x04000000, 0x04001FFF)); } bool CMemoryScanner::PAddrRangeValid(uint32_t physAddrStart, uint32_t physAddrEnd) { return (RangeCheck(physAddrStart, physAddrEnd, 0x00000000, g_MMU->RdramSize()) || - RangeCheck(physAddrStart, physAddrEnd, 0x04000000, 0x04001FFF) || - RangeCheck(physAddrStart, physAddrEnd, 0x10000000, 0x15FFFFFF)); + RangeCheck(physAddrStart, physAddrEnd, 0x04000000, 0x04001FFF) || + RangeCheck(physAddrStart, physAddrEnd, 0x10000000, 0x15FFFFFF)); } void CMemoryScanner::SetAddressType(AddressType addressType) @@ -510,7 +511,7 @@ void CMemoryScanner::Reset(void) m_ValueType = ValueType_uint8; m_SearchType = SearchType_ExactValue; - + m_Results.clear(); } @@ -521,7 +522,7 @@ bool CMemoryScanner::SetAddressRange(uint32_t startAddress, uint32_t endAddress) return false; } - if(m_DidFirstScan) + if (m_DidFirstScan) { return false; } @@ -571,7 +572,7 @@ bool CMemoryScanner::SetAddressRange(uint32_t startAddress, uint32_t endAddress) { return false; // Invalid range } - + m_Memory = GetMemoryPool(startAddress); m_RangeStartAddress = startAddress; @@ -579,7 +580,7 @@ bool CMemoryScanner::SetAddressRange(uint32_t startAddress, uint32_t endAddress) return true; } -uint8_t* CMemoryScanner::GetMemoryPool(uint32_t physAddr) +uint8_t * CMemoryScanner::GetMemoryPool(uint32_t physAddr) { if (!g_MMU || !g_Rom) { @@ -599,17 +600,16 @@ uint8_t* CMemoryScanner::GetMemoryPool(uint32_t physAddr) { return nullptr; } - } bool CMemoryScanner::SetValueType(ValueType type) { - if(m_DidFirstScan) + if (m_DidFirstScan) { return false; } - - switch(type) + + switch (type) { case ValueType_string: case ValueType_istring: @@ -620,7 +620,7 @@ bool CMemoryScanner::SetValueType(ValueType type) m_bDataTypePrimitive = true; break; } - + m_ValueType = type; return true; } @@ -632,12 +632,12 @@ void CMemoryScanner::SetStringValueLength(int length) bool CMemoryScanner::SetSearchType(SearchType searchType) { - if(!m_bDataTypePrimitive) + if (!m_bDataTypePrimitive) { return false; } - - switch(searchType) + + switch (searchType) { case SearchType_UnknownValue: case SearchType_JalTo: @@ -650,13 +650,13 @@ bool CMemoryScanner::SetSearchType(SearchType searchType) case SearchType_UnchangedValue: case SearchType_IncreasedValue: case SearchType_DecreasedValue: - if(!m_DidFirstScan) + if (!m_DidFirstScan) { return false; } break; } - + m_SearchType = searchType; return true; } @@ -671,7 +671,7 @@ size_t CMemoryScanner::GetNumResults(void) return m_Results.size(); } -CScanResult* CMemoryScanner::GetResult(size_t index) +CScanResult * CMemoryScanner::GetResult(size_t index) { if (index >= m_Results.size()) { @@ -679,7 +679,7 @@ CScanResult* CMemoryScanner::GetResult(size_t index) } return &m_Results[index]; -} +} void CMemoryScanner::RemoveResult(size_t index) { @@ -714,7 +714,7 @@ void CMemoryScanner::FirstScanLoopString(DisplayFormat resultDisplayFormat) } result.m_Address = addr | m_VAddrBits; - result.Set((const wchar_t*)nullptr); + result.Set((const wchar_t *)nullptr); m_Results.push_back(result); next_addr:; } @@ -743,7 +743,7 @@ void CMemoryScanner::FirstScanLoopIString(DisplayFormat resultDisplayFormat) } result.m_Address = addr | m_VAddrBits; - result.Set((const wchar_t*)nullptr); + result.Set((const wchar_t *)nullptr); m_Results.push_back(result); next_addr:; } @@ -752,9 +752,9 @@ void CMemoryScanner::FirstScanLoopIString(DisplayFormat resultDisplayFormat) // Scan for text of unknown single-byte encoding void CMemoryScanner::FirstScanLoopUnkString(void) { - const char* str = stdstr().FromUTF16(m_Value._string).c_str(); + const char * str = stdstr().FromUTF16(m_Value._string).c_str(); int length = m_StringValueLength; - + uint32_t startAddr = m_RangeStartAddress; uint32_t endAddr = m_RangeEndAddress - length; @@ -816,7 +816,7 @@ void CMemoryScanner::FirstScanLoopUnkString(void) } result.m_Address = addr | m_VAddrBits; - result.Set((const wchar_t*)nullptr); + result.Set((const wchar_t *)nullptr); m_Results.push_back(result); next_addr:; @@ -826,19 +826,19 @@ void CMemoryScanner::FirstScanLoopUnkString(void) #define _FirstScanLoopPrimitive(T, Compare, resDisplayFormat) FirstScanLoopPrimitive(Compare, resDisplayFormat) #define _FirstScanLoopPrimitive64(T, Compare, resDisplayFormat) FirstScanLoopPrimitive64(Compare, resDisplayFormat) -#define FIRST_SCAN_PRIMITIVES(CompareFunc) \ - switch(m_ValueType) \ - { \ - case ValueType_uint8: _FirstScanLoopPrimitive(uint8_t, CompareFunc, resDisplayFormat); break; \ - case ValueType_int8: _FirstScanLoopPrimitive(int8_t, CompareFunc, resDisplayFormat); break; \ - case ValueType_uint16: _FirstScanLoopPrimitive(uint16_t, CompareFunc, resDisplayFormat); break; \ - case ValueType_int16: _FirstScanLoopPrimitive(int16_t, CompareFunc, resDisplayFormat); break; \ - case ValueType_uint32: _FirstScanLoopPrimitive(uint32_t, CompareFunc, resDisplayFormat); break; \ - case ValueType_int32: _FirstScanLoopPrimitive(int32_t, CompareFunc, resDisplayFormat); break; \ +#define FIRST_SCAN_PRIMITIVES(CompareFunc) \ + switch (m_ValueType) \ + { \ + case ValueType_uint8: _FirstScanLoopPrimitive(uint8_t, CompareFunc, resDisplayFormat); break; \ + case ValueType_int8: _FirstScanLoopPrimitive(int8_t, CompareFunc, resDisplayFormat); break; \ + case ValueType_uint16: _FirstScanLoopPrimitive(uint16_t, CompareFunc, resDisplayFormat); break; \ + case ValueType_int16: _FirstScanLoopPrimitive(int16_t, CompareFunc, resDisplayFormat); break; \ + case ValueType_uint32: _FirstScanLoopPrimitive(uint32_t, CompareFunc, resDisplayFormat); break; \ + case ValueType_int32: _FirstScanLoopPrimitive(int32_t, CompareFunc, resDisplayFormat); break; \ case ValueType_uint64: _FirstScanLoopPrimitive64(uint64_t, CompareFunc, resDisplayFormat); break; \ - case ValueType_int64: _FirstScanLoopPrimitive64(int64_t, CompareFunc, resDisplayFormat); break; \ - case ValueType_float: _FirstScanLoopPrimitive(float, CompareFunc, resDisplayFormat); break; \ - case ValueType_double: _FirstScanLoopPrimitive64(double, CompareFunc, resDisplayFormat); break; \ + case ValueType_int64: _FirstScanLoopPrimitive64(int64_t, CompareFunc, resDisplayFormat); break; \ + case ValueType_float: _FirstScanLoopPrimitive(float, CompareFunc, resDisplayFormat); break; \ + case ValueType_double: _FirstScanLoopPrimitive64(double, CompareFunc, resDisplayFormat); break; \ } bool CMemoryScanner::FirstScan(DisplayFormat resDisplayFormat) @@ -902,35 +902,35 @@ bool CMemoryScanner::FirstScan(DisplayFormat resDisplayFormat) #define _NextScanLoopPrimitiveResults64(T, Compare) NextScanLoopPrimitiveResults64(Compare) // Compare result's current value in memory against m_Value -#define NEXT_SCAN_PRIMITIVES_AGAINST_VALUE(CompareFunc) \ - switch(m_ValueType) \ - { \ - case ValueType_uint8: _NextScanLoopPrimitive(uint8_t, CompareFunc); break; \ - case ValueType_int8: _NextScanLoopPrimitive(int8_t, CompareFunc); break; \ - case ValueType_uint16: _NextScanLoopPrimitive(uint16_t, CompareFunc); break; \ - case ValueType_int16: _NextScanLoopPrimitive(int16_t, CompareFunc); break; \ - case ValueType_uint32: _NextScanLoopPrimitive(uint32_t, CompareFunc); break; \ - case ValueType_int32: _NextScanLoopPrimitive(int32_t, CompareFunc); break; \ +#define NEXT_SCAN_PRIMITIVES_AGAINST_VALUE(CompareFunc) \ + switch (m_ValueType) \ + { \ + case ValueType_uint8: _NextScanLoopPrimitive(uint8_t, CompareFunc); break; \ + case ValueType_int8: _NextScanLoopPrimitive(int8_t, CompareFunc); break; \ + case ValueType_uint16: _NextScanLoopPrimitive(uint16_t, CompareFunc); break; \ + case ValueType_int16: _NextScanLoopPrimitive(int16_t, CompareFunc); break; \ + case ValueType_uint32: _NextScanLoopPrimitive(uint32_t, CompareFunc); break; \ + case ValueType_int32: _NextScanLoopPrimitive(int32_t, CompareFunc); break; \ case ValueType_uint64: _NextScanLoopPrimitive64(uint64_t, CompareFunc); break; \ - case ValueType_int64: _NextScanLoopPrimitive64(int64_t, CompareFunc); break; \ - case ValueType_float: _NextScanLoopPrimitive(float, CompareFunc); break; \ - case ValueType_double: _NextScanLoopPrimitive64(double, CompareFunc); break; \ + case ValueType_int64: _NextScanLoopPrimitive64(int64_t, CompareFunc); break; \ + case ValueType_float: _NextScanLoopPrimitive(float, CompareFunc); break; \ + case ValueType_double: _NextScanLoopPrimitive64(double, CompareFunc); break; \ } // Compare result's current value in memory against result's old value -#define NEXT_SCAN_PRIMITIVES_AGAINST_RESULTS(CompareFunc) \ - switch(m_ValueType) \ - { \ - case ValueType_uint8: _NextScanLoopPrimitiveResults(uint8_t, CompareFunc); break; \ - case ValueType_int8: _NextScanLoopPrimitiveResults(int8_t, CompareFunc); break; \ - case ValueType_uint16: _NextScanLoopPrimitiveResults(uint16_t, CompareFunc); break; \ - case ValueType_int16: _NextScanLoopPrimitiveResults(int16_t, CompareFunc); break; \ - case ValueType_uint32: _NextScanLoopPrimitiveResults(uint32_t, CompareFunc); break; \ - case ValueType_int32: _NextScanLoopPrimitiveResults(int32_t, CompareFunc); break; \ +#define NEXT_SCAN_PRIMITIVES_AGAINST_RESULTS(CompareFunc) \ + switch (m_ValueType) \ + { \ + case ValueType_uint8: _NextScanLoopPrimitiveResults(uint8_t, CompareFunc); break; \ + case ValueType_int8: _NextScanLoopPrimitiveResults(int8_t, CompareFunc); break; \ + case ValueType_uint16: _NextScanLoopPrimitiveResults(uint16_t, CompareFunc); break; \ + case ValueType_int16: _NextScanLoopPrimitiveResults(int16_t, CompareFunc); break; \ + case ValueType_uint32: _NextScanLoopPrimitiveResults(uint32_t, CompareFunc); break; \ + case ValueType_int32: _NextScanLoopPrimitiveResults(int32_t, CompareFunc); break; \ case ValueType_uint64: _NextScanLoopPrimitiveResults64(uint64_t, CompareFunc); break; \ - case ValueType_int64: _NextScanLoopPrimitiveResults64(int64_t, CompareFunc); break; \ - case ValueType_float: _NextScanLoopPrimitiveResults(float, CompareFunc); break; \ - case ValueType_double: _NextScanLoopPrimitiveResults64(double, CompareFunc); break; \ + case ValueType_int64: _NextScanLoopPrimitiveResults64(int64_t, CompareFunc); break; \ + case ValueType_float: _NextScanLoopPrimitiveResults(float, CompareFunc); break; \ + case ValueType_double: _NextScanLoopPrimitiveResults64(double, CompareFunc); break; \ } bool CMemoryScanner::NextScan() @@ -940,8 +940,8 @@ bool CMemoryScanner::NextScan() // NextScan does not support complex data return false; } - - switch(m_SearchType) + + switch (m_SearchType) { case SearchType_ExactValue: NEXT_SCAN_PRIMITIVES_AGAINST_VALUE(CompareEqual); @@ -972,11 +972,10 @@ bool CMemoryScanner::NextScan() NEXT_SCAN_PRIMITIVES_AGAINST_RESULTS(CompareLessThan); break; } - + return true; } - int CMemoryScanner::HexDigitVal(char c) { if (c >= '0' && c <= '9') return (c - '0'); @@ -985,7 +984,7 @@ int CMemoryScanner::HexDigitVal(char c) return 0; } -int CMemoryScanner::ParseHexString(char *dst, const char* src) +int CMemoryScanner::ParseHexString(char * dst, const char * src) { bool bHiNibble = true; uint8_t curByte = 0; diff --git a/Source/Project64/UserInterface/Debugger/MemoryScanner.h b/Source/Project64/UserInterface/Debugger/MemoryScanner.h index 229ea3e8e..0f45d3ead 100644 --- a/Source/Project64/UserInterface/Debugger/MemoryScanner.h +++ b/Source/Project64/UserInterface/Debugger/MemoryScanner.h @@ -1,6 +1,4 @@ #pragma once - -#include #include enum ValueType diff --git a/Source/Project64/UserInterface/Debugger/OpInfo.h b/Source/Project64/UserInterface/Debugger/OpInfo.h index 535781a3b..e835ece70 100644 --- a/Source/Project64/UserInterface/Debugger/OpInfo.h +++ b/Source/Project64/UserInterface/Debugger/OpInfo.h @@ -1,7 +1,5 @@ #pragma once -#include - #include class COpInfo diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/JSIntervalWorker.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/JSIntervalWorker.cpp index 07f6b57e6..359c0d67f 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/JSIntervalWorker.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/JSIntervalWorker.cpp @@ -1,9 +1,10 @@ -#include -#include "JSIntervalWorker.h" +#include "stdafx.h" + #include "../ScriptInstance.h" +#include "JSIntervalWorker.h" #include "ScriptAPI.h" -CJSIntervalWorker::CJSIntervalWorker(CScriptInstance* inst, void* dukObjectHeapPtr, int delayMS, bool bOnce) : +CJSIntervalWorker::CJSIntervalWorker(CScriptInstance * inst, void * dukObjectHeapPtr, int delayMS, bool bOnce) : CScriptWorker(inst, dukObjectHeapPtr), m_DelayMS(delayMS), m_bOnce(bOnce) @@ -25,7 +26,7 @@ void CJSIntervalWorker::WorkerProc() liTime.QuadPart = -m_DelayMS * 10000; SetWaitableTimer(hTimer, &liTime, m_DelayMS, nullptr, nullptr, true); - HANDLE hWaitHandles[] = { hTimer, m_hTimerQuitEvent }; + HANDLE hWaitHandles[] = {hTimer, m_hTimerQuitEvent}; while (true) { diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/JSServerWorker.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/JSServerWorker.cpp index a03516258..4ba6e4de4 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/JSServerWorker.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/JSServerWorker.cpp @@ -1,4 +1,5 @@ -#include +#include "stdafx.h" + #include "JSServerWorker.h" #include "JSSocketWorker.h" @@ -171,7 +172,7 @@ unsigned short CJSServerWorker::GetPort() return m_Address.port; } -const char* CJSServerWorker::GetFamily() +const char * CJSServerWorker::GetFamily() { CGuard guard(m_CS); return m_Address.family; @@ -180,32 +181,32 @@ const char* CJSServerWorker::GetFamily() void CJSServerWorker::JSEmitConnection(SOCKET c) { m_Instance->PostCMethodCall(m_DukObjectHeapPtr, ScriptAPI::js__Emitter_emit, - CbArgs_EmitConnection, (void*)&c, sizeof(c)); + CbArgs_EmitConnection, (void *)&c, sizeof(c)); } void CJSServerWorker::JSEmitClose() { m_Instance->PostCMethodCall(m_DukObjectHeapPtr, ScriptAPI::js__Emitter_emit, - CbArgs_EmitClose); + CbArgs_EmitClose); } void CJSServerWorker::JSEmitListening() { m_Instance->PostCMethodCall(m_DukObjectHeapPtr, ScriptAPI::js__Emitter_emit, - CbArgs_EmitListening); + CbArgs_EmitListening); } -void CJSServerWorker::JSEmitError(const char* errMessage) +void CJSServerWorker::JSEmitError(const char * errMessage) { m_Instance->PostCMethodCall(m_DukObjectHeapPtr, ScriptAPI::js__Emitter_emit, - CbArgs_EmitError, (void*)errMessage, strlen(errMessage) + 1); + CbArgs_EmitError, (void *)errMessage, strlen(errMessage) + 1); } -duk_idx_t CJSServerWorker::CbArgs_EmitConnection(duk_context* ctx, void* _env) +duk_idx_t CJSServerWorker::CbArgs_EmitConnection(duk_context * ctx, void * _env) { duk_push_string(ctx, "connection"); - SOCKET client = *(SOCKET*)_env; + SOCKET client = *(SOCKET *)_env; duk_push_global_object(ctx); duk_get_prop_string(ctx, -1, "Socket"); duk_remove(ctx, -2); @@ -214,7 +215,7 @@ duk_idx_t CJSServerWorker::CbArgs_EmitConnection(duk_context* ctx, void* _env) ScriptAPI::RefObject(ctx, -1); duk_get_prop_string(ctx, -1, HS_socketWorkerPtr); - CJSSocketWorker* socketWorker = (CJSSocketWorker*)duk_get_pointer(ctx, -1); + CJSSocketWorker * socketWorker = (CJSSocketWorker *)duk_get_pointer(ctx, -1); duk_pop(ctx); socketWorker->Init(client); @@ -223,21 +224,21 @@ duk_idx_t CJSServerWorker::CbArgs_EmitConnection(duk_context* ctx, void* _env) return 2; } -duk_idx_t CJSServerWorker::CbArgs_EmitClose(duk_context* ctx, void* /*_env*/) +duk_idx_t CJSServerWorker::CbArgs_EmitClose(duk_context * ctx, void * /*_env*/) { duk_push_string(ctx, "close"); return 1; } -duk_idx_t CJSServerWorker::CbArgs_EmitListening(duk_context* ctx, void* /*_env*/) +duk_idx_t CJSServerWorker::CbArgs_EmitListening(duk_context * ctx, void * /*_env*/) { duk_push_string(ctx, "listening"); return 1; } -duk_idx_t CJSServerWorker::CbArgs_EmitError(duk_context* ctx, void* _env) +duk_idx_t CJSServerWorker::CbArgs_EmitError(duk_context * ctx, void * _env) { - const char* errMessage = (const char*)_env; + const char * errMessage = (const char *)_env; duk_push_string(ctx, "error"); duk_push_error_object(ctx, DUK_ERR_ERROR, errMessage); return 2; diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/JSSocketWorker.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/JSSocketWorker.cpp index fb232ad71..18979ea74 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/JSSocketWorker.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/JSSocketWorker.cpp @@ -1,8 +1,9 @@ -#include +#include "stdafx.h" + #include "JSSocketWorker.h" #include "ScriptAPI.h" -CJSSocketWorker::CJSSocketWorker(CScriptInstance* inst, void* objectHeapPtr, bool bAllowHalfOpen) : +CJSSocketWorker::CJSSocketWorker(CScriptInstance * inst, void * objectHeapPtr, bool bAllowHalfOpen) : CScriptWorker(inst, objectHeapPtr), m_Socket(INVALID_SOCKET), m_bAllowHalfOpen(bAllowHalfOpen), @@ -43,7 +44,7 @@ bool CJSSocketWorker::Init(SOCKET sock) return true; } -bool CJSSocketWorker::Init(const char* host, unsigned short port) +bool CJSSocketWorker::Init(const char * host, unsigned short port) { if (!m_bWinsockOK) { @@ -64,7 +65,7 @@ bool CJSSocketWorker::Init(const char* host, unsigned short port) return true; } -bool CJSSocketWorker::Write(const char* data, size_t length, duk_int_t callbackId, bool bEnd) +bool CJSSocketWorker::Write(const char * data, size_t length, duk_int_t callbackId, bool bEnd) { CGuard guard(m_Queue.cs); @@ -75,7 +76,7 @@ bool CJSSocketWorker::Write(const char* data, size_t length, duk_int_t callbackI return false; } - if(bEnd) + if (bEnd) { m_Queue.bSendClosePending = true; } @@ -150,8 +151,8 @@ void CJSSocketWorker::WorkerProc() int numFds; fd_set readFds, writeFds; - fd_set* pWriteFds = nullptr; - fd_set* pReadFds = nullptr; + fd_set * pWriteFds = nullptr; + fd_set * pReadFds = nullptr; if (!bRecvClosed) { @@ -284,7 +285,7 @@ bool CJSSocketWorker::ProcConnect() void CJSSocketWorker::ProcSendData() { CGuard guard(m_Queue.cs); - BufferedWrite& bufferedWrite = m_Queue.writes.front(); + BufferedWrite & bufferedWrite = m_Queue.writes.front(); int avail = bufferedWrite.data.size() - bufferedWrite.offset; int numBytesSent = send(m_Socket, &bufferedWrite.data[bufferedWrite.offset], avail, 0); @@ -297,7 +298,7 @@ void CJSSocketWorker::ProcSendData() if (bufferedWrite.callbackId != -1) { m_Instance->PostCMethodCall(m_DukObjectHeapPtr, ScriptAPI::js_Socket__invokeWriteCallback, - CbArgs_Write, &bufferedWrite.callbackId, sizeof(bufferedWrite.callbackId)); + CbArgs_Write, &bufferedWrite.callbackId, sizeof(bufferedWrite.callbackId)); } m_Queue.writes.erase(m_Queue.writes.begin()); } @@ -356,21 +357,23 @@ void CJSSocketWorker::UpdateAddresses() WSAPROTOCOL_INFO protocolInfo; int protocolInfoSize = sizeof(protocolInfo); - if (getsockopt(m_Socket, SOL_SOCKET, SO_PROTOCOL_INFO, (char*)&protocolInfo, &protocolInfoSize) != 0) + if (getsockopt(m_Socket, SOL_SOCKET, SO_PROTOCOL_INFO, (char *)&protocolInfo, &protocolInfoSize) != 0) { return; } - int& family = protocolInfo.iAddressFamily; - sockaddr* pLocalAddr = nullptr; - sockaddr* pRemoteAddr = nullptr; + int & family = protocolInfo.iAddressFamily; + sockaddr * pLocalAddr = nullptr; + sockaddr * pRemoteAddr = nullptr; - union { + union + { sockaddr_in ipv4; sockaddr_in6 ipv6; } localAddr; - union { + union + { sockaddr_in ipv4; sockaddr_in6 ipv6; } remoteAddr; @@ -379,14 +382,14 @@ void CJSSocketWorker::UpdateAddresses() if (family == AF_INET) { - pLocalAddr = (sockaddr*)&localAddr.ipv4; - pRemoteAddr = (sockaddr*)&remoteAddr.ipv4; + pLocalAddr = (sockaddr *)&localAddr.ipv4; + pRemoteAddr = (sockaddr *)&remoteAddr.ipv4; addrSize = sizeof(sockaddr_in); } else if (family == AF_INET6) { - pLocalAddr = (sockaddr*)&localAddr.ipv6; - pRemoteAddr = (sockaddr*)&remoteAddr.ipv6; + pLocalAddr = (sockaddr *)&localAddr.ipv6; + pRemoteAddr = (sockaddr *)&remoteAddr.ipv6; addrSize = sizeof(sockaddr_in6); } else @@ -397,14 +400,14 @@ void CJSSocketWorker::UpdateAddresses() getsockname(m_Socket, pLocalAddr, &addrSize); getpeername(m_Socket, pRemoteAddr, &addrSize); - + getnameinfo(pLocalAddr, addrSize, - m_LocalAddress.address, sizeof(m_LocalAddress.address), - 0, 0, NI_NUMERICHOST); + m_LocalAddress.address, sizeof(m_LocalAddress.address), + 0, 0, NI_NUMERICHOST); getnameinfo(pRemoteAddr, addrSize, - m_RemoteAddress.address, sizeof(m_RemoteAddress.address), - 0, 0, NI_NUMERICHOST); + m_RemoteAddress.address, sizeof(m_RemoteAddress.address), + 0, 0, NI_NUMERICHOST); if (family == AF_INET) { @@ -427,10 +430,10 @@ void CJSSocketWorker::UpdateAddresses() void CJSSocketWorker::JSEmitConnect() { m_Instance->PostCMethodCall(m_DukObjectHeapPtr, - ScriptAPI::js__Emitter_emit, CbArgs_EmitConnect); + ScriptAPI::js__Emitter_emit, CbArgs_EmitConnect); } -void CJSSocketWorker::JSEmitData(const char* data, size_t size) +void CJSSocketWorker::JSEmitData(const char * data, size_t size) { JSEmitDataEnv env; env.data = new char[size]; @@ -439,50 +442,50 @@ void CJSSocketWorker::JSEmitData(const char* data, size_t size) memcpy(env.data, data, size); m_Instance->PostCMethodCall(m_DukObjectHeapPtr, - ScriptAPI::js__Emitter_emit, CbArgs_EmitData, (void*)&env, sizeof(env)); + ScriptAPI::js__Emitter_emit, CbArgs_EmitData, (void *)&env, sizeof(env)); } void CJSSocketWorker::JSEmitEnd() { m_Instance->PostCMethodCall(m_DukObjectHeapPtr, - ScriptAPI::js__Emitter_emit, CbArgs_EmitEnd); + ScriptAPI::js__Emitter_emit, CbArgs_EmitEnd); } void CJSSocketWorker::JSEmitClose() { m_Instance->PostCMethodCall(m_DukObjectHeapPtr, - ScriptAPI::js__Emitter_emit, CbArgs_EmitClose); + ScriptAPI::js__Emitter_emit, CbArgs_EmitClose); } void CJSSocketWorker::JSEmitDrain() { m_Instance->PostCMethodCall(m_DukObjectHeapPtr, - ScriptAPI::js__Emitter_emit, CbArgs_EmitDrain); + ScriptAPI::js__Emitter_emit, CbArgs_EmitDrain); } -void CJSSocketWorker::JSEmitLookup(JSSocketAddrInfo& addr) +void CJSSocketWorker::JSEmitLookup(JSSocketAddrInfo & addr) { m_Instance->PostCMethodCall(m_DukObjectHeapPtr, - ScriptAPI::js__Emitter_emit, CbArgs_EmitLookup, (void*)&addr, sizeof(addr)); + ScriptAPI::js__Emitter_emit, CbArgs_EmitLookup, (void *)&addr, sizeof(addr)); } -void CJSSocketWorker::JSEmitError(const char* errMessage) +void CJSSocketWorker::JSEmitError(const char * errMessage) { m_Instance->PostCMethodCall(m_DukObjectHeapPtr, - ScriptAPI::js__Emitter_emit, CbArgs_EmitError, (void*)errMessage, strlen(errMessage) + 1); + ScriptAPI::js__Emitter_emit, CbArgs_EmitError, (void *)errMessage, strlen(errMessage) + 1); } -duk_idx_t CJSSocketWorker::CbArgs_EmitConnect(duk_context* ctx, void* /*_env*/) +duk_idx_t CJSSocketWorker::CbArgs_EmitConnect(duk_context * ctx, void * /*_env*/) { duk_push_string(ctx, "connect"); return 1; } -duk_idx_t CJSSocketWorker::CbArgs_EmitData(duk_context* ctx, void* _env) +duk_idx_t CJSSocketWorker::CbArgs_EmitData(duk_context * ctx, void * _env) { - JSEmitDataEnv* env = (JSEmitDataEnv*)_env; + JSEmitDataEnv * env = (JSEmitDataEnv *)_env; duk_push_string(ctx, "data"); - char* buffer = (char*)duk_push_fixed_buffer(ctx, env->size); + char * buffer = (char *)duk_push_fixed_buffer(ctx, env->size); memcpy(buffer, env->data, env->size); delete[] env->data; @@ -492,27 +495,27 @@ duk_idx_t CJSSocketWorker::CbArgs_EmitData(duk_context* ctx, void* _env) return 2; } -duk_idx_t CJSSocketWorker::CbArgs_EmitEnd(duk_context* ctx, void* /*_env*/) +duk_idx_t CJSSocketWorker::CbArgs_EmitEnd(duk_context * ctx, void * /*_env*/) { duk_push_string(ctx, "end"); return 1; } -duk_idx_t CJSSocketWorker::CbArgs_EmitClose(duk_context* ctx, void* /*_env*/) +duk_idx_t CJSSocketWorker::CbArgs_EmitClose(duk_context * ctx, void * /*_env*/) { duk_push_string(ctx, "close"); return 1; } -duk_idx_t CJSSocketWorker::CbArgs_EmitDrain(duk_context* ctx, void* /*_env*/) +duk_idx_t CJSSocketWorker::CbArgs_EmitDrain(duk_context * ctx, void * /*_env*/) { duk_push_string(ctx, "drain"); return 1; } -duk_idx_t CJSSocketWorker::CbArgs_EmitLookup(duk_context* ctx, void* _env) +duk_idx_t CJSSocketWorker::CbArgs_EmitLookup(duk_context * ctx, void * _env) { - JSSocketAddrInfo* addr = (JSSocketAddrInfo*)_env; + JSSocketAddrInfo * addr = (JSSocketAddrInfo *)_env; duk_push_string(ctx, "lookup"); duk_push_object(ctx); @@ -525,7 +528,7 @@ duk_idx_t CJSSocketWorker::CbArgs_EmitLookup(duk_context* ctx, void* _env) { duk_push_error_object(ctx, DUK_ERR_ERROR, "dns lookup error"); } - + duk_put_prop_string(ctx, -2, "err"); duk_push_string(ctx, addr->address); duk_put_prop_string(ctx, -2, "address"); @@ -536,17 +539,17 @@ duk_idx_t CJSSocketWorker::CbArgs_EmitLookup(duk_context* ctx, void* _env) return 2; } -duk_idx_t CJSSocketWorker::CbArgs_EmitError(duk_context* ctx, void* _env) +duk_idx_t CJSSocketWorker::CbArgs_EmitError(duk_context * ctx, void * _env) { - const char* errMessage = (const char*)_env; + const char * errMessage = (const char *)_env; duk_push_string(ctx, "error"); duk_push_error_object(ctx, DUK_ERR_ERROR, errMessage); return 2; } -duk_idx_t CJSSocketWorker::CbArgs_Write(duk_context* ctx, void* _env) +duk_idx_t CJSSocketWorker::CbArgs_Write(duk_context * ctx, void * _env) { - duk_int_t callbackId = *(duk_int_t*)_env; + duk_int_t callbackId = *(duk_int_t *)_env; duk_push_int(ctx, callbackId); return 1; } @@ -575,7 +578,7 @@ unsigned short CJSSocketWorker::GetRemotePort() return m_RemoteAddress.port; } -const char* CJSSocketWorker::GetFamily() +const char * CJSSocketWorker::GetFamily() { CGuard guard(m_CS); return m_LocalAddress.family; @@ -588,7 +591,7 @@ void CJSSocketWorker::ClearAddress() m_LocalAddress.port = 0; memset(m_LocalAddress.address, 0, sizeof(m_LocalAddress.address)); m_LocalAddress.family = ""; - + m_RemoteAddress.port = 0; memset(m_RemoteAddress.address, 0, sizeof(m_RemoteAddress.address)); m_RemoteAddress.family = ""; diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/N64Image.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/N64Image.cpp index 54c9c46d5..35001551d 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/N64Image.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/N64Image.cpp @@ -1,23 +1,25 @@ -#include +#include "stdafx.h" + #include "N64Image.h" -struct ImgFormatInfo { +struct ImgFormatInfo +{ int bitsPerPixel; int paletteColorCount; }; static const std::map FormatInfo = { - { IMG_I4, { 4, 0 } }, - { IMG_IA4, { 4, 0 } }, - { IMG_I8, { 8, 0 } }, - { IMG_IA8, { 8, 0 } }, - { IMG_IA16, { 16, 0 } }, - { IMG_RGBA16, { 16, 0 } }, - { IMG_RGBA32, { 32, 0 } }, - { IMG_CI4_RGBA16, { 4, 16 } }, - { IMG_CI4_IA16, { 4, 16 } }, - { IMG_CI8_RGBA16, { 8, 256 } }, - { IMG_CI8_IA16, { 8, 256 } }, + {IMG_I4, {4, 0}}, + {IMG_IA4, {4, 0}}, + {IMG_I8, {8, 0}}, + {IMG_IA8, {8, 0}}, + {IMG_IA16, {16, 0}}, + {IMG_RGBA16, {16, 0}}, + {IMG_RGBA32, {32, 0}}, + {IMG_CI4_RGBA16, {4, 16}}, + {IMG_CI4_IA16, {4, 16}}, + {IMG_CI8_RGBA16, {8, 256}}, + {IMG_CI8_IA16, {8, 256}}, }; CN64Image::CN64Image() : @@ -31,8 +33,8 @@ CN64Image::CN64Image() : } int CN64Image::Init(int format, size_t width, size_t height, - void* pixelData, size_t pixelDataSize, - void* paletteData, size_t paletteDataSize) + void * pixelData, size_t pixelDataSize, + void * paletteData, size_t paletteDataSize) { m_Format = format; m_PixelSize = BitsPerPixel(format); @@ -83,7 +85,7 @@ int CN64Image::Init(int format, size_t width, size_t height, return N64IMG_OK; } -int CN64Image::Init(int format, uint8_t* pngData, size_t pngSize) +int CN64Image::Init(int format, uint8_t * pngData, size_t pngSize) { m_Format = format; m_PixelSize = BitsPerPixel(format); @@ -115,44 +117,44 @@ int CN64Image::Init(int format, uint8_t* pngData, size_t pngSize) return N64IMG_OK; } -void CN64Image::ToPNG(std::vector& outPngImage) +void CN64Image::ToPNG(std::vector & outPngImage) { WritePNG(m_BitmapRgba32.data(), m_Width, m_Height, outPngImage); } -uint16_t* CN64Image::PalettePtr(size_t index) +uint16_t * CN64Image::PalettePtr(size_t index) { size_t offset = index * sizeof(uint16_t); if (offset + sizeof(uint16_t) > m_PaletteData.size()) { return nullptr; } - return (uint16_t*)&m_PaletteData[offset]; + return (uint16_t *)&m_PaletteData[offset]; } -void* CN64Image::TexelPtr(size_t index) +void * CN64Image::TexelPtr(size_t index) { size_t offset = (index * m_PixelSize) / 8; if (offset + max(1, (m_PixelSize / 8)) > m_PixelData.size()) { return nullptr; } - return (void*)&m_PixelData[offset]; + return (void *)&m_PixelData[offset]; } -uint32_t* CN64Image::BitmapPtr(size_t index) +uint32_t * CN64Image::BitmapPtr(size_t index) { size_t offset = index * sizeof(uint32_t); if (offset + sizeof(uint32_t) > m_BitmapRgba32.size()) { return nullptr; } - return (uint32_t*)&m_BitmapRgba32[offset]; + return (uint32_t *)&m_BitmapRgba32[offset]; } unsigned int CN64Image::GetTexel(size_t index) { - void* pTexel = TexelPtr(index); + void * pTexel = TexelPtr(index); if (pTexel == nullptr) { @@ -164,18 +166,18 @@ unsigned int CN64Image::GetTexel(size_t index) case 4: if ((index % 2) == 0) { - return (*(uint8_t*)pTexel & 0xF0) >> 4; + return (*(uint8_t *)pTexel & 0xF0) >> 4; } else { - return (*(uint8_t*)pTexel & 0x0F); + return (*(uint8_t *)pTexel & 0x0F); } case 8: - return *(uint8_t*)pTexel; + return *(uint8_t *)pTexel; case 16: - return _byteswap_ushort(*(uint16_t*)pTexel); + return _byteswap_ushort(*(uint16_t *)pTexel); case 32: - return _byteswap_ulong(*(uint32_t*)pTexel); + return _byteswap_ulong(*(uint32_t *)pTexel); } return 0; @@ -203,20 +205,20 @@ void CN64Image::SetTexel(size_t index, unsigned int value) } break; case 8: - *(uint8_t*)&m_PixelData[offset] = (uint8_t)value; + *(uint8_t *)&m_PixelData[offset] = (uint8_t)value; break; case 16: - *(uint16_t*)&m_PixelData[offset] = _byteswap_ushort((uint16_t)value); + *(uint16_t *)&m_PixelData[offset] = _byteswap_ushort((uint16_t)value); break; case 32: - *(uint32_t*)&m_PixelData[offset] = _byteswap_ulong(value); + *(uint32_t *)&m_PixelData[offset] = _byteswap_ulong(value); break; } } -bool CN64Image::GetPaletteColor(size_t index, unsigned int* color) +bool CN64Image::GetPaletteColor(size_t index, unsigned int * color) { - uint16_t* pColor = PalettePtr(index); + uint16_t * pColor = PalettePtr(index); if (pColor == nullptr) { @@ -230,7 +232,7 @@ bool CN64Image::GetPaletteColor(size_t index, unsigned int* color) bool CN64Image::SetPaletteColor(size_t index, unsigned int color) { - uint16_t* pColor = PalettePtr(index); + uint16_t * pColor = PalettePtr(index); if (pColor == nullptr) { @@ -241,9 +243,9 @@ bool CN64Image::SetPaletteColor(size_t index, unsigned int color) return true; } -bool CN64Image::GetBitmapColor(size_t index, uint32_t* color) +bool CN64Image::GetBitmapColor(size_t index, uint32_t * color) { - uint32_t* pColor = BitmapPtr(index); + uint32_t * pColor = BitmapPtr(index); if (pColor == nullptr) { *color = 0; @@ -255,7 +257,7 @@ bool CN64Image::GetBitmapColor(size_t index, uint32_t* color) bool CN64Image::SetBitmapColor(size_t index, unsigned int color) { - uint32_t* pColor = BitmapPtr(index); + uint32_t * pColor = BitmapPtr(index); if (pColor == nullptr) { return false; @@ -350,17 +352,17 @@ int CN64Image::UpdatePixelsAndPaletteFromBitmap() return N64IMG_OK; } -std::vector& CN64Image::PaletteData() +std::vector & CN64Image::PaletteData() { return m_PaletteData; } -std::vector& CN64Image::PixelData() +std::vector & CN64Image::PixelData() { return m_PixelData; } -std::vector& CN64Image::Bitmap() +std::vector & CN64Image::Bitmap() { return m_BitmapRgba32; } @@ -394,8 +396,8 @@ unsigned int CN64Image::ColorFromRgba32(int dstFormat, uint32_t rgba32) uint8_t r = ((rgba32 >> 24) & 0xFF); uint8_t g = ((rgba32 >> 16) & 0xFF); - uint8_t b = ((rgba32 >> 8) & 0xFF); - uint8_t a = ((rgba32 >> 0) & 0xFF); + uint8_t b = ((rgba32 >> 8) & 0xFF); + uint8_t a = ((rgba32 >> 0) & 0xFF); uint8_t i; @@ -404,7 +406,7 @@ unsigned int CN64Image::ColorFromRgba32(int dstFormat, uint32_t rgba32) case IMG_RGBA16: case IMG_CI8_RGBA16: case IMG_CI4_RGBA16: - return ((r / 8) << 11) | ((g / 8) << 6) | ((b / 8) << 1) | (a / 128); + return ((r / 8) << 11) | ((g / 8) << 6) | ((b / 8) << 1) | (a / 128); case IMG_IA16: case IMG_CI8_IA16: case IMG_CI4_IA16: @@ -439,8 +441,8 @@ uint32_t CN64Image::ColorToRgba32(int srcFormat, unsigned int color) case IMG_CI8_RGBA16: case IMG_CI4_RGBA16: r = (((color >> 11) & 0x1F) * 255) / 31; - g = (((color >> 6) & 0x1F) * 255) / 31; - b = (((color >> 1) & 0x1F) * 255) / 31; + g = (((color >> 6) & 0x1F) * 255) / 31; + b = (((color >> 1) & 0x1F) * 255) / 31; a = (color & 1) * 255; break; case IMG_IA16: @@ -467,7 +469,7 @@ uint32_t CN64Image::ColorToRgba32(int srcFormat, unsigned int color) break; } - return (r << 24) | (g << 16) | (b << 8) | a; + return (r << 24) | (g << 16) | (b << 8) | a; } int CN64Image::BitsPerPixel(int format) @@ -497,17 +499,17 @@ bool CN64Image::UsesPalette(int format) return false; } -const char* CN64Image::ResultCodeName(int resultCode) +const char * CN64Image::ResultCodeName(int resultCode) { - static const std::map names = { - { N64IMG_OK, "OK" }, - { N64IMG_DATA_SIZE_INCORRECT, "ERR_DATA_SIZE_INCORRECT" }, - { N64IMG_INVALID_COLOR_INDEX, "ERR_INVALID_COLOR_INDEX" }, - { N64IMG_INCOMPATIBLE_COLOR, "ERR_INCOMPATIBLE_COLOR" }, - { N64IMG_TOO_MANY_COLORS, "ERR_TOO_MANY_COLORS" }, - { N64IMG_PNG_HEADER_MISSING, "ERR_PNG_HEADER_MISSING" }, - { N64IMG_PNG_OUT_OF_MEMORY, "ERR_PNG_OUT_OF_MEMORY" }, - { N64IMG_PNG_EXCEPTION, "ERR_PNG_EXCEPTION" }, + static const std::map names = { + {N64IMG_OK, "OK"}, + {N64IMG_DATA_SIZE_INCORRECT, "ERR_DATA_SIZE_INCORRECT"}, + {N64IMG_INVALID_COLOR_INDEX, "ERR_INVALID_COLOR_INDEX"}, + {N64IMG_INCOMPATIBLE_COLOR, "ERR_INCOMPATIBLE_COLOR"}, + {N64IMG_TOO_MANY_COLORS, "ERR_TOO_MANY_COLORS"}, + {N64IMG_PNG_HEADER_MISSING, "ERR_PNG_HEADER_MISSING"}, + {N64IMG_PNG_OUT_OF_MEMORY, "ERR_PNG_OUT_OF_MEMORY"}, + {N64IMG_PNG_EXCEPTION, "ERR_PNG_EXCEPTION"}, { N64IMG_PNG_PARSER_FAILED, "ERR_PNG_PARSER_FAILED" } }; diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/N64Image.h b/Source/Project64/UserInterface/Debugger/ScriptAPI/N64Image.h index 8d30e598a..4423831b9 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/N64Image.h +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/N64Image.h @@ -1,5 +1,4 @@ #pragma once -#include #include "ScriptAPI.h" enum { diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/N64Image_PNG.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/N64Image_PNG.cpp index c9626ae86..79b9a0b0e 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/N64Image_PNG.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/N64Image_PNG.cpp @@ -1,21 +1,23 @@ -#include -#include <3rdParty/png/png.h> +#include "stdafx.h" + #include "N64Image.h" +#include <3rdParty/png/png.h> -#pragma warning (disable:4611) // disable setjmp/c++ deconstruction warning +#pragma warning(disable : 4611) // disable setjmp/c++ deconstruction warning -struct PNGReadState { - uint8_t* pngData; - size_t pngSize; +struct PNGReadState +{ + uint8_t * pngData; + size_t pngSize; png_size_t offset; }; static void PNGReadCallback(png_structp png_ptr, png_bytep data, png_size_t length); static void PNGWriteCallback(png_structp png_ptr, png_bytep data, png_size_t length); static void PNGFlushCallback(png_structp png_ptr); -static bool ParsePNGRow(png_byte* row, png_size_t rowSize, int bitDepth, int colorType, std::vector& outRGBA32); +static bool ParsePNGRow(png_byte * row, png_size_t rowSize, int bitDepth, int colorType, std::vector & outRGBA32); -int CN64Image::ReadPNG(uint8_t* pngData, size_t pngSize, size_t* outWidth, size_t* outHeight, std::vector& outRGBA32) +int CN64Image::ReadPNG(uint8_t * pngData, size_t pngSize, size_t * outWidth, size_t * outHeight, std::vector & outRGBA32) { if (!png_check_sig(pngData, 8)) { @@ -57,7 +59,7 @@ int CN64Image::ReadPNG(uint8_t* pngData, size_t pngSize, size_t* outWidth, size_ png_uint_32 width, height; int bitDepth, colorType; png_get_IHDR(png_ptr, info_ptr, &width, &height, &bitDepth, - &colorType, nullptr, nullptr, nullptr); + &colorType, nullptr, nullptr, nullptr); png_size_t rowSize = png_get_rowbytes(png_ptr, info_ptr); std::vector rowPointers(height); @@ -86,7 +88,7 @@ int CN64Image::ReadPNG(uint8_t* pngData, size_t pngSize, size_t* outWidth, size_ return N64IMG_OK; } -void CN64Image::WritePNG(uint8_t* rgba32, size_t width, size_t height, std::vector& buffer) +void CN64Image::WritePNG(uint8_t * rgba32, size_t width, size_t height, std::vector & buffer) { png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); @@ -111,8 +113,8 @@ void CN64Image::WritePNG(uint8_t* rgba32, size_t width, size_t height, std::vect } png_set_IHDR(png_ptr, info_ptr, width, height, - 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); png_set_write_fn(png_ptr, &buffer, PNGWriteCallback, PNGFlushCallback); png_write_info(png_ptr, info_ptr); @@ -132,7 +134,7 @@ void CN64Image::WritePNG(uint8_t* rgba32, size_t width, size_t height, std::vect static void PNGReadCallback(png_structp png_ptr, png_bytep data, png_size_t length) { - PNGReadState* state = (PNGReadState*)png_get_io_ptr(png_ptr); + PNGReadState * state = (PNGReadState *)png_get_io_ptr(png_ptr); if (state->offset + length > state->pngSize) { return; @@ -143,7 +145,7 @@ static void PNGReadCallback(png_structp png_ptr, png_bytep data, png_size_t leng static void PNGWriteCallback(png_structp png_ptr, png_bytep data, png_size_t length) { - std::vector* buffer = (std::vector*)png_get_io_ptr(png_ptr); + std::vector * buffer = (std::vector *)png_get_io_ptr(png_ptr); buffer->insert(buffer->end(), &data[0], &data[length]); } @@ -151,7 +153,7 @@ static void PNGFlushCallback(png_structp /*png_ptr*/) { } -static bool ParsePNGRow(png_byte* row, png_size_t rowSize, int bitDepth, int colorType, std::vector& outRGBA32) +static bool ParsePNGRow(png_byte * row, png_size_t rowSize, int bitDepth, int colorType, std::vector & outRGBA32) { if (colorType == PNG_COLOR_TYPE_RGBA) { diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI.cpp index 5195ff321..51270029d 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI.cpp @@ -1,11 +1,12 @@ -#include -#include -#include "ScriptAPI.h" +#include "stdafx.h" + #include "N64Image.h" +#include "ScriptAPI.h" +#include -#pragma warning(disable: 4702) // disable unreachable code warning +#pragma warning(disable : 4702) // disable unreachable code warning -void ScriptAPI::InitEnvironment(duk_context* ctx, CScriptInstance* inst) +void ScriptAPI::InitEnvironment(duk_context * ctx, CScriptInstance * inst) { duk_push_global_object(ctx); duk_push_string(ctx, "global"); @@ -58,29 +59,29 @@ void ScriptAPI::InitEnvironment(duk_context* ctx, CScriptInstance* inst) Define_mem(ctx); Define_pj64(ctx); Define_script(ctx); - + Define_alert(ctx); Define_exec(ctx); Define_interval(ctx); - + Define_AddressRange(ctx); Define_N64Image(ctx); Define_Server(ctx); Define_Socket(ctx); - + Define_Number_prototype_hex(ctx); DefineGlobalConstants(ctx); - if(duk_get_top(ctx) > 0) + if (duk_get_top(ctx) > 0) { inst->System()->ConsoleLog("[SCRIPTSYS]: warning: duktape stack is dirty after API init"); } } -void ScriptAPI::DefineGlobalClass(duk_context* ctx, const char* className, - duk_c_function constructorFunc, - const DukPropListEntry* prototypeProps, - const DukPropListEntry* staticProps) +void ScriptAPI::DefineGlobalClass(duk_context * ctx, const char * className, + duk_c_function constructorFunc, + const DukPropListEntry * prototypeProps, + const DukPropListEntry * staticProps) { duk_push_global_object(ctx); duk_push_string(ctx, className); @@ -112,7 +113,7 @@ void ScriptAPI::DefineGlobalClass(duk_context* ctx, const char* className, duk_pop(ctx); } -void ScriptAPI::DefineGlobalInterface(duk_context* ctx, const char* name, const DukPropListEntry* props) +void ScriptAPI::DefineGlobalInterface(duk_context * ctx, const char * name, const DukPropListEntry * props) { duk_push_global_object(ctx); duk_push_string(ctx, name); @@ -123,7 +124,7 @@ void ScriptAPI::DefineGlobalInterface(duk_context* ctx, const char* name, const duk_pop(ctx); } -void ScriptAPI::DefineGlobalFunction(duk_context* ctx, const char* name, duk_c_function func) +void ScriptAPI::DefineGlobalFunction(duk_context * ctx, const char * name, duk_c_function func) { duk_push_global_object(ctx); duk_push_string(ctx, name); @@ -133,222 +134,222 @@ void ScriptAPI::DefineGlobalFunction(duk_context* ctx, const char* name, duk_c_f duk_pop(ctx); } -void ScriptAPI::DefineGlobalConstants(duk_context* ctx) +void ScriptAPI::DefineGlobalConstants(duk_context * ctx) { const duk_number_list_entry numbers[] = { - { "u8", U8 }, - { "u16", U16 }, - { "u32", U32 }, - { "s8", S8 }, - { "s16", S16 }, - { "s32", S32 }, - { "f32", F32 }, - { "f64", F64 }, + {"u8", U8}, + {"u16", U16}, + {"u32", U32}, + {"s8", S8}, + {"s16", S16}, + {"s32", S32}, + {"f32", F32}, + {"f64", F64}, - { "s64", S64 }, - { "u64", U64 }, + {"s64", S64}, + {"u64", U64}, - { "GPR_R0", GPR_R0 }, - { "GPR_AT", GPR_AT }, - { "GPR_V0", GPR_V0 }, - { "GPR_V1", GPR_V1 }, - { "GPR_A0", GPR_A0 }, - { "GPR_A1", GPR_A1 }, - { "GPR_A2", GPR_A2 }, - { "GPR_A3", GPR_A3 }, - { "GPR_T0", GPR_T0 }, - { "GPR_T1", GPR_T1 }, - { "GPR_T2", GPR_T2 }, - { "GPR_T3", GPR_T3 }, - { "GPR_T4", GPR_T4 }, - { "GPR_T5", GPR_T5 }, - { "GPR_T6", GPR_T6 }, - { "GPR_T7", GPR_T7 }, - { "GPR_S0", GPR_S0 }, - { "GPR_S1", GPR_S1 }, - { "GPR_S2", GPR_S2 }, - { "GPR_S3", GPR_S3 }, - { "GPR_S4", GPR_S4 }, - { "GPR_S5", GPR_S5 }, - { "GPR_S6", GPR_S6 }, - { "GPR_S7", GPR_S7 }, - { "GPR_T8", GPR_T8 }, - { "GPR_T9", GPR_T9 }, - { "GPR_K0", GPR_K0 }, - { "GPR_K1", GPR_K1 }, - { "GPR_GP", GPR_GP }, - { "GPR_SP", GPR_SP }, - { "GPR_FP", GPR_FP }, - { "GPR_RA", GPR_RA }, + {"GPR_R0", GPR_R0}, + {"GPR_AT", GPR_AT}, + {"GPR_V0", GPR_V0}, + {"GPR_V1", GPR_V1}, + {"GPR_A0", GPR_A0}, + {"GPR_A1", GPR_A1}, + {"GPR_A2", GPR_A2}, + {"GPR_A3", GPR_A3}, + {"GPR_T0", GPR_T0}, + {"GPR_T1", GPR_T1}, + {"GPR_T2", GPR_T2}, + {"GPR_T3", GPR_T3}, + {"GPR_T4", GPR_T4}, + {"GPR_T5", GPR_T5}, + {"GPR_T6", GPR_T6}, + {"GPR_T7", GPR_T7}, + {"GPR_S0", GPR_S0}, + {"GPR_S1", GPR_S1}, + {"GPR_S2", GPR_S2}, + {"GPR_S3", GPR_S3}, + {"GPR_S4", GPR_S4}, + {"GPR_S5", GPR_S5}, + {"GPR_S6", GPR_S6}, + {"GPR_S7", GPR_S7}, + {"GPR_T8", GPR_T8}, + {"GPR_T9", GPR_T9}, + {"GPR_K0", GPR_K0}, + {"GPR_K1", GPR_K1}, + {"GPR_GP", GPR_GP}, + {"GPR_SP", GPR_SP}, + {"GPR_FP", GPR_FP}, + {"GPR_RA", GPR_RA}, //{ "GPR_S8", GPR_S8 }, - { "GPR_ANY", 0xFFFFFFFF }, + {"GPR_ANY", 0xFFFFFFFF}, - { "RDRAM_CONFIG_REG", 0xA3F00000 }, - { "RDRAM_DEVICE_TYPE_REG", 0xA3F00000 }, - { "RDRAM_DEVICE_ID_REG", 0xA3F00004 }, - { "RDRAM_DELAY_REG", 0xA3F00008 }, - { "RDRAM_MODE_REG", 0xA3F0000C }, - { "RDRAM_REF_INTERVAL_REG", 0xA3F00010 }, - { "RDRAM_REF_ROW_REG", 0xA3F00014 }, - { "RDRAM_RAS_INTERVAL_REG", 0xA3F00018 }, - { "RDRAM_MIN_INTERVAL_REG", 0xA3F0001C }, - { "RDRAM_ADDR_SELECT_REG", 0xA3F00020 }, - { "RDRAM_DEVICE_MANUF_REG", 0xA3F00024 }, - { "SP_MEM_ADDR_REG", 0xA4040000 }, - { "SP_DRAM_ADDR_REG", 0xA4040004 }, - { "SP_RD_LEN_REG", 0xA4040008 }, - { "SP_WR_LEN_REG", 0xA404000C }, - { "SP_STATUS_REG", 0xA4040010 }, - { "SP_DMA_FULL_REG", 0xA4040014 }, - { "SP_DMA_BUSY_REG", 0xA4040018 }, - { "SP_SEMAPHORE_REG", 0xA404001C }, - { "SP_PC_REG", 0xA4080000 }, - { "SP_IBIST_REG", 0xA4080004 }, - { "DPC_START_REG", 0xA4100000 }, - { "DPC_END_REG", 0xA4100004 }, - { "DPC_CURRENT_REG", 0xA4100008 }, - { "DPC_STATUS_REG", 0xA410000C }, - { "DPC_CLOCK_REG", 0xA4100010 }, - { "DPC_BUFBUSY_REG", 0xA4100014 }, - { "DPC_PIPEBUSY_REG", 0xA4100018 }, - { "DPC_TMEM_REG", 0xA410001C }, - { "DPS_TBIST_REG", 0xA4200000 }, - { "DPS_TEST_MODE_REG", 0xA4200004 }, - { "DPS_BUFTEST_ADDR_REG", 0xA4200008 }, - { "DPS_BUFTEST_DATA_REG", 0xA420000C }, - { "MI_INIT_MODE_REG", 0xA4300000 }, - { "MI_MODE_REG", 0xA4300000 }, - { "MI_VERSION_REG", 0xA4300004 }, - { "MI_NOOP_REG", 0xA4300004 }, - { "MI_INTR_REG", 0xA4300008 }, - { "MI_INTR_MASK_REG", 0xA430000C }, - { "VI_STATUS_REG", 0xA4400000 }, - { "VI_CONTROL_REG", 0xA4400000 }, - { "VI_ORIGIN_REG", 0xA4400004 }, - { "VI_DRAM_ADDR_REG", 0xA4400004 }, - { "VI_WIDTH_REG", 0xA4400008 }, - { "VI_H_WIDTH_REG", 0xA4400008 }, - { "VI_INTR_REG", 0xA440000C }, - { "VI_V_INTR_REG", 0xA440000C }, - { "VI_CURRENT_REG", 0xA4400010 }, - { "VI_V_CURRENT_LINE_REG", 0xA4400010 }, - { "VI_BURST_REG", 0xA4400014 }, - { "VI_TIMING_REG", 0xA4400014 }, - { "VI_V_SYNC_REG", 0xA4400018 }, - { "VI_H_SYNC_REG", 0xA440001C }, - { "VI_LEAP_REG", 0xA4400020 }, - { "VI_H_SYNC_LEAP_REG", 0xA4400020 }, - { "VI_H_START_REG", 0xA4400024 }, - { "VI_H_VIDEO_REG", 0xA4400024 }, - { "VI_V_START_REG", 0xA4400028 }, - { "VI_V_VIDEO_REG", 0xA4400028 }, - { "VI_V_BURST_REG", 0xA440002C }, - { "VI_X_SCALE_REG", 0xA4400030 }, - { "VI_Y_SCALE_REG", 0xA4400034 }, - { "AI_DRAM_ADDR_REG", 0xA4500000 }, - { "AI_LEN_REG", 0xA4500004 }, - { "AI_CONTROL_REG", 0xA4500008 }, - { "AI_STATUS_REG", 0xA450000C }, - { "AI_DACRATE_REG", 0xA4500010 }, - { "AI_BITRATE_REG", 0xA4500014 }, - { "PI_DRAM_ADDR_REG", 0xA4600000 }, - { "PI_CART_ADDR_REG", 0xA4600004 }, - { "PI_RD_LEN_REG", 0xA4600008 }, - { "PI_WR_LEN_REG", 0xA460000C }, - { "PI_STATUS_REG", 0xA4600010 }, - { "PI_BSD_DOM1_LAT_REG", 0xA4600014 }, - { "PI_BSD_DOM1_PWD_REG", 0xA4600018 }, - { "PI_BSD_DOM1_PGS_REG", 0xA460001C }, - { "PI_BSD_DOM1_RLS_REG", 0xA4600020 }, - { "PI_BSD_DOM2_LAT_REG", 0xA4600024 }, - { "PI_BSD_DOM2_PWD_REG", 0xA4600028 }, - { "PI_BSD_DOM2_PGS_REG", 0xA460002C }, - { "PI_BSD_DOM2_RLS_REG", 0xA4600030 }, - { "RI_MODE_REG", 0xA4700000 }, - { "RI_CONFIG_REG", 0xA4700004 }, - { "RI_CURRENT_LOAD_REG", 0xA4700008 }, - { "RI_SELECT_REG", 0xA470000C }, - { "RI_REFRESH_REG", 0xA4700010 }, - { "RI_COUNT_REG", 0xA4700010 }, - { "RI_LATENCY_REG", 0xA4700014 }, - { "RI_RERROR_REG", 0xA4700018 }, - { "RI_WERROR_REG", 0xA470001C }, - { "SI_DRAM_ADDR_REG", 0xA4800000 }, - { "SI_PIF_ADDR_RD64B_REG", 0xA4800004 }, - { "SI_PIF_ADDR_WR64B_REG", 0xA4800010 }, - { "SI_STATUS_REG", 0xA4800018 }, + {"RDRAM_CONFIG_REG", 0xA3F00000}, + {"RDRAM_DEVICE_TYPE_REG", 0xA3F00000}, + {"RDRAM_DEVICE_ID_REG", 0xA3F00004}, + {"RDRAM_DELAY_REG", 0xA3F00008}, + {"RDRAM_MODE_REG", 0xA3F0000C}, + {"RDRAM_REF_INTERVAL_REG", 0xA3F00010}, + {"RDRAM_REF_ROW_REG", 0xA3F00014}, + {"RDRAM_RAS_INTERVAL_REG", 0xA3F00018}, + {"RDRAM_MIN_INTERVAL_REG", 0xA3F0001C}, + {"RDRAM_ADDR_SELECT_REG", 0xA3F00020}, + {"RDRAM_DEVICE_MANUF_REG", 0xA3F00024}, + {"SP_MEM_ADDR_REG", 0xA4040000}, + {"SP_DRAM_ADDR_REG", 0xA4040004}, + {"SP_RD_LEN_REG", 0xA4040008}, + {"SP_WR_LEN_REG", 0xA404000C}, + {"SP_STATUS_REG", 0xA4040010}, + {"SP_DMA_FULL_REG", 0xA4040014}, + {"SP_DMA_BUSY_REG", 0xA4040018}, + {"SP_SEMAPHORE_REG", 0xA404001C}, + {"SP_PC_REG", 0xA4080000}, + {"SP_IBIST_REG", 0xA4080004}, + {"DPC_START_REG", 0xA4100000}, + {"DPC_END_REG", 0xA4100004}, + {"DPC_CURRENT_REG", 0xA4100008}, + {"DPC_STATUS_REG", 0xA410000C}, + {"DPC_CLOCK_REG", 0xA4100010}, + {"DPC_BUFBUSY_REG", 0xA4100014}, + {"DPC_PIPEBUSY_REG", 0xA4100018}, + {"DPC_TMEM_REG", 0xA410001C}, + {"DPS_TBIST_REG", 0xA4200000}, + {"DPS_TEST_MODE_REG", 0xA4200004}, + {"DPS_BUFTEST_ADDR_REG", 0xA4200008}, + {"DPS_BUFTEST_DATA_REG", 0xA420000C}, + {"MI_INIT_MODE_REG", 0xA4300000}, + {"MI_MODE_REG", 0xA4300000}, + {"MI_VERSION_REG", 0xA4300004}, + {"MI_NOOP_REG", 0xA4300004}, + {"MI_INTR_REG", 0xA4300008}, + {"MI_INTR_MASK_REG", 0xA430000C}, + {"VI_STATUS_REG", 0xA4400000}, + {"VI_CONTROL_REG", 0xA4400000}, + {"VI_ORIGIN_REG", 0xA4400004}, + {"VI_DRAM_ADDR_REG", 0xA4400004}, + {"VI_WIDTH_REG", 0xA4400008}, + {"VI_H_WIDTH_REG", 0xA4400008}, + {"VI_INTR_REG", 0xA440000C}, + {"VI_V_INTR_REG", 0xA440000C}, + {"VI_CURRENT_REG", 0xA4400010}, + {"VI_V_CURRENT_LINE_REG", 0xA4400010}, + {"VI_BURST_REG", 0xA4400014}, + {"VI_TIMING_REG", 0xA4400014}, + {"VI_V_SYNC_REG", 0xA4400018}, + {"VI_H_SYNC_REG", 0xA440001C}, + {"VI_LEAP_REG", 0xA4400020}, + {"VI_H_SYNC_LEAP_REG", 0xA4400020}, + {"VI_H_START_REG", 0xA4400024}, + {"VI_H_VIDEO_REG", 0xA4400024}, + {"VI_V_START_REG", 0xA4400028}, + {"VI_V_VIDEO_REG", 0xA4400028}, + {"VI_V_BURST_REG", 0xA440002C}, + {"VI_X_SCALE_REG", 0xA4400030}, + {"VI_Y_SCALE_REG", 0xA4400034}, + {"AI_DRAM_ADDR_REG", 0xA4500000}, + {"AI_LEN_REG", 0xA4500004}, + {"AI_CONTROL_REG", 0xA4500008}, + {"AI_STATUS_REG", 0xA450000C}, + {"AI_DACRATE_REG", 0xA4500010}, + {"AI_BITRATE_REG", 0xA4500014}, + {"PI_DRAM_ADDR_REG", 0xA4600000}, + {"PI_CART_ADDR_REG", 0xA4600004}, + {"PI_RD_LEN_REG", 0xA4600008}, + {"PI_WR_LEN_REG", 0xA460000C}, + {"PI_STATUS_REG", 0xA4600010}, + {"PI_BSD_DOM1_LAT_REG", 0xA4600014}, + {"PI_BSD_DOM1_PWD_REG", 0xA4600018}, + {"PI_BSD_DOM1_PGS_REG", 0xA460001C}, + {"PI_BSD_DOM1_RLS_REG", 0xA4600020}, + {"PI_BSD_DOM2_LAT_REG", 0xA4600024}, + {"PI_BSD_DOM2_PWD_REG", 0xA4600028}, + {"PI_BSD_DOM2_PGS_REG", 0xA460002C}, + {"PI_BSD_DOM2_RLS_REG", 0xA4600030}, + {"RI_MODE_REG", 0xA4700000}, + {"RI_CONFIG_REG", 0xA4700004}, + {"RI_CURRENT_LOAD_REG", 0xA4700008}, + {"RI_SELECT_REG", 0xA470000C}, + {"RI_REFRESH_REG", 0xA4700010}, + {"RI_COUNT_REG", 0xA4700010}, + {"RI_LATENCY_REG", 0xA4700014}, + {"RI_RERROR_REG", 0xA4700018}, + {"RI_WERROR_REG", 0xA470001C}, + {"SI_DRAM_ADDR_REG", 0xA4800000}, + {"SI_PIF_ADDR_RD64B_REG", 0xA4800004}, + {"SI_PIF_ADDR_WR64B_REG", 0xA4800010}, + {"SI_STATUS_REG", 0xA4800018}, - { "PIF_ROM_START", 0xBFC00000 }, - { "PIF_RAM_START", 0xBFC007C0 }, + {"PIF_ROM_START", 0xBFC00000}, + {"PIF_RAM_START", 0xBFC007C0}, - { "SP_DMEM_START", 0xA4000000 }, - { "SP_IMEM_START", 0xA4001000 }, + {"SP_DMEM_START", 0xA4000000}, + {"SP_IMEM_START", 0xA4001000}, - { "KUBASE", 0x00000000 }, - { "K0BASE", 0x80000000 }, - { "K1BASE", 0xA0000000 }, - { "K2BASE", 0xC0000000 }, + {"KUBASE", 0x00000000}, + {"K0BASE", 0x80000000}, + {"K1BASE", 0xA0000000}, + {"K2BASE", 0xC0000000}, - { "UT_VEC", 0x80000000 }, - { "R_VEC", 0xBFC00000 }, - { "XUT_VEC", 0x80000080 }, - { "ECC_VEC", 0x80000100 }, - { "E_VEC", 0x80000180 }, - - { "M_GFXTASK", 1 }, - { "M_AUDTASK", 2 }, - { "OS_READ", 0 }, - { "OS_WRITE", 1 }, - - { "COLOR_BLACK", 0x000000FF }, - { "COLOR_WHITE", 0xFFFFFFFF }, - { "COLOR_GRAY", 0x808080FF }, - { "COLOR_RED", 0xFF0000FF }, - { "COLOR_GREEN", 0x00FF00FF }, - { "COLOR_BLUE", 0x0000FFFF }, - { "COLOR_YELLOW", 0xFFFF00FF }, - { "COLOR_CYAN", 0x00FFFFFF }, - { "COLOR_MAGENTA", 0xFF00FFFF }, + {"UT_VEC", 0x80000000}, + {"R_VEC", 0xBFC00000}, + {"XUT_VEC", 0x80000080}, + {"ECC_VEC", 0x80000100}, + {"E_VEC", 0x80000180}, - { "EMU_STARTED", JS_EMU_STARTED }, - { "EMU_STOPPED", JS_EMU_STOPPED }, - { "EMU_PAUSED", JS_EMU_PAUSED }, - { "EMU_RESUMED", JS_EMU_RESUMED }, - { "EMU_RESETTING", JS_EMU_RESETTING }, - { "EMU_RESET", JS_EMU_RESET }, - { "EMU_LOADED_ROM", JS_EMU_LOADED_ROM }, - { "EMU_LOADED_STATE", JS_EMU_LOADED_STATE }, - { "EMU_DEBUG_PAUSED", JS_EMU_DEBUG_PAUSED }, - { "EMU_DEBUG_RESUMED", JS_EMU_DEBUG_RESUMED }, + {"M_GFXTASK", 1}, + {"M_AUDTASK", 2}, + {"OS_READ", 0}, + {"OS_WRITE", 1}, - { "IMG_I4", IMG_I4 }, - { "IMG_I8", IMG_I8 }, - { "IMG_IA4", IMG_IA4 }, - { "IMG_IA8", IMG_IA8 }, - { "IMG_IA16", IMG_IA16 }, - { "IMG_RGBA16", IMG_RGBA16 }, - { "IMG_RGBA32", IMG_RGBA32 }, - { "IMG_CI8_RGBA16", IMG_CI8_RGBA16 }, - { "IMG_CI4_RGBA16", IMG_CI4_RGBA16 }, - { "IMG_CI8_IA16", IMG_CI8_IA16 }, - { "IMG_CI4_IA16", IMG_CI4_IA16 }, + {"COLOR_BLACK", 0x000000FF}, + {"COLOR_WHITE", 0xFFFFFFFF}, + {"COLOR_GRAY", 0x808080FF}, + {"COLOR_RED", 0xFF0000FF}, + {"COLOR_GREEN", 0x00FF00FF}, + {"COLOR_BLUE", 0x0000FFFF}, + {"COLOR_YELLOW", 0xFFFF00FF}, + {"COLOR_CYAN", 0x00FFFFFF}, + {"COLOR_MAGENTA", 0xFF00FFFF}, - { "G_IM_FMT_RGBA", G_IM_FMT_RGBA }, - { "G_IM_FMT_YUV", G_IM_FMT_YUV }, - { "G_IM_FMT_CI", G_IM_FMT_CI }, - { "G_IM_FMT_IA", G_IM_FMT_IA }, - { "G_IM_FMT_I", G_IM_FMT_I }, + {"EMU_STARTED", JS_EMU_STARTED}, + {"EMU_STOPPED", JS_EMU_STOPPED}, + {"EMU_PAUSED", JS_EMU_PAUSED}, + {"EMU_RESUMED", JS_EMU_RESUMED}, + {"EMU_RESETTING", JS_EMU_RESETTING}, + {"EMU_RESET", JS_EMU_RESET}, + {"EMU_LOADED_ROM", JS_EMU_LOADED_ROM}, + {"EMU_LOADED_STATE", JS_EMU_LOADED_STATE}, + {"EMU_DEBUG_PAUSED", JS_EMU_DEBUG_PAUSED}, + {"EMU_DEBUG_RESUMED", JS_EMU_DEBUG_RESUMED}, - { "G_IM_SIZ_4b", G_IM_SIZ_4b }, - { "G_IM_SIZ_8b", G_IM_SIZ_8b }, - { "G_IM_SIZ_16b", G_IM_SIZ_16b }, - { "G_IM_SIZ_32b", G_IM_SIZ_32b }, + {"IMG_I4", IMG_I4}, + {"IMG_I8", IMG_I8}, + {"IMG_IA4", IMG_IA4}, + {"IMG_IA8", IMG_IA8}, + {"IMG_IA16", IMG_IA16}, + {"IMG_RGBA16", IMG_RGBA16}, + {"IMG_RGBA32", IMG_RGBA32}, + {"IMG_CI8_RGBA16", IMG_CI8_RGBA16}, + {"IMG_CI4_RGBA16", IMG_CI4_RGBA16}, + {"IMG_CI8_IA16", IMG_CI8_IA16}, + {"IMG_CI4_IA16", IMG_CI4_IA16}, - { "G_TT_NONE", G_TT_NONE }, - { "G_TT_RGBA16", G_TT_RGBA16 }, - { "G_TT_IA16", G_TT_IA16 }, + {"G_IM_FMT_RGBA", G_IM_FMT_RGBA}, + {"G_IM_FMT_YUV", G_IM_FMT_YUV}, + {"G_IM_FMT_CI", G_IM_FMT_CI}, + {"G_IM_FMT_IA", G_IM_FMT_IA}, + {"G_IM_FMT_I", G_IM_FMT_I}, - { nullptr, 0 }, + {"G_IM_SIZ_4b", G_IM_SIZ_4b}, + {"G_IM_SIZ_8b", G_IM_SIZ_8b}, + {"G_IM_SIZ_16b", G_IM_SIZ_16b}, + {"G_IM_SIZ_32b", G_IM_SIZ_32b}, + + {"G_TT_NONE", G_TT_NONE}, + {"G_TT_RGBA16", G_TT_RGBA16}, + {"G_TT_IA16", G_TT_IA16}, + + {nullptr, 0}, }; duk_push_global_object(ctx); @@ -356,28 +357,28 @@ void ScriptAPI::DefineGlobalConstants(duk_context* ctx) duk_pop(ctx); } -CScriptInstance* ScriptAPI::GetInstance(duk_context* ctx) +CScriptInstance * ScriptAPI::GetInstance(duk_context * ctx) { duk_get_global_string(ctx, HS_gInstancePtr); - CScriptInstance* instance = (CScriptInstance*)duk_get_pointer(ctx, -1); + CScriptInstance * instance = (CScriptInstance *)duk_get_pointer(ctx, -1); duk_pop(ctx); return instance; } -JSAppCallbackID ScriptAPI::AddAppCallback(duk_context* ctx, duk_idx_t callbackIdx, JSAppHookID hookId, - JSDukArgSetupFunc argSetupFunc, JSAppCallbackCondFunc conditionFunc, JSAppCallbackCleanupFunc cleanupFunc) +JSAppCallbackID ScriptAPI::AddAppCallback(duk_context * ctx, duk_idx_t callbackIdx, JSAppHookID hookId, + JSDukArgSetupFunc argSetupFunc, JSAppCallbackCondFunc conditionFunc, JSAppCallbackCleanupFunc cleanupFunc) { - void* dukFuncHeapPtr = duk_get_heapptr(ctx, callbackIdx); + void * dukFuncHeapPtr = duk_get_heapptr(ctx, callbackIdx); JSAppCallback cb(GetInstance(ctx), dukFuncHeapPtr, conditionFunc, argSetupFunc, cleanupFunc); return AddAppCallback(ctx, hookId, cb); } -JSAppCallbackID ScriptAPI::AddAppCallback(duk_context* ctx, JSAppHookID hookId, JSAppCallback& callback) +JSAppCallbackID ScriptAPI::AddAppCallback(duk_context * ctx, JSAppHookID hookId, JSAppCallback & callback) { - CScriptInstance* inst = GetInstance(ctx); + CScriptInstance * inst = GetInstance(ctx); JSAppCallbackID callbackId = inst->System()->RawAddAppCallback(hookId, callback); - if(callbackId == JS_INVALID_CALLBACK) + if (callbackId == JS_INVALID_CALLBACK) { inst->System()->ConsoleLog("[SCRIPTSYS]: error: callback was not added"); return JS_INVALID_CALLBACK; @@ -403,24 +404,24 @@ JSAppCallbackID ScriptAPI::AddAppCallback(duk_context* ctx, JSAppHookID hookId, return callbackId; } -bool ScriptAPI::RemoveAppCallback(duk_context* ctx, JSAppCallbackID callbackId) +bool ScriptAPI::RemoveAppCallback(duk_context * ctx, JSAppCallbackID callbackId) { duk_get_global_string(ctx, HS_gAppCallbacks); duk_bool_t bExists = duk_has_prop_index(ctx, -1, callbackId); - if(bExists) + if (bExists) { // will invoke CallbackFinalizer - duk_del_prop_index(ctx, -1, callbackId); + duk_del_prop_index(ctx, -1, callbackId); } duk_pop(ctx); return bExists != 0; } -duk_ret_t ScriptAPI::js__AppCallbackFinalizer(duk_context* ctx) +duk_ret_t ScriptAPI::js__AppCallbackFinalizer(duk_context * ctx) { - CScriptInstance* inst = ScriptAPI::GetInstance(ctx); + CScriptInstance * inst = ScriptAPI::GetInstance(ctx); duk_get_prop_string(ctx, 0, "hookId"); duk_get_prop_string(ctx, 0, "callbackId"); @@ -434,10 +435,10 @@ duk_ret_t ScriptAPI::js__AppCallbackFinalizer(duk_context* ctx) return 0; } -void ScriptAPI::RefObject(duk_context* ctx, duk_idx_t idx) +void ScriptAPI::RefObject(duk_context * ctx, duk_idx_t idx) { idx = duk_normalize_index(ctx, idx); - CScriptInstance* inst = GetInstance(ctx); + CScriptInstance * inst = GetInstance(ctx); if (duk_has_prop_string(ctx, idx, HS_objectRefId)) { @@ -458,16 +459,16 @@ void ScriptAPI::RefObject(duk_context* ctx, duk_idx_t idx) duk_get_prop_string(ctx, -1, HS_gObjectRefs); duk_dup(ctx, idx); duk_put_prop_index(ctx, -2, curObjectId); - + duk_pop_n(ctx, 2); inst->IncRefCount(); } -void ScriptAPI::UnrefObject(duk_context* ctx, duk_idx_t idx) +void ScriptAPI::UnrefObject(duk_context * ctx, duk_idx_t idx) { idx = duk_normalize_index(ctx, idx); - CScriptInstance* inst = GetInstance(ctx); + CScriptInstance * inst = GetInstance(ctx); if (!duk_has_prop_string(ctx, idx, HS_objectRefId)) { @@ -481,21 +482,21 @@ void ScriptAPI::UnrefObject(duk_context* ctx, duk_idx_t idx) duk_push_global_object(ctx); duk_get_prop_string(ctx, -1, HS_gObjectRefs); - duk_del_prop_index(ctx, -1, objectId); + duk_del_prop_index(ctx, -1, objectId); duk_pop_n(ctx, 2); inst->DecRefCount(); } // PostCMethodCall variant -duk_ret_t ScriptAPI::js__UnrefObject(duk_context* ctx) +duk_ret_t ScriptAPI::js__UnrefObject(duk_context * ctx) { duk_push_this(ctx); UnrefObject(ctx, -1); return 0; } -void ScriptAPI::InitEmitter(duk_context* ctx, duk_idx_t obj_idx, const std::vector& eventNames) +void ScriptAPI::InitEmitter(duk_context * ctx, duk_idx_t obj_idx, const std::vector & eventNames) { obj_idx = duk_normalize_index(ctx, obj_idx); @@ -514,9 +515,9 @@ void ScriptAPI::InitEmitter(duk_context* ctx, duk_idx_t obj_idx, const std::vect duk_put_prop_string(ctx, obj_idx, HS_emitterNextListenerId); } -duk_ret_t ScriptAPI::js__Emitter_emit(duk_context* ctx) +duk_ret_t ScriptAPI::js__Emitter_emit(duk_context * ctx) { - const char* eventName = duk_get_string(ctx, 0); + const char * eventName = duk_get_string(ctx, 0); duk_idx_t numListenerArgs = duk_get_top(ctx) - 1; duk_push_this(ctx); @@ -533,7 +534,7 @@ duk_ret_t ScriptAPI::js__Emitter_emit(duk_context* ctx) int count = 0; - while (duk_next(ctx, -1, (duk_bool_t)true)) + while (duk_next(ctx, -1, (duk_bool_t) true)) { duk_push_this(ctx); for (duk_idx_t nArg = 0; nArg < numListenerArgs; nArg++) @@ -542,7 +543,7 @@ duk_ret_t ScriptAPI::js__Emitter_emit(duk_context* ctx) } // [ listenerFunc this args... ] -> [ retval ] - if (duk_pcall_method(ctx, numListenerArgs) != 0) + if (duk_pcall_method(ctx, numListenerArgs) != 0) { duk_throw(ctx); } @@ -561,11 +562,11 @@ duk_ret_t ScriptAPI::js__Emitter_emit(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js__Emitter_on(duk_context* ctx) +duk_ret_t ScriptAPI::js__Emitter_on(duk_context * ctx) { - CheckArgs(ctx, { Arg_String, Arg_Function }); + CheckArgs(ctx, {Arg_String, Arg_Function}); - const char* eventName = duk_get_string(ctx, 0); + const char * eventName = duk_get_string(ctx, 0); duk_push_this(ctx); duk_get_prop_string(ctx, -1, HS_emitterListeners); @@ -591,11 +592,11 @@ duk_ret_t ScriptAPI::js__Emitter_on(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js__Emitter_off(duk_context* ctx) +duk_ret_t ScriptAPI::js__Emitter_off(duk_context * ctx) { - CheckArgs(ctx, { Arg_String, Arg_Function }); + CheckArgs(ctx, {Arg_String, Arg_Function}); - const char* eventName = duk_get_string(ctx, 0); + const char * eventName = duk_get_string(ctx, 0); duk_push_this(ctx); duk_get_prop_string(ctx, -1, HS_emitterListeners); @@ -608,7 +609,7 @@ duk_ret_t ScriptAPI::js__Emitter_off(duk_context* ctx) duk_get_prop_string(ctx, -1, eventName); duk_enum(ctx, -1, 0); - while (duk_next(ctx, -1, (duk_bool_t)true)) + while (duk_next(ctx, -1, (duk_bool_t) true)) { if (duk_equals(ctx, 1, -1)) { @@ -625,14 +626,14 @@ duk_ret_t ScriptAPI::js__Emitter_off(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_Duktape_modSearch(duk_context* ctx) +duk_ret_t ScriptAPI::js_Duktape_modSearch(duk_context * ctx) { if (!duk_is_string(ctx, 0)) { return ThrowInvalidArgsError(ctx); } - const char* id = duk_get_string(ctx, 0); + const char * id = duk_get_string(ctx, 0); stdstr strPath = GetInstance(ctx)->System()->ModulesDirPath() + id; CPath path(strPath); @@ -644,7 +645,7 @@ duk_ret_t ScriptAPI::js_Duktape_modSearch(duk_context* ctx) if (hModule == nullptr) { duk_push_error_object(ctx, DUK_ERR_ERROR, - "failed to load native module (\"%s\")", strPath.c_str()); + "failed to load native module (\"%s\")", strPath.c_str()); return duk_throw(ctx); } @@ -655,7 +656,7 @@ duk_ret_t ScriptAPI::js_Duktape_modSearch(duk_context* ctx) { FreeLibrary(hModule); duk_push_error_object(ctx, DUK_ERR_ERROR, - "failed to locate module entry-point (\"%s\")", strProcName.c_str()); + "failed to locate module entry-point (\"%s\")", strProcName.c_str()); return duk_throw(ctx); } @@ -682,7 +683,7 @@ duk_ret_t ScriptAPI::js_Duktape_modSearch(duk_context* ctx) uint32_t length = file.GetLength(); - char* sourceCode = new char[length + 1]; + char * sourceCode = new char[length + 1]; sourceCode[length] = '\0'; if (file.Read(sourceCode, length) != length) @@ -696,7 +697,7 @@ duk_ret_t ScriptAPI::js_Duktape_modSearch(duk_context* ctx) return 1; } -void ScriptAPI::RegisterNativeModule(duk_context* ctx, HMODULE hModule) +void ScriptAPI::RegisterNativeModule(duk_context * ctx, HMODULE hModule) { duk_get_global_string(ctx, HS_gNativeModules); duk_size_t index = duk_get_length(ctx, -1); @@ -709,7 +710,7 @@ void ScriptAPI::RegisterNativeModule(duk_context* ctx, HMODULE hModule) duk_pop(ctx); } -duk_ret_t ScriptAPI::js__NativeModuleFinalizer(duk_context* ctx) +duk_ret_t ScriptAPI::js__NativeModuleFinalizer(duk_context * ctx) { duk_get_prop_string(ctx, 0, "modPtr"); HMODULE hModule = (HMODULE)duk_get_pointer(ctx, -1); @@ -717,10 +718,10 @@ duk_ret_t ScriptAPI::js__NativeModuleFinalizer(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::ThrowInvalidArgsError(duk_context* ctx) +duk_ret_t ScriptAPI::ThrowInvalidArgsError(duk_context * ctx) { duk_push_error_object(ctx, DUK_ERR_TYPE_ERROR, "invalid argument(s)"); - return duk_throw(ctx); + return duk_throw(ctx); } duk_ret_t ScriptAPI::ThrowInvalidArgError(duk_context * ctx, duk_idx_t idx, ArgType wantType) @@ -735,32 +736,32 @@ duk_ret_t ScriptAPI::ThrowTooManyArgsError(duk_context * ctx) return duk_throw(ctx); } -duk_ret_t ScriptAPI::ThrowInvalidAssignmentError(duk_context* ctx, ArgType wantType) +duk_ret_t ScriptAPI::ThrowInvalidAssignmentError(duk_context * ctx, ArgType wantType) { duk_push_error_object(ctx, DUK_ERR_TYPE_ERROR, "invalid assignment, expected %s", ArgTypeName(wantType)); return duk_throw(ctx); } -duk_ret_t ScriptAPI::ThrowNotCallableError(duk_context* ctx) +duk_ret_t ScriptAPI::ThrowNotCallableError(duk_context * ctx) { duk_push_error_object(ctx, DUK_ERR_TYPE_ERROR, "not callable"); return duk_throw(ctx); } -void ScriptAPI::DebugStack(duk_context* ctx, const char* file, int line) +void ScriptAPI::DebugStack(duk_context * ctx, const char * file, int line) { duk_push_context_dump(ctx); GetInstance(ctx)->System()->ConsoleLog("[SCRIPTSYS] <%s:%d> %s", file, line, duk_to_string(ctx, -1)); duk_pop(ctx); } -void ScriptAPI::AllowPrivateCall(duk_context* ctx, bool bAllow) +void ScriptAPI::AllowPrivateCall(duk_context * ctx, bool bAllow) { duk_push_boolean(ctx, (duk_bool_t)bAllow); duk_put_global_string(ctx, HS_gPrivateCallEnabled); } -bool ScriptAPI::PrivateCallAllowed(duk_context* ctx) +bool ScriptAPI::PrivateCallAllowed(duk_context * ctx) { if (!duk_get_global_string(ctx, HS_gPrivateCallEnabled)) { @@ -773,12 +774,12 @@ bool ScriptAPI::PrivateCallAllowed(duk_context* ctx) return bAllowed; } -duk_ret_t ScriptAPI::js_DummyConstructor(duk_context* ctx) +duk_ret_t ScriptAPI::js_DummyConstructor(duk_context * ctx) { return ThrowNotCallableError(ctx); } -void ScriptAPI::PushNewDummyConstructor(duk_context* ctx, bool bFrozen) +void ScriptAPI::PushNewDummyConstructor(duk_context * ctx, bool bFrozen) { duk_push_c_function(ctx, js_DummyConstructor, 0); duk_push_object(ctx); @@ -790,7 +791,7 @@ void ScriptAPI::PushNewDummyConstructor(duk_context* ctx, bool bFrozen) } } -void ScriptAPI::DefineGlobalDummyConstructors(duk_context* ctx, const char* constructorNames[], bool bFreeze) +void ScriptAPI::DefineGlobalDummyConstructors(duk_context * ctx, const char * constructorNames[], bool bFreeze) { duk_push_global_object(ctx); @@ -808,7 +809,7 @@ void ScriptAPI::DefineGlobalDummyConstructors(duk_context* ctx, const char* cons duk_pop(ctx); } -void ScriptAPI::SetDummyConstructor(duk_context* ctx, duk_idx_t obj_idx, const char* globalConstructorName) +void ScriptAPI::SetDummyConstructor(duk_context * ctx, duk_idx_t obj_idx, const char * globalConstructorName) { obj_idx = duk_normalize_index(ctx, obj_idx); duk_get_global_string(ctx, globalConstructorName); @@ -817,13 +818,13 @@ void ScriptAPI::SetDummyConstructor(duk_context* ctx, duk_idx_t obj_idx, const c duk_pop(ctx); } -void ScriptAPI::DukPutPropList(duk_context* ctx, duk_idx_t obj_idx, const DukPropListEntry* props) +void ScriptAPI::DukPutPropList(duk_context * ctx, duk_idx_t obj_idx, const DukPropListEntry * props) { obj_idx = duk_normalize_index(ctx, obj_idx); for (size_t i = 0;; i++) { - const DukPropListEntry& prop = props[i]; + const DukPropListEntry & prop = props[i]; if (prop.key == nullptr) { @@ -832,7 +833,7 @@ void ScriptAPI::DukPutPropList(duk_context* ctx, duk_idx_t obj_idx, const DukPro duk_uint_t propFlags = 0; bool bHiddenSymbol = (prop.key[0] == '\xFF'); - + if (!bHiddenSymbol) { propFlags |= prop.writable ? DUK_DEFPROP_SET_WRITABLE : 0; @@ -881,17 +882,17 @@ void ScriptAPI::DukPutPropList(duk_context* ctx, duk_idx_t obj_idx, const DukPro duk_push_c_function(ctx, prop.value.dukCFunction.func, prop.value.dukCFunction.nargs); break; case Type_DukDupIndex: + { + propFlags |= DUK_DEFPROP_HAVE_VALUE; + duk_idx_t fixedDupIndex = prop.value.dukDupIndex.value; + if (fixedDupIndex < 0) { - propFlags |= DUK_DEFPROP_HAVE_VALUE; - duk_idx_t fixedDupIndex = prop.value.dukDupIndex.value; - if (fixedDupIndex < 0) - { - // -1 to account for prop.key push above - fixedDupIndex = duk_normalize_index(ctx, fixedDupIndex - 1); - } - duk_dup(ctx, fixedDupIndex); + // -1 to account for prop.key push above + fixedDupIndex = duk_normalize_index(ctx, fixedDupIndex - 1); } - break; + duk_dup(ctx, fixedDupIndex); + } + break; case Type_DukGetter: propFlags |= DUK_DEFPROP_HAVE_GETTER; duk_push_c_function(ctx, prop.value.dukGetter.value, 0); @@ -935,7 +936,7 @@ void ScriptAPI::DukPutPropList(duk_context* ctx, duk_idx_t obj_idx, const DukPro } } -duk_bool_t ScriptAPI::ArgTypeMatches(duk_context* ctx, duk_idx_t idx, ArgType wantType) +duk_bool_t ScriptAPI::ArgTypeMatches(duk_context * ctx, duk_idx_t idx, ArgType wantType) { ArgType argType = (ArgType)(wantType & (~ArgAttrs)); @@ -965,18 +966,17 @@ duk_bool_t ScriptAPI::ArgTypeMatches(duk_context* ctx, duk_idx_t idx, ArgType wa return false; } -const char* ScriptAPI::ArgTypeName(ArgType argType) +const char * ScriptAPI::ArgTypeName(ArgType argType) { static const std::map argTypeNames = { - { Arg_Any, "any" }, - { Arg_Number, "number" }, - { Arg_BufferData, "bufferdata" }, - { Arg_String, "string" }, - { Arg_Function, "function" }, - { Arg_Object, "object" }, - { Arg_Array, "array" }, - { Arg_Boolean, "boolean" } - }; + {Arg_Any, "any"}, + {Arg_Number, "number"}, + {Arg_BufferData, "bufferdata"}, + {Arg_String, "string"}, + {Arg_Function, "function"}, + {Arg_Object, "object"}, + {Arg_Array, "array"}, + {Arg_Boolean, "boolean"}}; if (argTypeNames.count(argType) == 0) { @@ -986,7 +986,7 @@ const char* ScriptAPI::ArgTypeName(ArgType argType) return argTypeNames.at(argType).c_str(); } -duk_ret_t ScriptAPI::CheckSetterAssignment(duk_context* ctx, ArgType wantType) +duk_ret_t ScriptAPI::CheckSetterAssignment(duk_context * ctx, ArgType wantType) { if (!ArgTypeMatches(ctx, 0, wantType)) { @@ -995,7 +995,7 @@ duk_ret_t ScriptAPI::CheckSetterAssignment(duk_context* ctx, ArgType wantType) return 0; } -duk_ret_t ScriptAPI::CheckArgs(duk_context* ctx, const std::vector& argTypes) +duk_ret_t ScriptAPI::CheckArgs(duk_context * ctx, const std::vector & argTypes) { duk_idx_t nargs = duk_get_top(ctx); diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_AddressRange.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_AddressRange.cpp index 9e383102d..42cad9a3f 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_AddressRange.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_AddressRange.cpp @@ -1,38 +1,43 @@ -#include +#include "stdafx.h" + #include "ScriptAPI.h" -#pragma warning(disable: 4702) // disable unreachable code warning +#pragma warning(disable : 4702) // disable unreachable code warning -static void GetRange(duk_context* ctx, duk_idx_t idx, uint32_t* start, uint32_t* end); +static void GetRange(duk_context * ctx, duk_idx_t idx, uint32_t * start, uint32_t * end); -void ScriptAPI::Define_AddressRange(duk_context* ctx) +void ScriptAPI::Define_AddressRange(duk_context * ctx) { const DukPropListEntry prototype[] = { - { "size", DukCFunction(js_AddressRange_size) }, - { "includes", DukCFunction(js_AddressRange_includes) }, - { "offset", DukCFunction(js_AddressRange_offset) }, - { "address", DukCFunction(js_AddressRange_address) }, + {"size", DukCFunction(js_AddressRange_size)}, + {"includes", DukCFunction(js_AddressRange_includes)}, + {"offset", DukCFunction(js_AddressRange_offset)}, + {"address", DukCFunction(js_AddressRange_address)}, { nullptr } }; DefineGlobalClass(ctx, "AddressRange", js_AddressRange__constructor, prototype); - struct { const char* key; uint32_t start, end; } ranges[] = { - { "ADDR_ANY", 0x00000000, 0xFFFFFFFF }, - { "ADDR_ANY_KUSEG", 0x00000000, 0x7FFFFFFF }, - { "ADDR_ANY_KSEG0", 0x80000000, 0x9FFFFFFF }, - { "ADDR_ANY_KSEG1", 0xA0000000, 0xBFFFFFFF }, - { "ADDR_ANY_KSEG2", 0xC0000000, 0xFFFFFFFF }, - { "ADDR_ANY_RDRAM", 0x80000000, 0x807FFFFF }, - { "ADDR_ANY_RDRAM_UNC", 0xA0000000, 0xA07FFFFF }, - { "ADDR_ANY_CART_ROM", 0x90000000, 0x95FFFFFF }, - { "ADDR_ANY_CART_ROM_UNC", 0xB0000000, 0xB5FFFFFF }, + struct + { + const char * key; + uint32_t start, end; + } ranges[] = { + {"ADDR_ANY", 0x00000000, 0xFFFFFFFF}, + {"ADDR_ANY_KUSEG", 0x00000000, 0x7FFFFFFF}, + {"ADDR_ANY_KSEG0", 0x80000000, 0x9FFFFFFF}, + {"ADDR_ANY_KSEG1", 0xA0000000, 0xBFFFFFFF}, + {"ADDR_ANY_KSEG2", 0xC0000000, 0xFFFFFFFF}, + {"ADDR_ANY_RDRAM", 0x80000000, 0x807FFFFF}, + {"ADDR_ANY_RDRAM_UNC", 0xA0000000, 0xA07FFFFF}, + {"ADDR_ANY_CART_ROM", 0x90000000, 0x95FFFFFF}, + {"ADDR_ANY_CART_ROM_UNC", 0xB0000000, 0xB5FFFFFF}, { nullptr, 0, 0 } }; duk_push_global_object(ctx); - for(int i = 0; ranges[i].key != nullptr; i++) + for (int i = 0; ranges[i].key != nullptr; i++) { duk_push_string(ctx, ranges[i].key); duk_get_global_string(ctx, "AddressRange"); @@ -45,16 +50,16 @@ void ScriptAPI::Define_AddressRange(duk_context* ctx) duk_pop(ctx); } -duk_ret_t ScriptAPI::js_AddressRange__constructor(duk_context* ctx) +duk_ret_t ScriptAPI::js_AddressRange__constructor(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number, Arg_Number }); + CheckArgs(ctx, {Arg_Number, Arg_Number}); duk_to_uint32(ctx, 0); duk_to_uint32(ctx, 1); duk_uint_t start = duk_get_uint(ctx, 0); duk_uint_t end = duk_get_uint(ctx, 1); - + if (end < start) { duk_push_error_object(ctx, DUK_ERR_RANGE_ERROR, "invalid range; end cannot be less than start"); @@ -72,7 +77,7 @@ duk_ret_t ScriptAPI::js_AddressRange__constructor(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js_AddressRange_size(duk_context* ctx) +duk_ret_t ScriptAPI::js_AddressRange_size(duk_context * ctx) { CheckArgs(ctx, {}); duk_uint_t start, end; @@ -84,9 +89,9 @@ duk_ret_t ScriptAPI::js_AddressRange_size(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_AddressRange_includes(duk_context* ctx) +duk_ret_t ScriptAPI::js_AddressRange_includes(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number }); + CheckArgs(ctx, {Arg_Number}); duk_to_uint32(ctx, 0); duk_uint_t address = duk_get_uint(ctx, 0); duk_uint_t start, end; @@ -98,9 +103,9 @@ duk_ret_t ScriptAPI::js_AddressRange_includes(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_AddressRange_offset(duk_context* ctx) +duk_ret_t ScriptAPI::js_AddressRange_offset(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number }); + CheckArgs(ctx, {Arg_Number}); duk_to_uint32(ctx, 0); duk_uint_t address = duk_get_uint(ctx, 0); duk_uint_t start, end; @@ -108,7 +113,8 @@ duk_ret_t ScriptAPI::js_AddressRange_offset(duk_context* ctx) duk_push_this(ctx); GetRange(ctx, -1, &start, &end); - if (address < start || address > end) { + if (address < start || address > end) + { duk_push_error_object(ctx, DUK_ERR_RANGE_ERROR, "address out of bounds"); return duk_throw(ctx); } @@ -117,9 +123,9 @@ duk_ret_t ScriptAPI::js_AddressRange_offset(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_AddressRange_address(duk_context* ctx) +duk_ret_t ScriptAPI::js_AddressRange_address(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number }); + CheckArgs(ctx, {Arg_Number}); duk_int_t offset = duk_get_int(ctx, 0); duk_uint_t start, end; @@ -129,7 +135,8 @@ duk_ret_t ScriptAPI::js_AddressRange_address(duk_context* ctx) duk_uint_t address = start + offset; - if (address < start || address > end) { + if (address < start || address > end) + { duk_push_error_object(ctx, DUK_ERR_RANGE_ERROR, "offset out of bounds"); return duk_throw(ctx); } @@ -138,7 +145,7 @@ duk_ret_t ScriptAPI::js_AddressRange_address(duk_context* ctx) return 1; } -static void GetRange(duk_context* ctx, duk_idx_t idx, uint32_t* start, uint32_t* end) +static void GetRange(duk_context * ctx, duk_idx_t idx, uint32_t * start, uint32_t * end) { idx = duk_normalize_index(ctx, idx); duk_get_prop_string(ctx, idx, "start"); diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_N64Image.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_N64Image.cpp index 3e0d8982d..13a24ca36 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_N64Image.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_N64Image.cpp @@ -1,16 +1,17 @@ -#include -#include "ScriptAPI.h" -#include "N64Image.h" +#include "stdafx.h" -#pragma warning(disable: 4702) // disable unreachable code warning +#include "N64Image.h" +#include "ScriptAPI.h" + +#pragma warning(disable : 4702) // disable unreachable code warning using namespace ScriptAPI; -static CN64Image* GetThisImage(duk_context* ctx) +static CN64Image * GetThisImage(duk_context * ctx) { duk_push_this(ctx); duk_get_prop_string(ctx, -1, HS_n64ImagePtr); - CN64Image* image = (CN64Image*)duk_get_pointer(ctx, -1); + CN64Image * image = (CN64Image *)duk_get_pointer(ctx, -1); duk_pop_n(ctx, 2); if (image == nullptr) @@ -22,25 +23,25 @@ static CN64Image* GetThisImage(duk_context* ctx) return image; } -void ScriptAPI::Define_N64Image(duk_context* ctx) +void ScriptAPI::Define_N64Image(duk_context * ctx) { const DukPropListEntry prototype[] = { - { "toPNG", DukCFunction(js_N64Image_toPNG) }, - { "update", DukCFunction(js_N64Image_update) }, + {"toPNG", DukCFunction(js_N64Image_toPNG)}, + {"update", DukCFunction(js_N64Image_update)}, { nullptr} }; const DukPropListEntry staticProps[] = { - { "fromPNG", DukCFunction(js_N64Image_static_fromPNG) }, - { "format", DukCFunction(js_N64Image_static_format) }, - { "bpp", DukCFunction(js_N64Image_static_bpp) }, + {"fromPNG", DukCFunction(js_N64Image_static_fromPNG)}, + {"format", DukCFunction(js_N64Image_static_format)}, + {"bpp", DukCFunction(js_N64Image_static_bpp)}, { nullptr } }; DefineGlobalClass(ctx, "N64Image", js_N64Image__constructor, prototype, staticProps); } -static void InitImageObjectProps(duk_context* ctx, duk_idx_t idx, CN64Image* image) +static void InitImageObjectProps(duk_context * ctx, duk_idx_t idx, CN64Image * image) { idx = duk_normalize_index(ctx, idx); @@ -66,11 +67,11 @@ static void InitImageObjectProps(duk_context* ctx, duk_idx_t idx, CN64Image* ima duk_idx_t palette_idx = duk_normalize_index(ctx, -1); const DukPropListEntry props[] = { - { HS_n64ImagePtr, DukPointer(image) }, - { "pixels", DukDupIndex(pixels_idx) }, - { "palette", DukDupIndex(palette_idx) }, - { "width", DukUInt(image->Width()) }, - { "height", DukUInt(image->Height()) }, + {HS_n64ImagePtr, DukPointer(image)}, + {"pixels", DukDupIndex(pixels_idx)}, + {"palette", DukDupIndex(palette_idx)}, + {"width", DukUInt(image->Width())}, + {"height", DukUInt(image->Height())}, { nullptr } }; @@ -82,9 +83,9 @@ static void InitImageObjectProps(duk_context* ctx, duk_idx_t idx, CN64Image* ima duk_set_finalizer(ctx, idx); } -duk_ret_t ScriptAPI::js_N64Image__constructor(duk_context* ctx) +duk_ret_t ScriptAPI::js_N64Image__constructor(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number, Arg_Number, Arg_OptNumber, Arg_OptBufferData, Arg_OptBufferData }); + CheckArgs(ctx, {Arg_Number, Arg_Number, Arg_OptNumber, Arg_OptBufferData, Arg_OptBufferData}); if (!duk_is_constructor_call(ctx)) { @@ -96,16 +97,16 @@ duk_ret_t ScriptAPI::js_N64Image__constructor(duk_context* ctx) size_t width = duk_get_uint(ctx, 0); size_t height = duk_get_uint(ctx, 1); int format = duk_get_int_default(ctx, 2, IMG_RGBA32); - void* pixelData = duk_get_buffer_data_default(ctx, 3, &pixelDataSize, nullptr, 0); - void* paletteData = duk_get_buffer_data_default(ctx, 4, &paletteDataSize, nullptr, 0); + void * pixelData = duk_get_buffer_data_default(ctx, 3, &pixelDataSize, nullptr, 0); + void * paletteData = duk_get_buffer_data_default(ctx, 4, &paletteDataSize, nullptr, 0); - CN64Image* image = new CN64Image(); + CN64Image * image = new CN64Image(); int result = image->Init(format, width, height, pixelData, pixelDataSize, paletteData, paletteDataSize); if (result != N64IMG_OK) { duk_push_error_object(ctx, DUK_ERR_ERROR, "failed to initialize image (%s)", - CN64Image::ResultCodeName(result)); + CN64Image::ResultCodeName(result)); return duk_throw(ctx); } @@ -114,10 +115,10 @@ duk_ret_t ScriptAPI::js_N64Image__constructor(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js_N64Image__finalizer(duk_context* ctx) +duk_ret_t ScriptAPI::js_N64Image__finalizer(duk_context * ctx) { duk_get_prop_string(ctx, 0, HS_n64ImagePtr); - CN64Image* image = (CN64Image*)duk_get_pointer(ctx, -1); + CN64Image * image = (CN64Image *)duk_get_pointer(ctx, -1); if (image == nullptr) { return 0; @@ -126,12 +127,12 @@ duk_ret_t ScriptAPI::js_N64Image__finalizer(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js_N64Image_static_fromPNG(duk_context* ctx) +duk_ret_t ScriptAPI::js_N64Image_static_fromPNG(duk_context * ctx) { - CheckArgs(ctx, { Arg_BufferData, Arg_OptNumber }); + CheckArgs(ctx, {Arg_BufferData, Arg_OptNumber}); int format = duk_get_int_default(ctx, 1, IMG_RGBA32); - + if (CN64Image::BitsPerPixel(format) == 0) { duk_push_error_object(ctx, DUK_RET_TYPE_ERROR, "invalid format"); @@ -139,18 +140,18 @@ duk_ret_t ScriptAPI::js_N64Image_static_fromPNG(duk_context* ctx) } size_t pngSize; - uint8_t* pngData = (uint8_t*)duk_get_buffer_data(ctx, 0, &pngSize); + uint8_t * pngData = (uint8_t *)duk_get_buffer_data(ctx, 0, &pngSize); - CN64Image* image = new CN64Image(); + CN64Image * image = new CN64Image(); int result = image->Init(format, pngData, pngSize); if (result != N64IMG_OK) { delete image; duk_push_error_object(ctx, DUK_ERR_ERROR, "failed to initialize image (%s)", - CN64Image::ResultCodeName(result), result); + CN64Image::ResultCodeName(result), result); return duk_throw(ctx); } - + duk_push_object(ctx); duk_get_global_string(ctx, "N64Image"); duk_get_prop_string(ctx, -1, "prototype"); @@ -161,9 +162,9 @@ duk_ret_t ScriptAPI::js_N64Image_static_fromPNG(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_N64Image_static_format(duk_context* ctx) +duk_ret_t ScriptAPI::js_N64Image_static_format(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number, Arg_Number, Arg_OptNumber }); + CheckArgs(ctx, {Arg_Number, Arg_Number, Arg_OptNumber}); duk_uint_t gbiFmt = duk_get_uint(ctx, 0); duk_uint_t gbiSiz = duk_get_uint(ctx, 1); @@ -193,9 +194,9 @@ duk_ret_t ScriptAPI::js_N64Image_static_format(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_N64Image_static_bpp(duk_context* ctx) +duk_ret_t ScriptAPI::js_N64Image_static_bpp(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number }); + CheckArgs(ctx, {Arg_Number}); duk_uint_t format = duk_get_uint(ctx, 0); @@ -214,28 +215,28 @@ duk_ret_t ScriptAPI::js_N64Image_static_bpp(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_N64Image_toPNG(duk_context* ctx) +duk_ret_t ScriptAPI::js_N64Image_toPNG(duk_context * ctx) { - CN64Image* image = GetThisImage(ctx); + CN64Image * image = GetThisImage(ctx); std::vector png; image->ToPNG(png); - void* pngCopy = duk_push_buffer(ctx, png.size(), false); + void * pngCopy = duk_push_buffer(ctx, png.size(), false); duk_push_buffer_object(ctx, -1, 0, png.size(), DUK_BUFOBJ_NODEJS_BUFFER); memcpy(pngCopy, png.data(), png.size()); return 1; } -duk_ret_t ScriptAPI::js_N64Image_update(duk_context* ctx) +duk_ret_t ScriptAPI::js_N64Image_update(duk_context * ctx) { - CN64Image* image = GetThisImage(ctx); + CN64Image * image = GetThisImage(ctx); int result = image->UpdateBitmap(); if (result != N64IMG_OK) { duk_push_error_object(ctx, DUK_ERR_ERROR, "bitmap update failed (%s)", - CN64Image::ResultCodeName(result)); + CN64Image::ResultCodeName(result)); } return 0; } diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_Number_hex.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_Number_hex.cpp index 78a3be2d7..ef84aeff9 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_Number_hex.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_Number_hex.cpp @@ -1,7 +1,8 @@ -#include +#include "stdafx.h" + #include "ScriptAPI.h" -void ScriptAPI::Define_Number_prototype_hex(duk_context *ctx) +void ScriptAPI::Define_Number_prototype_hex(duk_context * ctx) { duk_get_global_string(ctx, "Number"); duk_get_prop_string(ctx, -1, "prototype"); @@ -10,9 +11,9 @@ void ScriptAPI::Define_Number_prototype_hex(duk_context *ctx) duk_pop_n(ctx, 2); } -duk_ret_t ScriptAPI::js_Number_prototype_hex(duk_context *ctx) +duk_ret_t ScriptAPI::js_Number_prototype_hex(duk_context * ctx) { - CheckArgs(ctx, { Arg_OptNumber }); + CheckArgs(ctx, {Arg_OptNumber}); duk_uint_t value; duk_uint_t length = 8; diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_Server.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_Server.cpp index c9b256b0f..dc98d0957 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_Server.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_Server.cpp @@ -1,26 +1,27 @@ -#include -#include "ScriptAPI.h" +#include "stdafx.h" + #include "JSServerWorker.h" +#include "ScriptAPI.h" -static CJSServerWorker* GetThisServer(duk_context* ctx); +static CJSServerWorker * GetThisServer(duk_context * ctx); -void ScriptAPI::Define_Server(duk_context* ctx) +void ScriptAPI::Define_Server(duk_context * ctx) { const DukPropListEntry prototype[] = { - { "listen", DukCFunction(js_Server_listen) }, - { "close", DukCFunction(js_Server_close) }, - { "on", DukCFunction(js__Emitter_on) }, - { "off", DukCFunction(js__Emitter_off) }, - { "port", DukGetter(js_Server__get_port) }, - { "address", DukGetter(js_Server__get_address) }, - { "addressFamily", DukGetter(js_Server__get_addressFamily) }, + {"listen", DukCFunction(js_Server_listen)}, + {"close", DukCFunction(js_Server_close)}, + {"on", DukCFunction(js__Emitter_on)}, + {"off", DukCFunction(js__Emitter_off)}, + {"port", DukGetter(js_Server__get_port)}, + {"address", DukGetter(js_Server__get_address)}, + {"addressFamily", DukGetter(js_Server__get_addressFamily)}, { nullptr } }; DefineGlobalClass(ctx, "Server", js_Server__constructor, prototype); } -duk_ret_t ScriptAPI::js_Server__constructor(duk_context* ctx) +duk_ret_t ScriptAPI::js_Server__constructor(duk_context * ctx) { CheckArgs(ctx, {}); @@ -29,44 +30,39 @@ duk_ret_t ScriptAPI::js_Server__constructor(duk_context* ctx) return DUK_RET_ERROR; } - CScriptInstance* inst = GetInstance(ctx); + CScriptInstance * inst = GetInstance(ctx); duk_push_this(ctx); - void* objectHeapPtr = duk_get_heapptr(ctx, -1); + void * objectHeapPtr = duk_get_heapptr(ctx, -1); + + InitEmitter(ctx, -1, {"close", "connection", "error", "listening"}); - InitEmitter(ctx, -1, { - "close", - "connection", - "error", - "listening" - }); - duk_push_c_function(ctx, js_Server__finalizer, 1); duk_set_finalizer(ctx, -2); - CJSServerWorker* serverWorker = new CJSServerWorker(inst, objectHeapPtr); + CJSServerWorker * serverWorker = new CJSServerWorker(inst, objectHeapPtr); duk_push_pointer(ctx, serverWorker); duk_put_prop_string(ctx, -2, HS_serverWorkerPtr); return 0; } -duk_ret_t ScriptAPI::js_Server__finalizer(duk_context* ctx) +duk_ret_t ScriptAPI::js_Server__finalizer(duk_context * ctx) { UnrefObject(ctx, 0); duk_get_prop_string(ctx, 0, HS_serverWorkerPtr); - CJSServerWorker* serverWorker = (CJSServerWorker*)duk_get_pointer(ctx, -1); + CJSServerWorker * serverWorker = (CJSServerWorker *)duk_get_pointer(ctx, -1); delete serverWorker; return 0; } -duk_ret_t ScriptAPI::js_Server_listen(duk_context* ctx) +duk_ret_t ScriptAPI::js_Server_listen(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number, Arg_OptString, Arg_OptFunction }); - CJSServerWorker* serverWorker = GetThisServer(ctx); + CheckArgs(ctx, {Arg_Number, Arg_OptString, Arg_OptFunction}); + CJSServerWorker * serverWorker = GetThisServer(ctx); unsigned short port = (unsigned short)duk_get_int(ctx, 0); - const char* address = duk_get_string_default(ctx, 1, "0.0.0.0"); + const char * address = duk_get_string_default(ctx, 1, "0.0.0.0"); // todo callback @@ -79,41 +75,41 @@ duk_ret_t ScriptAPI::js_Server_listen(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js_Server_close(duk_context* ctx) +duk_ret_t ScriptAPI::js_Server_close(duk_context * ctx) { CheckArgs(ctx, {}); - CJSServerWorker* serverWorker = GetThisServer(ctx); + CJSServerWorker * serverWorker = GetThisServer(ctx); serverWorker->StopWorkerProc(); return 0; } -duk_ret_t ScriptAPI::js_Server__get_port(duk_context* ctx) +duk_ret_t ScriptAPI::js_Server__get_port(duk_context * ctx) { - CJSServerWorker* serverWorker = GetThisServer(ctx); + CJSServerWorker * serverWorker = GetThisServer(ctx); duk_push_uint(ctx, serverWorker->GetPort()); return 1; } -duk_ret_t ScriptAPI::js_Server__get_address(duk_context* ctx) +duk_ret_t ScriptAPI::js_Server__get_address(duk_context * ctx) { - CJSServerWorker* serverWorker = GetThisServer(ctx); + CJSServerWorker * serverWorker = GetThisServer(ctx); duk_push_string(ctx, serverWorker->GetAddress().c_str()); return 1; } -duk_ret_t ScriptAPI::js_Server__get_addressFamily(duk_context* ctx) +duk_ret_t ScriptAPI::js_Server__get_addressFamily(duk_context * ctx) { - CJSServerWorker* serverWorker = GetThisServer(ctx); + CJSServerWorker * serverWorker = GetThisServer(ctx); duk_push_string(ctx, serverWorker->GetFamily()); return 1; } -CJSServerWorker* GetThisServer(duk_context* ctx) +CJSServerWorker * GetThisServer(duk_context * ctx) { duk_push_this(ctx); duk_get_prop_string(ctx, -1, HS_serverWorkerPtr); - CJSServerWorker* serverWorker = (CJSServerWorker*)duk_get_pointer(ctx, -1); + CJSServerWorker * serverWorker = (CJSServerWorker *)duk_get_pointer(ctx, -1); duk_pop_n(ctx, 2); return serverWorker; } diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_Socket.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_Socket.cpp index edf8d09bd..5b211fa51 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_Socket.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_Socket.cpp @@ -1,37 +1,38 @@ -#include -#include "ScriptAPI.h" +#include "stdafx.h" + #include "JSSocketWorker.h" +#include "ScriptAPI.h" -#pragma warning(disable: 4702) // disable unreachable code warning +#pragma warning(disable : 4702) // disable unreachable code warning -static CJSSocketWorker* GetThisSocket(duk_context* ctx); -static duk_ret_t RequireBufferDataOrString(duk_context* ctx, duk_idx_t idx, const char** data, duk_size_t* size); -static duk_int_t RegisterWriteCallback(duk_context* ctx, duk_idx_t idx); -static void RegisterWriteEndCallback(duk_context* ctx, duk_idx_t idx); +static CJSSocketWorker * GetThisSocket(duk_context * ctx); +static duk_ret_t RequireBufferDataOrString(duk_context * ctx, duk_idx_t idx, const char ** data, duk_size_t * size); +static duk_int_t RegisterWriteCallback(duk_context * ctx, duk_idx_t idx); +static void RegisterWriteEndCallback(duk_context * ctx, duk_idx_t idx); -void ScriptAPI::Define_Socket(duk_context* ctx) +void ScriptAPI::Define_Socket(duk_context * ctx) { const DukPropListEntry prototype[] = { - { "connect", DukCFunction(js_Socket_connect) }, - { "write", DukCFunction(js_Socket_write) }, - { "end", DukCFunction(js_Socket_end) }, - { "close", DukCFunction(js_Socket_close) }, - { "on", DukCFunction(js__Emitter_on) }, - { "off", DukCFunction(js__Emitter_off) }, - { "localAddress", DukGetter(js_Socket__get_localAddress) }, - { "localPort", DukGetter(js_Socket__get_localPort) }, - { "remoteAddress", DukGetter(js_Socket__get_remoteAddress) }, - { "remotePort", DukGetter(js_Socket__get_remotePort) }, - { "addressFamily", DukGetter(js_Socket__get_addressFamily) }, + {"connect", DukCFunction(js_Socket_connect)}, + {"write", DukCFunction(js_Socket_write)}, + {"end", DukCFunction(js_Socket_end)}, + {"close", DukCFunction(js_Socket_close)}, + {"on", DukCFunction(js__Emitter_on)}, + {"off", DukCFunction(js__Emitter_off)}, + {"localAddress", DukGetter(js_Socket__get_localAddress)}, + {"localPort", DukGetter(js_Socket__get_localPort)}, + {"remoteAddress", DukGetter(js_Socket__get_remoteAddress)}, + {"remotePort", DukGetter(js_Socket__get_remotePort)}, + {"addressFamily", DukGetter(js_Socket__get_addressFamily)}, { nullptr } }; DefineGlobalClass(ctx, "Socket", js_Socket__constructor, prototype, nullptr); } -duk_ret_t ScriptAPI::js_Socket__constructor(duk_context* ctx) +duk_ret_t ScriptAPI::js_Socket__constructor(duk_context * ctx) { - CheckArgs(ctx, { Arg_OptObject }); + CheckArgs(ctx, {Arg_OptObject}); if (!duk_is_constructor_call(ctx)) { @@ -40,7 +41,7 @@ duk_ret_t ScriptAPI::js_Socket__constructor(duk_context* ctx) bool bAllowHalfOpen = false; - CScriptInstance* inst = GetInstance(ctx); + CScriptInstance * inst = GetInstance(ctx); if (duk_is_object(ctx, 0)) { @@ -53,17 +54,9 @@ duk_ret_t ScriptAPI::js_Socket__constructor(duk_context* ctx) } duk_push_this(ctx); - void* objectHeapPtr = duk_get_heapptr(ctx, -1); - - InitEmitter(ctx, -1, { - "data", - "end", - "connect", - "error", - "close", - "drain", - "lookup" - }); + void * objectHeapPtr = duk_get_heapptr(ctx, -1); + + InitEmitter(ctx, -1, {"data", "end", "connect", "error", "close", "drain", "lookup"}); duk_push_uint(ctx, 0); duk_put_prop_string(ctx, -2, HS_socketNextWriteCallbackId); @@ -74,9 +67,9 @@ duk_ret_t ScriptAPI::js_Socket__constructor(duk_context* ctx) duk_push_array(ctx); duk_put_prop_string(ctx, -2, HS_socketWriteEndCallbacks); - CJSSocketWorker* socketWorker = new CJSSocketWorker(inst, objectHeapPtr, bAllowHalfOpen); + CJSSocketWorker * socketWorker = new CJSSocketWorker(inst, objectHeapPtr, bAllowHalfOpen); - duk_push_pointer(ctx, (void*)socketWorker); + duk_push_pointer(ctx, (void *)socketWorker); duk_put_prop_string(ctx, -2, HS_socketWorkerPtr); duk_push_c_function(ctx, js_Socket__finalizer, 1); @@ -85,10 +78,10 @@ duk_ret_t ScriptAPI::js_Socket__constructor(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js_Socket__finalizer(duk_context* ctx) +duk_ret_t ScriptAPI::js_Socket__finalizer(duk_context * ctx) { duk_get_prop_string(ctx, 0, HS_socketWorkerPtr); - CJSSocketWorker* socketWorker = (CJSSocketWorker*)duk_get_pointer(ctx, -1); + CJSSocketWorker * socketWorker = (CJSSocketWorker *)duk_get_pointer(ctx, -1); if (socketWorker == nullptr) { @@ -101,15 +94,15 @@ duk_ret_t ScriptAPI::js_Socket__finalizer(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js_Socket_connect(duk_context* ctx) +duk_ret_t ScriptAPI::js_Socket_connect(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number, Arg_String, Arg_OptFunction }); + CheckArgs(ctx, {Arg_Number, Arg_String, Arg_OptFunction}); + + CJSSocketWorker * socketWorker = GetThisSocket(ctx); - CJSSocketWorker* socketWorker = GetThisSocket(ctx); - duk_idx_t nargs = duk_get_top(ctx); unsigned short port = (unsigned short)duk_get_uint(ctx, 0); - const char* host = duk_get_string(ctx, 1); + const char * host = duk_get_string(ctx, 1); if (nargs == 3) { @@ -131,14 +124,14 @@ duk_ret_t ScriptAPI::js_Socket_connect(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js_Socket_write(duk_context* ctx) +duk_ret_t ScriptAPI::js_Socket_write(duk_context * ctx) { - CJSSocketWorker* socketWorker = GetThisSocket(ctx); + CJSSocketWorker * socketWorker = GetThisSocket(ctx); - const char* data; + const char * data; duk_size_t size; duk_int_t callbackId = -1; - + duk_idx_t nargs = duk_get_top(ctx); RequireBufferDataOrString(ctx, 0, &data, &size); @@ -147,15 +140,15 @@ duk_ret_t ScriptAPI::js_Socket_write(duk_context* ctx) callbackId = RegisterWriteCallback(ctx, 1); } - socketWorker->Write((char*)data, size, callbackId, false); + socketWorker->Write((char *)data, size, callbackId, false); return 0; } -duk_ret_t ScriptAPI::js_Socket_end(duk_context* ctx) +duk_ret_t ScriptAPI::js_Socket_end(duk_context * ctx) { - CJSSocketWorker* socketWorker = GetThisSocket(ctx); + CJSSocketWorker * socketWorker = GetThisSocket(ctx); - const char* data; + const char * data; duk_size_t size; duk_int_t callbackId = -1; @@ -167,11 +160,11 @@ duk_ret_t ScriptAPI::js_Socket_end(duk_context* ctx) RegisterWriteEndCallback(ctx, 1); } - socketWorker->Write((char*)data, size, callbackId, true); + socketWorker->Write((char *)data, size, callbackId, true); return 0; } -duk_ret_t ScriptAPI::js_Socket__invokeWriteCallback(duk_context* ctx) +duk_ret_t ScriptAPI::js_Socket__invokeWriteCallback(duk_context * ctx) { duk_int_t callbackId = duk_get_int(ctx, 0); @@ -191,7 +184,7 @@ duk_ret_t ScriptAPI::js_Socket__invokeWriteCallback(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js_Socket__invokeWriteEndCallbacks(duk_context* ctx) +duk_ret_t ScriptAPI::js_Socket__invokeWriteEndCallbacks(duk_context * ctx) { duk_push_this(ctx); duk_get_prop_string(ctx, -1, HS_socketWriteEndCallbacks); @@ -212,59 +205,59 @@ duk_ret_t ScriptAPI::js_Socket__invokeWriteEndCallbacks(duk_context* ctx) duk_pop(ctx); // reset array - duk_push_array(ctx); + duk_push_array(ctx); duk_put_prop_string(ctx, -2, HS_socketWriteEndCallbacks); return 0; } -duk_ret_t ScriptAPI::js_Socket_close(duk_context* ctx) +duk_ret_t ScriptAPI::js_Socket_close(duk_context * ctx) { - CJSSocketWorker* socketWorker = GetThisSocket(ctx); + CJSSocketWorker * socketWorker = GetThisSocket(ctx); socketWorker->StopWorkerProc(); return 0; } -duk_ret_t ScriptAPI::js_Socket__get_localAddress(duk_context* ctx) +duk_ret_t ScriptAPI::js_Socket__get_localAddress(duk_context * ctx) { - CJSSocketWorker* socketWorker = GetThisSocket(ctx); + CJSSocketWorker * socketWorker = GetThisSocket(ctx); duk_push_string(ctx, socketWorker->GetLocalAddress().c_str()); return 1; } -duk_ret_t ScriptAPI::js_Socket__get_localPort(duk_context* ctx) +duk_ret_t ScriptAPI::js_Socket__get_localPort(duk_context * ctx) { - CJSSocketWorker* socketWorker = GetThisSocket(ctx); + CJSSocketWorker * socketWorker = GetThisSocket(ctx); duk_push_uint(ctx, socketWorker->GetLocalPort()); return 1; } -duk_ret_t ScriptAPI::js_Socket__get_remoteAddress(duk_context* ctx) +duk_ret_t ScriptAPI::js_Socket__get_remoteAddress(duk_context * ctx) { - CJSSocketWorker* socketWorker = GetThisSocket(ctx); + CJSSocketWorker * socketWorker = GetThisSocket(ctx); duk_push_string(ctx, socketWorker->GetRemoteAddress().c_str()); return 1; } -duk_ret_t ScriptAPI::js_Socket__get_remotePort(duk_context* ctx) +duk_ret_t ScriptAPI::js_Socket__get_remotePort(duk_context * ctx) { - CJSSocketWorker* socketWorker = GetThisSocket(ctx); + CJSSocketWorker * socketWorker = GetThisSocket(ctx); duk_push_uint(ctx, socketWorker->GetRemotePort()); return 1; } -duk_ret_t ScriptAPI::js_Socket__get_addressFamily(duk_context* ctx) +duk_ret_t ScriptAPI::js_Socket__get_addressFamily(duk_context * ctx) { - CJSSocketWorker* socketWorker = GetThisSocket(ctx); + CJSSocketWorker * socketWorker = GetThisSocket(ctx); duk_push_string(ctx, socketWorker->GetFamily()); return 1; } -CJSSocketWorker* GetThisSocket(duk_context* ctx) +CJSSocketWorker * GetThisSocket(duk_context * ctx) { duk_push_this(ctx); duk_get_prop_string(ctx, -1, HS_socketWorkerPtr); - CJSSocketWorker* socketWorker = (CJSSocketWorker*)duk_get_pointer(ctx, -1); + CJSSocketWorker * socketWorker = (CJSSocketWorker *)duk_get_pointer(ctx, -1); duk_pop_n(ctx, 2); if (socketWorker == nullptr) @@ -276,11 +269,11 @@ CJSSocketWorker* GetThisSocket(duk_context* ctx) return socketWorker; } -duk_ret_t RequireBufferDataOrString(duk_context* ctx, duk_idx_t idx, const char** data, duk_size_t* size) +duk_ret_t RequireBufferDataOrString(duk_context * ctx, duk_idx_t idx, const char ** data, duk_size_t * size) { if (duk_is_buffer_data(ctx, idx)) { - *data = (const char*)duk_get_buffer_data(ctx, idx, size); + *data = (const char *)duk_get_buffer_data(ctx, idx, size); return 0; } else if (duk_is_string(ctx, idx)) @@ -293,7 +286,7 @@ duk_ret_t RequireBufferDataOrString(duk_context* ctx, duk_idx_t idx, const char* return duk_throw(ctx); } -duk_int_t RegisterWriteCallback(duk_context* ctx, duk_idx_t idx) +duk_int_t RegisterWriteCallback(duk_context * ctx, duk_idx_t idx) { idx = duk_normalize_index(ctx, idx); @@ -313,7 +306,7 @@ duk_int_t RegisterWriteCallback(duk_context* ctx, duk_idx_t idx) return callbackId; } -void RegisterWriteEndCallback(duk_context* ctx, duk_idx_t idx) +void RegisterWriteEndCallback(duk_context * ctx, duk_idx_t idx) { idx = duk_normalize_index(ctx, idx); diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_alert.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_alert.cpp index 549cbc171..4f15fbb79 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_alert.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_alert.cpp @@ -1,19 +1,20 @@ -#include -#include -#include "ScriptAPI.h" +#include "stdafx.h" -void ScriptAPI::Define_alert(duk_context* ctx) +#include "ScriptAPI.h" +#include + +void ScriptAPI::Define_alert(duk_context * ctx) { DefineGlobalFunction(ctx, "alert", js_alert); } -duk_ret_t ScriptAPI::js_alert(duk_context* ctx) +duk_ret_t ScriptAPI::js_alert(duk_context * ctx) { - CheckArgs(ctx, { Arg_Any, Arg_OptAny }); + CheckArgs(ctx, {Arg_Any, Arg_OptAny}); duk_idx_t nargs = duk_get_top(ctx); - const char* message = duk_safe_to_string(ctx, 0); - const char* caption = (nargs == 2) ? duk_safe_to_string(ctx, 1) : ""; + const char * message = duk_safe_to_string(ctx, 0); + const char * caption = (nargs == 2) ? duk_safe_to_string(ctx, 1) : ""; HWND mainWindow = (HWND)g_Plugins->MainWindow()->GetWindowHandle(); MessageBoxA(mainWindow, message, caption, MB_OK); diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_asm.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_asm.cpp index cb5d219d0..d1d8d2837 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_asm.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_asm.cpp @@ -1,30 +1,31 @@ -#include -#include "ScriptAPI.h" +#include "stdafx.h" + #include "../Assembler.h" +#include "ScriptAPI.h" #include -void ScriptAPI::Define_asm(duk_context *ctx) +void ScriptAPI::Define_asm(duk_context * ctx) { const DukPropListEntry props[] = { - { "gprname", DukCFunction(js_asm_gprname) }, - { "encode", DukCFunction(js_asm_encode) }, - { "decode", DukCFunction(js_asm_decode) }, + {"gprname", DukCFunction(js_asm_gprname)}, + {"encode", DukCFunction(js_asm_encode)}, + {"decode", DukCFunction(js_asm_decode)}, { nullptr } }; DefineGlobalInterface(ctx, "asm", props); } -duk_ret_t ScriptAPI::js_asm_gprname(duk_context* ctx) +duk_ret_t ScriptAPI::js_asm_gprname(duk_context * ctx) { - const char* names[32] = { + const char * names[32] = { "r0", "at", "v0", "v1", "a0", "a1", "a2", "a3", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra" }; - CheckArgs(ctx, { Arg_Number }); + CheckArgs(ctx, {Arg_Number}); duk_uint_t idx = duk_get_uint(ctx, 0); @@ -40,11 +41,11 @@ duk_ret_t ScriptAPI::js_asm_gprname(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_asm_encode(duk_context* ctx) +duk_ret_t ScriptAPI::js_asm_encode(duk_context * ctx) { - CheckArgs(ctx, { Arg_String, Arg_OptNumber }); + CheckArgs(ctx, {Arg_String, Arg_OptNumber}); - const char *code = duk_get_string(ctx, 0); + const char * code = duk_get_string(ctx, 0); uint32_t address = duk_get_uint_default(ctx, 1, 0); // TODO: CAssembler's state is not thread safe. @@ -61,9 +62,9 @@ duk_ret_t ScriptAPI::js_asm_encode(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_asm_decode(duk_context* ctx) +duk_ret_t ScriptAPI::js_asm_decode(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number, Arg_OptNumber }); + CheckArgs(ctx, {Arg_Number, Arg_OptNumber}); uint32_t opcode = duk_get_uint(ctx, 0); uint32_t address = duk_get_uint_default(ctx, 1, 0); diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_console.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_console.cpp index c6f089c34..9ae664dc0 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_console.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_console.cpp @@ -1,24 +1,25 @@ -#include -#include +#include "stdafx.h" + #include "ScriptAPI.h" +#include -static void ConcatArgs(duk_context* ctx, stdstr& out); +static void ConcatArgs(duk_context * ctx, stdstr & out); -void ScriptAPI::Define_console(duk_context* ctx) +void ScriptAPI::Define_console(duk_context * ctx) { const DukPropListEntry props[] = { - { "print", DukCFunction(js_console_print) }, - { "log", DukCFunction(js_console_log) }, - { "error", DukCFunction(js_console_error) }, - { "clear", DukCFunction(js_console_clear) }, - { "listen", DukCFunction(js_console_listen) }, + {"print", DukCFunction(js_console_print)}, + {"log", DukCFunction(js_console_log)}, + {"error", DukCFunction(js_console_error)}, + {"clear", DukCFunction(js_console_clear)}, + {"listen", DukCFunction(js_console_listen)}, { nullptr } }; DefineGlobalInterface(ctx, "console", props); } -duk_ret_t ScriptAPI::js_console_print(duk_context* ctx) +duk_ret_t ScriptAPI::js_console_print(duk_context * ctx) { stdstr out; ConcatArgs(ctx, out); @@ -26,7 +27,7 @@ duk_ret_t ScriptAPI::js_console_print(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js_console_log(duk_context* ctx) +duk_ret_t ScriptAPI::js_console_log(duk_context * ctx) { stdstr out; ConcatArgs(ctx, out); @@ -34,14 +35,14 @@ duk_ret_t ScriptAPI::js_console_log(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js_console_error(duk_context* ctx) +duk_ret_t ScriptAPI::js_console_error(duk_context * ctx) { - CheckArgs(ctx, { Arg_OptAny }); + CheckArgs(ctx, {Arg_OptAny}); if (duk_is_error(ctx, 0)) { duk_get_prop_string(ctx, 0, "stack"); - const char* message = duk_get_string(ctx, -1); + const char * message = duk_get_string(ctx, -1); GetInstance(ctx)->System()->ConsoleLog("%s", message); return 0; } @@ -50,16 +51,16 @@ duk_ret_t ScriptAPI::js_console_error(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js_console_clear(duk_context* ctx) +duk_ret_t ScriptAPI::js_console_clear(duk_context * ctx) { CheckArgs(ctx, {}); GetInstance(ctx)->System()->ConsoleClear(); return 0; } -duk_ret_t ScriptAPI::js_console_listen(duk_context* ctx) +duk_ret_t ScriptAPI::js_console_listen(duk_context * ctx) { - CScriptInstance* inst = GetInstance(ctx); + CScriptInstance * inst = GetInstance(ctx); duk_push_global_object(ctx); duk_bool_t haveListener = duk_has_prop_string(ctx, -1, HS_gInputListener); @@ -87,11 +88,11 @@ duk_ret_t ScriptAPI::js_console_listen(duk_context* ctx) return ThrowInvalidArgsError(ctx); } -void ConcatArgs(duk_context* ctx, stdstr& out) +void ConcatArgs(duk_context * ctx, stdstr & out) { out = ""; duk_idx_t nargs = duk_get_top(ctx); - + // note: global JSON.stringify must be intact duk_get_global_string(ctx, "JSON"); diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_cpu.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_cpu.cpp index b5e95e56f..24672af1a 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_cpu.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_cpu.cpp @@ -1,24 +1,25 @@ #include "stdafx.h" + #include "ScriptAPI.h" #include -#pragma warning(disable: 4702) // disable unreachable code warning +#pragma warning(disable : 4702) // disable unreachable code warning -static duk_ret_t GPRGetImpl(duk_context* ctx, bool bUpper); -static duk_ret_t GPRSetImpl(duk_context* ctx, bool bUpper); -static duk_ret_t FPRGetImpl(duk_context* ctx, bool bDouble); -static duk_ret_t FPRSetImpl(duk_context* ctx, bool bDouble); +static duk_ret_t GPRGetImpl(duk_context * ctx, bool bUpper); +static duk_ret_t GPRSetImpl(duk_context * ctx, bool bUpper); +static duk_ret_t FPRGetImpl(duk_context * ctx, bool bDouble); +static duk_ret_t FPRSetImpl(duk_context * ctx, bool bDouble); -static int FPRIndex(const char* regName); -static int GPRIndex(const char* regName); -static uint32_t* COP0RegPtr(const char* regName); -static uint32_t* CPURegPtr(const char *regName); +static int FPRIndex(const char * regName); +static int GPRIndex(const char * regName); +static uint32_t * COP0RegPtr(const char * regName); +static uint32_t * CPURegPtr(const char * regName); -static duk_ret_t ThrowRegInvalidError(duk_context* ctx); -static duk_ret_t ThrowRegContextUnavailableError(duk_context* ctx); -static duk_ret_t ThrowRegAssignmentTypeError(duk_context* ctx); +static duk_ret_t ThrowRegInvalidError(duk_context * ctx); +static duk_ret_t ThrowRegContextUnavailableError(duk_context * ctx); +static duk_ret_t ThrowRegAssignmentTypeError(duk_context * ctx); -void ScriptAPI::Define_cpu(duk_context* ctx) +void ScriptAPI::Define_cpu(duk_context * ctx) { // todo cleanup @@ -28,15 +29,16 @@ void ScriptAPI::Define_cpu(duk_context* ctx) { nullptr, nullptr, 0 } \ } - const struct { - const char *key; + const struct + { + const char * key; const duk_function_list_entry functions[3]; } proxies[] = { - { "gpr", REG_PROXY_FUNCTIONS(js_cpu_gpr_get, js_cpu_gpr_set) }, - { "ugpr", REG_PROXY_FUNCTIONS(js_cpu_ugpr_get, js_cpu_ugpr_set) }, - { "fpr", REG_PROXY_FUNCTIONS(js_cpu_fpr_get, js_cpu_fpr_set) }, - { "dfpr", REG_PROXY_FUNCTIONS(js_cpu_dfpr_get, js_cpu_dfpr_set) }, - { "cop0", REG_PROXY_FUNCTIONS(js_cpu_cop0_get, js_cpu_cop0_set) }, + {"gpr", REG_PROXY_FUNCTIONS(js_cpu_gpr_get, js_cpu_gpr_set)}, + {"ugpr", REG_PROXY_FUNCTIONS(js_cpu_ugpr_get, js_cpu_ugpr_set)}, + {"fpr", REG_PROXY_FUNCTIONS(js_cpu_fpr_get, js_cpu_fpr_set)}, + {"dfpr", REG_PROXY_FUNCTIONS(js_cpu_dfpr_get, js_cpu_dfpr_set)}, + {"cop0", REG_PROXY_FUNCTIONS(js_cpu_cop0_get, js_cpu_cop0_set)}, { nullptr, nullptr } }; @@ -65,15 +67,15 @@ void ScriptAPI::Define_cpu(duk_context* ctx) duk_pop(ctx); } -duk_ret_t ScriptAPI::js_cpu_get(duk_context* ctx) +duk_ret_t ScriptAPI::js_cpu_get(duk_context * ctx) { if (g_Reg == nullptr) { return ThrowRegContextUnavailableError(ctx); } - const char* key = duk_get_string(ctx, 1); - uint32_t* pReg = CPURegPtr(key); + const char * key = duk_get_string(ctx, 1); + uint32_t * pReg = CPURegPtr(key); if (pReg == nullptr) { @@ -85,14 +87,14 @@ duk_ret_t ScriptAPI::js_cpu_get(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_cpu_set(duk_context* ctx) +duk_ret_t ScriptAPI::js_cpu_set(duk_context * ctx) { if (g_Reg == nullptr) { return ThrowRegContextUnavailableError(ctx); } - uint32_t* pReg = CPURegPtr(duk_get_string(ctx, 1)); + uint32_t * pReg = CPURegPtr(duk_get_string(ctx, 1)); if (!duk_is_number(ctx, 2) || pReg == nullptr) { @@ -104,47 +106,47 @@ duk_ret_t ScriptAPI::js_cpu_set(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_cpu_gpr_get(duk_context* ctx) +duk_ret_t ScriptAPI::js_cpu_gpr_get(duk_context * ctx) { return GPRGetImpl(ctx, false); } -duk_ret_t ScriptAPI::js_cpu_gpr_set(duk_context* ctx) +duk_ret_t ScriptAPI::js_cpu_gpr_set(duk_context * ctx) { return GPRSetImpl(ctx, false); } -duk_ret_t ScriptAPI::js_cpu_ugpr_get(duk_context* ctx) +duk_ret_t ScriptAPI::js_cpu_ugpr_get(duk_context * ctx) { return GPRGetImpl(ctx, true); } -duk_ret_t ScriptAPI::js_cpu_ugpr_set(duk_context* ctx) +duk_ret_t ScriptAPI::js_cpu_ugpr_set(duk_context * ctx) { return GPRSetImpl(ctx, true); } -duk_ret_t ScriptAPI::js_cpu_fpr_get(duk_context* ctx) +duk_ret_t ScriptAPI::js_cpu_fpr_get(duk_context * ctx) { return FPRGetImpl(ctx, false); } -duk_ret_t ScriptAPI::js_cpu_fpr_set(duk_context* ctx) +duk_ret_t ScriptAPI::js_cpu_fpr_set(duk_context * ctx) { return FPRSetImpl(ctx, false); } -duk_ret_t ScriptAPI::js_cpu_dfpr_get(duk_context* ctx) +duk_ret_t ScriptAPI::js_cpu_dfpr_get(duk_context * ctx) { return FPRGetImpl(ctx, true); } -duk_ret_t ScriptAPI::js_cpu_dfpr_set(duk_context* ctx) +duk_ret_t ScriptAPI::js_cpu_dfpr_set(duk_context * ctx) { return FPRSetImpl(ctx, true); } -duk_ret_t ScriptAPI::js_cpu_cop0_get(duk_context* ctx) +duk_ret_t ScriptAPI::js_cpu_cop0_get(duk_context * ctx) { if (g_Reg == nullptr) { @@ -156,15 +158,15 @@ duk_ret_t ScriptAPI::js_cpu_cop0_get(duk_context* ctx) return ThrowRegInvalidError(ctx); } - const char* name = duk_get_string(ctx, 1); - + const char * name = duk_get_string(ctx, 1); + if (strcmp(name, "cause") == 0) { duk_push_uint(ctx, (uint32_t)(g_Reg->FAKE_CAUSE_REGISTER | g_Reg->CAUSE_REGISTER)); return 1; } - uint32_t* reg = COP0RegPtr(name); + uint32_t * reg = COP0RegPtr(name); if (reg == nullptr) { @@ -175,7 +177,7 @@ duk_ret_t ScriptAPI::js_cpu_cop0_get(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_cpu_cop0_set(duk_context* ctx) +duk_ret_t ScriptAPI::js_cpu_cop0_set(duk_context * ctx) { if (g_Reg == nullptr) { @@ -187,8 +189,8 @@ duk_ret_t ScriptAPI::js_cpu_cop0_set(duk_context* ctx) return ThrowRegInvalidError(ctx); } - const char* name = duk_get_string(ctx, 1); - + const char * name = duk_get_string(ctx, 1); + if (!duk_is_number(ctx, 2)) { return ThrowRegAssignmentTypeError(ctx); @@ -205,7 +207,7 @@ duk_ret_t ScriptAPI::js_cpu_cop0_set(duk_context* ctx) return 1; } - uint32_t* reg = COP0RegPtr(name); + uint32_t * reg = COP0RegPtr(name); if (reg == nullptr) { @@ -217,7 +219,7 @@ duk_ret_t ScriptAPI::js_cpu_cop0_set(duk_context* ctx) return 1; } -static duk_ret_t GPRGetImpl(duk_context* ctx, bool bUpper) +static duk_ret_t GPRGetImpl(duk_context * ctx, bool bUpper) { int regIndex = -1; @@ -239,12 +241,12 @@ static duk_ret_t GPRGetImpl(duk_context* ctx, bool bUpper) { return ThrowRegInvalidError(ctx); } - - duk_push_uint(ctx, g_Reg->m_GPR[regIndex].UW[bUpper ? 1: 0]); + + duk_push_uint(ctx, g_Reg->m_GPR[regIndex].UW[bUpper ? 1 : 0]); return 1; } -static duk_ret_t GPRSetImpl(duk_context* ctx, bool bUpper) +static duk_ret_t GPRSetImpl(duk_context * ctx, bool bUpper) { int regIndex = -1; @@ -285,7 +287,7 @@ static duk_ret_t GPRSetImpl(duk_context* ctx, bool bUpper) return 1; } -static duk_ret_t FPRGetImpl(duk_context* ctx, bool bDouble) +static duk_ret_t FPRGetImpl(duk_context * ctx, bool bDouble) { int regIndex = -1; @@ -320,7 +322,7 @@ static duk_ret_t FPRGetImpl(duk_context* ctx, bool bDouble) return 1; } -static duk_ret_t FPRSetImpl(duk_context* ctx, bool bDouble) +static duk_ret_t FPRSetImpl(duk_context * ctx, bool bDouble) { int regIndex = -1; @@ -363,9 +365,9 @@ static duk_ret_t FPRSetImpl(duk_context* ctx, bool bDouble) return 1; } -static int GPRIndex(const char* regName) +static int GPRIndex(const char * regName) { - const char* names[] = { + const char * names[] = { "r0", "at", "v0", "v1", "a0", "a1", "a2", "a3", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", @@ -383,10 +385,10 @@ static int GPRIndex(const char* regName) return -1; } -static int FPRIndex(const char* regName) +static int FPRIndex(const char * regName) { - const char* names[32] = { - "f0", "f1", "f2", "f3", "f4","f5", "f6", "f7", "f8", + const char * names[32] = { + "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31" @@ -403,35 +405,36 @@ static int FPRIndex(const char* regName) return -1; } -static uint32_t* COP0RegPtr(const char *regName) +static uint32_t * COP0RegPtr(const char * regName) { if (g_Reg == nullptr) { return nullptr; } - struct { - const char* name; - uint32_t *ptr; + struct + { + const char * name; + uint32_t * ptr; } names[] = { - { "index", (uint32_t*)&g_Reg->INDEX_REGISTER }, - { "random", (uint32_t*)&g_Reg->RANDOM_REGISTER }, - { "entrylo0", (uint32_t*)&g_Reg->ENTRYLO0_REGISTER }, - { "entrylo1", (uint32_t*)&g_Reg->ENTRYLO1_REGISTER }, - { "context", (uint32_t*)&g_Reg->CONTEXT_REGISTER }, - { "pagemask", (uint32_t*)&g_Reg->PAGE_MASK_REGISTER }, - { "wired", (uint32_t*)&g_Reg->WIRED_REGISTER }, - { "badvaddr", (uint32_t*)&g_Reg->BAD_VADDR_REGISTER }, - { "count", (uint32_t*)&g_Reg->COUNT_REGISTER }, - { "entryhi", (uint32_t*)&g_Reg->ENTRYHI_REGISTER }, - { "compare", (uint32_t*)&g_Reg->COMPARE_REGISTER }, - { "status", (uint32_t*)&g_Reg->STATUS_REGISTER }, + {"index", (uint32_t *)&g_Reg->INDEX_REGISTER}, + {"random", (uint32_t *)&g_Reg->RANDOM_REGISTER}, + {"entrylo0", (uint32_t *)&g_Reg->ENTRYLO0_REGISTER}, + {"entrylo1", (uint32_t *)&g_Reg->ENTRYLO1_REGISTER}, + {"context", (uint32_t *)&g_Reg->CONTEXT_REGISTER}, + {"pagemask", (uint32_t *)&g_Reg->PAGE_MASK_REGISTER}, + {"wired", (uint32_t *)&g_Reg->WIRED_REGISTER}, + {"badvaddr", (uint32_t *)&g_Reg->BAD_VADDR_REGISTER}, + {"count", (uint32_t *)&g_Reg->COUNT_REGISTER}, + {"entryhi", (uint32_t *)&g_Reg->ENTRYHI_REGISTER}, + {"compare", (uint32_t *)&g_Reg->COMPARE_REGISTER}, + {"status", (uint32_t *)&g_Reg->STATUS_REGISTER}, //{ "cause", (uint32_t*)&g_Reg->CAUSE_REGISTER }, - { "epc", (uint32_t*)&g_Reg->EPC_REGISTER }, - { "config", (uint32_t*)&g_Reg->CONFIG_REGISTER }, - { "taglo", (uint32_t*)&g_Reg->TAGLO_REGISTER }, - { "taghi",(uint32_t*)&g_Reg->TAGHI_REGISTER }, - { "errorepc", (uint32_t*)&g_Reg->ERROREPC_REGISTER }, + {"epc", (uint32_t *)&g_Reg->EPC_REGISTER}, + {"config", (uint32_t *)&g_Reg->CONFIG_REGISTER}, + {"taglo", (uint32_t *)&g_Reg->TAGLO_REGISTER}, + {"taghi", (uint32_t *)&g_Reg->TAGHI_REGISTER}, + {"errorepc", (uint32_t *)&g_Reg->ERROREPC_REGISTER}, { nullptr, nullptr } }; @@ -446,7 +449,7 @@ static uint32_t* COP0RegPtr(const char *regName) return nullptr; } -static uint32_t* CPURegPtr(const char* key) +static uint32_t * CPURegPtr(const char * key) { if (g_Reg == nullptr) { @@ -481,19 +484,19 @@ static uint32_t* CPURegPtr(const char* key) return nullptr; } -static duk_ret_t ThrowRegInvalidError(duk_context* ctx) +static duk_ret_t ThrowRegInvalidError(duk_context * ctx) { duk_push_error_object(ctx, DUK_ERR_REFERENCE_ERROR, "invalid register name or number"); return duk_throw(ctx); } -static duk_ret_t ThrowRegContextUnavailableError(duk_context* ctx) +static duk_ret_t ThrowRegContextUnavailableError(duk_context * ctx) { duk_push_error_object(ctx, DUK_ERR_ERROR, "CPU register context is unavailable"); return duk_throw(ctx); } -static duk_ret_t ThrowRegAssignmentTypeError(duk_context* ctx) +static duk_ret_t ThrowRegAssignmentTypeError(duk_context * ctx) { duk_push_error_object(ctx, DUK_ERR_TYPE_ERROR, "invalid register value assignment"); return duk_throw(ctx); diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_debug.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_debug.cpp index c7149a938..f97f79af2 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_debug.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_debug.cpp @@ -1,16 +1,17 @@ -#include +#include "stdafx.h" + #include "ScriptAPI.h" #include -void ScriptAPI::Define_debug(duk_context* ctx) +void ScriptAPI::Define_debug(duk_context * ctx) { const DukPropListEntry props[] = { - { "breakhere", DukCFunction(js_debug_breakhere) }, - { "step", DukCFunction(js_debug_step) }, - { "skip", DukCFunction(js_debug_skip) }, - { "resume", DukCFunction(js_debug_resume) }, - { "showmemory", DukCFunction(js_debug_showmemory) }, - { "showcommands", DukCFunction(js_debug_showcommands) }, + {"breakhere", DukCFunction(js_debug_breakhere)}, + {"step", DukCFunction(js_debug_step)}, + {"skip", DukCFunction(js_debug_skip)}, + {"resume", DukCFunction(js_debug_resume)}, + {"showmemory", DukCFunction(js_debug_showmemory)}, + {"showcommands", DukCFunction(js_debug_showcommands)}, { "paused", DukGetter(js_debug__get_paused) }, { nullptr } }; @@ -18,11 +19,11 @@ void ScriptAPI::Define_debug(duk_context* ctx) DefineGlobalInterface(ctx, "debug", props); } -duk_ret_t ScriptAPI::js_debug_breakhere(duk_context* ctx) +duk_ret_t ScriptAPI::js_debug_breakhere(duk_context * ctx) { - CheckArgs(ctx, { Arg_OptBoolean }); + CheckArgs(ctx, {Arg_OptBoolean}); - if (duk_get_boolean_default(ctx, 0, (duk_bool_t)false) == 1) + if (duk_get_boolean_default(ctx, 0, (duk_bool_t) false) == 1) { g_Settings->SaveBool(Debugger_SilentBreak, true); } @@ -30,11 +31,11 @@ duk_ret_t ScriptAPI::js_debug_breakhere(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js_debug_step(duk_context* ctx) +duk_ret_t ScriptAPI::js_debug_step(duk_context * ctx) { CheckArgs(ctx, {}); - if (g_Settings->LoadBool(Debugger_SteppingOps) && + if (g_Settings->LoadBool(Debugger_SteppingOps) && CDebugSettings::WaitingForStep()) { g_Settings->SaveBool(Debugger_SilentBreak, true); @@ -43,7 +44,7 @@ duk_ret_t ScriptAPI::js_debug_step(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js_debug_skip(duk_context* ctx) +duk_ret_t ScriptAPI::js_debug_skip(duk_context * ctx) { CheckArgs(ctx, {}); @@ -57,9 +58,9 @@ duk_ret_t ScriptAPI::js_debug_skip(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js_debug_showmemory(duk_context* ctx) +duk_ret_t ScriptAPI::js_debug_showmemory(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number, Arg_OptBoolean }); + CheckArgs(ctx, {Arg_Number, Arg_OptBoolean}); uint32_t address = duk_get_uint(ctx, 0); bool bPhysical = duk_get_boolean_default(ctx, 1, 0) ? true : false; @@ -68,15 +69,15 @@ duk_ret_t ScriptAPI::js_debug_showmemory(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js_debug_showcommands(duk_context* ctx) +duk_ret_t ScriptAPI::js_debug_showcommands(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number }); + CheckArgs(ctx, {Arg_Number}); uint32_t address = duk_get_uint(ctx, 0); GetInstance(ctx)->Debugger()->Debug_ShowCommandsLocation(address, true); return 0; } -duk_ret_t ScriptAPI::js_debug_resume(duk_context* ctx) +duk_ret_t ScriptAPI::js_debug_resume(duk_context * ctx) { CheckArgs(ctx, {}); @@ -89,7 +90,7 @@ duk_ret_t ScriptAPI::js_debug_resume(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js_debug__get_paused(duk_context* ctx) +duk_ret_t ScriptAPI::js_debug__get_paused(duk_context * ctx) { duk_push_boolean(ctx, CDebugSettings::WaitingForStep() && g_Settings->LoadBool(Debugger_SteppingOps)); return 1; diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_events.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_events.cpp index cfff62aae..c191ae346 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_events.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_events.cpp @@ -1,47 +1,48 @@ -#include -#include "ScriptAPI.h" -#include "../OpInfo.h" +#include "stdafx.h" -#pragma warning(disable: 4702) // disable unreachable code warning +#include "../OpInfo.h" +#include "ScriptAPI.h" + +#pragma warning(disable : 4702) // disable unreachable code warning using namespace ScriptAPI; -static bool CbCond_PcBetween(JSAppCallback* cb, void* env); -static bool CbCond_ReadAddrBetween(JSAppCallback* cb, void* env); -static bool CbCond_WriteAddrBetween(JSAppCallback* cb, void* env); -static bool CbCond_PcBetween_OpcodeEquals(JSAppCallback* cb, void* env); -static bool CbCond_PcBetween_GprValueEquals(JSAppCallback* cb, void* env); +static bool CbCond_PcBetween(JSAppCallback * cb, void * env); +static bool CbCond_ReadAddrBetween(JSAppCallback * cb, void * env); +static bool CbCond_WriteAddrBetween(JSAppCallback * cb, void * env); +static bool CbCond_PcBetween_OpcodeEquals(JSAppCallback * cb, void * env); +static bool CbCond_PcBetween_GprValueEquals(JSAppCallback * cb, void * env); -static duk_idx_t CbArgs_GenericEventObject(duk_context* ctx, void* env); -static duk_idx_t CbArgs_EmuStateChangeEventObject(duk_context* ctx, void* env); -static duk_idx_t CbArgs_ExecEventObject(duk_context* ctx, void* env); -static duk_idx_t CbArgs_ReadEventObject(duk_context* ctx, void* env); -static duk_idx_t CbArgs_WriteEventObject(duk_context* ctx, void* env); -static duk_idx_t CbArgs_OpcodeEventObject(duk_context* ctx, void* env); -static duk_idx_t CbArgs_RegValueEventObject(duk_context* ctx, void* env); -static duk_idx_t CbArgs_MouseEventObject(duk_context* ctx, void* env); -static duk_idx_t CbArgs_SPTaskEventObject(duk_context* ctx, void* env); -static duk_idx_t CbArgs_PIEventObject(duk_context* ctx, void* env); +static duk_idx_t CbArgs_GenericEventObject(duk_context * ctx, void * env); +static duk_idx_t CbArgs_EmuStateChangeEventObject(duk_context * ctx, void * env); +static duk_idx_t CbArgs_ExecEventObject(duk_context * ctx, void * env); +static duk_idx_t CbArgs_ReadEventObject(duk_context * ctx, void * env); +static duk_idx_t CbArgs_WriteEventObject(duk_context * ctx, void * env); +static duk_idx_t CbArgs_OpcodeEventObject(duk_context * ctx, void * env); +static duk_idx_t CbArgs_RegValueEventObject(duk_context * ctx, void * env); +static duk_idx_t CbArgs_MouseEventObject(duk_context * ctx, void * env); +static duk_idx_t CbArgs_SPTaskEventObject(duk_context * ctx, void * env); +static duk_idx_t CbArgs_PIEventObject(duk_context * ctx, void * env); -static duk_ret_t RequireAddressOrAddressRange(duk_context* ctx, duk_idx_t idx, uint32_t* addrStart, uint32_t *addrEnd); -static duk_ret_t RequireInterpreterCPU(duk_context* ctx); +static duk_ret_t RequireAddressOrAddressRange(duk_context * ctx, duk_idx_t idx, uint32_t * addrStart, uint32_t * addrEnd); +static duk_ret_t RequireInterpreterCPU(duk_context * ctx); -void ScriptAPI::Define_events(duk_context* ctx) +void ScriptAPI::Define_events(duk_context * ctx) { const DukPropListEntry props[] = { - { "onstatechange", DukCFunction(js_events_onstatechange) }, - { "onexec", DukCFunction(js_events_onexec) }, - { "onread", DukCFunction(js_events_onread) }, - { "onwrite", DukCFunction(js_events_onwrite) }, - { "ongprvalue", DukCFunction(js_events_ongprvalue) }, - { "onopcode", DukCFunction(js_events_onopcode) }, - { "onpifread", DukCFunction(js_events_onpifread) }, - { "onsptask", DukCFunction(js_events_onsptask) }, - { "onpidma", DukCFunction(js_events_onpidma) }, - { "onmouseup", DukCFunction(js_events_onmouseup) }, - { "onmousedown", DukCFunction(js_events_onmousedown) }, - { "onmousemove", DukCFunction(js_events_onmousemove) }, - { "remove", DukCFunction(js_events_remove) }, + {"onstatechange", DukCFunction(js_events_onstatechange)}, + {"onexec", DukCFunction(js_events_onexec)}, + {"onread", DukCFunction(js_events_onread)}, + {"onwrite", DukCFunction(js_events_onwrite)}, + {"ongprvalue", DukCFunction(js_events_ongprvalue)}, + {"onopcode", DukCFunction(js_events_onopcode)}, + {"onpifread", DukCFunction(js_events_onpifread)}, + {"onsptask", DukCFunction(js_events_onsptask)}, + {"onpidma", DukCFunction(js_events_onpidma)}, + {"onmouseup", DukCFunction(js_events_onmouseup)}, + {"onmousedown", DukCFunction(js_events_onmousedown)}, + {"onmousemove", DukCFunction(js_events_onmousemove)}, + {"remove", DukCFunction(js_events_remove)}, { nullptr } }; @@ -58,10 +59,10 @@ void ScriptAPI::Define_events(duk_context* ctx) DefineGlobalClass(ctx, "DrawEvent", js_DummyConstructor); const DukPropListEntry mouseEventStaticProps[] = { - { "NONE", DukNumber(-1) }, - { "LEFT", DukNumber(0) }, - { "MIDDLE", DukNumber(1) }, - { "RIGHT", DukNumber(2) }, + {"NONE", DukNumber(-1)}, + {"LEFT", DukNumber(0)}, + {"MIDDLE", DukNumber(1)}, + {"RIGHT", DukNumber(2)}, {nullptr} }; @@ -70,17 +71,17 @@ void ScriptAPI::Define_events(duk_context* ctx) duk_ret_t ScriptAPI::js_events_onstatechange(duk_context * ctx) { - CheckArgs(ctx, { Arg_Function }); + CheckArgs(ctx, {Arg_Function}); JSAppCallbackID callbackId = AddAppCallback(ctx, 0, JS_HOOK_EMUSTATECHANGE, - CbArgs_EmuStateChangeEventObject); + CbArgs_EmuStateChangeEventObject); duk_push_uint(ctx, callbackId); return 1; } -duk_ret_t ScriptAPI::js_events_onexec(duk_context* ctx) +duk_ret_t ScriptAPI::js_events_onexec(duk_context * ctx) { - CheckArgs(ctx, { Arg_Any, Arg_Function }); + CheckArgs(ctx, {Arg_Any, Arg_Function}); uint32_t addrStart, addrEnd; RequireAddressOrAddressRange(ctx, 0, &addrStart, &addrEnd); @@ -88,7 +89,7 @@ duk_ret_t ScriptAPI::js_events_onexec(duk_context* ctx) RequireInterpreterCPU(ctx); JSAppCallback cb(GetInstance(ctx), duk_get_heapptr(ctx, 1), - CbCond_PcBetween, CbArgs_ExecEventObject); + CbCond_PcBetween, CbArgs_ExecEventObject); cb.m_Params.addrStart = addrStart; cb.m_Params.addrEnd = addrEnd; @@ -98,9 +99,9 @@ duk_ret_t ScriptAPI::js_events_onexec(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_events_onread(duk_context* ctx) +duk_ret_t ScriptAPI::js_events_onread(duk_context * ctx) { - CheckArgs(ctx, { Arg_Any, Arg_Function }); + CheckArgs(ctx, {Arg_Any, Arg_Function}); uint32_t addrStart, addrEnd; RequireAddressOrAddressRange(ctx, 0, &addrStart, &addrEnd); @@ -108,7 +109,7 @@ duk_ret_t ScriptAPI::js_events_onread(duk_context* ctx) RequireInterpreterCPU(ctx); JSAppCallback cb(GetInstance(ctx), duk_get_heapptr(ctx, 1), - CbCond_ReadAddrBetween, CbArgs_ReadEventObject); + CbCond_ReadAddrBetween, CbArgs_ReadEventObject); cb.m_Params.addrStart = addrStart; cb.m_Params.addrEnd = addrEnd; @@ -118,9 +119,9 @@ duk_ret_t ScriptAPI::js_events_onread(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_events_onwrite(duk_context* ctx) +duk_ret_t ScriptAPI::js_events_onwrite(duk_context * ctx) { - CheckArgs(ctx, { Arg_Any, Arg_Function }); + CheckArgs(ctx, {Arg_Any, Arg_Function}); uint32_t addrStart, addrEnd; RequireAddressOrAddressRange(ctx, 0, &addrStart, &addrEnd); @@ -128,7 +129,7 @@ duk_ret_t ScriptAPI::js_events_onwrite(duk_context* ctx) RequireInterpreterCPU(ctx); JSAppCallback cb(GetInstance(ctx), duk_get_heapptr(ctx, 1), - CbCond_WriteAddrBetween, CbArgs_WriteEventObject); + CbCond_WriteAddrBetween, CbArgs_WriteEventObject); cb.m_Params.addrStart = addrStart; cb.m_Params.addrEnd = addrEnd; @@ -138,9 +139,9 @@ duk_ret_t ScriptAPI::js_events_onwrite(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_events_onopcode(duk_context* ctx) +duk_ret_t ScriptAPI::js_events_onopcode(duk_context * ctx) { - CheckArgs(ctx, { Arg_Any, Arg_Number, Arg_Number, Arg_Function }); + CheckArgs(ctx, {Arg_Any, Arg_Number, Arg_Number, Arg_Function}); uint32_t addrStart, addrEnd; RequireAddressOrAddressRange(ctx, 0, &addrStart, &addrEnd); @@ -151,7 +152,7 @@ duk_ret_t ScriptAPI::js_events_onopcode(duk_context* ctx) uint32_t mask = duk_get_uint(ctx, 2); JSAppCallback cb(GetInstance(ctx), duk_get_heapptr(ctx, 3), - CbCond_PcBetween_OpcodeEquals, CbArgs_OpcodeEventObject); + CbCond_PcBetween_OpcodeEquals, CbArgs_OpcodeEventObject); cb.m_Params.addrStart = addrStart; cb.m_Params.addrEnd = addrEnd; cb.m_Params.opcode = opcode; @@ -163,9 +164,9 @@ duk_ret_t ScriptAPI::js_events_onopcode(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_events_ongprvalue(duk_context* ctx) +duk_ret_t ScriptAPI::js_events_ongprvalue(duk_context * ctx) { - CheckArgs(ctx, { Arg_Any, Arg_Number, Arg_Number, Arg_Function }); + CheckArgs(ctx, {Arg_Any, Arg_Number, Arg_Number, Arg_Function}); uint32_t addrStart, addrEnd; RequireAddressOrAddressRange(ctx, 0, &addrStart, &addrEnd); @@ -173,7 +174,7 @@ duk_ret_t ScriptAPI::js_events_ongprvalue(duk_context* ctx) RequireInterpreterCPU(ctx); JSAppCallback cb(GetInstance(ctx), duk_get_heapptr(ctx, 3), - CbCond_PcBetween_GprValueEquals, CbArgs_RegValueEventObject); + CbCond_PcBetween_GprValueEquals, CbArgs_RegValueEventObject); cb.m_Params.addrStart = addrStart; cb.m_Params.addrEnd = addrEnd; cb.m_Params.regIndices = duk_get_uint(ctx, 1); @@ -185,63 +186,63 @@ duk_ret_t ScriptAPI::js_events_ongprvalue(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_events_onpifread(duk_context* ctx) +duk_ret_t ScriptAPI::js_events_onpifread(duk_context * ctx) { - CheckArgs(ctx, { Arg_Function }); + CheckArgs(ctx, {Arg_Function}); JSAppCallbackID callbackId = AddAppCallback(ctx, 0, JS_HOOK_PIFREAD, CbArgs_GenericEventObject); duk_push_uint(ctx, callbackId); return 1; } -duk_ret_t ScriptAPI::js_events_onsptask(duk_context* ctx) +duk_ret_t ScriptAPI::js_events_onsptask(duk_context * ctx) { - CheckArgs(ctx, { Arg_Function }); + CheckArgs(ctx, {Arg_Function}); JSAppCallbackID callbackId = AddAppCallback(ctx, 0, JS_HOOK_RSPTASK, CbArgs_SPTaskEventObject); duk_push_uint(ctx, callbackId); return 1; } -duk_ret_t ScriptAPI::js_events_onpidma(duk_context* ctx) +duk_ret_t ScriptAPI::js_events_onpidma(duk_context * ctx) { - CheckArgs(ctx, { Arg_Function }); + CheckArgs(ctx, {Arg_Function}); JSAppCallbackID callbackId = AddAppCallback(ctx, 0, JS_HOOK_PIDMA, CbArgs_PIEventObject); duk_push_uint(ctx, callbackId); return 1; } -duk_ret_t ScriptAPI::js_events_onmouseup(duk_context* ctx) +duk_ret_t ScriptAPI::js_events_onmouseup(duk_context * ctx) { - CheckArgs(ctx, { Arg_Function }); + CheckArgs(ctx, {Arg_Function}); JSAppCallbackID callbackId = AddAppCallback(ctx, 0, JS_HOOK_MOUSEUP, CbArgs_MouseEventObject); duk_push_uint(ctx, callbackId); return 1; } -duk_ret_t ScriptAPI::js_events_onmousedown(duk_context* ctx) +duk_ret_t ScriptAPI::js_events_onmousedown(duk_context * ctx) { - CheckArgs(ctx, { Arg_Function }); + CheckArgs(ctx, {Arg_Function}); JSAppCallbackID callbackId = AddAppCallback(ctx, 0, JS_HOOK_MOUSEDOWN, CbArgs_MouseEventObject); duk_push_uint(ctx, callbackId); return 1; } -duk_ret_t ScriptAPI::js_events_onmousemove(duk_context* ctx) +duk_ret_t ScriptAPI::js_events_onmousemove(duk_context * ctx) { - CheckArgs(ctx, { Arg_Function }); + CheckArgs(ctx, {Arg_Function}); JSAppCallbackID callbackId = AddAppCallback(ctx, 0, JS_HOOK_MOUSEMOVE, CbArgs_MouseEventObject); duk_push_uint(ctx, callbackId); return 1; } -duk_ret_t ScriptAPI::js_events_remove(duk_context* ctx) +duk_ret_t ScriptAPI::js_events_remove(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number }); + CheckArgs(ctx, {Arg_Number}); JSAppCallbackID callbackId = (JSAppCallbackID)duk_get_uint(ctx, 0); @@ -254,9 +255,9 @@ duk_ret_t ScriptAPI::js_events_remove(duk_context* ctx) return 0; } -bool CbCond_ReadAddrBetween(JSAppCallback* cb, void* _env) +bool CbCond_ReadAddrBetween(JSAppCallback * cb, void * _env) { - JSHookCpuStepEnv* env = (JSHookCpuStepEnv*)_env; + JSHookCpuStepEnv * env = (JSHookCpuStepEnv *)_env; if (!env->opInfo.IsLoadCommand()) { @@ -269,9 +270,9 @@ bool CbCond_ReadAddrBetween(JSAppCallback* cb, void* _env) addr <= cb->m_Params.addrEnd); } -bool CbCond_WriteAddrBetween(JSAppCallback* cb, void* _env) +bool CbCond_WriteAddrBetween(JSAppCallback * cb, void * _env) { - JSHookCpuStepEnv* env = (JSHookCpuStepEnv*)_env; + JSHookCpuStepEnv * env = (JSHookCpuStepEnv *)_env; if (!env->opInfo.IsStoreCommand()) { @@ -284,38 +285,38 @@ bool CbCond_WriteAddrBetween(JSAppCallback* cb, void* _env) addr <= cb->m_Params.addrEnd); } -bool CbCond_PcBetween(JSAppCallback* cb, void* _env) +bool CbCond_PcBetween(JSAppCallback * cb, void * _env) { - JSHookCpuStepEnv* env = (JSHookCpuStepEnv*)_env; + JSHookCpuStepEnv * env = (JSHookCpuStepEnv *)_env; return (env->pc >= cb->m_Params.addrStart && env->pc <= cb->m_Params.addrEnd); } -bool CbCond_PcBetween_OpcodeEquals(JSAppCallback* cb, void* _env) +bool CbCond_PcBetween_OpcodeEquals(JSAppCallback * cb, void * _env) { if (!CbCond_PcBetween(cb, _env)) { return false; } - JSHookCpuStepEnv* env = (JSHookCpuStepEnv*)_env; + JSHookCpuStepEnv * env = (JSHookCpuStepEnv *)_env; return cb->m_Params.opcode == (env->opInfo.m_OpCode.Value & cb->m_Params.opcodeMask); } -static bool CbCond_PcBetween_GprValueEquals(JSAppCallback* cb, void* _env) +static bool CbCond_PcBetween_GprValueEquals(JSAppCallback * cb, void * _env) { if (!CbCond_PcBetween(cb, _env)) { return false; } - JSHookCpuStepEnv* env = (JSHookCpuStepEnv*)_env; + JSHookCpuStepEnv * env = (JSHookCpuStepEnv *)_env; - for(int i = 0; i < 32; i++) + for (int i = 0; i < 32; i++) { - if(cb->m_Params.regIndices & (1 << i)) + if (cb->m_Params.regIndices & (1 << i)) { - if(g_Reg->m_GPR[i].UW[0] == cb->m_Params.regValue) + if (g_Reg->m_GPR[i].UW[0] == cb->m_Params.regValue) { env->outAffectedRegIndex = i; return true; @@ -326,16 +327,16 @@ static bool CbCond_PcBetween_GprValueEquals(JSAppCallback* cb, void* _env) return false; } -duk_idx_t CbArgs_EmuStateChangeEventObject(duk_context* ctx, void* _env) +duk_idx_t CbArgs_EmuStateChangeEventObject(duk_context * ctx, void * _env) { - CScriptInstance* inst = GetInstance(ctx); - JSHookEmuStateChangeEnv* env = (JSHookEmuStateChangeEnv*)_env; + CScriptInstance * inst = GetInstance(ctx); + JSHookEmuStateChangeEnv * env = (JSHookEmuStateChangeEnv *)_env; duk_push_object(ctx); SetDummyConstructor(ctx, -1, "EmuStateChangeEvent"); const DukPropListEntry props[] = { - { "callbackId", DukUInt(inst->CallbackId()) }, - { "state", DukUInt(env->state) }, + {"callbackId", DukUInt(inst->CallbackId())}, + {"state", DukUInt(env->state)}, { nullptr } }; @@ -344,14 +345,14 @@ duk_idx_t CbArgs_EmuStateChangeEventObject(duk_context* ctx, void* _env) return 1; } -duk_idx_t CbArgs_GenericEventObject(duk_context* ctx, void* /*_env*/) +duk_idx_t CbArgs_GenericEventObject(duk_context * ctx, void * /*_env*/) { - CScriptInstance* inst = GetInstance(ctx); + CScriptInstance * inst = GetInstance(ctx); duk_push_object(ctx); SetDummyConstructor(ctx, -1, "GenericEvent"); - + const DukPropListEntry props[] = { - { "callbackId", DukUInt(inst->CallbackId()) }, + {"callbackId", DukUInt(inst->CallbackId())}, { nullptr } }; @@ -360,16 +361,16 @@ duk_idx_t CbArgs_GenericEventObject(duk_context* ctx, void* /*_env*/) return 1; } -duk_idx_t CbArgs_ExecEventObject(duk_context* ctx, void* _env) +duk_idx_t CbArgs_ExecEventObject(duk_context * ctx, void * _env) { - CScriptInstance* inst = GetInstance(ctx); - JSHookCpuStepEnv* env = (JSHookCpuStepEnv*)_env; + CScriptInstance * inst = GetInstance(ctx); + JSHookCpuStepEnv * env = (JSHookCpuStepEnv *)_env; duk_push_object(ctx); SetDummyConstructor(ctx, -1, "CPUExecEvent"); - + const DukPropListEntry props[] = { - { "callbackId", DukUInt(inst->CallbackId()) }, - { "pc", DukUInt(env->pc) }, + {"callbackId", DukUInt(inst->CallbackId())}, + {"pc", DukUInt(env->pc)}, { nullptr } }; @@ -378,12 +379,12 @@ duk_idx_t CbArgs_ExecEventObject(duk_context* ctx, void* _env) return 1; } -duk_idx_t CbArgs_ReadEventObject(duk_context* ctx, void* _env) +duk_idx_t CbArgs_ReadEventObject(duk_context * ctx, void * _env) { - CScriptInstance* inst = GetInstance(ctx); - CDebuggerUI* debugger = inst->Debugger(); - JSHookCpuStepEnv* env = (JSHookCpuStepEnv*)_env; - + CScriptInstance * inst = GetInstance(ctx); + CDebuggerUI * debugger = inst->Debugger(); + JSHookCpuStepEnv * env = (JSHookCpuStepEnv *)_env; + uint32_t address = env->opInfo.GetLoadStoreAddress(); uint8_t op = env->opInfo.m_OpCode.op; @@ -394,17 +395,18 @@ duk_idx_t CbArgs_ReadEventObject(duk_context* ctx, void* _env) SetDummyConstructor(ctx, -1, "CPUReadWriteEvent"); const DukPropListEntry props[] = { - { "callbackId", DukUInt(inst->CallbackId()) }, - { "pc", DukUInt(env->pc) }, - { "address", DukUInt(address) }, - { "reg", DukUInt(rt) }, - { "fpu", DukBoolean(bFPU) }, + {"callbackId", DukUInt(inst->CallbackId())}, + {"pc", DukUInt(env->pc)}, + {"address", DukUInt(address)}, + {"reg", DukUInt(rt)}, + {"fpu", DukBoolean(bFPU)}, { nullptr } }; DukPutPropList(ctx, -1, props); - union { + union + { uint8_t u8; int8_t s8; uint16_t u16; @@ -415,9 +417,9 @@ duk_idx_t CbArgs_ReadEventObject(duk_context* ctx, void* _env) double f64; uint64_t u64; } value = {0}; - + bool bNeedUpper32 = false; - + switch (env->opInfo.m_OpCode.op) { case R4300i_LB: @@ -528,11 +530,11 @@ duk_idx_t CbArgs_ReadEventObject(duk_context* ctx, void* _env) return 1; } -duk_idx_t CbArgs_WriteEventObject(duk_context* ctx, void* _env) +duk_idx_t CbArgs_WriteEventObject(duk_context * ctx, void * _env) { - CScriptInstance* inst = GetInstance(ctx); - CDebuggerUI* debugger = inst->Debugger(); - JSHookCpuStepEnv* env = (JSHookCpuStepEnv*)_env; + CScriptInstance * inst = GetInstance(ctx); + CDebuggerUI * debugger = inst->Debugger(); + JSHookCpuStepEnv * env = (JSHookCpuStepEnv *)_env; uint32_t address = env->opInfo.GetLoadStoreAddress(); @@ -544,11 +546,11 @@ duk_idx_t CbArgs_WriteEventObject(duk_context* ctx, void* _env) SetDummyConstructor(ctx, -1, "CPUReadWriteEvent"); const DukPropListEntry props[] = { - { "callbackId", DukUInt(inst->CallbackId()) }, - { "pc", DukUInt(env->pc) }, - { "address", DukUInt(address) }, - { "reg", DukUInt(rt) }, - { "fpu", DukBoolean(bFPU) }, + {"callbackId", DukUInt(inst->CallbackId())}, + {"pc", DukUInt(env->pc)}, + {"address", DukUInt(address)}, + {"reg", DukUInt(rt)}, + {"fpu", DukBoolean(bFPU)}, { nullptr } }; @@ -640,21 +642,21 @@ duk_idx_t CbArgs_WriteEventObject(duk_context* ctx, void* _env) } duk_freeze(ctx, -1); - + return 1; } -duk_idx_t CbArgs_OpcodeEventObject(duk_context* ctx, void* _env) +duk_idx_t CbArgs_OpcodeEventObject(duk_context * ctx, void * _env) { - CScriptInstance* inst = GetInstance(ctx); - JSHookCpuStepEnv* env = (JSHookCpuStepEnv*)_env; + CScriptInstance * inst = GetInstance(ctx); + JSHookCpuStepEnv * env = (JSHookCpuStepEnv *)_env; duk_push_object(ctx); SetDummyConstructor(ctx, -1, "CPUOpcodeEvent"); const DukPropListEntry props[] = { - { "callbackId", DukUInt(inst->CallbackId()) }, - { "pc", DukUInt(env->pc) }, - { "opcode", DukUInt(env->opInfo.m_OpCode.Value) }, + {"callbackId", DukUInt(inst->CallbackId())}, + {"pc", DukUInt(env->pc)}, + {"opcode", DukUInt(env->opInfo.m_OpCode.Value)}, { nullptr } }; @@ -663,18 +665,18 @@ duk_idx_t CbArgs_OpcodeEventObject(duk_context* ctx, void* _env) return 1; } -duk_idx_t CbArgs_RegValueEventObject(duk_context* ctx, void* _env) +duk_idx_t CbArgs_RegValueEventObject(duk_context * ctx, void * _env) { - CScriptInstance* inst = GetInstance(ctx); - JSHookCpuStepEnv* env = (JSHookCpuStepEnv*)_env; + CScriptInstance * inst = GetInstance(ctx); + JSHookCpuStepEnv * env = (JSHookCpuStepEnv *)_env; duk_push_object(ctx); SetDummyConstructor(ctx, -1, "CPURegValueEvent"); const DukPropListEntry props[] = { - { "callbackId", DukUInt(inst->CallbackId()) }, - { "pc", DukUInt(env->pc) }, - { "value", DukUInt(g_Reg->m_GPR[env->outAffectedRegIndex].UW[0]) }, - { "reg", DukUInt(env->outAffectedRegIndex) }, + {"callbackId", DukUInt(inst->CallbackId())}, + {"pc", DukUInt(env->pc)}, + {"value", DukUInt(g_Reg->m_GPR[env->outAffectedRegIndex].UW[0])}, + {"reg", DukUInt(env->outAffectedRegIndex)}, { nullptr } }; @@ -683,18 +685,18 @@ duk_idx_t CbArgs_RegValueEventObject(duk_context* ctx, void* _env) return 1; } -static duk_idx_t CbArgs_MouseEventObject(duk_context* ctx, void* _env) +static duk_idx_t CbArgs_MouseEventObject(duk_context * ctx, void * _env) { - CScriptInstance* inst = GetInstance(ctx); - JSHookMouseEnv* env = (JSHookMouseEnv*)_env; + CScriptInstance * inst = GetInstance(ctx); + JSHookMouseEnv * env = (JSHookMouseEnv *)_env; duk_push_object(ctx); SetDummyConstructor(ctx, -1, "MouseEvent"); const DukPropListEntry props[] = { - { "callbackId", DukUInt(inst->CallbackId()) }, - { "button", DukInt(env->button) }, - { "x", DukInt(env->x) }, - { "y", DukInt(env->y) }, + {"callbackId", DukUInt(inst->CallbackId())}, + {"button", DukInt(env->button)}, + {"x", DukInt(env->x)}, + {"y", DukInt(env->y)}, { nullptr } }; @@ -703,31 +705,31 @@ static duk_idx_t CbArgs_MouseEventObject(duk_context* ctx, void* _env) return 1; } -static duk_idx_t CbArgs_SPTaskEventObject(duk_context* ctx, void* _env) +static duk_idx_t CbArgs_SPTaskEventObject(duk_context * ctx, void * _env) { - CScriptInstance* inst = GetInstance(ctx); - JSHookSpTaskEnv* env = (JSHookSpTaskEnv*)_env; + CScriptInstance * inst = GetInstance(ctx); + JSHookSpTaskEnv * env = (JSHookSpTaskEnv *)_env; duk_push_object(ctx); SetDummyConstructor(ctx, -1, "SPTaskEvent"); const DukPropListEntry props[] = { - { "callbackId", DukUInt(inst->CallbackId()) }, - { "taskType", DukUInt(env->taskType) }, - { "taskFlags", DukUInt(env->taskFlags) }, - { "ucodeBootAddress", DukUInt(env->ucodeBootAddress | 0x80000000) }, - { "ucodeBootSize", DukUInt(env->ucodeBootSize) }, - { "ucodeAddress", DukUInt(env->ucodeAddress | 0x80000000) }, - { "ucodeSize", DukUInt(env->ucodeSize) }, - { "ucodeDataAddress", DukUInt(env->ucodeDataAddress | 0x80000000) }, - { "ucodeDataSize", DukUInt(env->ucodeDataSize) }, - { "dramStackAddress", DukUInt(env->dramStackAddress | 0x80000000) }, - { "dramStackSize", DukUInt(env->dramStackSize) }, - { "outputBuffAddress", DukUInt(env->outputBuffAddress | 0x80000000) }, - { "outputBuffSize", DukUInt(env->outputBuffSize) }, - { "dataAddress", DukUInt(env->dataAddress | 0x80000000) }, - { "dataSize", DukUInt(env->dataSize) }, - { "yieldDataAddress", DukUInt(env->yieldDataAddress | 0x80000000) }, - { "yieldDataSize", DukUInt(env->yieldDataSize) }, + {"callbackId", DukUInt(inst->CallbackId())}, + {"taskType", DukUInt(env->taskType)}, + {"taskFlags", DukUInt(env->taskFlags)}, + {"ucodeBootAddress", DukUInt(env->ucodeBootAddress | 0x80000000)}, + {"ucodeBootSize", DukUInt(env->ucodeBootSize)}, + {"ucodeAddress", DukUInt(env->ucodeAddress | 0x80000000)}, + {"ucodeSize", DukUInt(env->ucodeSize)}, + {"ucodeDataAddress", DukUInt(env->ucodeDataAddress | 0x80000000)}, + {"ucodeDataSize", DukUInt(env->ucodeDataSize)}, + {"dramStackAddress", DukUInt(env->dramStackAddress | 0x80000000)}, + {"dramStackSize", DukUInt(env->dramStackSize)}, + {"outputBuffAddress", DukUInt(env->outputBuffAddress | 0x80000000)}, + {"outputBuffSize", DukUInt(env->outputBuffSize)}, + {"dataAddress", DukUInt(env->dataAddress | 0x80000000)}, + {"dataSize", DukUInt(env->dataSize)}, + {"yieldDataAddress", DukUInt(env->yieldDataAddress | 0x80000000)}, + {"yieldDataSize", DukUInt(env->yieldDataSize)}, { nullptr } }; @@ -736,19 +738,19 @@ static duk_idx_t CbArgs_SPTaskEventObject(duk_context* ctx, void* _env) return 1; } -static duk_idx_t CbArgs_PIEventObject(duk_context* ctx, void* _env) +static duk_idx_t CbArgs_PIEventObject(duk_context * ctx, void * _env) { - CScriptInstance* inst = GetInstance(ctx); - JSHookPiDmaEnv* env = (JSHookPiDmaEnv*)_env; + CScriptInstance * inst = GetInstance(ctx); + JSHookPiDmaEnv * env = (JSHookPiDmaEnv *)_env; duk_push_object(ctx); SetDummyConstructor(ctx, -1, "PIEvent"); const DukPropListEntry props[] = { - { "callbackId", DukUInt(inst->CallbackId()) }, - { "direction", DukUInt(env->direction) }, - { "dramAddress", DukUInt(env->dramAddress | 0x80000000) }, - { "cartAddress", DukUInt(env->cartAddress | 0xA0000000) }, - { "length", DukUInt(env->length + 1) }, + {"callbackId", DukUInt(inst->CallbackId())}, + {"direction", DukUInt(env->direction)}, + {"dramAddress", DukUInt(env->dramAddress | 0x80000000)}, + {"cartAddress", DukUInt(env->cartAddress | 0xA0000000)}, + {"length", DukUInt(env->length + 1)}, { nullptr } }; @@ -757,14 +759,14 @@ static duk_idx_t CbArgs_PIEventObject(duk_context* ctx, void* _env) return 1; } -duk_ret_t RequireAddressOrAddressRange(duk_context* ctx, duk_idx_t idx, uint32_t* addrStart, uint32_t* addrEnd) +duk_ret_t RequireAddressOrAddressRange(duk_context * ctx, duk_idx_t idx, uint32_t * addrStart, uint32_t * addrEnd) { - if(duk_is_number(ctx, idx)) + if (duk_is_number(ctx, idx)) { if (abs(duk_get_number(ctx, idx)) > 0xFFFFFFFF) { duk_push_error_object(ctx, DUK_ERR_RANGE_ERROR, - "address is out of range"); + "address is out of range"); return duk_throw(ctx); } @@ -774,25 +776,25 @@ duk_ret_t RequireAddressOrAddressRange(duk_context* ctx, duk_idx_t idx, uint32_t return 0; } - if(duk_is_object(ctx, idx)) + if (duk_is_object(ctx, idx)) { - if(!duk_has_prop_string(ctx, idx, "start") || - !duk_has_prop_string(ctx, idx, "end")) + if (!duk_has_prop_string(ctx, idx, "start") || + !duk_has_prop_string(ctx, idx, "end")) { duk_push_error_object(ctx, DUK_ERR_REFERENCE_ERROR, - "object is missing 'start' or 'end' property"); + "object is missing 'start' or 'end' property"); return duk_throw(ctx); } duk_get_prop_string(ctx, idx, "start"); duk_get_prop_string(ctx, idx, "end"); - if(!duk_is_number(ctx, -2) || - !duk_is_number(ctx, -1)) + if (!duk_is_number(ctx, -2) || + !duk_is_number(ctx, -1)) { duk_pop_n(ctx, 2); duk_push_error_object(ctx, DUK_ERR_REFERENCE_ERROR, - "'start' and 'end' properties must be numbers"); + "'start' and 'end' properties must be numbers"); return duk_throw(ctx); } @@ -800,7 +802,7 @@ duk_ret_t RequireAddressOrAddressRange(duk_context* ctx, duk_idx_t idx, uint32_t abs(duk_get_number(ctx, -1)) > 0xFFFFFFFF) { duk_push_error_object(ctx, DUK_ERR_RANGE_ERROR, - "'start' or 'end' property out of range"); + "'start' or 'end' property out of range"); return duk_throw(ctx); } @@ -811,17 +813,17 @@ duk_ret_t RequireAddressOrAddressRange(duk_context* ctx, duk_idx_t idx, uint32_t } duk_push_error_object(ctx, DUK_ERR_TYPE_ERROR, - "argument %d invalid; expected number or object", idx); + "argument %d invalid; expected number or object", idx); return duk_throw(ctx); } -duk_ret_t RequireInterpreterCPU(duk_context* ctx) +duk_ret_t RequireInterpreterCPU(duk_context * ctx) { if (!g_Settings->LoadBool(Setting_ForceInterpreterCPU) && (CPU_TYPE)g_Settings->LoadDword(Game_CpuType) != CPU_Interpreter) { duk_push_error_object(ctx, DUK_ERR_ERROR, - "this feature requires the interpreter core"); + "this feature requires the interpreter core"); return duk_throw(ctx); } diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_exec.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_exec.cpp index 65549f627..ca56b89ea 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_exec.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_exec.cpp @@ -1,20 +1,21 @@ -#include -#include -#include "ScriptAPI.h" +#include "stdafx.h" -void ScriptAPI::Define_exec(duk_context* ctx) +#include "ScriptAPI.h" +#include + +void ScriptAPI::Define_exec(duk_context * ctx) { DefineGlobalFunction(ctx, "exec", js_exec); } -duk_ret_t ScriptAPI::js_exec(duk_context* ctx) +duk_ret_t ScriptAPI::js_exec(duk_context * ctx) { - CheckArgs(ctx, { Arg_String, Arg_OptObject }); + CheckArgs(ctx, {Arg_String, Arg_OptObject}); - CScriptInstance* inst = GetInstance(ctx); - CScriptSystem* sys = inst->System(); + CScriptInstance * inst = GetInstance(ctx); + CScriptSystem * sys = inst->System(); - const char* command = duk_get_string(ctx, 0); + const char * command = duk_get_string(ctx, 0); struct { @@ -45,7 +46,7 @@ duk_ret_t ScriptAPI::js_exec(duk_context* ctx) stdstr resultStdOut; stdstr resultStdErr; - DWORD resultExitCode = EXIT_FAILURE; + DWORD resultExitCode = EXIT_FAILURE; SECURITY_ATTRIBUTES secAttr; secAttr.nLength = sizeof(SECURITY_ATTRIBUTES); @@ -76,7 +77,7 @@ duk_ret_t ScriptAPI::js_exec(duk_context* ctx) PROCESS_INFORMATION processInfo; BOOL bSuccess = CreateProcessA(nullptr, (LPSTR)stdstr_f("cmd /c %s", command).c_str(), nullptr, nullptr, TRUE, - 0, nullptr, options.cwd.c_str(), &startupInfo, &processInfo); + 0, nullptr, options.cwd.c_str(), &startupInfo, &processInfo); if (bSuccess) { @@ -130,10 +131,10 @@ duk_ret_t ScriptAPI::js_exec(duk_context* ctx) if (!bSuccess || resultExitCode != 0) { const DukPropListEntry props[] = { - { "status", DukInt(resultExitCode) }, - { "stdout", DukString(resultStdOut.c_str()) }, - { "stderr", DukString(resultStdErr.c_str()) }, - { "pid", DukUInt(processInfo.dwProcessId) }, + {"status", DukInt(resultExitCode)}, + {"stdout", DukString(resultStdOut.c_str())}, + {"stderr", DukString(resultStdErr.c_str())}, + {"pid", DukUInt(processInfo.dwProcessId)}, { nullptr } }; diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_interval.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_interval.cpp index 74421d318..f4119ccc7 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_interval.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_interval.cpp @@ -1,13 +1,14 @@ -#include -#include "ScriptAPI.h" +#include "stdafx.h" + #include "JSIntervalWorker.h" +#include "ScriptAPI.h" using namespace ScriptAPI; -static int AddIntervalContext(duk_context* ctx, duk_idx_t func_idx, int delayMS, bool bOnce); -static void RemoveIntervalContext(duk_context* ctx, int intervalId); +static int AddIntervalContext(duk_context * ctx, duk_idx_t func_idx, int delayMS, bool bOnce); +static void RemoveIntervalContext(duk_context * ctx, int intervalId); -void ScriptAPI::Define_interval(duk_context* ctx) +void ScriptAPI::Define_interval(duk_context * ctx) { DefineGlobalFunction(ctx, "setInterval", js_setInterval); DefineGlobalFunction(ctx, "clearInterval", js_clearInterval); @@ -15,41 +16,41 @@ void ScriptAPI::Define_interval(duk_context* ctx) DefineGlobalFunction(ctx, "clearTimeout", js_clearTimeout); } -duk_ret_t ScriptAPI::js_setInterval(duk_context* ctx) +duk_ret_t ScriptAPI::js_setInterval(duk_context * ctx) { - CheckArgs(ctx, { Arg_Function, Arg_Number }); + CheckArgs(ctx, {Arg_Function, Arg_Number}); int delayMS = duk_get_int(ctx, 1); int intervalId = AddIntervalContext(ctx, 0, delayMS, false); duk_push_int(ctx, intervalId); return 1; } -duk_ret_t ScriptAPI::js_clearInterval(duk_context* ctx) +duk_ret_t ScriptAPI::js_clearInterval(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number }); + CheckArgs(ctx, {Arg_Number}); int intervalId = duk_get_int(ctx, 0); RemoveIntervalContext(ctx, intervalId); return 0; } -duk_ret_t ScriptAPI::js_setTimeout(duk_context* ctx) +duk_ret_t ScriptAPI::js_setTimeout(duk_context * ctx) { - CheckArgs(ctx, { Arg_Function, Arg_Number }); + CheckArgs(ctx, {Arg_Function, Arg_Number}); int delayMS = duk_get_int(ctx, 1); int intervalId = AddIntervalContext(ctx, 0, delayMS, true); duk_push_int(ctx, intervalId); return 1; } -duk_ret_t ScriptAPI::js_clearTimeout(duk_context* ctx) +duk_ret_t ScriptAPI::js_clearTimeout(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number }); + CheckArgs(ctx, {Arg_Number}); int intervalId = duk_get_int(ctx, 0); RemoveIntervalContext(ctx, intervalId); return 0; } -duk_ret_t ScriptAPI::js__IntervalContext_invokeFunc(duk_context* ctx) +duk_ret_t ScriptAPI::js__IntervalContext_invokeFunc(duk_context * ctx) { duk_push_this(ctx); duk_get_prop_string(ctx, -1, "func"); @@ -57,7 +58,7 @@ duk_ret_t ScriptAPI::js__IntervalContext_invokeFunc(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js__IntervalContext_remove(duk_context* ctx) +duk_ret_t ScriptAPI::js__IntervalContext_remove(duk_context * ctx) { duk_push_this(ctx); duk_get_prop_string(ctx, -1, "id"); @@ -66,11 +67,11 @@ duk_ret_t ScriptAPI::js__IntervalContext_remove(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js__IntervalContext_finalizer(duk_context* ctx) +duk_ret_t ScriptAPI::js__IntervalContext_finalizer(duk_context * ctx) { duk_get_prop_string(ctx, 0, "worker"); - CJSIntervalWorker* intervalWorker = (CJSIntervalWorker*)duk_get_pointer(ctx, -1); - + CJSIntervalWorker * intervalWorker = (CJSIntervalWorker *)duk_get_pointer(ctx, -1); + if (intervalWorker != nullptr) { delete intervalWorker; @@ -79,11 +80,11 @@ duk_ret_t ScriptAPI::js__IntervalContext_finalizer(duk_context* ctx) return 0; } -int AddIntervalContext(duk_context* ctx, duk_idx_t func_idx, int delayMS, bool bOnce) +int AddIntervalContext(duk_context * ctx, duk_idx_t func_idx, int delayMS, bool bOnce) { func_idx = duk_normalize_index(ctx, func_idx); - CScriptInstance* inst = GetInstance(ctx); + CScriptInstance * inst = GetInstance(ctx); duk_push_global_object(ctx); duk_get_prop_string(ctx, -1, HS_gNextInvervalId); @@ -97,8 +98,8 @@ int AddIntervalContext(duk_context* ctx, duk_idx_t func_idx, int delayMS, bool b duk_push_object(ctx); RefObject(ctx, -1); - void* objectHeapPtr = duk_get_heapptr(ctx, -1); - CJSIntervalWorker* intervalWorker = new CJSIntervalWorker(inst, objectHeapPtr, delayMS, bOnce); + void * objectHeapPtr = duk_get_heapptr(ctx, -1); + CJSIntervalWorker * intervalWorker = new CJSIntervalWorker(inst, objectHeapPtr, delayMS, bOnce); duk_dup(ctx, func_idx); duk_put_prop_string(ctx, -2, "func"); @@ -120,7 +121,7 @@ int AddIntervalContext(duk_context* ctx, duk_idx_t func_idx, int delayMS, bool b return intervalId; } -void RemoveIntervalContext(duk_context* ctx, int intervalId) +void RemoveIntervalContext(duk_context * ctx, int intervalId) { duk_push_global_object(ctx); duk_get_prop_string(ctx, -1, HS_gIntervals); @@ -135,7 +136,7 @@ void RemoveIntervalContext(duk_context* ctx, int intervalId) duk_get_prop_string(ctx, -1, "worker"); - CJSIntervalWorker* intervalWorker = (CJSIntervalWorker*)duk_get_pointer(ctx, -1); + CJSIntervalWorker * intervalWorker = (CJSIntervalWorker *)duk_get_pointer(ctx, -1); intervalWorker->StopWorkerProc(); delete intervalWorker; diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_mem.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_mem.cpp index ea31f0b7d..cae8d1d9d 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_mem.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_mem.cpp @@ -1,41 +1,42 @@ -#include +#include "stdafx.h" + #include "ScriptAPI.h" -#include #include +#include #include #include -#pragma warning(disable: 4702) // disable unreachable code warning +#pragma warning(disable : 4702) // disable unreachable code warning using namespace ScriptAPI; static size_t MemTypeSize(MemType t); -static duk_ret_t ThrowMemoryError(duk_context* ctx, uint32_t address); +static duk_ret_t ThrowMemoryError(duk_context * ctx, uint32_t address); -void ScriptAPI::Define_mem(duk_context *ctx) +void ScriptAPI::Define_mem(duk_context * ctx) { - #define MEM_PROXY_FUNCS(T) js_mem__get, js_mem__set +#define MEM_PROXY_FUNCS(T) js_mem__get, js_mem__set const DukPropListEntry props[] = { - { "getblock", DukCFunction(js_mem_getblock) }, - { "setblock", DukCFunction(js_mem_setblock) }, - { "getstring", DukCFunction(js_mem_getstring) }, - { "setstring", DukCFunction(js_mem_setblock) }, - { "bindvar", DukCFunction(js_mem_bindvar) }, - { "bindvars", DukCFunction(js_mem_bindvars) }, - { "bindstruct", DukCFunction(js_mem_bindstruct) }, - { "typedef", DukCFunction(js_mem_typedef) }, - { "ramSize", DukGetter(js_mem__get_ramsize) }, - { "romSize", DukGetter(js_mem__get_romsize) }, - { "ptr", DukGetter(js_mem__get_ptr) }, - { "u32", DukProxy(MEM_PROXY_FUNCS(uint32_t)) }, - { "u16", DukProxy(MEM_PROXY_FUNCS(uint16_t)) }, - { "u8", DukProxy(MEM_PROXY_FUNCS(uint8_t)) }, - { "s32", DukProxy(MEM_PROXY_FUNCS(int32_t)) }, - { "s16", DukProxy(MEM_PROXY_FUNCS(int16_t)) }, - { "s8", DukProxy(MEM_PROXY_FUNCS(int8_t)) }, - { "f64", DukProxy(MEM_PROXY_FUNCS(double)) }, - { "f32", DukProxy(MEM_PROXY_FUNCS(float)) }, + {"getblock", DukCFunction(js_mem_getblock)}, + {"setblock", DukCFunction(js_mem_setblock)}, + {"getstring", DukCFunction(js_mem_getstring)}, + {"setstring", DukCFunction(js_mem_setblock)}, + {"bindvar", DukCFunction(js_mem_bindvar)}, + {"bindvars", DukCFunction(js_mem_bindvars)}, + {"bindstruct", DukCFunction(js_mem_bindstruct)}, + {"typedef", DukCFunction(js_mem_typedef)}, + {"ramSize", DukGetter(js_mem__get_ramsize)}, + {"romSize", DukGetter(js_mem__get_romsize)}, + {"ptr", DukGetter(js_mem__get_ptr)}, + {"u32", DukProxy(MEM_PROXY_FUNCS(uint32_t))}, + {"u16", DukProxy(MEM_PROXY_FUNCS(uint16_t))}, + {"u8", DukProxy(MEM_PROXY_FUNCS(uint8_t))}, + {"s32", DukProxy(MEM_PROXY_FUNCS(int32_t))}, + {"s16", DukProxy(MEM_PROXY_FUNCS(int16_t))}, + {"s8", DukProxy(MEM_PROXY_FUNCS(int8_t))}, + {"f64", DukProxy(MEM_PROXY_FUNCS(double))}, + {"f32", DukProxy(MEM_PROXY_FUNCS(float))}, { nullptr } }; @@ -43,14 +44,14 @@ void ScriptAPI::Define_mem(duk_context *ctx) } template -duk_ret_t ScriptAPI::js_mem__get(duk_context *ctx) +duk_ret_t ScriptAPI::js_mem__get(duk_context * ctx) { - CScriptInstance *inst = GetInstance(ctx); + CScriptInstance * inst = GetInstance(ctx); uint32_t addr = (uint32_t)duk_to_number(ctx, 1); - + T value; - if(inst->Debugger()->DebugLoad_VAddr(addr, value)) + if (inst->Debugger()->DebugLoad_VAddr(addr, value)) { duk_push_number(ctx, value); return 1; @@ -60,14 +61,14 @@ duk_ret_t ScriptAPI::js_mem__get(duk_context *ctx) } template -duk_ret_t ScriptAPI::js_mem__set(duk_context *ctx) +duk_ret_t ScriptAPI::js_mem__set(duk_context * ctx) { - CScriptInstance *inst = GetInstance(ctx); + CScriptInstance * inst = GetInstance(ctx); uint32_t addr = (uint32_t)duk_to_number(ctx, 1); T value = (T)duk_to_number(ctx, 2); - if(inst->Debugger()->DebugStore_VAddr(addr, value)) + if (inst->Debugger()->DebugStore_VAddr(addr, value)) { duk_push_true(ctx); return 1; @@ -76,19 +77,19 @@ duk_ret_t ScriptAPI::js_mem__set(duk_context *ctx) return ThrowMemoryError(ctx, addr); } -duk_ret_t ScriptAPI::js_mem_getblock(duk_context *ctx) +duk_ret_t ScriptAPI::js_mem_getblock(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number, Arg_Number }); - CScriptInstance *inst = GetInstance(ctx); + CheckArgs(ctx, {Arg_Number, Arg_Number}); + CScriptInstance * inst = GetInstance(ctx); duk_uint_t addr = duk_to_uint(ctx, 0); duk_uint_t length = duk_to_uint(ctx, 1); - uint8_t *data = (uint8_t*)duk_push_fixed_buffer(ctx, length); + uint8_t * data = (uint8_t *)duk_push_fixed_buffer(ctx, length); duk_push_buffer_object(ctx, -1, 0, length, DUK_BUFOBJ_NODEJS_BUFFER); uint32_t paddr; - uint8_t* memsrc = nullptr; + uint8_t * memsrc = nullptr; uint32_t offsetStart = 0; if (addr < 0x80000000 || addr >= 0xC0000000) @@ -124,9 +125,9 @@ duk_ret_t ScriptAPI::js_mem_getblock(duk_context *ctx) uint32_t middleLen = alignedOffsetEnd - alignedOffsetStart; uint32_t suffixLen = offsetEnd - alignedOffsetEnd; - uint32_t* middleDst = (uint32_t*)&data[0 + prefixLen]; - uint32_t* middleDstEnd = (uint32_t*)&data[0 + prefixLen + middleLen]; - uint32_t* middleSrc = (uint32_t*)&memsrc[alignedOffsetStart]; + uint32_t * middleDst = (uint32_t *)&data[0 + prefixLen]; + uint32_t * middleDstEnd = (uint32_t *)&data[0 + prefixLen + middleLen]; + uint32_t * middleSrc = (uint32_t *)&memsrc[alignedOffsetStart]; for (size_t i = 0; i < prefixLen; i++) { @@ -165,10 +166,10 @@ duk_ret_t ScriptAPI::js_mem_getblock(duk_context *ctx) return 1; } -duk_ret_t ScriptAPI::js_mem_getstring(duk_context *ctx) +duk_ret_t ScriptAPI::js_mem_getstring(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number, Arg_OptNumber }); - CScriptInstance *inst = GetInstance(ctx); + CheckArgs(ctx, {Arg_Number, Arg_OptNumber}); + CScriptInstance * inst = GetInstance(ctx); duk_idx_t nargs = duk_get_top(ctx); @@ -176,15 +177,15 @@ duk_ret_t ScriptAPI::js_mem_getstring(duk_context *ctx) duk_uint_t maxLength = nargs > 1 ? duk_to_uint(ctx, 1) : 0xFFFFFFFF; size_t length = 0; - for(size_t i = 0; i < maxLength; i++) + for (size_t i = 0; i < maxLength; i++) { char c; - if(!inst->Debugger()->DebugLoad_VAddr(addr + i, c)) + if (!inst->Debugger()->DebugLoad_VAddr(addr + i, c)) { return ThrowMemoryError(ctx, addr); } - if(c == 0) + if (c == 0) { break; } @@ -192,12 +193,12 @@ duk_ret_t ScriptAPI::js_mem_getstring(duk_context *ctx) length++; } - char *str = new char[length + 1]; + char * str = new char[length + 1]; str[length] = '\0'; - for(size_t i = 0; i < length; i++) + for (size_t i = 0; i < length; i++) { - if(!inst->Debugger()->DebugLoad_VAddr(addr + i, str[i])) + if (!inst->Debugger()->DebugLoad_VAddr(addr + i, str[i])) { delete[] str; return ThrowMemoryError(ctx, addr); @@ -209,26 +210,26 @@ duk_ret_t ScriptAPI::js_mem_getstring(duk_context *ctx) return 1; } -duk_ret_t ScriptAPI::js_mem_setblock(duk_context *ctx) +duk_ret_t ScriptAPI::js_mem_setblock(duk_context * ctx) { - CheckArgs(ctx, { Arg_Number, Arg_Any, Arg_OptNumber }); - CScriptInstance *inst = GetInstance(ctx); - CDebuggerUI *debugger = inst->Debugger(); + CheckArgs(ctx, {Arg_Number, Arg_Any, Arg_OptNumber}); + CScriptInstance * inst = GetInstance(ctx); + CDebuggerUI * debugger = inst->Debugger(); duk_idx_t nargs = duk_get_top(ctx); - char* data; + char * data; duk_size_t dataSize, length; uint32_t address = duk_get_uint(ctx, 0); if (duk_is_buffer_data(ctx, 1)) { - data = (char*)duk_get_buffer_data(ctx, 1, &dataSize); + data = (char *)duk_get_buffer_data(ctx, 1, &dataSize); } - else if(duk_is_string(ctx, 1)) + else if (duk_is_string(ctx, 1)) { - data = (char*)duk_get_lstring(ctx, 1, &dataSize); + data = (char *)duk_get_lstring(ctx, 1, &dataSize); } else { @@ -262,14 +263,15 @@ duk_ret_t ScriptAPI::js_mem_setblock(duk_context *ctx) return 0; } -duk_ret_t ScriptAPI::js_mem__boundget(duk_context *ctx) +duk_ret_t ScriptAPI::js_mem__boundget(duk_context * ctx) { - CDebuggerUI *debugger = GetInstance(ctx)->Debugger(); + CDebuggerUI * debugger = GetInstance(ctx)->Debugger(); uint32_t addr = duk_get_uint(ctx, 0); duk_int_t type = duk_get_int(ctx, 1); - union { + union + { uint8_t u8; uint16_t u16; uint32_t u32; @@ -283,8 +285,8 @@ duk_ret_t ScriptAPI::js_mem__boundget(duk_context *ctx) #define MEM_BOUNDGET_TRY(addr, T, result, dukpush) \ if(debugger->DebugLoad_VAddr(addr, result)) { dukpush(ctx, result); } \ else { goto memory_error; } - - switch(type) + + switch (type) { case U8: MEM_BOUNDGET_TRY(addr, uint8_t, retval.u8, duk_push_uint); @@ -316,9 +318,9 @@ memory_error: return ThrowMemoryError(ctx, addr); } -duk_ret_t ScriptAPI::js_mem__boundset(duk_context *ctx) +duk_ret_t ScriptAPI::js_mem__boundset(duk_context * ctx) { - CDebuggerUI *debugger = GetInstance(ctx)->Debugger(); + CDebuggerUI * debugger = GetInstance(ctx)->Debugger(); uint32_t addr = duk_get_uint(ctx, 0); duk_int_t type = duk_get_int(ctx, 1); @@ -327,7 +329,7 @@ duk_ret_t ScriptAPI::js_mem__boundset(duk_context *ctx) if(debugger->DebugStore_VAddr(addr, value)) { return 1; } \ else { goto memory_error; } - switch(type) + switch (type) { case U8: MEM_BOUNDSET_TRY(addr, uint8_t, duk_get_uint(ctx, 2) & 0xFF); @@ -361,12 +363,12 @@ memory_error: return ThrowMemoryError(ctx, addr); } -duk_ret_t ScriptAPI::js_mem_bindvar(duk_context *ctx) +duk_ret_t ScriptAPI::js_mem_bindvar(duk_context * ctx) { - CheckArgs(ctx, { Arg_Object, Arg_Number, Arg_String, Arg_Number }); + CheckArgs(ctx, {Arg_Object, Arg_Number, Arg_String, Arg_Number}); duk_uint_t addr = duk_get_uint(ctx, 1); - const char* key = duk_get_string(ctx, 2); + const char * key = duk_get_string(ctx, 2); duk_int_t type = duk_get_int(ctx, 3); duk_push_string(ctx, key); @@ -393,17 +395,17 @@ duk_ret_t ScriptAPI::js_mem_bindvar(duk_context *ctx) return 0; } -duk_ret_t ScriptAPI::js_mem_bindvars(duk_context *ctx) +duk_ret_t ScriptAPI::js_mem_bindvars(duk_context * ctx) { - CheckArgs(ctx, { Arg_Object, Arg_Array }); + CheckArgs(ctx, {Arg_Object, Arg_Array}); duk_size_t length = duk_get_length(ctx, 1); - for(duk_uarridx_t i = 0; i < length; i++) + for (duk_uarridx_t i = 0; i < length; i++) { duk_get_prop_index(ctx, 1, i); - if(!duk_is_array(ctx, -1) || - duk_get_length(ctx, -1) != 3) + if (!duk_is_array(ctx, -1) || + duk_get_length(ctx, -1) != 3) { return DUK_RET_TYPE_ERROR; } @@ -414,7 +416,7 @@ duk_ret_t ScriptAPI::js_mem_bindvars(duk_context *ctx) duk_get_prop_index(ctx, -4, 1); duk_get_prop_index(ctx, -5, 2); - if(duk_pcall(ctx, 4) != DUK_EXEC_SUCCESS) + if (duk_pcall(ctx, 4) != DUK_EXEC_SUCCESS) { return duk_throw(ctx); } @@ -426,15 +428,15 @@ duk_ret_t ScriptAPI::js_mem_bindvars(duk_context *ctx) return 1; } -duk_ret_t ScriptAPI::js_mem_bindstruct(duk_context *ctx) +duk_ret_t ScriptAPI::js_mem_bindstruct(duk_context * ctx) { - CheckArgs(ctx, { Arg_Object, Arg_Number, Arg_Object }); + CheckArgs(ctx, {Arg_Object, Arg_Number, Arg_Object}); uint32_t curAddr = duk_get_uint(ctx, 1); duk_enum(ctx, 2, DUK_ENUM_OWN_PROPERTIES_ONLY); - while(duk_next(ctx, -1, 1)) + while (duk_next(ctx, -1, 1)) { MemType type = (MemType)duk_get_int(ctx, -1); @@ -444,7 +446,7 @@ duk_ret_t ScriptAPI::js_mem_bindstruct(duk_context *ctx) duk_pull(ctx, -5); duk_pull(ctx, -5); - if(duk_pcall(ctx, 4) != DUK_EXEC_SUCCESS) + if (duk_pcall(ctx, 4) != DUK_EXEC_SUCCESS) { return duk_throw(ctx); } @@ -459,16 +461,16 @@ duk_ret_t ScriptAPI::js_mem_bindstruct(duk_context *ctx) return 1; } -duk_ret_t ScriptAPI::js_mem__type_constructor(duk_context* ctx) +duk_ret_t ScriptAPI::js_mem__type_constructor(duk_context * ctx) { - CheckArgs(ctx, { Arg_Object, Arg_Number }); + CheckArgs(ctx, {Arg_Object, Arg_Number}); duk_push_c_function(ctx, js_mem_bindstruct, 3); duk_push_this(ctx); duk_pull(ctx, 1); duk_pull(ctx, 0); - if(duk_pcall(ctx, 3) != DUK_EXEC_SUCCESS) + if (duk_pcall(ctx, 3) != DUK_EXEC_SUCCESS) { return duk_throw(ctx); } @@ -476,9 +478,9 @@ duk_ret_t ScriptAPI::js_mem__type_constructor(duk_context* ctx) return 0; } -duk_ret_t ScriptAPI::js_mem_typedef(duk_context* ctx) +duk_ret_t ScriptAPI::js_mem_typedef(duk_context * ctx) { - CheckArgs(ctx, { Arg_Object }); + CheckArgs(ctx, {Arg_Object}); duk_push_c_function(ctx, js_mem__type_constructor, DUK_VARARGS); duk_push_string(ctx, "bind"); @@ -488,19 +490,19 @@ duk_ret_t ScriptAPI::js_mem_typedef(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_mem__get_ramsize(duk_context* ctx) +duk_ret_t ScriptAPI::js_mem__get_ramsize(duk_context * ctx) { duk_push_number(ctx, g_MMU ? g_MMU->RdramSize() : 0); return 1; } -duk_ret_t ScriptAPI::js_mem__get_romsize(duk_context* ctx) +duk_ret_t ScriptAPI::js_mem__get_romsize(duk_context * ctx) { duk_push_number(ctx, g_Rom ? g_Rom->GetRomSize() : 0); return 1; } -duk_ret_t ScriptAPI::js_mem__get_ptr(duk_context* ctx) +duk_ret_t ScriptAPI::js_mem__get_ptr(duk_context * ctx) { duk_push_pointer(ctx, g_MMU ? g_MMU->Rdram() : nullptr); return 1; @@ -508,7 +510,7 @@ duk_ret_t ScriptAPI::js_mem__get_ptr(duk_context* ctx) size_t MemTypeSize(MemType t) { - switch(t) + switch (t) { case U8: case S8: @@ -526,7 +528,7 @@ size_t MemTypeSize(MemType t) return 0; } -duk_ret_t ThrowMemoryError(duk_context* ctx, uint32_t address) +duk_ret_t ThrowMemoryError(duk_context * ctx, uint32_t address) { duk_push_error_object(ctx, DUK_ERR_ERROR, "memory error (can't access 0x%08X)", address); return duk_throw(ctx); diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_pj64.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_pj64.cpp index 4e0266b39..2863aaa38 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_pj64.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_pj64.cpp @@ -1,93 +1,94 @@ -#include +#include "stdafx.h" + #include "ScriptAPI.h" #include #include -void ScriptAPI::Define_pj64(duk_context* ctx) +void ScriptAPI::Define_pj64(duk_context * ctx) { const DukPropListEntry romInfoProps[] = { - { "goodName", DukGetter(js_pj64_romInfo__get_goodName) }, - { "fileName", DukGetter(js_pj64_romInfo__get_fileName) }, - { "filePath", DukGetter(js_pj64_romInfo__get_filePath) }, - { "crc1", DukGetter(js_pj64_romInfo__get_headerCrc1) }, - { "crc2", DukGetter(js_pj64_romInfo__get_headerCrc2) }, - { "name", DukGetter(js_pj64_romInfo__get_headerName) }, - { "mediaFormat", DukGetter(js_pj64_romInfo__get_headerMediaFormat) }, - { "id", DukGetter(js_pj64_romInfo__get_headerId) }, - { "countryCode", DukGetter(js_pj64_romInfo__get_headerCountryCode) }, - { "version", DukGetter(js_pj64_romInfo__get_headerVersion) }, + {"goodName", DukGetter(js_pj64_romInfo__get_goodName)}, + {"fileName", DukGetter(js_pj64_romInfo__get_fileName)}, + {"filePath", DukGetter(js_pj64_romInfo__get_filePath)}, + {"crc1", DukGetter(js_pj64_romInfo__get_headerCrc1)}, + {"crc2", DukGetter(js_pj64_romInfo__get_headerCrc2)}, + {"name", DukGetter(js_pj64_romInfo__get_headerName)}, + {"mediaFormat", DukGetter(js_pj64_romInfo__get_headerMediaFormat)}, + {"id", DukGetter(js_pj64_romInfo__get_headerId)}, + {"countryCode", DukGetter(js_pj64_romInfo__get_headerCountryCode)}, + {"version", DukGetter(js_pj64_romInfo__get_headerVersion)}, { nullptr } }; const DukPropListEntry props[] = { - { "open", DukCFunction(js_pj64_open) }, - { "close", DukCFunction(js_pj64_close) }, - { "reset", DukCFunction(js_pj64_reset) }, - { "pause", DukCFunction(js_pj64_pause) }, - { "resume", DukCFunction(js_pj64_resume) }, - { "limitfps", DukCFunction(js_pj64_limitfps) }, + {"open", DukCFunction(js_pj64_open)}, + {"close", DukCFunction(js_pj64_close)}, + {"reset", DukCFunction(js_pj64_reset)}, + {"pause", DukCFunction(js_pj64_pause)}, + {"resume", DukCFunction(js_pj64_resume)}, + {"limitfps", DukCFunction(js_pj64_limitfps)}, //{ "savestate", DukCFunction(js_pj64_savestate) }, //{ "loadstate", DukCFunction(js_pj64_loadstate) }, - { "installDirectory", DukGetter(js_pj64__get_installDirectory) }, - { "scriptsDirectory", DukGetter(js_pj64__get_scriptsDirectory) }, - { "modulesDirectory", DukGetter(js_pj64__get_modulesDirectory) }, - { "romDirectory", DukGetter(js_pj64__get_romDirectory) }, - { DUK_HIDDEN_SYMBOL("romInfo"), DukObject(romInfoProps) }, - { "romInfo", DukGetter(js_pj64__get_romInfo) }, + {"installDirectory", DukGetter(js_pj64__get_installDirectory)}, + {"scriptsDirectory", DukGetter(js_pj64__get_scriptsDirectory)}, + {"modulesDirectory", DukGetter(js_pj64__get_modulesDirectory)}, + {"romDirectory", DukGetter(js_pj64__get_romDirectory)}, + {DUK_HIDDEN_SYMBOL("romInfo"), DukObject(romInfoProps)}, + {"romInfo", DukGetter(js_pj64__get_romInfo)}, { nullptr } }; DefineGlobalInterface(ctx, "pj64", props); } -duk_ret_t ScriptAPI::js_pj64_open(duk_context* ctx) +duk_ret_t ScriptAPI::js_pj64_open(duk_context * ctx) { - CheckArgs(ctx, { Arg_String }); + CheckArgs(ctx, {Arg_String}); - const char* romPath = duk_get_string(ctx, 0); + const char * romPath = duk_get_string(ctx, 0); HWND hMainWindow = (HWND)g_Plugins->MainWindow()->GetWindowHandle(); - char* romPathCopy = new char[MAX_PATH]; // main window proc deletes + char * romPathCopy = new char[MAX_PATH]; // main window proc deletes strncpy(romPathCopy, romPath, MAX_PATH); PostMessage(hMainWindow, WM_JSAPI_ACTION, JSAPI_ACT_OPEN_ROM, (WPARAM)romPath); return 0; } -duk_ret_t ScriptAPI::js_pj64_close(duk_context* /*ctx*/) +duk_ret_t ScriptAPI::js_pj64_close(duk_context * /*ctx*/) { HWND hMainWindow = (HWND)g_Plugins->MainWindow()->GetWindowHandle(); PostMessage(hMainWindow, WM_JSAPI_ACTION, JSAPI_ACT_CLOSE_ROM, 0); return 0; } -duk_ret_t ScriptAPI::js_pj64_reset(duk_context* ctx) +duk_ret_t ScriptAPI::js_pj64_reset(duk_context * ctx) { - CheckArgs(ctx, { Arg_OptBoolean }); - bool bSoftReset = (bool)duk_get_boolean_default(ctx, 0, (duk_bool_t)false); + CheckArgs(ctx, {Arg_OptBoolean}); + bool bSoftReset = (bool)duk_get_boolean_default(ctx, 0, (duk_bool_t) false); HWND hMainWindow = (HWND)g_Plugins->MainWindow()->GetWindowHandle(); PostMessage(hMainWindow, WM_JSAPI_ACTION, JSAPI_ACT_RESET, (WPARAM)bSoftReset); return 0; } -duk_ret_t ScriptAPI::js_pj64_pause(duk_context* /*ctx*/) +duk_ret_t ScriptAPI::js_pj64_pause(duk_context * /*ctx*/) { HWND hMainWindow = (HWND)g_Plugins->MainWindow()->GetWindowHandle(); PostMessage(hMainWindow, WM_JSAPI_ACTION, JSAPI_ACT_PAUSE, 0); return 0; } -duk_ret_t ScriptAPI::js_pj64_resume(duk_context* /*ctx*/) +duk_ret_t ScriptAPI::js_pj64_resume(duk_context * /*ctx*/) { HWND hMainWindow = (HWND)g_Plugins->MainWindow()->GetWindowHandle(); PostMessage(hMainWindow, WM_JSAPI_ACTION, JSAPI_ACT_RESUME, 0); return 0; } -duk_ret_t ScriptAPI::js_pj64_limitfps(duk_context* ctx) +duk_ret_t ScriptAPI::js_pj64_limitfps(duk_context * ctx) { - CheckArgs(ctx, { Arg_Boolean }); + CheckArgs(ctx, {Arg_Boolean}); bool bLimitFps = duk_get_boolean(ctx, 0); g_Settings->SaveBool(GameRunning_LimitFPS, bLimitFps); return 0; @@ -117,21 +118,21 @@ duk_ret_t ScriptAPI::js_pj64_loadstate(duk_context* ctx) } */ -duk_ret_t ScriptAPI::js_pj64__get_installDirectory(duk_context* ctx) +duk_ret_t ScriptAPI::js_pj64__get_installDirectory(duk_context * ctx) { stdstr dirPath = GetInstance(ctx)->System()->InstallDirPath(); duk_push_string(ctx, dirPath.c_str()); return 1; } -duk_ret_t ScriptAPI::js_pj64__get_scriptsDirectory(duk_context* ctx) +duk_ret_t ScriptAPI::js_pj64__get_scriptsDirectory(duk_context * ctx) { stdstr dirPath = GetInstance(ctx)->System()->ScriptsDirPath(); duk_push_string(ctx, dirPath.c_str()); return 1; } -duk_ret_t ScriptAPI::js_pj64__get_modulesDirectory(duk_context* ctx) +duk_ret_t ScriptAPI::js_pj64__get_modulesDirectory(duk_context * ctx) { stdstr dirPath = GetInstance(ctx)->System()->ModulesDirPath(); duk_push_string(ctx, dirPath.c_str()); @@ -144,7 +145,7 @@ duk_ret_t ScriptAPI::js_pj64__get_romDirectory(duk_context * ctx) return 1; } -duk_ret_t ScriptAPI::js_pj64__get_romInfo(duk_context* ctx) +duk_ret_t ScriptAPI::js_pj64__get_romInfo(duk_context * ctx) { if (g_Settings->LoadStringVal(Game_GameName) != "") { @@ -158,45 +159,45 @@ duk_ret_t ScriptAPI::js_pj64__get_romInfo(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_pj64_romInfo__get_goodName(duk_context* ctx) +duk_ret_t ScriptAPI::js_pj64_romInfo__get_goodName(duk_context * ctx) { duk_push_string(ctx, g_Settings->LoadStringVal(Rdb_GoodName).c_str()); return 1; } -duk_ret_t ScriptAPI::js_pj64_romInfo__get_fileName(duk_context* ctx) +duk_ret_t ScriptAPI::js_pj64_romInfo__get_fileName(duk_context * ctx) { duk_push_string(ctx, CPath(g_Settings->LoadStringVal(Game_File)).GetNameExtension().c_str()); return 1; } -duk_ret_t ScriptAPI::js_pj64_romInfo__get_filePath(duk_context* ctx) +duk_ret_t ScriptAPI::js_pj64_romInfo__get_filePath(duk_context * ctx) { duk_push_string(ctx, g_Settings->LoadStringVal(Game_File).c_str()); return 1; } -duk_ret_t ScriptAPI::js_pj64_romInfo__get_headerCrc1(duk_context* ctx) +duk_ret_t ScriptAPI::js_pj64_romInfo__get_headerCrc1(duk_context * ctx) { - CDebuggerUI* debugger = GetInstance(ctx)->Debugger(); + CDebuggerUI * debugger = GetInstance(ctx)->Debugger(); uint32_t crc1 = 0; debugger->DebugLoad_VAddr(0xB0000010, crc1); duk_push_uint(ctx, crc1); return 1; } -duk_ret_t ScriptAPI::js_pj64_romInfo__get_headerCrc2(duk_context* ctx) +duk_ret_t ScriptAPI::js_pj64_romInfo__get_headerCrc2(duk_context * ctx) { - CDebuggerUI* debugger = GetInstance(ctx)->Debugger(); + CDebuggerUI * debugger = GetInstance(ctx)->Debugger(); uint32_t crc2 = 0; debugger->DebugLoad_VAddr(0xB0000014, crc2); duk_push_uint(ctx, crc2); return 1; } -duk_ret_t ScriptAPI::js_pj64_romInfo__get_headerName(duk_context* ctx) +duk_ret_t ScriptAPI::js_pj64_romInfo__get_headerName(duk_context * ctx) { - CDebuggerUI* debugger = GetInstance(ctx)->Debugger(); + CDebuggerUI * debugger = GetInstance(ctx)->Debugger(); char headerName[0x15] = ""; for (size_t i = 0; i < 0x14; i++) { @@ -207,18 +208,18 @@ duk_ret_t ScriptAPI::js_pj64_romInfo__get_headerName(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_pj64_romInfo__get_headerMediaFormat(duk_context* ctx) +duk_ret_t ScriptAPI::js_pj64_romInfo__get_headerMediaFormat(duk_context * ctx) { - CDebuggerUI* debugger = GetInstance(ctx)->Debugger(); + CDebuggerUI * debugger = GetInstance(ctx)->Debugger(); uint32_t mediaFormat = 0; debugger->DebugLoad_VAddr(0xB0000038, mediaFormat); duk_push_uint(ctx, mediaFormat); return 1; } -duk_ret_t ScriptAPI::js_pj64_romInfo__get_headerId(duk_context* ctx) +duk_ret_t ScriptAPI::js_pj64_romInfo__get_headerId(duk_context * ctx) { - CDebuggerUI* debugger = GetInstance(ctx)->Debugger(); + CDebuggerUI * debugger = GetInstance(ctx)->Debugger(); char headerId[3] = ""; debugger->DebugLoad_VAddr(0xB000003C, headerId[0]); debugger->DebugLoad_VAddr(0xB000003D, headerId[1]); @@ -226,18 +227,18 @@ duk_ret_t ScriptAPI::js_pj64_romInfo__get_headerId(duk_context* ctx) return 1; } -duk_ret_t ScriptAPI::js_pj64_romInfo__get_headerCountryCode(duk_context* ctx) +duk_ret_t ScriptAPI::js_pj64_romInfo__get_headerCountryCode(duk_context * ctx) { - CDebuggerUI* debugger = GetInstance(ctx)->Debugger(); + CDebuggerUI * debugger = GetInstance(ctx)->Debugger(); char countryCode[2] = ""; debugger->DebugLoad_VAddr(0xB000003E, countryCode[0]); duk_push_string(ctx, countryCode); return 1; } -duk_ret_t ScriptAPI::js_pj64_romInfo__get_headerVersion(duk_context* ctx) +duk_ret_t ScriptAPI::js_pj64_romInfo__get_headerVersion(duk_context * ctx) { - CDebuggerUI* debugger = GetInstance(ctx)->Debugger(); + CDebuggerUI * debugger = GetInstance(ctx)->Debugger(); uint8_t headerVersion = 0; debugger->DebugLoad_VAddr(0xB000003F, headerVersion); duk_push_uint(ctx, headerVersion); diff --git a/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp b/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp index c7329314b..bb6d801d4 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp @@ -1,18 +1,20 @@ -#include -#include "ScriptTypes.h" -#include "ScriptInstance.h" +#include "stdafx.h" + #include "ScriptAPI/ScriptAPI.h" +#include "ScriptInstance.h" +#include "ScriptTypes.h" #include -extern "C" { - int DukTimeoutCheck(void* udata) +extern "C" +{ + int DukTimeoutCheck(void * udata) { - CScriptInstance* inst = (CScriptInstance*)udata; + CScriptInstance * inst = (CScriptInstance *)udata; return (int)inst->IsTimedOut(); } } -CScriptInstance::CScriptInstance(CScriptSystem* sys, const char* name) : +CScriptInstance::CScriptInstance(CScriptSystem * sys, const char * name) : m_System(sys), m_InstanceName(name), m_Ctx(nullptr), @@ -31,17 +33,17 @@ CScriptInstance::~CScriptInstance() Cleanup(); } -std::string& CScriptInstance::Name() +std::string & CScriptInstance::Name() { return m_InstanceName; } -CScriptSystem* CScriptInstance::System() +CScriptSystem * CScriptInstance::System() { return m_System; } -CDebuggerUI* CScriptInstance::Debugger() +CDebuggerUI * CScriptInstance::Debugger() { return m_System->Debugger(); } @@ -51,22 +53,22 @@ JSAppCallbackID CScriptInstance::CallbackId() return m_CurExecCallbackId; } -bool CScriptInstance::Run(const char* path) +bool CScriptInstance::Run(const char * path) { - if(m_Ctx != nullptr) + if (m_Ctx != nullptr) { return false; } m_Ctx = duk_create_heap(nullptr, nullptr, nullptr, this, nullptr); - if(m_Ctx == nullptr) + if (m_Ctx == nullptr) { goto error_cleanup; } struct stat statBuf; - if(stat(path, &statBuf) != 0) + if (stat(path, &statBuf) != 0) { m_System->ConsoleLog("[SCRIPTSYS]: error: could not stat '%s'", path); goto error_cleanup; @@ -76,7 +78,7 @@ bool CScriptInstance::Run(const char* path) m_SourceCode[statBuf.st_size] = '\0'; m_SourceFile.open(path, std::ios::in | std::ios::binary); - if(!m_SourceFile.is_open()) + if (!m_SourceFile.is_open()) { m_System->ConsoleLog("[SCRIPTSYS]: error: could not open '%s'", path); goto error_cleanup; @@ -84,7 +86,7 @@ bool CScriptInstance::Run(const char* path) m_SourceFile.read(m_SourceCode, statBuf.st_size); - if((size_t)m_SourceFile.tellg() != (size_t)statBuf.st_size) + if ((size_t)m_SourceFile.tellg() != (size_t)statBuf.st_size) { m_System->ConsoleLog("[SCRIPTSYS]: error: could not read '%s'", path); goto error_cleanup; @@ -108,13 +110,12 @@ bool CScriptInstance::Run(const char* path) duk_pop(m_Ctx); } - catch (std::runtime_error& exc) + catch (std::runtime_error & exc) { FatalHandler(exc); } return true; - error_cleanup: Cleanup(); @@ -128,7 +129,7 @@ void CScriptInstance::IncRefCount() void CScriptInstance::DecRefCount() { - if(m_RefCount > 0) + if (m_RefCount > 0) { m_RefCount--; } @@ -150,7 +151,7 @@ bool CScriptInstance::PrepareAbort() return false; } -void CScriptInstance::RawCMethodCall(void* dukThisHeapPtr, duk_c_function func, JSDukArgSetupFunc argSetupFunc, void *argSetupParam) +void CScriptInstance::RawCMethodCall(void * dukThisHeapPtr, duk_c_function func, JSDukArgSetupFunc argSetupFunc, void * argSetupParam) { try { @@ -168,22 +169,22 @@ void CScriptInstance::RawCMethodCall(void* dukThisHeapPtr, duk_c_function func, duk_pop(m_Ctx); } - catch (std::runtime_error& exc) + catch (std::runtime_error & exc) { FatalHandler(exc); } } -void CScriptInstance::PostCMethodCall(void* dukThisHeapPtr, duk_c_function func, JSDukArgSetupFunc argSetupFunc, - void* argSetupParam, size_t argSetupParamSize) +void CScriptInstance::PostCMethodCall(void * dukThisHeapPtr, duk_c_function func, JSDukArgSetupFunc argSetupFunc, + void * argSetupParam, size_t argSetupParamSize) { m_System->PostCMethodCall(m_InstanceName.c_str(), dukThisHeapPtr, func, argSetupFunc, argSetupParam, argSetupParamSize); } -void CScriptInstance::RawConsoleInput(const char* code) +void CScriptInstance::RawConsoleInput(const char * code) { m_System->ConsoleLog("> %s", code); - + try { duk_get_global_string(m_Ctx, HS_gInputListener); @@ -234,8 +235,8 @@ void CScriptInstance::RawConsoleInput(const char* code) duk_push_int(m_Ctx, 2); duk_pcall(m_Ctx, 3); - const char* str = duk_safe_to_string(m_Ctx, -2); - const char* res = duk_get_string(m_Ctx, -1); + const char * str = duk_safe_to_string(m_Ctx, -2); + const char * res = duk_get_string(m_Ctx, -1); m_System->ConsoleLog("%s %s", str, res); duk_pop(m_Ctx); @@ -247,7 +248,7 @@ void CScriptInstance::RawConsoleInput(const char* code) } duk_pop(m_Ctx); } - catch (std::runtime_error& exc) + catch (std::runtime_error & exc) { FatalHandler(exc); } @@ -260,7 +261,7 @@ void CScriptInstance::SetExecTimeout(uint64_t timeout) bool CScriptInstance::IsTimedOut() { - if(m_ExecStartTime == 0 || m_ExecTimeout == 0) + if (m_ExecStartTime == 0 || m_ExecTimeout == 0) { return false; } @@ -283,23 +284,23 @@ uint64_t CScriptInstance::Timestamp() void CScriptInstance::Cleanup() { - if(m_Ctx != nullptr) + if (m_Ctx != nullptr) { duk_destroy_heap(m_Ctx); m_Ctx = nullptr; } - if(m_SourceCode != nullptr) + if (m_SourceCode != nullptr) { delete[] m_SourceCode; m_SourceCode = nullptr; } - if(m_SourceFile.is_open()) + if (m_SourceFile.is_open()) { m_SourceFile.close(); } } -bool CScriptInstance::RegisterWorker(CScriptWorker* worker) +bool CScriptInstance::RegisterWorker(CScriptWorker * worker) { if (IsStopping()) { @@ -310,9 +311,9 @@ bool CScriptInstance::RegisterWorker(CScriptWorker* worker) return true; } -void CScriptInstance::UnregisterWorker(CScriptWorker* worker) +void CScriptInstance::UnregisterWorker(CScriptWorker * worker) { - std::vector::iterator it; + std::vector::iterator it; for (it = m_Workers.begin(); it != m_Workers.end(); it++) { @@ -326,15 +327,15 @@ void CScriptInstance::UnregisterWorker(CScriptWorker* worker) void CScriptInstance::StopRegisteredWorkers() { - std::vector::iterator it; + std::vector::iterator it; for (it = m_Workers.begin(); it != m_Workers.end(); it++) { - CScriptWorker* worker = *it; + CScriptWorker * worker = *it; worker->StopWorkerProc(); } } -void CScriptInstance::FatalHandler(std::runtime_error& exc) +void CScriptInstance::FatalHandler(std::runtime_error & exc) { if (m_bAborting) { diff --git a/Source/Project64/UserInterface/Debugger/ScriptSystem.cpp b/Source/Project64/UserInterface/Debugger/ScriptSystem.cpp index f975cbdfb..b4690d233 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptSystem.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptSystem.cpp @@ -1,14 +1,15 @@ -#include -#include -#include -#include "ScriptTypes.h" -#include "ScriptSystem.h" -#include "ScriptInstance.h" -#include "ScriptAPI/ScriptAPI.h" +#include "stdafx.h" + #include "Debugger.h" #include "Project64\UserInterface\DiscordRPC.h" +#include "ScriptAPI/ScriptAPI.h" +#include "ScriptInstance.h" +#include "ScriptSystem.h" +#include "ScriptTypes.h" +#include +#include -CScriptSystem::CScriptSystem(CDebuggerUI *debugger) : +CScriptSystem::CScriptSystem(CDebuggerUI * debugger) : m_Debugger(debugger), m_NextAppCallbackId(0), m_AppCallbackCount(0), @@ -30,7 +31,7 @@ CScriptSystem::~CScriptSystem() CloseHandle(m_hCmdEvent); } -JSInstanceStatus CScriptSystem::GetStatus(const char* name) +JSInstanceStatus CScriptSystem::GetStatus(const char * name) { CGuard guard(m_UIStateCS); if (m_UIInstanceStatus.count(name) == 0) @@ -43,7 +44,7 @@ JSInstanceStatus CScriptSystem::GetStatus(const char* name) } } -void CScriptSystem::NotifyStatus(const char* name, JSInstanceStatus status) +void CScriptSystem::NotifyStatus(const char * name, JSInstanceStatus status) { CGuard guard(m_UIStateCS); if (status == JS_STATUS_STOPPED) @@ -57,7 +58,7 @@ void CScriptSystem::NotifyStatus(const char* name, JSInstanceStatus status) m_Debugger->Debug_RefreshScriptsWindow(); } -void CScriptSystem::ConsoleLog(const char* format, ...) +void CScriptSystem::ConsoleLog(const char * format, ...) { CGuard guard(m_UIStateCS); @@ -65,11 +66,11 @@ void CScriptSystem::ConsoleLog(const char* format, ...) va_start(args, format); int size = vsnprintf(nullptr, 0, format, args) + 1; - char* str = new char[size]; + char * str = new char[size]; vsnprintf(str, size, format, args); stdstr formattedMsg = FixStringReturns(str) + "\r\n"; - + m_Debugger->Debug_LogScriptsWindow(formattedMsg.c_str()); m_UILog += formattedMsg; @@ -77,7 +78,7 @@ void CScriptSystem::ConsoleLog(const char* format, ...) va_end(args); } -void CScriptSystem::ConsolePrint(const char* format, ...) +void CScriptSystem::ConsolePrint(const char * format, ...) { CGuard guard(m_UIStateCS); @@ -85,11 +86,11 @@ void CScriptSystem::ConsolePrint(const char* format, ...) va_start(args, format); int size = vsnprintf(nullptr, 0, format, args) + 1; - char* str = new char[size]; + char * str = new char[size]; vsnprintf(str, size, format, args); - + stdstr formattedMsg = FixStringReturns(str); - + m_Debugger->Debug_LogScriptsWindow(formattedMsg.c_str()); m_UILog += formattedMsg; @@ -142,17 +143,17 @@ void CScriptSystem::InitDirectories() } } -void CScriptSystem::StartScript(const char *name, const char *path) +void CScriptSystem::StartScript(const char * name, const char * path) { PostCommand(JS_CMD_START_SCRIPT, name, path); } -void CScriptSystem::StopScript(const char *name) +void CScriptSystem::StopScript(const char * name) { PostCommand(JS_CMD_STOP_SCRIPT, name); } -void CScriptSystem::Input(const char *name, const char *code) +void CScriptSystem::Input(const char * name, const char * code) { PostCommand(JS_CMD_INPUT, name, code); } @@ -165,19 +166,19 @@ bool CScriptSystem::HaveAppCallbacks(JSAppHookID hookId) m_AppCallbackHooks[hookId].size() > 0); } -void CScriptSystem::InvokeAppCallbacks(JSAppHookID hookId, void* env) +void CScriptSystem::InvokeAppCallbacks(JSAppHookID hookId, void * env) { CGuard guard(m_InstancesCS); - - JSAppCallbackList& callbacks = m_AppCallbackHooks[hookId]; + + JSAppCallbackList & callbacks = m_AppCallbackHooks[hookId]; size_t numCallbacks = callbacks.size(); bool bNeedSweep = false; for (size_t i = 0; i < numCallbacks; i++) { - JSAppCallback& callback = callbacks[i]; - CScriptInstance* instance = callback.m_Instance; + JSAppCallback & callback = callbacks[i]; + CScriptInstance * instance = callback.m_Instance; if (callback.m_bDisabled || instance->IsStopping() || @@ -201,14 +202,14 @@ void CScriptSystem::InvokeAppCallbacks(JSAppHookID hookId, void* env) } } -void CScriptSystem::UpdateCpuCbListInfo(volatile JSCpuCbListInfo& info, JSAppCallbackList& callbacks) +void CScriptSystem::UpdateCpuCbListInfo(volatile JSCpuCbListInfo & info, JSAppCallbackList & callbacks) { uint32_t minAddrStart = 0; uint32_t maxAddrEnd = 0; int numCacheEntries = 0; bool bCacheExceeded = false; - for (JSAppCallback& callback : callbacks) + for (JSAppCallback & callback : callbacks) { size_t i; for (i = 0; i < numCacheEntries; i++) @@ -238,7 +239,7 @@ void CScriptSystem::UpdateCpuCbListInfo(volatile JSCpuCbListInfo& info, JSAppCal numCacheEntries++; } } - + if (callback.m_Params.addrStart < minAddrStart) { minAddrStart = callback.m_Params.addrStart; @@ -259,7 +260,7 @@ void CScriptSystem::UpdateCpuCbListInfo(volatile JSCpuCbListInfo& info, JSAppCal void CScriptSystem::RefreshCallbackMaps() { - for (JSAppCallbackList& callbacks : m_AppCallbackHooks) + for (JSAppCallbackList & callbacks : m_AppCallbackHooks) { JSAppCallbackList::iterator it = callbacks.begin(); @@ -301,23 +302,23 @@ void CScriptSystem::DoMouseEvent(JSAppHookID hookId, int x, int y, DWORD uMsg) break; } - JSHookMouseEnv env = { x, y, button }; - InvokeAppCallbacks(hookId, (void*)&env); + JSHookMouseEnv env = {x, y, button}; + InvokeAppCallbacks(hookId, (void *)&env); } -void CScriptSystem::PostCMethodCall(const char* name, void *dukThisHeapPtr, duk_c_function func, - JSDukArgSetupFunc argSetupFunc, void *argSetupParam, size_t argSetupParamSize) +void CScriptSystem::PostCMethodCall(const char * name, void * dukThisHeapPtr, duk_c_function func, + JSDukArgSetupFunc argSetupFunc, void * argSetupParam, size_t argSetupParamSize) { CGuard guard(m_CmdQueueCS); // Will be deleted by command handler - JSSysCMethodCall* methodCall = new JSSysCMethodCall(dukThisHeapPtr, func, argSetupFunc, argSetupParam, argSetupParamSize); - PostCommand(JS_CMD_C_METHOD_CALL, name, "", (void*)methodCall); + JSSysCMethodCall * methodCall = new JSSysCMethodCall(dukThisHeapPtr, func, argSetupFunc, argSetupParam, argSetupParamSize); + PostCommand(JS_CMD_C_METHOD_CALL, name, "", (void *)methodCall); } -void CScriptSystem::PostCommand(JSSysCommandID id, stdstr paramA, stdstr paramB, void* paramC) +void CScriptSystem::PostCommand(JSSysCommandID id, stdstr paramA, stdstr paramB, void * paramC) { CGuard guard(m_CmdQueueCS); - JSSysCommand cmd = { id, paramA, paramB, paramC }; + JSSysCommand cmd = {id, paramA, paramB, paramC}; if (id == JS_CMD_STOP_SCRIPT) { @@ -336,7 +337,7 @@ void CScriptSystem::PostCommand(JSSysCommandID id, stdstr paramA, stdstr paramB, SetEvent(m_hCmdEvent); } -DWORD CScriptSystem::ThreadProc(void *_this) +DWORD CScriptSystem::ThreadProc(void * _this) { ((CScriptSystem *)_this)->ThreadProc(); return 0; @@ -346,7 +347,7 @@ void CScriptSystem::ThreadProc() { std::vector queue; - while(true) + while (true) { WaitForSingleObject(m_hCmdEvent, INFINITE); @@ -363,18 +364,18 @@ void CScriptSystem::ThreadProc() } } -void CScriptSystem::OnStartScript(const char *name, const char *path) +void CScriptSystem::OnStartScript(const char * name, const char * path) { if (m_Instances.count(name) != 0) { ConsoleLog("[SCRIPTSYS]: error: START_SCRIPT aborted; '%s' is already instanced", name); } - CScriptInstance *inst = new CScriptInstance(this, name); - + CScriptInstance * inst = new CScriptInstance(this, name); + NotifyStatus(name, JS_STATUS_STARTING); - if(inst->Run(path) && inst->GetRefCount() > 0) + if (inst->Run(path) && inst->GetRefCount() > 0) { m_Instances[name] = inst; NotifyStatus(name, JS_STATUS_STARTED); @@ -386,7 +387,7 @@ void CScriptSystem::OnStartScript(const char *name, const char *path) } } -void CScriptSystem::OnStopScript(const char *name) +void CScriptSystem::OnStopScript(const char * name) { if (m_Instances.count(name) == 0) { @@ -399,26 +400,26 @@ void CScriptSystem::OnStopScript(const char *name) NotifyStatus(name, JS_STATUS_STOPPED); } -void CScriptSystem::OnInput(const char *name, const char *code) +void CScriptSystem::OnInput(const char * name, const char * code) { - if(m_Instances.count(name) == 0) + if (m_Instances.count(name) == 0) { ConsoleLog("[SCRIPTSYS]: error: INPUT aborted; instance '%s' does not exist", name); return; } - CScriptInstance* inst = m_Instances[name]; + CScriptInstance * inst = m_Instances[name]; inst->RawConsoleInput(code); - if(!inst->IsStopping() && inst->GetRefCount() == 0) + if (!inst->IsStopping() && inst->GetRefCount() == 0) { NotifyStatus(name, JS_STATUS_STOPPED); RawRemoveInstance(name); } } -void CScriptSystem::OnCMethodCall(const char *name, JSSysCMethodCall* methodCall) +void CScriptSystem::OnCMethodCall(const char * name, JSSysCMethodCall * methodCall) { if (m_Instances.count(name) == 0) { @@ -430,7 +431,7 @@ void CScriptSystem::OnCMethodCall(const char *name, JSSysCMethodCall* methodCall return; } - CScriptInstance* inst = m_Instances[name]; + CScriptInstance * inst = m_Instances[name]; inst->RawCMethodCall(methodCall->m_DukThisHeapPtr, methodCall->m_Func, methodCall->m_ArgSetupFunc, methodCall->m_ArgSetupParam); @@ -444,10 +445,10 @@ void CScriptSystem::OnCMethodCall(const char *name, JSSysCMethodCall* methodCall void CScriptSystem::OnSweep(bool bIfDone) { JSInstanceMap::iterator it = m_Instances.begin(); - while(it != m_Instances.end()) + while (it != m_Instances.end()) { - CScriptInstance*& inst = it->second; - if(!bIfDone || inst->GetRefCount() == 0) + CScriptInstance *& inst = it->second; + if (!bIfDone || inst->GetRefCount() == 0) { NotifyStatus(inst->Name().c_str(), JS_STATUS_STOPPED); delete inst; @@ -460,14 +461,14 @@ void CScriptSystem::OnSweep(bool bIfDone) } } -bool CScriptSystem::RawRemoveInstance(const char *name) +bool CScriptSystem::RawRemoveInstance(const char * name) { - if(m_Instances.count(name) == 0) + if (m_Instances.count(name) == 0) { return false; } - CScriptInstance*& inst = m_Instances[name]; + CScriptInstance *& inst = m_Instances[name]; if (inst->IsStopping()) { @@ -476,7 +477,7 @@ bool CScriptSystem::RawRemoveInstance(const char *name) inst->SetStopping(true); inst->StopRegisteredWorkers(); - + std::vector pendingCalls; PullCommands(JS_CMD_C_METHOD_CALL, pendingCalls); ProcessCommandQueue(pendingCalls); @@ -486,9 +487,9 @@ bool CScriptSystem::RawRemoveInstance(const char *name) return true; } -JSAppCallbackID CScriptSystem::RawAddAppCallback(JSAppHookID hookId, JSAppCallback& callback) +JSAppCallbackID CScriptSystem::RawAddAppCallback(JSAppHookID hookId, JSAppCallback & callback) { - if(hookId >= JS_NUM_APP_HOOKS) + if (hookId >= JS_NUM_APP_HOOKS) { return JS_INVALID_CALLBACK; } @@ -533,7 +534,7 @@ void CScriptSystem::ExecAutorunList() } } -std::set& CScriptSystem::AutorunList() +std::set & CScriptSystem::AutorunList() { return m_AutorunList; } @@ -568,12 +569,12 @@ void CScriptSystem::SaveAutorunList() g_Settings->SaveString(Debugger_AutorunScripts, joinedNames.c_str()); } -CDebuggerUI* CScriptSystem::Debugger() +CDebuggerUI * CScriptSystem::Debugger() { return m_Debugger; } -stdstr CScriptSystem::FixStringReturns(const char* str) +stdstr CScriptSystem::FixStringReturns(const char * str) { stdstr fstr = str; size_t pos = 0; @@ -585,7 +586,7 @@ stdstr CScriptSystem::FixStringReturns(const char* str) return fstr; } -bool CScriptSystem::ProcessCommandQueue(std::vector& queue) +bool CScriptSystem::ProcessCommandQueue(std::vector & queue) { std::vector::iterator it; for (it = queue.begin(); it != queue.end(); it++) @@ -599,7 +600,7 @@ bool CScriptSystem::ProcessCommandQueue(std::vector& queue) return true; } -bool CScriptSystem::ProcessCommand(JSSysCommand& cmd) +bool CScriptSystem::ProcessCommand(JSSysCommand & cmd) { CGuard guard(m_InstancesCS); @@ -615,12 +616,12 @@ bool CScriptSystem::ProcessCommand(JSSysCommand& cmd) OnInput(cmd.paramA.c_str(), cmd.paramB.c_str()); break; case JS_CMD_C_METHOD_CALL: - { - JSSysCMethodCall* methodCall = (JSSysCMethodCall*)cmd.paramC; - OnCMethodCall(cmd.paramA.c_str(), methodCall); - delete methodCall; - } - break; + { + JSSysCMethodCall * methodCall = (JSSysCMethodCall *)cmd.paramC; + OnCMethodCall(cmd.paramA.c_str(), methodCall); + delete methodCall; + } + break; case JS_CMD_SWEEP: OnSweep(true); break; @@ -633,7 +634,7 @@ bool CScriptSystem::ProcessCommand(JSSysCommand& cmd) return true; } -void CScriptSystem::PullCommands(JSSysCommandID id, std::vector& out) +void CScriptSystem::PullCommands(JSSysCommandID id, std::vector & out) { CGuard guard(m_CmdQueueCS); diff --git a/Source/Project64/UserInterface/Debugger/ScriptWorker.cpp b/Source/Project64/UserInterface/Debugger/ScriptWorker.cpp index 01db434ab..3791d1982 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptWorker.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptWorker.cpp @@ -1,8 +1,9 @@ -#include -#include "ScriptWorker.h" -#include "ScriptInstance.h" +#include "stdafx.h" -CScriptWorker::CScriptWorker(CScriptInstance* instance, void* dukObjectHeapPtr) : +#include "ScriptInstance.h" +#include "ScriptWorker.h" + +CScriptWorker::CScriptWorker(CScriptInstance * instance, void * dukObjectHeapPtr) : m_bStopping(false), m_bRegistered(false), m_hThread(nullptr), @@ -21,8 +22,9 @@ CScriptWorker::~CScriptWorker() } } -DWORD WINAPI CScriptWorker::ThreadProc(void* _this) { - ((CScriptWorker*)_this)->WorkerProc(); +DWORD WINAPI CScriptWorker::ThreadProc(void * _this) +{ + ((CScriptWorker *)_this)->WorkerProc(); return 0; } @@ -38,7 +40,7 @@ void CScriptWorker::StartWorkerProc() return; } - m_hThread = CreateThread(0, 0, ThreadProc, (void*)this, 0, nullptr); + m_hThread = CreateThread(0, 0, ThreadProc, (void *)this, 0, nullptr); } void CScriptWorker::StopWorkerProc() diff --git a/Source/Project64/UserInterface/Debugger/Symbols.cpp b/Source/Project64/UserInterface/Debugger/Symbols.cpp index 830eecee5..f4f1efa7b 100644 --- a/Source/Project64/UserInterface/Debugger/Symbols.cpp +++ b/Source/Project64/UserInterface/Debugger/Symbols.cpp @@ -1,7 +1,8 @@ #include "stdafx.h" + #include "Symbols.h" -CSymbolTable::CSymbolTable(CDebuggerUI* debugger) : +CSymbolTable::CSymbolTable(CDebuggerUI * debugger) : m_Debugger(debugger), m_NextSymbolId(0), m_SymFileBuffer(nullptr), @@ -22,27 +23,27 @@ CSymbolTable::~CSymbolTable() } symbol_type_info_t CSymbolTable::m_SymbolTypes[] = { - { SYM_CODE, "code", 1 }, - { SYM_DATA, "data", 1 }, - { SYM_U8, "u8", 1 }, - { SYM_U16, "u16", 2 }, - { SYM_U32, "u32", 4 }, - { SYM_U64, "u64", 8 }, - { SYM_S8, "s8", 1 }, - { SYM_S16, "s16", 2 }, - { SYM_S32, "s32", 4 }, - { SYM_S64, "s64", 8 }, - { SYM_FLOAT, "float", 4 }, - { SYM_DOUBLE, "double", 8 }, - { SYM_VECTOR2, "v2", 8 }, - { SYM_VECTOR3, "v3", 12 }, - { SYM_VECTOR4, "v4", 16 }, + {SYM_CODE, "code", 1}, + {SYM_DATA, "data", 1}, + {SYM_U8, "u8", 1}, + {SYM_U16, "u16", 2}, + {SYM_U32, "u32", 4}, + {SYM_U64, "u64", 8}, + {SYM_S8, "s8", 1}, + {SYM_S16, "s16", 2}, + {SYM_S32, "s32", 4}, + {SYM_S64, "s64", 8}, + {SYM_FLOAT, "float", 4}, + {SYM_DOUBLE, "double", 8}, + {SYM_VECTOR2, "v2", 8}, + {SYM_VECTOR3, "v3", 12}, + {SYM_VECTOR4, "v4", 16}, { SYM_INVALID, nullptr, 0 } }; -symbol_type_id_t CSymbolTable::GetTypeId(char* typeName) +symbol_type_id_t CSymbolTable::GetTypeId(char * typeName) { - const char* name; + const char * name; for (int i = 0; (name = m_SymbolTypes[i].name) != nullptr; i++) { if (strcmp(typeName, name) == 0) @@ -53,7 +54,7 @@ symbol_type_id_t CSymbolTable::GetTypeId(char* typeName) return SYM_INVALID; } -const char* CSymbolTable::GetTypeName(int typeId) +const char * CSymbolTable::GetTypeName(int typeId) { if (typeId >= NUM_SYM_TYPES) { @@ -94,7 +95,7 @@ CPath CSymbolTable::GetSymFilePath() return symFilePath; } -void CSymbolTable::ParserFetchToken(const char* delim) +void CSymbolTable::ParserFetchToken(const char * delim) { if (!m_bHaveFirstToken) { @@ -106,7 +107,7 @@ void CSymbolTable::ParserFetchToken(const char* delim) { m_ParserToken = strtok_s(nullptr, delim, &m_TokPos); } - + if (m_ParserToken != nullptr) { m_ParserTokenLength = strlen(m_ParserToken); @@ -133,16 +134,16 @@ void CSymbolTable::Load() MessageBox(nullptr, L"Game must be loaded", L"Symbols", MB_ICONWARNING | MB_OK); return; } - + CPath symFilePath = GetSymFilePath(); - + bool bOpened = m_SymFileHandle.Open(symFilePath, CFileBase::modeRead); - + if (!bOpened) { return; } - + if (m_SymFileBuffer != nullptr) { delete[] m_SymFileBuffer; @@ -159,7 +160,7 @@ void CSymbolTable::Load() m_SymFileHandle.Read(m_SymFileBuffer, m_SymFileSize); m_SymFileHandle.Close(); m_SymFileBuffer[m_SymFileSize] = '\0'; - + strcpy(m_SymFileParseBuffer, m_SymFileBuffer); m_bHaveFirstToken = false; @@ -170,9 +171,9 @@ void CSymbolTable::Load() { uint32_t address = 0; int type = 0; - char* name = nullptr; - char* description = nullptr; - + char * name = nullptr; + char * description = nullptr; + // Address ParserFetchToken(",\n\0"); @@ -183,22 +184,22 @@ void CSymbolTable::Load() break; } - char* endptr; + char * endptr; address = (uint32_t)strtoull(m_ParserToken, &endptr, 16); - + if (endptr == m_ParserToken) { errorCode = ERR_INVALID_ADDR; break; } - + // Type if (m_ParserDelimeter != ',') { errorCode = ERR_MISSING_FIELDS; break; } - + ParserFetchToken(",\n\0"); type = GetTypeId(m_ParserToken); @@ -207,7 +208,7 @@ void CSymbolTable::Load() errorCode = ERR_INVALID_TYPE; break; } - + // Name if (m_ParserDelimeter != ',') { @@ -224,7 +225,7 @@ void CSymbolTable::Load() ParserFetchToken("\n\0"); description = m_ParserToken; } - + // Add symbol object to the vector AddSymbol(type, address, name, description, false); @@ -239,7 +240,7 @@ void CSymbolTable::Load() sort(m_Symbols.begin(), m_Symbols.end(), CmpSymbolAddresses); UpdateAddressMap(); - + delete[] m_SymFileParseBuffer; m_SymFileParseBuffer = nullptr; @@ -274,9 +275,9 @@ void CSymbolTable::Save() for (size_t i = 0; i < m_Symbols.size(); i++) { - CSymbol& symbol = m_Symbols[i]; + CSymbol & symbol = m_Symbols[i]; stdstr strLine = stdstr_f("%08X,%s,%s", symbol.m_Address, symbol.TypeName(), symbol.m_Name); - + if (symbol.m_Description != nullptr) { strLine += stdstr_f(",%s", symbol.m_Description); @@ -290,20 +291,20 @@ void CSymbolTable::Save() m_SymFileHandle.Close(); } -void CSymbolTable::GetValueString(char* dst, CSymbol* symbol) +void CSymbolTable::GetValueString(char * dst, CSymbol * symbol) { union { - uint8_t u8; - int8_t s8; + uint8_t u8; + int8_t s8; uint16_t u16; - int16_t s16; + int16_t s16; uint32_t u32; - int32_t s32; + int32_t s32; uint64_t u64; - int64_t s64; - float f32; - double f64; + int64_t s64; + float f32; + double f64; } value; uint32_t address = symbol->m_Address; @@ -356,21 +357,24 @@ void CSymbolTable::GetValueString(char* dst, CSymbol* symbol) sprintf(dst, "%f", value.f64); break; case SYM_VECTOR2: - for (int i = 0; i < 2; i++) { + for (int i = 0; i < 2; i++) + { m_Debugger->DebugLoad_VAddr(address + (i * sizeof(float)), value.f32); xyzw[i] = value.f32; } sprintf(dst, "%f, %f", xyzw[0], xyzw[1]); break; case SYM_VECTOR3: - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) + { m_Debugger->DebugLoad_VAddr(address + (i * sizeof(float)), value.f32); xyzw[i] = value.f32; } sprintf(dst, "%f, %f, %f", xyzw[0], xyzw[1], xyzw[2]); break; case SYM_VECTOR4: - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) + { m_Debugger->DebugLoad_VAddr(address + (i * sizeof(float)), value.f32); xyzw[i] = value.f32; } @@ -382,7 +386,7 @@ void CSymbolTable::GetValueString(char* dst, CSymbol* symbol) } } -void CSymbolTable::ParseErrorAlert(char* message, int lineNumber) +void CSymbolTable::ParseErrorAlert(char * message, int lineNumber) { stdstr messageFormatted = stdstr_f("%s\nLine %d", message, lineNumber); MessageBox(nullptr, messageFormatted.ToUTF16().c_str(), L"Symbol parse error", MB_OK | MB_ICONWARNING); @@ -394,12 +398,12 @@ void CSymbolTable::Reset() m_Symbols.clear(); } -bool CSymbolTable::CmpSymbolAddresses(CSymbol& a, CSymbol& b) +bool CSymbolTable::CmpSymbolAddresses(CSymbol & a, CSymbol & b) { return (a.m_Address < b.m_Address); } -void CSymbolTable::AddSymbol(int type, uint32_t address, const char* name, const char* description, bool bSortAfter) +void CSymbolTable::AddSymbol(int type, uint32_t address, const char * name, const char * description, bool bSortAfter) { CGuard guard(m_CS); @@ -441,7 +445,7 @@ int CSymbolTable::GetCount() return m_Symbols.size(); } -bool CSymbolTable::GetSymbolByIndex(size_t index, CSymbol* symbol) +bool CSymbolTable::GetSymbolByIndex(size_t index, CSymbol * symbol) { CGuard guard(m_CS); if (index < 0 || index >= m_Symbols.size()) @@ -452,7 +456,7 @@ bool CSymbolTable::GetSymbolByIndex(size_t index, CSymbol* symbol) return true; } -bool CSymbolTable::GetSymbolByAddress(uint32_t address, CSymbol* symbol) +bool CSymbolTable::GetSymbolByAddress(uint32_t address, CSymbol * symbol) { CGuard guard(m_CS); @@ -466,7 +470,7 @@ bool CSymbolTable::GetSymbolByAddress(uint32_t address, CSymbol* symbol) return true; } -bool CSymbolTable::GetSymbolById(int id, CSymbol* symbol) +bool CSymbolTable::GetSymbolById(int id, CSymbol * symbol) { CGuard guard(m_CS); for (size_t i = 0; i < m_Symbols.size(); i++) diff --git a/Source/Project64/UserInterface/Debugger/Symbols.h b/Source/Project64/UserInterface/Debugger/Symbols.h index 899f38ae1..61104dec4 100644 --- a/Source/Project64/UserInterface/Debugger/Symbols.h +++ b/Source/Project64/UserInterface/Debugger/Symbols.h @@ -1,5 +1,4 @@ #pragma once -#include "stdafx.h" class CSymbol; diff --git a/Source/Project64/UserInterface/DiscordRPC.cpp b/Source/Project64/UserInterface/DiscordRPC.cpp index 7740d2f0e..d985f31d0 100644 --- a/Source/Project64/UserInterface/DiscordRPC.cpp +++ b/Source/Project64/UserInterface/DiscordRPC.cpp @@ -1,77 +1,80 @@ #include "stdafx.h" -#include <3rdParty\discord-rpc\include\discord_rpc.h> -#include "DiscordRPC.h" -#define UNIX_TIME_START 0x019DB1DED53E8000 -#define TICKS_PER_SECOND 10000000 +#include "DiscordRPC.h" +#include <3rdParty\discord-rpc\include\discord_rpc.h> + +#define UNIX_TIME_START 0x019DB1DED53E8000 +#define TICKS_PER_SECOND 10000000 // Discord Project64 app ID #define PJ64_DISCORD_APPID "704794684387491891" void CDiscord::Init() { - DiscordEventHandlers handlers = {}; + DiscordEventHandlers handlers = {}; - Discord_Initialize(PJ64_DISCORD_APPID, &handlers, 1, nullptr); + Discord_Initialize(PJ64_DISCORD_APPID, &handlers, 1, nullptr); } void CDiscord::Shutdown() { - Discord_ClearPresence(); - Discord_Shutdown(); + Discord_ClearPresence(); + Discord_Shutdown(); } -static stdstr GetTitle() +static stdstr GetTitle() { - stdstr Default = ""; - bool existsInRdb = g_Settings->LoadStringVal(Rdb_GoodName, Default); - if (existsInRdb) - return g_Settings->LoadStringVal(Rdb_GoodName); - else { - Default = CPath(g_Settings->LoadStringVal(Game_File)).GetName().c_str(); - if (strstr(const_cast(Default.c_str()), "?") != nullptr) { - return Default.substr(Default.find("?") + 1); - } - return Default; - } + stdstr Default = ""; + bool existsInRdb = g_Settings->LoadStringVal(Rdb_GoodName, Default); + if (existsInRdb) + return g_Settings->LoadStringVal(Rdb_GoodName); + else + { + Default = CPath(g_Settings->LoadStringVal(Game_File)).GetName().c_str(); + if (strstr(const_cast(Default.c_str()), "?") != nullptr) + { + return Default.substr(Default.find("?") + 1); + } + return Default; + } } void CDiscord::Update(bool bHaveGame) { - // Variables we use later - // Title uses the Rdb_GoodName to display a proper game name over DiscordRPC - // Artwork uses the header of the ROM to easily add game images through the Discord developer panel using the ID above - stdstr title = bHaveGame ? GetTitle() : ""; - stdstr artwork = bHaveGame ? g_Settings->LoadStringVal(Rdb_RPCKey) : ""; + // Variables we use later + // Title uses the Rdb_GoodName to display a proper game name over DiscordRPC + // Artwork uses the header of the ROM to easily add game images through the Discord developer panel using the ID above + stdstr title = bHaveGame ? GetTitle() : ""; + stdstr artwork = bHaveGame ? g_Settings->LoadStringVal(Rdb_RPCKey) : ""; - // Load game into DiscordRPC - DiscordRichPresence discordPresence = {}; // Activates DiscordRPC - if (artwork.empty()) - { - discordPresence.largeImageKey = "pj64_icon"; - discordPresence.largeImageText = "Project64"; - } - else - { - discordPresence.largeImageKey = artwork.c_str(); - discordPresence.largeImageText = title.c_str(); - discordPresence.smallImageKey = "pj64_icon"; - discordPresence.smallImageText = "Project64"; - } - discordPresence.details = title.empty() ? "Not in-game" : title.c_str(); - discordPresence.startTimestamp = Timestamp(); + // Load game into DiscordRPC + DiscordRichPresence discordPresence = {}; // Activates DiscordRPC + if (artwork.empty()) + { + discordPresence.largeImageKey = "pj64_icon"; + discordPresence.largeImageText = "Project64"; + } + else + { + discordPresence.largeImageKey = artwork.c_str(); + discordPresence.largeImageText = title.c_str(); + discordPresence.smallImageKey = "pj64_icon"; + discordPresence.smallImageText = "Project64"; + } + discordPresence.details = title.empty() ? "Not in-game" : title.c_str(); + discordPresence.startTimestamp = Timestamp(); - Discord_UpdatePresence(&discordPresence); // End DiscordRPC + Discord_UpdatePresence(&discordPresence); // End DiscordRPC } int64_t CDiscord::Timestamp() { - FILETIME ft; - GetSystemTimeAsFileTime(&ft); + FILETIME ft; + GetSystemTimeAsFileTime(&ft); - LARGE_INTEGER li; - li.LowPart = ft.dwLowDateTime; - li.HighPart = ft.dwHighDateTime; + LARGE_INTEGER li; + li.LowPart = ft.dwLowDateTime; + li.HighPart = ft.dwHighDateTime; - return (li.QuadPart - UNIX_TIME_START) / TICKS_PER_SECOND; + return (li.QuadPart - UNIX_TIME_START) / TICKS_PER_SECOND; } diff --git a/Source/Project64/UserInterface/EnhancementUI.cpp b/Source/Project64/UserInterface/EnhancementUI.cpp index 9a8e5c80e..32b2db5aa 100644 --- a/Source/Project64/UserInterface/EnhancementUI.cpp +++ b/Source/Project64/UserInterface/EnhancementUI.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include #include diff --git a/Source/Project64/UserInterface/LoggingUI.cpp b/Source/Project64/UserInterface/LoggingUI.cpp index 5fc7dae3f..e1ec75f22 100644 --- a/Source/Project64/UserInterface/LoggingUI.cpp +++ b/Source/Project64/UserInterface/LoggingUI.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include #include #include @@ -102,7 +103,7 @@ LRESULT CALLBACK LogPifProc(HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lPar } break; case WM_NOTIFY: - if (((NMHDR FAR *) lParam)->code != PSN_APPLY) + if (((NMHDR FAR *)lParam)->code != PSN_APPLY) { break; } @@ -138,7 +139,7 @@ LRESULT CALLBACK LogRegProc(HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lPar } break; case WM_NOTIFY: - if (((NMHDR FAR *) lParam)->code != PSN_APPLY) + if (((NMHDR FAR *)lParam)->code != PSN_APPLY) { break; } diff --git a/Source/Project64/UserInterface/MainMenu.cpp b/Source/Project64/UserInterface/MainMenu.cpp index 9d55bc3ae..4e2bf58f2 100644 --- a/Source/Project64/UserInterface/MainMenu.cpp +++ b/Source/Project64/UserInterface/MainMenu.cpp @@ -1,12 +1,13 @@ #include "stdafx.h" -#include "RomInformation.h" + #include "Debugger/Breakpoints.h" #include "Debugger/ScriptSystem.h" #include "DiscordRPC.h" +#include "RomInformation.h" #include #include -#include #include +#include CMainMenu::CMainMenu(CMainGui * hMainWindow) : CBaseMenu(), @@ -150,7 +151,7 @@ void CMainMenu::OnOpenRom(HWND hWnd) { return; } - + stdstr ext = CPath(File).GetExtension(); if ((_stricmp(ext.c_str(), "ndd") != 0) && (_stricmp(ext.c_str(), "d64") != 0)) { @@ -203,10 +204,10 @@ void CMainMenu::OnEndEmulation(void) } m_Gui->SaveWindowLoc(); - if (UISettingsLoadBool(Setting_EnableDiscordRPC)) - { - CDiscord::Update(false); - } + if (UISettingsLoadBool(Setting_EnableDiscordRPC)) + { + CDiscord::Update(false); + } } void CMainMenu::OnScreenShot(void) @@ -333,7 +334,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI WriteTrace(TraceUserInterface, TraceDebug, "ID_FILE_ROMDIRECTORY 3"); break; case ID_FILE_REFRESHROMLIST: m_Gui->RefreshRomList(); break; - case ID_FILE_EXIT: DestroyWindow((HWND)hWnd); break; + case ID_FILE_EXIT: DestroyWindow((HWND)hWnd); break; case ID_SYSTEM_RESET_SOFT: WriteTrace(TraceUserInterface, TraceDebug, "ID_SYSTEM_RESET_SOFT"); g_BaseSystem->ExternalEvent(SysEvent_ResetCPU_Soft); @@ -348,7 +349,9 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI g_BaseSystem->ExternalEvent(g_Settings->LoadBool(GameRunning_CPU_Paused) ? SysEvent_ResumeCPU_FromMenu : SysEvent_PauseCPU_FromMenu); WriteTrace(TraceUserInterface, TraceDebug, "ID_SYSTEM_PAUSE 1"); break; - case ID_SYSTEM_BITMAP: OnScreenShot(); break; + case ID_SYSTEM_BITMAP: + OnScreenShot(); + break; break; case ID_SYSTEM_LIMITFPS: WriteTrace(TraceUserInterface, TraceDebug, "ID_SYSTEM_LIMITFPS"); @@ -419,7 +422,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI ShowCursor(true); m_Gui->ShowStatusBar(g_Settings->LoadBool((SettingID)UserInterface_ShowStatusBar)); m_Gui->MakeWindowOnTop(UISettingsLoadBool(UserInterface_AlwaysOnTop)); - UISettingsSaveBool(UserInterface_InFullScreen, (DWORD)false); + UISettingsSaveBool(UserInterface_InFullScreen, (DWORD) false); } else { @@ -491,7 +494,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI g_Settings->SaveBool(UserInterface_ShowCPUPer, true); } break; - case ID_OPTIONS_SETTINGS: OnSettings(hWnd); break; + case ID_OPTIONS_SETTINGS: OnSettings(hWnd); break; case ID_PROFILE_PROFILE: g_Settings->SaveBool(Debugger_RecordExecutionTimes, !g_Settings->LoadBool(Debugger_RecordExecutionTimes)); g_BaseSystem->ExternalEvent(SysEvent_ResetFunctionTimes); @@ -649,7 +652,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI stdstr CMainMenu::GetFileLastMod(const CPath & FileName) { HANDLE hFile = CreateFileA(FileName, GENERIC_READ, FILE_SHARE_READ, nullptr, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, nullptr); + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, nullptr); if (hFile == INVALID_HANDLE_VALUE) { return ""; diff --git a/Source/Project64/UserInterface/MainWindow.cpp b/Source/Project64/UserInterface/MainWindow.cpp index 6f3ff2436..933387255 100644 --- a/Source/Project64/UserInterface/MainWindow.cpp +++ b/Source/Project64/UserInterface/MainWindow.cpp @@ -1,12 +1,13 @@ #include "stdafx.h" + +#include "DiscordRPC.h" #include "RomInformation.h" -#include -#include -#include #include #include +#include #include -#include "DiscordRPC.h" +#include +#include void EnterLogOptions(HWND hwndOwner); @@ -40,7 +41,7 @@ CMainGui::CMainGui(bool bMainWindow, const char * WindowTitle) : { g_Settings->RegisterChangeCB((SettingID)RomBrowser_Enabled, this, (CSettings::SettingChangedFunc)RomBowserEnabledChanged); g_Settings->RegisterChangeCB((SettingID)RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); - g_Settings->RegisterChangeCB((SettingID)Setting_EnableDiscordRPC, this, (CSettings::SettingChangedFunc)DiscordRPCChanged); + g_Settings->RegisterChangeCB((SettingID)Setting_EnableDiscordRPC, this, (CSettings::SettingChangedFunc)DiscordRPCChanged); g_Settings->RegisterChangeCB(RomList_GameDirRecursive, this, (CSettings::SettingChangedFunc)RomBrowserListChanged); g_Settings->RegisterChangeCB(RomList_ShowFileExtensions, this, (CSettings::SettingChangedFunc)RomBrowserListChanged); g_Settings->RegisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged); @@ -49,11 +50,11 @@ CMainGui::CMainGui(bool bMainWindow, const char * WindowTitle) : g_Settings->RegisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded); g_Settings->RegisterChangeCB((SettingID)UserInterface_ShowStatusBar, this, (CSettings::SettingChangedFunc)ShowStatusBarChanged); - if (UISettingsLoadBool(Setting_EnableDiscordRPC)) - { - CDiscord::Init(); - CDiscord::Update(false); - } + if (UISettingsLoadBool(Setting_EnableDiscordRPC)) + { + CDiscord::Init(); + CDiscord::Update(false); + } } // If this fails then it has already been created @@ -68,8 +69,8 @@ CMainGui::~CMainGui(void) { g_Settings->UnregisterChangeCB((SettingID)RomBrowser_Enabled, this, (CSettings::SettingChangedFunc)RomBowserEnabledChanged); g_Settings->UnregisterChangeCB((SettingID)RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); - g_Settings->UnregisterChangeCB((SettingID)Setting_EnableDiscordRPC, this, (CSettings::SettingChangedFunc)DiscordRPCChanged); - g_Settings->UnregisterChangeCB(RomList_GameDirRecursive, this, (CSettings::SettingChangedFunc)RomBrowserListChanged); + g_Settings->UnregisterChangeCB((SettingID)Setting_EnableDiscordRPC, this, (CSettings::SettingChangedFunc)DiscordRPCChanged); + g_Settings->UnregisterChangeCB(RomList_GameDirRecursive, this, (CSettings::SettingChangedFunc)RomBrowserListChanged); g_Settings->UnregisterChangeCB(RomList_ShowFileExtensions, this, (CSettings::SettingChangedFunc)RomBrowserListChanged); g_Settings->UnregisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged); g_Settings->UnregisterChangeCB(GameRunning_CPU_Running, this, (CSettings::SettingChangedFunc)GameCpuRunning); @@ -77,11 +78,11 @@ CMainGui::~CMainGui(void) g_Settings->UnregisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded); g_Settings->UnregisterChangeCB((SettingID)UserInterface_ShowStatusBar, this, (CSettings::SettingChangedFunc)ShowStatusBarChanged); - if (UISettingsLoadBool(Setting_EnableDiscordRPC)) - { - CDiscord::Shutdown(); - } - } + if (UISettingsLoadBool(Setting_EnableDiscordRPC)) + { + CDiscord::Shutdown(); + } + } if (m_hMainWindow) { DestroyWindow(m_hMainWindow); @@ -210,12 +211,12 @@ void CMainGui::GameLoaded(CMainGui * Gui) WriteTrace(TraceUserInterface, TraceDebug, "Add recent ROM"); Gui->AddRecentRom(FileLoc.c_str()); Gui->SetWindowCaption(stdstr(g_Settings->LoadStringVal(Rdb_GoodName)).ToUTF16().c_str()); - - if (UISettingsLoadBool(Setting_EnableDiscordRPC)) - { - CDiscord::Update(); - } - } + + if (UISettingsLoadBool(Setting_EnableDiscordRPC)) + { + CDiscord::Update(); + } + } } void CMainGui::GamePaused(CMainGui * Gui) @@ -260,7 +261,7 @@ void CMainGui::ShowStatusBarChanged(CMainGui * Gui) if (!Gui->bCPURunning()) { ShowWindow(Gui->m_hStatusWnd, g_Settings->LoadBool((SettingID)UserInterface_ShowStatusBar) ? SW_SHOW : SW_HIDE); - + RECT rc; GetClientRect(Gui->m_hMainWindow, &rc); Gui->ResizeRomList((WORD)(rc.right - rc.left), (WORD)(rc.bottom - rc.top)); @@ -278,17 +279,17 @@ void RomBrowserListChanged(CMainGui * Gui) Gui->HighLightLastRom(); } -void DiscordRPCChanged(CMainGui*) +void DiscordRPCChanged(CMainGui *) { - if (UISettingsLoadBool(Setting_EnableDiscordRPC)) - { - CDiscord::Init(); - CDiscord::Update(); - } - else - { - CDiscord::Shutdown(); - } + if (UISettingsLoadBool(Setting_EnableDiscordRPC)) + { + CDiscord::Init(); + CDiscord::Update(); + } + else + { + CDiscord::Shutdown(); + } } void CMainGui::ChangeWinSize(long width, long height) @@ -375,7 +376,7 @@ void CMainGui::MakeWindowOnTop(bool OnTop) { CGuard Guard(m_CS); SetWindowPos(m_hMainWindow, OnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW); + SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW); } void CMainGui::Caption(LPCWSTR Caption) @@ -387,16 +388,15 @@ void CMainGui::Caption(LPCWSTR Caption) void CMainGui::Create(const char * WindowTitle) { stdstr_f VersionDisplay("Project64 %s", VER_FILE_VERSION_STR); - m_hMainWindow = CreateWindowEx(WS_EX_ACCEPTFILES, VersionDisplay.ToUTF16().c_str(), stdstr(WindowTitle).ToUTF16().c_str(), WS_OVERLAPPED | WS_CLIPCHILDREN | - WS_CLIPSIBLINGS | WS_SYSMENU | WS_MINIMIZEBOX, 5, 5, 640, 480, - nullptr, nullptr, GetModuleHandle(nullptr), this); + m_hMainWindow = CreateWindowEx(WS_EX_ACCEPTFILES, VersionDisplay.ToUTF16().c_str(), stdstr(WindowTitle).ToUTF16().c_str(), WS_OVERLAPPED | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_SYSMENU | WS_MINIMIZEBOX, 5, 5, 640, 480, + nullptr, nullptr, GetModuleHandle(nullptr), this); m_Created = m_hMainWindow != nullptr; } void CMainGui::CreateStatusBar(void) { m_hStatusWnd = (HWND)CreateStatusWindow(WS_CHILD | WS_VISIBLE, L"", m_hMainWindow, StatusBarID); - SendMessage((HWND)m_hStatusWnd, SB_SETTEXT, 0, (LPARAM)""); + SendMessage((HWND)m_hStatusWnd, SB_SETTEXT, 0, (LPARAM) ""); ShowWindow(m_hStatusWnd, g_Settings->LoadBool((SettingID)UserInterface_ShowStatusBar) ? SW_SHOW : SW_HIDE); } @@ -454,7 +454,7 @@ void CMainGui::Resize(DWORD /*fwSizeType*/, WORD nWidth, WORD nHeight) GetClientRect(m_hStatusWnd, &swrect); int Parts[2]; - Parts[0] = (int) (nWidth - 135 * DPIScale(m_hStatusWnd)); + Parts[0] = (int)(nWidth - 135 * DPIScale(m_hStatusWnd)); Parts[1] = nWidth; SendMessage(m_hStatusWnd, SB_SETPARTS, 2, (LPARAM)&Parts[0]); @@ -501,7 +501,7 @@ int CMainGui::Width(void) return rect.right - rect.left; } -float CMainGui::DPIScale(HWND hWnd) +float CMainGui::DPIScale(HWND hWnd) { return CClientDC(hWnd).GetDeviceCaps(LOGPIXELSX) / 96.0f; } @@ -553,7 +553,7 @@ void CMainGui::SetStatusText(int Panel, const wchar_t * Text) { SendMessage(m_hStatusWnd, SB_SETTEXT, Panel, (LPARAM)Msg); } - else + else { PostMessage(m_hStatusWnd, SB_SETTEXT, Panel, (LPARAM)Msg); } @@ -594,100 +594,101 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO switch (uMsg) { case WM_CREATE: - { - // Record class for future usage - LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam; - CMainGui * _this = (CMainGui *)lpcs->lpCreateParams; - SetProp(hWnd, L"Class", _this); + { + // Record class for future usage + LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam; + CMainGui * _this = (CMainGui *)lpcs->lpCreateParams; + SetProp(hWnd, L"Class", _this); - _this->m_hMainWindow = hWnd; - _this->CreateStatusBar(); + _this->m_hMainWindow = hWnd; + _this->CreateStatusBar(); - // Move the main window to the location last executed from or center the window - int X = (GetSystemMetrics(SM_CXSCREEN) - _this->Width()) / 2; - int Y = (GetSystemMetrics(SM_CYSCREEN) - _this->Height()) / 2; + // Move the main window to the location last executed from or center the window + int X = (GetSystemMetrics(SM_CXSCREEN) - _this->Width()) / 2; + int Y = (GetSystemMetrics(SM_CYSCREEN) - _this->Height()) / 2; - UISettingsLoadDword(UserInterface_MainWindowTop, (uint32_t &)Y); - UISettingsLoadDword(UserInterface_MainWindowLeft, (uint32_t &)X); + UISettingsLoadDword(UserInterface_MainWindowTop, (uint32_t &)Y); + UISettingsLoadDword(UserInterface_MainWindowLeft, (uint32_t &)X); - _this->SetPos(X, Y); + _this->SetPos(X, Y); - _this->ChangeWinSize(int (640 * _this->DPIScale(hWnd)), int (480 * _this->DPIScale(hWnd))); - } - break; + _this->ChangeWinSize(int(640 * _this->DPIScale(hWnd)), int(480 * _this->DPIScale(hWnd))); + } + break; case WM_SYSCOMMAND: - switch (wParam) { + switch (wParam) + { case SC_SCREENSAVE: case SC_MONITORPOWER: + { + CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + if (_this && + _this->bCPURunning() && + !g_Settings->LoadBool(GameRunning_CPU_Paused) && + UISettingsLoadBool(Setting_DisableScrSaver)) { - CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); - if (_this && - _this->bCPURunning() && - !g_Settings->LoadBool(GameRunning_CPU_Paused) && - UISettingsLoadBool(Setting_DisableScrSaver)) - { - return 0; - } + return 0; } - break; + } + break; case SC_MAXIMIZE: + { + CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + if (_this) { - CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); - if (_this) + if (_this->RomBrowserVisible()) { - if (_this->RomBrowserVisible()) - { - _this->RomBrowserMaximize(true); - } + _this->RomBrowserMaximize(true); } } - break; + } + break; } return DefWindowProc(hWnd, uMsg, wParam, lParam); break; case WM_MOVE: + { + CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + + if (!_this->m_bMainWindow || + !_this->m_Created || + _this->m_AttachingMenu || + _this->m_MakingVisible || + IsIconic(hWnd) || + _this->ShowingRomBrowser()) { - CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + break; + } - if (!_this->m_bMainWindow || - !_this->m_Created || - _this->m_AttachingMenu || - _this->m_MakingVisible || - IsIconic(hWnd) || - _this->ShowingRomBrowser()) - { - break; - } - - if (IsZoomed(hWnd)) - { - if (_this->RomBrowserVisible()) - { - // Save that browser is maximized - } - break; - } - - // Get the current position of the window - RECT WinRect; - GetWindowRect(hWnd, &WinRect); - - // Save the location of the window + if (IsZoomed(hWnd)) + { if (_this->RomBrowserVisible()) { - _this->m_SaveRomBrowserPos = true; - _this->m_SaveRomBrowserTop = WinRect.top; - _this->m_SaveRomBrowserLeft = WinRect.left; + // Save that browser is maximized } - else - { - _this->m_SaveMainWindowPos = true; - _this->m_SaveMainWindowTop = WinRect.top; - _this->m_SaveMainWindowLeft = WinRect.left; - } - KillTimer(hWnd, Timer_SetWindowPos); - SetTimer(hWnd, Timer_SetWindowPos, 1000, nullptr); + break; } + + // Get the current position of the window + RECT WinRect; + GetWindowRect(hWnd, &WinRect); + + // Save the location of the window + if (_this->RomBrowserVisible()) + { + _this->m_SaveRomBrowserPos = true; + _this->m_SaveRomBrowserTop = WinRect.top; + _this->m_SaveRomBrowserLeft = WinRect.left; + } + else + { + _this->m_SaveMainWindowPos = true; + _this->m_SaveMainWindowTop = WinRect.top; + _this->m_SaveMainWindowLeft = WinRect.left; + } + KillTimer(hWnd, Timer_SetWindowPos); + SetTimer(hWnd, Timer_SetWindowPos, 1000, nullptr); + } if (CGuiSettings::bCPURunning() && g_BaseSystem) { if (g_Plugins->Gfx() && g_Plugins->Gfx()->MoveScreen) @@ -708,167 +709,169 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO } break; case WM_SIZE: - { - CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + { + CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); if (_this) { _this->Resize(wParam, LOWORD(lParam), HIWORD(lParam)); } - if (_this) + if (_this) + { + if (wParam == SIZE_MAXIMIZED) { - if (wParam == SIZE_MAXIMIZED) + if (_this->RomBrowserVisible()) { - if (_this->RomBrowserVisible()) - { - _this->RomBrowserMaximize(true); - } + _this->RomBrowserMaximize(true); } - _this->ResizeRomList(LOWORD(lParam), HIWORD(lParam)); } - if (_this) + _this->ResizeRomList(LOWORD(lParam), HIWORD(lParam)); + } + if (_this) + { + if (wParam == SIZE_RESTORED && _this->RomBrowserVisible()) { - if (wParam == SIZE_RESTORED && _this->RomBrowserVisible()) - { - _this->RomBrowserMaximize(false); - } + _this->RomBrowserMaximize(false); } } - break; + } + break; case WM_NOTIFY: + { + CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + if (_this == nullptr || !_this->RomBrowserVisible() || !_this->RomListNotify(wParam, lParam)) { - CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); - if (_this == nullptr || !_this->RomBrowserVisible() || !_this->RomListNotify(wParam, lParam)) + return DefWindowProc(hWnd, uMsg, wParam, lParam); + } + } + break; + case WM_DRAWITEM: + { + CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + if (_this) + { + if (!_this->RomListDrawItem(wParam, lParam)) { return DefWindowProc(hWnd, uMsg, wParam, lParam); } } - break; - case WM_DRAWITEM: - { - CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); - if (_this) - { - if (!_this->RomListDrawItem(wParam, lParam)) - { - return DefWindowProc(hWnd, uMsg, wParam, lParam); - } - } - } - break; + } + break; case WM_PAINT: - { - // CMainGui * _this = (CMainGui *)GetProp(hWnd,"Class"); - // CN64System * System = _this->m_System; + { + // CMainGui * _this = (CMainGui *)GetProp(hWnd,"Class"); + // CN64System * System = _this->m_System; - // if (bCPURunning() && Settings->Load(CPU_Paused)) { - // CPlugins * Plugins = System->Plugins(); - // if (Plugins->Gfx()->DrawScreen) { - // Plugins->Gfx()->DrawScreen(); - // } - // } - ValidateRect(hWnd, nullptr); - } - break; + // if (bCPURunning() && Settings->Load(CPU_Paused)) { + // CPlugins * Plugins = System->Plugins(); + // if (Plugins->Gfx()->DrawScreen) { + // Plugins->Gfx()->DrawScreen(); + // } + // } + ValidateRect(hWnd, nullptr); + } + break; case WM_KEYUP: - { - CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + { + CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); - if (_this->m_bMainWindow && bCPURunning()) + if (_this->m_bMainWindow && bCPURunning()) + { + if (g_BaseSystem) { - if (g_BaseSystem) + if (g_Plugins && g_Plugins->Control()->WM_KeyUp) { - if (g_Plugins && g_Plugins->Control()->WM_KeyUp) { - g_Plugins->Control()->WM_KeyUp(wParam, lParam); - } + g_Plugins->Control()->WM_KeyUp(wParam, lParam); } } } - break; + } + break; case WM_KEYDOWN: - { - CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + { + CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); - if (_this->m_bMainWindow && bCPURunning()) + if (_this->m_bMainWindow && bCPURunning()) + { + if (g_BaseSystem) { - if (g_BaseSystem) + if (g_Plugins && g_Plugins->Control()->WM_KeyDown) { - if (g_Plugins && g_Plugins->Control()->WM_KeyDown) - { - g_Plugins->Control()->WM_KeyDown(wParam, lParam); - } + g_Plugins->Control()->WM_KeyDown(wParam, lParam); } } } - break; + } + break; case WM_SETFOCUS: + { + CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + if (_this->RomBrowserVisible()) { - CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); - if (_this->RomBrowserVisible()) - { - PostMessage(hWnd, WM_BROWSER_TOP, 0, 0); - break; - } + PostMessage(hWnd, WM_BROWSER_TOP, 0, 0); + break; + } - if (_this->m_bMainWindow && bCPURunning() && bAutoSleep()) + if (_this->m_bMainWindow && bCPURunning() && bAutoSleep()) + { + if (g_BaseSystem) { - if (g_BaseSystem) - { - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_AppGainedFocus); - } + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_AppGainedFocus); } } - break; + } + break; case WM_KILLFOCUS: + { + CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + if (_this->RomBrowserVisible()) { - CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); - if (_this->RomBrowserVisible()) + break; + } + + if (_this->m_bMainWindow && bCPURunning()) + { + if (g_BaseSystem) { + if (bAutoSleep()) + { + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_AppLostFocus); + } + + if (g_Plugins && g_Plugins->Control()->WM_KillFocus) + { + g_Plugins->Control()->WM_KillFocus(wParam, lParam); + } + } + } + } + break; + case WM_ACTIVATEAPP: + { + CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + DWORD fActive = (BOOL)wParam; + + if (fActive && _this->RomBrowserVisible()) + { + PostMessage(hWnd, WM_BROWSER_TOP, 0, 0); + } + if (_this->m_bMainWindow && bCPURunning()) + { + if (!fActive && UISettingsLoadBool(UserInterface_InFullScreen) && UISettingsLoadBool(UserInterface_ExitFullscreenOnLoseFocus)) + { + Notify().WindowMode(); + if (bAutoSleep() && g_BaseSystem) + { + //System->ExternalEvent(PauseCPU_AppLostActiveDelayed ); + } break; } - - if (_this->m_bMainWindow && bCPURunning()) + if (bAutoSleep() || fActive) { if (g_BaseSystem) { - if (bAutoSleep()) - { - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_AppLostFocus); - } - - if (g_Plugins && g_Plugins->Control()->WM_KillFocus) { - g_Plugins->Control()->WM_KillFocus(wParam, lParam); - } + g_BaseSystem->ExternalEvent(fActive ? SysEvent_ResumeCPU_AppGainedActive : SysEvent_PauseCPU_AppLostActive); } } } - break; - case WM_ACTIVATEAPP: - { - CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); - DWORD fActive = (BOOL)wParam; - - if (fActive && _this->RomBrowserVisible()) - { - PostMessage(hWnd, WM_BROWSER_TOP, 0, 0); - } - if (_this->m_bMainWindow && bCPURunning()) - { - if (!fActive && UISettingsLoadBool(UserInterface_InFullScreen) && UISettingsLoadBool(UserInterface_ExitFullscreenOnLoseFocus)) - { - Notify().WindowMode(); - if (bAutoSleep() && g_BaseSystem) - { - //System->ExternalEvent(PauseCPU_AppLostActiveDelayed ); - } - break; - } - if (bAutoSleep() || fActive) - { - if (g_BaseSystem) - { - g_BaseSystem->ExternalEvent(fActive ? SysEvent_ResumeCPU_AppGainedActive : SysEvent_PauseCPU_AppLostActive); - } - } - } - } - break; + } + break; case WM_HIDE_CUROSR: if (!wParam) { @@ -880,117 +883,120 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO } break; case WM_MAKE_FOCUS: - { - CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); - _this->BringToTop(); - } - break; + { + CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + _this->BringToTop(); + } + break; case WM_BROWSER_TOP: - { - CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); - _this->RomBrowserToTop(); - } - break; + { + CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + _this->RomBrowserToTop(); + } + break; case WM_RESET_PLUGIN: + { + CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + if (_this->m_ResetInfo != nullptr) { - CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); - if (_this->m_ResetInfo != nullptr) - { - g_Notify->BreakPoint(__FILE__, __LINE__); - } - _this->m_ResetInfo = (RESET_PLUGIN *)lParam; - _this->m_ResetPlugins = true; + g_Notify->BreakPoint(__FILE__, __LINE__); } - break; + _this->m_ResetInfo = (RESET_PLUGIN *)lParam; + _this->m_ResetPlugins = true; + } + break; case WM_GAME_CLOSED: + { + CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + Notify().WindowMode(); + if (UISettingsLoadBool(RomBrowser_Enabled)) { - CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); - Notify().WindowMode(); - if (UISettingsLoadBool(RomBrowser_Enabled)) - { - _this->ShowRomBrowser(); - } - _this->RefreshMenu(); - _this->MakeWindowOnTop(false); - _this->SetStatusText(0, L""); - _this->SetStatusText(1, L""); + _this->ShowRomBrowser(); } - break; + _this->RefreshMenu(); + _this->MakeWindowOnTop(false); + _this->SetStatusText(0, L""); + _this->SetStatusText(1, L""); + } + break; case WM_JSAPI_ACTION: + { + switch (wParam) { - switch (wParam) + case JSAPI_ACT_OPEN_ROM: + { + char * romPath = (char *)lParam; + stdstr ext = CPath(romPath).GetExtension(); + if ((_stricmp(ext.c_str(), "ndd") != 0) && + (_stricmp(ext.c_str(), "d64") != 0)) { - case JSAPI_ACT_OPEN_ROM: - { - char* romPath = (char*)lParam; - stdstr ext = CPath(romPath).GetExtension(); - if ((_stricmp(ext.c_str(), "ndd") != 0) && - (_stricmp(ext.c_str(), "d64") != 0)) - { - g_BaseSystem->RunFileImage(romPath); - } - else - { - g_BaseSystem->RunDiskImage(romPath); - } - delete[] romPath; - } - break; - case JSAPI_ACT_CLOSE_ROM: - if (g_BaseSystem) - { - g_BaseSystem->ExternalEvent(SysEvent_CloseCPU); - } - - if (UISettingsLoadBool(Setting_EnableDiscordRPC)) - { - CDiscord::Update(false); - } - break; - case JSAPI_ACT_RESET: - if (g_BaseSystem) - { - g_BaseSystem->ExternalEvent((bool)lParam ? SysEvent_ResetCPU_Soft : SysEvent_ResetCPU_Hard); - } - break; - case JSAPI_ACT_PAUSE: - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_FromMenu); - break; - case JSAPI_ACT_RESUME: - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_FromMenu); - break; + g_BaseSystem->RunFileImage(romPath); } + else + { + g_BaseSystem->RunDiskImage(romPath); + } + delete[] romPath; } break; + case JSAPI_ACT_CLOSE_ROM: + if (g_BaseSystem) + { + g_BaseSystem->ExternalEvent(SysEvent_CloseCPU); + } + + if (UISettingsLoadBool(Setting_EnableDiscordRPC)) + { + CDiscord::Update(false); + } + break; + case JSAPI_ACT_RESET: + if (g_BaseSystem) + { + g_BaseSystem->ExternalEvent((bool)lParam ? SysEvent_ResetCPU_Soft : SysEvent_ResetCPU_Hard); + } + break; + case JSAPI_ACT_PAUSE: + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_FromMenu); + break; + case JSAPI_ACT_RESUME: + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_FromMenu); + break; + } + } + break; case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: - if (g_Settings->LoadBool(Debugger_Enabled)) { + if (g_Settings->LoadBool(Debugger_Enabled)) + { SetCapture(hWnd); - CDebuggerUI* debugger = (CDebuggerUI*)g_Debugger; + CDebuggerUI * debugger = (CDebuggerUI *)g_Debugger; debugger->ScriptSystem()->DoMouseEvent(JS_HOOK_MOUSEDOWN, - GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), uMsg); + GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), uMsg); } break; case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: - if (g_Settings->LoadBool(Debugger_Enabled)) { + if (g_Settings->LoadBool(Debugger_Enabled)) + { ReleaseCapture(); - CDebuggerUI* debugger = (CDebuggerUI*)g_Debugger; + CDebuggerUI * debugger = (CDebuggerUI *)g_Debugger; debugger->ScriptSystem()->DoMouseEvent(JS_HOOK_MOUSEUP, - GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), uMsg); + GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), uMsg); } break; case WM_MOUSEMOVE: - if (g_Settings->LoadBool(Debugger_Enabled)) { + if (g_Settings->LoadBool(Debugger_Enabled)) + { static int lastX = 0; static int lastY = 0; int x = GET_X_LPARAM(lParam); int y = GET_Y_LPARAM(lParam); if (lastX != x || lastY != y) { - CDebuggerUI* debugger = (CDebuggerUI*)g_Debugger; + CDebuggerUI * debugger = (CDebuggerUI *)g_Debugger; debugger->ScriptSystem()->DoMouseEvent(JS_HOOK_MOUSEMOVE, x, y, (DWORD)-1); lastX = x; lastY = y; @@ -998,179 +1004,180 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO } break; case WM_COMMAND: - { - CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + { + CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); if (_this == nullptr) { break; } - switch (LOWORD(wParam)) { - case ID_POPUPMENU_PLAYGAME: + switch (LOWORD(wParam)) + { + case ID_POPUPMENU_PLAYGAME: + { + if ((CPath(_this->CurrentedSelectedRom()).GetExtension() != "ndd") && (CPath(_this->CurrentedSelectedRom()).GetExtension() != "d64")) + { + g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom()); + } + else + { + g_BaseSystem->RunDiskImage(_this->CurrentedSelectedRom()); + } + break; + } + case ID_POPUPMENU_PLAYGAMEWITHDISK: + { + CPath FileName; + const char * Filter = "N64DD Disk Image (*.ndd, *.d64)\0*.ndd;*.d64\0All files (*.*)\0*.*\0"; + if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true)) + { + g_BaseSystem->RunDiskComboImage(_this->CurrentedSelectedRom(), FileName); + } + } + break; + case ID_POPUPMENU_ROMDIRECTORY: _this->SelectRomDir(); break; + case ID_POPUPMENU_REFRESHROMLIST: _this->RefreshRomList(); break; + case ID_POPUPMENU_ROMINFORMATION: + { + RomInformation Info(_this->CurrentedSelectedRom()); + Info.DisplayInformation(hWnd); + } + break; + case ID_POPUPMENU_EDITSETTINGS: + case ID_POPUPMENU_EDITCHEATS: + case ID_POPUPMENU_CHOOSEENHANCEMENT: + { + if ((CPath(_this->CurrentedSelectedRom()).GetExtension() != "ndd") && (CPath(_this->CurrentedSelectedRom()).GetExtension() != "d64")) + { + CN64Rom Rom; + Rom.LoadN64Image(_this->CurrentedSelectedRom(), true); + Rom.SaveRomSettingID(true); + + if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS) { - if ((CPath(_this->CurrentedSelectedRom()).GetExtension() != "ndd") && (CPath(_this->CurrentedSelectedRom()).GetExtension() != "d64")) - { - g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom()); - } - else - { - g_BaseSystem->RunDiskImage(_this->CurrentedSelectedRom()); - } - break; + CSettingConfig SettingConfig(true); + SettingConfig.Display(hWnd); } - case ID_POPUPMENU_PLAYGAMEWITHDISK: + else if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS) { - CPath FileName; - const char * Filter = "N64DD Disk Image (*.ndd, *.d64)\0*.ndd;*.d64\0All files (*.*)\0*.*\0"; - if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true)) + g_Enhancements->ResetActive(nullptr); + g_Enhancements->LoadActive(nullptr, nullptr); + _this->m_CheatsUI.Display(hWnd, true); + } + else if (LOWORD(wParam) == ID_POPUPMENU_CHOOSEENHANCEMENT) + { + g_Enhancements->LoadActive(nullptr, nullptr); + _this->m_EnhancementUI.Display(hWnd, true); + } + + if (g_Rom) + { + g_Rom->SaveRomSettingID(false); + } + else + { + Rom.ClearRomSettingID(); + } + } + else + { + CN64Disk Disk; + Disk.LoadDiskImage(_this->CurrentedSelectedRom()); + Disk.SaveDiskSettingID(true); + + if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS) + { + CSettingConfig SettingConfig(true); + SettingConfig.Display(hWnd); + } + else if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS) + { + CCheatsUI().Display(hWnd, true); + } + + if (g_Disk) + { + g_Disk->SaveDiskSettingID(false); + } + else + { + Disk.ClearDiskSettingID(); + } + } + } + break; + default: + if (_this->m_Menu) + { + if (LOWORD(wParam) > 5000 && LOWORD(wParam) <= 5100) + { + if (g_Plugins->RSP()) { - g_BaseSystem->RunDiskComboImage(_this->CurrentedSelectedRom(), FileName); + g_Plugins->RSP()->ProcessMenuItem(LOWORD(wParam)); } } - break; - case ID_POPUPMENU_ROMDIRECTORY: _this->SelectRomDir(); break; - case ID_POPUPMENU_REFRESHROMLIST: _this->RefreshRomList(); break; - case ID_POPUPMENU_ROMINFORMATION: + else if (LOWORD(wParam) > 5100 && LOWORD(wParam) <= 5200) { - RomInformation Info(_this->CurrentedSelectedRom()); - Info.DisplayInformation(hWnd); + if (g_Plugins->Gfx()) + { + WriteTrace(TraceVideoPlugin, TraceDebug, "Starting"); + g_Plugins->Gfx()->ProcessMenuItem(LOWORD(wParam)); + WriteTrace(TraceVideoPlugin, TraceDebug, "Done"); + } } - break; - case ID_POPUPMENU_EDITSETTINGS: - case ID_POPUPMENU_EDITCHEATS: - case ID_POPUPMENU_CHOOSEENHANCEMENT: + else if (LOWORD(wParam) > 5200 && LOWORD(wParam) <= 5300) { - if ((CPath(_this->CurrentedSelectedRom()).GetExtension() != "ndd") && (CPath(_this->CurrentedSelectedRom()).GetExtension() != "d64")) + if (g_Plugins->Gfx() && g_Plugins->Gfx()->OnRomBrowserMenuItem != nullptr) { CN64Rom Rom; - Rom.LoadN64Image(_this->CurrentedSelectedRom(), true); + if (!Rom.LoadN64Image(_this->CurrentedSelectedRom(), true)) + { + break; + } Rom.SaveRomSettingID(true); - - if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS) - { - CSettingConfig SettingConfig(true); - SettingConfig.Display(hWnd); - } - else if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS) - { - g_Enhancements->ResetActive(nullptr); - g_Enhancements->LoadActive(nullptr, nullptr); - _this->m_CheatsUI.Display(hWnd, true); - } - else if (LOWORD(wParam) == ID_POPUPMENU_CHOOSEENHANCEMENT) - { - g_Enhancements->LoadActive(nullptr, nullptr); - _this->m_EnhancementUI.Display(hWnd, true); - } - + g_Notify->DisplayMessage(0, EMPTY_STRING); + BYTE * RomHeader = Rom.GetRomAddress(); + WriteTrace(TraceVideoPlugin, TraceDebug, "OnRomBrowserMenuItem - Starting"); + g_Plugins->Gfx()->OnRomBrowserMenuItem(LOWORD(wParam), hWnd, RomHeader); + WriteTrace(TraceVideoPlugin, TraceDebug, "OnRomBrowserMenuItem - Done"); if (g_Rom) { g_Rom->SaveRomSettingID(false); } else { - Rom.ClearRomSettingID(); - } - } - else - { - CN64Disk Disk; - Disk.LoadDiskImage(_this->CurrentedSelectedRom()); - Disk.SaveDiskSettingID(true); - - if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS) - { - CSettingConfig SettingConfig(true); - SettingConfig.Display(hWnd); - } - else if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS) - { - CCheatsUI().Display(hWnd,true); - } - - if (g_Disk) - { - g_Disk->SaveDiskSettingID(false); - } - else - { - Disk.ClearDiskSettingID(); + g_Settings->SaveString(Game_IniKey, ""); } } } - break; - default: - if (_this->m_Menu) + else if (_this->m_Menu->ProcessMessage(hWnd, HIWORD(wParam), LOWORD(wParam))) { - if (LOWORD(wParam) > 5000 && LOWORD(wParam) <= 5100) - { - if (g_Plugins->RSP()) - { - g_Plugins->RSP()->ProcessMenuItem(LOWORD(wParam)); - } - } - else if (LOWORD(wParam) > 5100 && LOWORD(wParam) <= 5200) - { - if (g_Plugins->Gfx()) - { - WriteTrace(TraceVideoPlugin, TraceDebug, "Starting"); - g_Plugins->Gfx()->ProcessMenuItem(LOWORD(wParam)); - WriteTrace(TraceVideoPlugin, TraceDebug, "Done"); - } - } - else if (LOWORD(wParam) > 5200 && LOWORD(wParam) <= 5300) - { - if (g_Plugins->Gfx() && g_Plugins->Gfx()->OnRomBrowserMenuItem != nullptr) - { - CN64Rom Rom; - if (!Rom.LoadN64Image(_this->CurrentedSelectedRom(), true)) - { - break; - } - Rom.SaveRomSettingID(true); - g_Notify->DisplayMessage(0, EMPTY_STRING); - BYTE * RomHeader = Rom.GetRomAddress(); - WriteTrace(TraceVideoPlugin, TraceDebug, "OnRomBrowserMenuItem - Starting"); - g_Plugins->Gfx()->OnRomBrowserMenuItem(LOWORD(wParam), hWnd, RomHeader); - WriteTrace(TraceVideoPlugin, TraceDebug, "OnRomBrowserMenuItem - Done"); - if (g_Rom) - { - g_Rom->SaveRomSettingID(false); - } - else - { - g_Settings->SaveString(Game_IniKey, ""); - } - } - } - else if (_this->m_Menu->ProcessMessage(hWnd, HIWORD(wParam), LOWORD(wParam))) - { - return true; - } + return true; } } } - break; + } + break; case WM_DROPFILES: + { + char filename[MAX_PATH]; + + HDROP hDrop = (HDROP)wParam; + DragQueryFileA(hDrop, 0, filename, sizeof(filename)); + DragFinish(hDrop); + + stdstr ext = CPath(filename).GetExtension(); + if ((!(_stricmp(ext.c_str(), "ndd") == 0)) && (!(_stricmp(ext.c_str(), "d64") == 0))) { - char filename[MAX_PATH]; - - HDROP hDrop = (HDROP)wParam; - DragQueryFileA(hDrop, 0, filename, sizeof(filename)); - DragFinish(hDrop); - - stdstr ext = CPath(filename).GetExtension(); - if ((!(_stricmp(ext.c_str(), "ndd") == 0)) && (!(_stricmp(ext.c_str(), "d64") == 0))) - { - CN64System::RunFileImage(filename); - } - else - { - CN64System::RunDiskImage(filename); - } + CN64System::RunFileImage(filename); } - break; + else + { + CN64System::RunDiskImage(filename); + } + } + break; case WM_DESTROY: WriteTrace(TraceUserInterface, TraceDebug, "WM_DESTROY - start"); { - CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); + CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class"); if (_this->m_bMainWindow) { Notify().WindowMode(); diff --git a/Source/Project64/UserInterface/MenuShortCuts.cpp b/Source/Project64/UserInterface/MenuShortCuts.cpp index a11c3e950..03c7fcacc 100644 --- a/Source/Project64/UserInterface/MenuShortCuts.cpp +++ b/Source/Project64/UserInterface/MenuShortCuts.cpp @@ -192,7 +192,7 @@ CMenuShortCutKey::CMenuShortCutKey(WORD key, bool bCtrl, bool bAlt, bool bShift, m_ShortCutName = ShortCutName.ToUTF16(); } -VIRTUAL_KEY * CMenuShortCutKey::VirtualKeyList(int &Size) +VIRTUAL_KEY * CMenuShortCutKey::VirtualKeyList(int & Size) { Size = sizeof(m_VirtualKeyList) / sizeof(m_VirtualKeyList[0]); return (VIRTUAL_KEY *)m_VirtualKeyList; @@ -479,7 +479,7 @@ void CShortCuts::Load(bool InitialValues) CMenuShortCutKey::ACCESS_MODE AccessMode; int ID, key, bCtrl, bAlt, bShift, bUserAdded, bInactive; - FILE *file = fopen(ShortCutFile, "r"); + FILE * file = fopen(ShortCutFile, "r"); if (file) { do @@ -488,7 +488,7 @@ void CShortCuts::Load(bool InitialValues) if (fgets(Line, sizeof(Line), file) != nullptr) { sscanf(Line, "%d,%d,%d,%d,%d,%d,%d,%d", &ID, &key, &bCtrl, &bAlt, &bShift, &AccessMode, - &bUserAdded, &bInactive); + &bUserAdded, &bInactive); MSC_MAP::iterator item = m_ShortCuts.find(ID); if (item == m_ShortCuts.end()) { continue; } @@ -505,7 +505,7 @@ void CShortCuts::Save(void) CGuard CS(m_CS); stdstr FileName = UISettingsLoadStringVal(SupportFile_ShortCuts); - FILE *file = fopen(FileName.c_str(), "w"); + FILE * file = fopen(FileName.c_str(), "w"); if (file == nullptr) { return; @@ -516,14 +516,14 @@ void CShortCuts::Save(void) for (SHORTCUT_KEY_LIST::const_iterator ShortCut = Item->second.GetAccelItems().begin(); ShortCut != Item->second.GetAccelItems().end(); ShortCut++) { fprintf(file, "%d,%d,%d,%d,%d,%d,%d,%d\n", - Item->first, - ShortCut->Key(), - ShortCut->Ctrl(), - ShortCut->Alt(), - ShortCut->Shift(), - ShortCut->AccessMode(), - ShortCut->UserAdded(), - ShortCut->Inactive()); + Item->first, + ShortCut->Key(), + ShortCut->Ctrl(), + ShortCut->Alt(), + ShortCut->Shift(), + ShortCut->AccessMode(), + ShortCut->UserAdded(), + ShortCut->Inactive()); } } fclose(file); diff --git a/Source/Project64/UserInterface/Notification.cpp b/Source/Project64/UserInterface/Notification.cpp index 5c7abdeb7..492f77bfc 100644 --- a/Source/Project64/UserInterface/Notification.cpp +++ b/Source/Project64/UserInterface/Notification.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include CNotificationImp & Notify(void) diff --git a/Source/Project64/UserInterface/ProjectSupport.cpp b/Source/Project64/UserInterface/ProjectSupport.cpp index ed8a80e98..2d588950a 100644 --- a/Source/Project64/UserInterface/ProjectSupport.cpp +++ b/Source/Project64/UserInterface/ProjectSupport.cpp @@ -1,8 +1,9 @@ #include "stdafx.h" + #include +#include #include #include -#include #pragma comment(lib, "Wininet.lib") @@ -78,7 +79,7 @@ bool CProjectSupport::ValidateCode(const char * Code) m_SupportInfo.Validated = true; SaveSupportInfo(); } - } + } return m_SupportInfo.Validated; } @@ -88,7 +89,7 @@ std::string CProjectSupport::GenerateMachineID(void) DWORD Length = sizeof(ComputerName) / sizeof(ComputerName[0]); GetComputerName(ComputerName, &Length); - wchar_t SysPath[MAX_PATH] = { 0 }, VolumePath[MAX_PATH] = { 0 }; + wchar_t SysPath[MAX_PATH] = {0}, VolumePath[MAX_PATH] = {0}; GetSystemDirectory(SysPath, sizeof(SysPath) / sizeof(SysPath[0])); GetVolumePathName(SysPath, VolumePath, sizeof(VolumePath) / sizeof(VolumePath[0])); @@ -96,7 +97,7 @@ std::string CProjectSupport::GenerateMachineID(void) DWORD SerialNumber = 0; GetVolumeInformation(VolumePath, nullptr, NULL, &SerialNumber, nullptr, nullptr, nullptr, NULL); - wchar_t MachineGuid[200] = { 0 }; + wchar_t MachineGuid[200] = {0}; HKEY hKey; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography", 0, KEY_QUERY_VALUE | KEY_WOW64_64KEY, &hKey) == ERROR_SUCCESS) { diff --git a/Source/Project64/UserInterface/RomBrowser.cpp b/Source/Project64/UserInterface/RomBrowser.cpp index d6a3b9162..066b43a8b 100644 --- a/Source/Project64/UserInterface/RomBrowser.cpp +++ b/Source/Project64/UserInterface/RomBrowser.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include #include diff --git a/Source/Project64/UserInterface/RomInformation.cpp b/Source/Project64/UserInterface/RomInformation.cpp index 852f214fc..f6d909000 100644 --- a/Source/Project64/UserInterface/RomInformation.cpp +++ b/Source/Project64/UserInterface/RomInformation.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "RomInformation.h" #include diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.cpp index ea2a1d4d7..e05a3cae1 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.cpp @@ -25,7 +25,7 @@ CAdvancedOptionsPage::CAdvancedOptionsPage(HWND hParent, const RECT & rcDispay) AddModCheckBox(GetDlgItem(IDC_START_ON_ROM_OPEN), Setting_AutoStart); AddModCheckBox(GetDlgItem(IDC_ZIP), Setting_AutoZipInstantSave); AddModCheckBox(GetDlgItem(IDC_DEBUGGER), Debugger_Enabled); - AddModCheckBox(GetDlgItem(IDC_INTERPRETER), Setting_ForceInterpreterCPU); + AddModCheckBox(GetDlgItem(IDC_INTERPRETER), Setting_ForceInterpreterCPU); AddModCheckBox(GetDlgItem(IDC_REMEMBER_CHEAT), Setting_RememberCheats); AddModCheckBox(GetDlgItem(IDC_UNIQUE_SAVE_DIR), Setting_UniqueSaveDir); AddModCheckBox(GetDlgItem(IDC_CHECK_RUNNING), Setting_CheckEmuRunning); @@ -64,7 +64,10 @@ void CAdvancedOptionsPage::ApplySettings(bool UpdateScreen) bool CAdvancedOptionsPage::EnableReset(void) { - if (CSettingsPageImpl::EnableReset()) { return true; } + if (CSettingsPageImpl::EnableReset()) + { + return true; + } return false; } diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.cpp index b9b10c4ab..5c25b34db 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "SettingsPage.h" CDefaultsOptionsPage::CDefaultsOptionsPage(HWND hParent, const RECT & rcDispay) @@ -89,7 +90,10 @@ void CDefaultsOptionsPage::ApplySettings(bool UpdateScreen) bool CDefaultsOptionsPage::EnableReset(void) { - if (CSettingsPageImpl::EnableReset()) { return true; } + if (CSettingsPageImpl::EnableReset()) + { + return true; + } return false; } diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Directories.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Directories.cpp index 3287d453a..159e52564 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Directories.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Directories.cpp @@ -3,7 +3,7 @@ #include "SettingsPage.h" COptionsDirectoriesPage::COptionsDirectoriesPage(HWND hParent, const RECT & rcDispay) : -m_InUpdateSettings(false) + m_InUpdateSettings(false) { Create(hParent); if (m_hWnd == nullptr) @@ -94,35 +94,50 @@ void COptionsDirectoriesPage::SelectDirectory(LanguageStringID Title, CModifiedE void COptionsDirectoriesPage::PluginDirChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - if (m_InUpdateSettings) { return; } + if (m_InUpdateSettings) + { + return; + } m_PluginDir.SetChanged(true); SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } void COptionsDirectoriesPage::AutoSaveDirChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - if (m_InUpdateSettings) { return; } + if (m_InUpdateSettings) + { + return; + } m_AutoSaveDir.SetChanged(true); SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } void COptionsDirectoriesPage::InstantSaveDirChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - if (m_InUpdateSettings) { return; } + if (m_InUpdateSettings) + { + return; + } m_InstantSaveDir.SetChanged(true); SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } void COptionsDirectoriesPage::SnapShotDirChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - if (m_InUpdateSettings) { return; } + if (m_InUpdateSettings) + { + return; + } m_ScreenShotDir.SetChanged(true); SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } void COptionsDirectoriesPage::TextureDirChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - if (m_InUpdateSettings) { return; } + if (m_InUpdateSettings) + { + return; + } m_TextureDir.SetChanged(true); SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } @@ -312,16 +327,46 @@ void COptionsDirectoriesPage::ApplySettings(bool UpdateScreen) bool COptionsDirectoriesPage::EnableReset(void) { - if (m_PluginDir.IsChanged()) { return true; } - if (m_AutoSaveDir.IsChanged()) { return true; } - if (m_InstantSaveDir.IsChanged()) { return true; } - if (m_ScreenShotDir.IsChanged()) { return true; } - if (m_TextureDir.IsChanged()) { return true; } - if (m_PluginDefault.IsChanged()) { return true; } - if (m_AutoSaveDefault.IsChanged()) { return true; } - if (m_InstantDefault.IsChanged()) { return true; } - if (m_ScreenShotDefault.IsChanged()) { return true; } - if (m_TextureDefault.IsChanged()) { return true; } + if (m_PluginDir.IsChanged()) + { + return true; + } + if (m_AutoSaveDir.IsChanged()) + { + return true; + } + if (m_InstantSaveDir.IsChanged()) + { + return true; + } + if (m_ScreenShotDir.IsChanged()) + { + return true; + } + if (m_TextureDir.IsChanged()) + { + return true; + } + if (m_PluginDefault.IsChanged()) + { + return true; + } + if (m_AutoSaveDefault.IsChanged()) + { + return true; + } + if (m_InstantDefault.IsChanged()) + { + return true; + } + if (m_ScreenShotDefault.IsChanged()) + { + return true; + } + if (m_TextureDefault.IsChanged()) + { + return true; + } return false; } diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-DiskDrive.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-DiskDrive.cpp index c0d0c79b5..54195c2fe 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-DiskDrive.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-DiskDrive.cpp @@ -74,7 +74,10 @@ void CDiskDrivePage::ApplySettings(bool UpdateScreen) bool CDiskDrivePage::EnableReset(void) { - if (CSettingsPageImpl::EnableReset()) { return true; } + if (CSettingsPageImpl::EnableReset()) + { + return true; + } return false; } @@ -100,21 +103,30 @@ void CDiskDrivePage::SelectIplDirTl(UINT /*Code*/, int /*id*/, HWND /*ctl*/) void CDiskDrivePage::IplDirJpChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - if (m_InUpdateSettings) { return; } + if (m_InUpdateSettings) + { + return; + } m_IplDirJp.SetChanged(true); SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } void CDiskDrivePage::IplDirUsChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - if (m_InUpdateSettings) { return; } + if (m_InUpdateSettings) + { + return; + } m_IplDirUs.SetChanged(true); SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } void CDiskDrivePage::IplDirTlChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - if (m_InUpdateSettings) { return; } + if (m_InUpdateSettings) + { + return; + } m_IplDirTl.SetChanged(true); SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-DiskDrive.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Game-DiskDrive.cpp index c5df839aa..31eb158e1 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-DiskDrive.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-DiskDrive.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" -#include "SettingsPage.h" #include "SettingsPage-Game-DiskDrive.h" +#include "SettingsPage.h" CGameDiskDrivePage::CGameDiskDrivePage(HWND hParent, const RECT & rcDispay) { @@ -13,7 +13,7 @@ CGameDiskDrivePage::CGameDiskDrivePage(HWND hParent, const RECT & rcDispay) // Set the text for all GUI items SetDlgItemText(IDC_DISKSEEKTIMING_TEXT2, wGS(ROM_DISK_SEEK_TIMING).c_str()); - CModifiedComboBox* ComboBox; + CModifiedComboBox * ComboBox; ComboBox = AddModComboBox(GetDlgItem(IDC_DISKSEEKTIMING2), Game_DiskSeekTiming); if (ComboBox) { @@ -42,7 +42,10 @@ void CGameDiskDrivePage::ApplySettings(bool UpdateScreen) bool CGameDiskDrivePage::EnableReset(void) { - if (CSettingsPageImpl::EnableReset()) { return true; } + if (CSettingsPageImpl::EnableReset()) + { + return true; + } return false; } diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-DiskDrive.h b/Source/Project64/UserInterface/Settings/SettingsPage-Game-DiskDrive.h index ea1a37185..396b78f75 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-DiskDrive.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-DiskDrive.h @@ -1,6 +1,7 @@ #pragma once -#include "../WTLControls/ModifiedCheckBox.h" +#include "SettingsPage.h" +#include #include class CGameDiskDrivePage : diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.cpp index 70299f45f..2611e038a 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" -#include "SettingsPage.h" #include "SettingsPage-Game-General.h" +#include "SettingsPage.h" CGameGeneralPage::CGameGeneralPage(HWND hParent, const RECT & rcDispay) { @@ -81,10 +81,10 @@ CGameGeneralPage::CGameGeneralPage(HWND hParent, const RECT & rcDispay) TxtBox = AddModTextBox(GetDlgItem(IDC_OVER_CLOCK_MODIFIER), Game_OverClockModifier, false); TxtBox->SetTextField(GetDlgItem(IDC_OVER_CLOCK_MODIFIER_TEXT)); - if (!g_Settings->LoadBool(Setting_SyncViaAudioEnabled)) - { - GetDlgItem(IDC_SYNC_AUDIO).EnableWindow(false); - } + if (!g_Settings->LoadBool(Setting_SyncViaAudioEnabled)) + { + GetDlgItem(IDC_SYNC_AUDIO).EnableWindow(false); + } UpdatePageSettings(); } @@ -106,7 +106,10 @@ void CGameGeneralPage::ApplySettings(bool UpdateScreen) bool CGameGeneralPage::EnableReset(void) { - if (CSettingsPageImpl::EnableReset()) { return true; } + if (CSettingsPageImpl::EnableReset()) + { + return true; + } return false; } diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.h b/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.h index 933ed688b..9c2ee265a 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.h @@ -1,7 +1,8 @@ #pragma once -#include "../WTLControls/ModifiedCheckBox.h" +#include #include +#include "SettingsPage.h" class CGameGeneralPage : public CSettingsPageImpl, diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.cpp index 5ee676adc..ff16d2e44 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" -#include "SettingsPage.h" #include "SettingsPage-Game-Plugin.h" +#include "SettingsPage.h" CGamePluginPage::CGamePluginPage(HWND hParent, const RECT & rcDispay) { @@ -116,7 +116,7 @@ void CGamePluginPage::ShowAboutButton(int id) } // Get DLL about - void(CALL *DllAbout) (HWND hWnd); + void(CALL * DllAbout)(HWND hWnd); DllAbout = (void(CALL *)(HWND))GetProcAddress(hLib, "DllAbout"); // Call the function from the DLL @@ -190,7 +190,8 @@ void CGamePluginPage::UpdatePageSettings(void) ComboBox->SetDefault((WPARAM)Plugin); } } - else { + else + { ComboBox->SetDefault(NULL); } } @@ -217,7 +218,10 @@ void CGamePluginPage::ApplySettings(bool UpdateScreen) bool CGamePluginPage::EnableReset(void) { - if (CSettingsPageImpl::EnableReset()) { return true; } + if (CSettingsPageImpl::EnableReset()) + { + return true; + } return false; } @@ -254,7 +258,8 @@ void CGamePluginPage::ApplyComboBoxes(void) g_Settings->SaveString(cb_iter->first, Plugin->FileName.c_str()); } } - else { + else + { g_Settings->DeleteSetting(cb_iter->first); } } @@ -324,7 +329,7 @@ void CGamePluginPage::HleAudioChanged(UINT /*Code*/, int id, HWND /*ctl*/) continue; } if ((Button->GetCheck() & BST_CHECKED) != 0) - { + { if (!g_Notify->AskYesNoQuestion(g_Lang->GetString(MSG_SET_HLE_AUD_MSG).c_str())) { Button->SetCheck(BST_UNCHECKED); diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.h b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.h index 25f882dcc..5763ac20e 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.h @@ -2,6 +2,7 @@ #include #include +#include "SettingsPage.h" class CGamePluginPage : public CSettingsPageImpl, diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Recompiler.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Recompiler.cpp index 70e4205ac..376b66282 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Recompiler.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Recompiler.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" -#include "SettingsPage.h" #include "SettingsPage-Game-Recompiler.h" +#include "SettingsPage.h" CGameRecompilePage::CGameRecompilePage(HWND hParent, const RECT & rcDispay) { @@ -76,7 +76,10 @@ void CGameRecompilePage::ApplySettings(bool UpdateScreen) bool CGameRecompilePage::EnableReset(void) { - if (CSettingsPageImpl::EnableReset()) { return true; } + if (CSettingsPageImpl::EnableReset()) + { + return true; + } return false; } diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Recompiler.h b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Recompiler.h index 867a173e2..7e9ea5c69 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Recompiler.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Recompiler.h @@ -1,4 +1,5 @@ #pragma once +#include "SettingsPage.h" class CGameRecompilePage : public CSettingsPageImpl, diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Status.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Status.cpp index 87825d626..721056895 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Status.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Status.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" -#include "SettingsPage.h" #include "SettingsPage-Game-Status.h" +#include "SettingsPage.h" CGameStatusPage::CGameStatusPage(HWND hParent, const RECT & rcDispay) { @@ -11,7 +11,7 @@ CGameStatusPage::CGameStatusPage(HWND hParent, const RECT & rcDispay) } CIniFile RomIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str()); - CIniFile::strlist Keys; + CIniFile::strlist Keys; RomIniFile.GetKeyList("ROM Status", Keys); stdstr Status = UISettingsLoadStringVal(Rdb_Status); @@ -21,8 +21,14 @@ CGameStatusPage::CGameStatusPage(HWND hParent, const RECT & rcDispay) { for (CIniFile::strlist::iterator item = Keys.begin(); item != Keys.end(); item++) { - if (strstr(item->c_str(), ".Sel") != nullptr) { continue; } - if (strstr(item->c_str(), ".Auto") != nullptr) { continue; } + if (strstr(item->c_str(), ".Sel") != nullptr) + { + continue; + } + if (strstr(item->c_str(), ".Auto") != nullptr) + { + continue; + } ComboBox->AddItem(stdstr(*item).ToUTF16().c_str(), item->c_str()); } ComboBox->SetTextField(GetDlgItem(IDC_STATUS_TEXT)); @@ -53,7 +59,10 @@ void CGameStatusPage::ApplySettings(bool UpdateScreen) bool CGameStatusPage::EnableReset(void) { - if (CSettingsPageImpl::EnableReset()) { return true; } + if (CSettingsPageImpl::EnableReset()) + { + return true; + } return false; } diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Status.h b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Status.h index cafcb1e37..a3dc1f52f 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Status.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Status.h @@ -1,4 +1,5 @@ #pragma once +#include "SettingsPage.h" class CGameStatusPage : public CSettingsPageImpl, diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-GameBrowser.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-GameBrowser.cpp index b2f30582b..cdc231748 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-GameBrowser.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-GameBrowser.cpp @@ -54,7 +54,10 @@ void COptionsGameBrowserPage::UpdateFieldList(const ROMBROWSER_FIELDS_LIST & Fie continue; } int listCount = m_Using.GetCount(); - if (Pos > listCount) { Pos = listCount; } + if (Pos > listCount) + { + Pos = listCount; + } m_Using.SetItemData(m_Using.InsertString(Pos, wGS(Fields[i].LangID()).c_str()), i); } } @@ -66,13 +69,13 @@ void COptionsGameBrowserPage::UpdatePageSettings(void) FixCtrlState(); } -void COptionsGameBrowserPage::UseRomBrowserChanged(UINT Code, int id, HWND ctl) +void COptionsGameBrowserPage::UseRomBrowserChanged(UINT Code, int id, HWND ctl) { CheckBoxChanged(Code, id, ctl); FixCtrlState(); } -void COptionsGameBrowserPage::FixCtrlState(void) +void COptionsGameBrowserPage::FixCtrlState(void) { bool bEnabled = (SendDlgItemMessage(IDC_USE_ROMBROWSER, BM_GETCHECK, 0, 0) == BST_CHECKED); ::EnableWindow(GetDlgItem(IDC_ROMSEL_TEXT5), bEnabled); @@ -99,7 +102,10 @@ void COptionsGameBrowserPage::AddFieldClicked(UINT /*Code*/, int /*id*/, HWND /* // Select next in list int listCount = m_Avaliable.GetCount(); - if (index >= listCount) { index -= 1; } + if (index >= listCount) + { + index -= 1; + } m_Avaliable.SetCurSel(index); // Add to list @@ -125,7 +131,10 @@ void COptionsGameBrowserPage::RemoveFieldClicked(UINT /*Code*/, int /*id*/, HWND // Select next in list int listCount = m_Using.GetCount(); - if (index >= listCount) { index -= 1; } + if (index >= listCount) + { + index -= 1; + } m_Using.SetCurSel(index); // Add to list @@ -231,7 +240,10 @@ void COptionsGameBrowserPage::ApplySettings(bool UpdateScreen) bool COptionsGameBrowserPage::EnableReset(void) { - if (m_OrderChanged) { return true; } + if (m_OrderChanged) + { + return true; + } return CSettingsPageImpl::EnableReset(); } diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-KeyboardShortcuts.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-KeyboardShortcuts.cpp index 1548e3194..0e3d3d973 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-KeyboardShortcuts.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-KeyboardShortcuts.cpp @@ -218,7 +218,10 @@ void COptionsShortCutsPage::OnShortCutChanged(UINT /*Code*/, int /*id*/, HWND /* { // Get the virtual key info int index = m_VirtualKeyList.GetCurSel(); - if (index < 0) { return; } + if (index < 0) + { + return; + } WORD key = (WORD)m_VirtualKeyList.GetItemData(index); bool bCtrl = (SendDlgItemMessage(IDC_CTL, BM_GETCHECK, 0, 0) == BST_CHECKED); bool bAlt = (SendDlgItemMessage(IDC_ALT, BM_GETCHECK, 0, 0) == BST_CHECKED); @@ -266,7 +269,7 @@ void COptionsShortCutsPage::RefreshShortCutOptions(HTREEITEM hItem) } const std::wstring & Name = ShortCut_item->Name(); - m_CurrentKeys.SetItemData(m_CurrentKeys.AddString(Name.c_str()), (DWORD_PTR)&*ShortCut_item); + m_CurrentKeys.SetItemData(m_CurrentKeys.AddString(Name.c_str()), (DWORD_PTR) & *ShortCut_item); } } @@ -297,22 +300,39 @@ void COptionsShortCutsPage::InputGetKeys(void) ::EnableWindow(GetParent(), false); MSG msg; - for (bool fDone = false; !fDone; MsgWaitForMultipleObjects(0, nullptr, false, 45, QS_ALLINPUT)) { - while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { - if (msg.message == WM_QUIT) { + for (bool fDone = false; !fDone; MsgWaitForMultipleObjects(0, nullptr, false, 45, QS_ALLINPUT)) + { + while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) + { + if (msg.message == WM_QUIT) + { fDone = true; ::PostMessage(nullptr, WM_QUIT, 0, 0); break; } - if (msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN) { + if (msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN) + { int nVirtKey = (int)msg.wParam; - if (nVirtKey == VK_SHIFT) { continue; } - if (nVirtKey == VK_CONTROL) { continue; } - if (nVirtKey == VK_MENU) { continue; } + if (nVirtKey == VK_SHIFT) + { + continue; + } + if (nVirtKey == VK_CONTROL) + { + continue; + } + if (nVirtKey == VK_MENU) + { + continue; + } SendDlgItemMessage(IDC_VIRTUALKEY, CB_SETCURSEL, (WPARAM)-1, 0); - for (int count = 0; count < SendDlgItemMessage(IDC_VIRTUALKEY, CB_GETCOUNT, 0, 0); count++) { + for (int count = 0; count < SendDlgItemMessage(IDC_VIRTUALKEY, CB_GETCOUNT, 0, 0); count++) + { int Data = (int)SendDlgItemMessage(IDC_VIRTUALKEY, CB_GETITEMDATA, count, 0); - if (Data != nVirtKey) { continue; } + if (Data != nVirtKey) + { + continue; + } SendDlgItemMessage(IDC_VIRTUALKEY, CB_SETCURSEL, count, 0); SendDlgItemMessage(IDC_CTL, BM_SETCHECK, (GetKeyState(VK_CONTROL) & 0x80) != 0 ? BST_CHECKED : BST_UNCHECKED, 0); SendDlgItemMessage(IDC_ALT, BM_SETCHECK, (GetKeyState(VK_MENU) & 0x80) != 0 ? BST_CHECKED : BST_UNCHECKED, 0); @@ -323,13 +343,17 @@ void COptionsShortCutsPage::InputGetKeys(void) } continue; } - if (!::IsDialogMessage(hKeyDlg, &msg)) { + if (!::IsDialogMessage(hKeyDlg, &msg)) + { TranslateMessage(&msg); DispatchMessage(&msg); } } - if (!::IsWindow(hKeyDlg)) { fDone = true; } + if (!::IsWindow(hKeyDlg)) + { + fDone = true; + } } ::SetFocus(GetParent()); ::EnableWindow(GetParent(), true); diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Options.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Options.cpp index 957884d09..9d2892d6d 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Options.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Options.cpp @@ -3,7 +3,7 @@ #include "SettingsPage.h" CGeneralOptionsPage::CGeneralOptionsPage(CSettingConfig * SettingsConfig, HWND hParent, const RECT & rcDispay) : -m_SettingsConfig(SettingsConfig) + m_SettingsConfig(SettingsConfig) { if (!Create(hParent, rcDispay)) { @@ -25,7 +25,7 @@ m_SettingsConfig(SettingsConfig) AddModCheckBox(GetDlgItem(IDC_AUTOSLEEP), (SettingID)Setting_AutoSleep); AddModCheckBox(GetDlgItem(IDC_LOAD_FULLSCREEN), (SettingID)Setting_AutoFullscreen); AddModCheckBox(GetDlgItem(IDC_SCREEN_SAVER), (SettingID)Setting_DisableScrSaver); - AddModCheckBox(GetDlgItem(IDC_DISCORD_RPC), (SettingID)Setting_EnableDiscordRPC); + AddModCheckBox(GetDlgItem(IDC_DISCORD_RPC), (SettingID)Setting_EnableDiscordRPC); AddModCheckBox(GetDlgItem(IDC_BASIC_MODE), UserInterface_BasicMode); CModifiedEditBox * TxtBox = AddModTextBox(GetDlgItem(IDC_REMEMBER), (SettingID)File_RecentGameFileCount, false); @@ -54,7 +54,10 @@ void CGeneralOptionsPage::ApplySettings(bool UpdateScreen) bool CGeneralOptionsPage::EnableReset(void) { - if (CSettingsPageImpl::EnableReset()) { return true; } + if (CSettingsPageImpl::EnableReset()) + { + return true; + } return false; } diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.cpp index 6095673e9..128afa916 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.cpp @@ -108,7 +108,7 @@ void COptionPluginPage::ShowAboutButton(int id) } // Get DLL about - void(CALL *DllAbout) (HWND hWnd); + void(CALL * DllAbout)(HWND hWnd); DllAbout = (void(CALL *)(HWND))GetProcAddress(hLib, "DllAbout"); // Call the function from the DLL @@ -207,7 +207,10 @@ void COptionPluginPage::ApplySettings(bool UpdateScreen) bool COptionPluginPage::EnableReset(void) { - if (CSettingsPageImpl::EnableReset()) { return true; } + if (CSettingsPageImpl::EnableReset()) + { + return true; + } return false; } diff --git a/Source/Project64/UserInterface/Settings/SettingsPage.cpp b/Source/Project64/UserInterface/Settings/SettingsPage.cpp index b289d7931..1617922ea 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage.cpp @@ -3,30 +3,30 @@ #include "SettingsPage.h" CConfigSettingSection::CConfigSettingSection(LPCWSTR PageTitle) : -m_PageTitle(PageTitle) + m_PageTitle(PageTitle) { } CConfigSettingSection::~CConfigSettingSection() { - for (size_t i = 0; i < m_Pages.size(); i++) - { - CSettingsPage * Page = m_Pages[i]; - delete Page; - } - m_Pages.clear(); + for (size_t i = 0; i < m_Pages.size(); i++) + { + CSettingsPage * Page = m_Pages[i]; + delete Page; + } + m_Pages.clear(); } void CConfigSettingSection::AddPage(CSettingsPage * Page) { - m_Pages.push_back(Page); + m_Pages.push_back(Page); } CSettingsPage * CConfigSettingSection::GetPage(int PageNo) { - if (PageNo < 0 || PageNo >= (int)m_Pages.size()) - { - return nullptr; - } - return m_Pages[PageNo]; + if (PageNo < 0 || PageNo >= (int)m_Pages.size()) + { + return nullptr; + } + return m_Pages[PageNo]; } diff --git a/Source/Project64/UserInterface/SettingsConfig.cpp b/Source/Project64/UserInterface/SettingsConfig.cpp index 6d3c2b48a..cde50f48c 100644 --- a/Source/Project64/UserInterface/SettingsConfig.cpp +++ b/Source/Project64/UserInterface/SettingsConfig.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" -#include "SettingsConfig.h" #include "Settings/SettingsPage.h" +#include "SettingsConfig.h" #include CSettingConfig::CSettingConfig(bool bJustGameSetting /* = false */) : diff --git a/Source/Project64/UserInterface/SupportEnterCode.cpp b/Source/Project64/UserInterface/SupportEnterCode.cpp index 9021fc94a..db4d30fe9 100644 --- a/Source/Project64/UserInterface/SupportEnterCode.cpp +++ b/Source/Project64/UserInterface/SupportEnterCode.cpp @@ -1,7 +1,8 @@ #include "stdafx.h" + #include "SupportEnterCode.h" -#include #include "resource.h" +#include class CRequestCode : public CDialogImpl diff --git a/Source/Project64/UserInterface/SupportWindow.cpp b/Source/Project64/UserInterface/SupportWindow.cpp index 6cedf4dff..1457408ce 100644 --- a/Source/Project64/UserInterface/SupportWindow.cpp +++ b/Source/Project64/UserInterface/SupportWindow.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "SupportEnterCode.h" #include @@ -56,7 +57,7 @@ void CSupportWindow::EnableContinue() ::EnableWindow(GetDlgItem(IDCANCEL), true); } -LRESULT CSupportWindow::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CSupportWindow::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { m_Logo.SubclassWindow(GetDlgItem(IDC_BMP_LOGO)); m_Logo.SetBitmap(MAKEINTRESOURCE(IDB_ABOUT_LOGO)); @@ -72,37 +73,37 @@ LRESULT CSupportWindow::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /* m_EnterLink.EnableWindow(!m_Support.Validated()); CWindow hInfo = GetDlgItem(IDC_INFO); - CRect rcWin = { 0 }; + CRect rcWin = {0}; hInfo.GetClientRect(&rcWin); CDC hDC = hInfo.GetDC(); HFONT hFont = hInfo.GetFont(); - if(hFont == nullptr) + if (hFont == nullptr) { hFont = (HFONT)::GetStockObject(SYSTEM_FONT); } hDC.SelectFont(hFont); - if (hDC.DrawText(InfoText.c_str(),InfoText.length(),&rcWin,DT_LEFT | DT_CALCRECT | DT_WORDBREAK | DT_NOCLIP) > 0) + if (hDC.DrawText(InfoText.c_str(), InfoText.length(), &rcWin, DT_LEFT | DT_CALCRECT | DT_WORDBREAK | DT_NOCLIP) > 0) { - hInfo.SetWindowPos(nullptr,0,0,rcWin.right, rcWin.bottom,SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER); + hInfo.SetWindowPos(nullptr, 0, 0, rcWin.right, rcWin.bottom, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER); } hInfo.SetWindowText(InfoText.c_str()); hInfo.GetWindowRect(&rcWin); ::MapWindowPoints(nullptr, m_hWnd, (LPPOINT)&rcWin, 2); - + CWindow EnterCode = GetDlgItem(IDC_ENTER_CODE); - EnterCode.SetWindowPos(nullptr,rcWin.left,rcWin.bottom + 4,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOOWNERZORDER); + EnterCode.SetWindowPos(nullptr, rcWin.left, rcWin.bottom + 4, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOOWNERZORDER); EnterCode.GetWindowRect(&rcWin); ::MapWindowPoints(nullptr, m_hWnd, (LPPOINT)&rcWin, 2); CWindow SupportBtn = GetDlgItem(ID_SUPPORT_PJ64); - RECT SupportBtnWin = { 0 }; + RECT SupportBtnWin = {0}; SupportBtn.GetWindowRect(&SupportBtnWin); ::MapWindowPoints(nullptr, m_hWnd, (LPPOINT)&SupportBtnWin, 2); SupportBtn.SetWindowPos(nullptr, SupportBtnWin.left, rcWin.bottom + 40, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOOWNERZORDER); CWindow CancelBtn = GetDlgItem(IDCANCEL); - RECT CancelBtnWin = { 0 }; + RECT CancelBtnWin = {0}; CancelBtn.GetWindowRect(&CancelBtnWin); ::MapWindowPoints(nullptr, m_hWnd, (LPPOINT)&CancelBtnWin, 2); CancelBtn.SetWindowPos(nullptr, CancelBtnWin.left, rcWin.bottom + 40, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOOWNERZORDER); @@ -114,7 +115,7 @@ LRESULT CSupportWindow::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /* AdjustWindowRectEx(&rcWin, GetStyle(), GetMenu() != nullptr, GetExStyle()); int32_t Left = (GetSystemMetrics(SM_CXSCREEN) - rcWin.Width()) / 2; - int32_t Top = (GetSystemMetrics(SM_CYSCREEN) - rcWin.Height()) / 2; + int32_t Top = (GetSystemMetrics(SM_CYSCREEN) - rcWin.Height()) / 2; MoveWindow(Left, Top, rcWin.Width(), rcWin.Height(), TRUE); @@ -127,13 +128,13 @@ LRESULT CSupportWindow::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /* SetWindowLong(GWL_STYLE, dwStyle); GetDlgItem(IDCANCEL).EnableWindow(false); - srand ((uint32_t)time(nullptr)); + srand((uint32_t)time(nullptr)); SetTimer(0, 1000, nullptr); } return TRUE; } -LRESULT CSupportWindow::OnColorStatic(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CSupportWindow::OnColorStatic(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL & /*bHandled*/) { CDCHandle hdcStatic = (HDC)wParam; hdcStatic.SetTextColor(RGB(0, 0, 0)); @@ -141,7 +142,7 @@ LRESULT CSupportWindow::OnColorStatic(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lPa return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH)); } -LRESULT CSupportWindow::OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CSupportWindow::OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL & /*bHandled*/) { static HPEN Outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF); static HBRUSH Fill = CreateSolidBrush(0x00FFFFFF); @@ -156,7 +157,7 @@ LRESULT CSupportWindow::OnEraseBackground(UINT /*uMsg*/, WPARAM wParam, LPARAM / return TRUE; } -LRESULT CSupportWindow::OnTimer(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT CSupportWindow::OnTimer(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL & /*bHandled*/) { m_TimeOutTime -= 1; if (m_TimeOutTime == 0) @@ -169,21 +170,21 @@ LRESULT CSupportWindow::OnTimer(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, return true; } -LRESULT CSupportWindow::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CSupportWindow::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { UISettingsSaveBool(UserInterface_ShowingNagWindow, false); EndDialog(wID); return TRUE; } -LRESULT CSupportWindow::OnSupportProject64(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CSupportWindow::OnSupportProject64(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { stdstr SupportURL = stdstr_f("https://www.pj64-emu.com/support-project64.html?ver=%s&machine=%s", VER_FILE_VERSION_STR, m_Support.MachineID()); ShellExecute(nullptr, L"open", SupportURL.ToUTF16().c_str(), nullptr, nullptr, SW_SHOWMAXIMIZED); return TRUE; } -LRESULT CSupportWindow::OnEnterCode(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +LRESULT CSupportWindow::OnEnterCode(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/) { CSupportEnterCode EnterCodeWindow(m_Support); EnterCodeWindow.DoModal(m_hWnd); diff --git a/Source/Project64/UserInterface/WTLControls/EditConInput.h b/Source/Project64/UserInterface/WTLControls/EditConInput.h index b65079705..528c8a4e8 100644 --- a/Source/Project64/UserInterface/WTLControls/EditConInput.h +++ b/Source/Project64/UserInterface/WTLControls/EditConInput.h @@ -1,5 +1,3 @@ -#include "stdafx.h" - #pragma once enum { diff --git a/Source/Project64/UserInterface/WTLControls/EditNumber32.cpp b/Source/Project64/UserInterface/WTLControls/EditNumber32.cpp index 1cd3362fe..9e161e0b1 100644 --- a/Source/Project64/UserInterface/WTLControls/EditNumber32.cpp +++ b/Source/Project64/UserInterface/WTLControls/EditNumber32.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "EditNumber32.h" CEditNumber32::CEditNumber32(void) : @@ -72,7 +73,7 @@ bool CEditNumber32::IsHexConvertableText(LPTSTR _text) for (; i < wcslen(_text); i++) { wchar_t c = _text[i]; - if (!(c >= 48 && c <= 57 || c >= L'A'&&c <= L'F' || c >= L'a'&&c <= L'f' || c == L' ')) + if (!(c >= 48 && c <= 57 || c >= L'A' && c <= L'F' || c >= L'a' && c <= L'f' || c == L' ')) { bPaste = false; break; @@ -83,7 +84,7 @@ bool CEditNumber32::IsHexConvertableText(LPTSTR _text) void CEditNumber32::FormatClipboard() { - LPTSTR lptstr, lptstrCopy; + LPTSTR lptstr, lptstrCopy; HGLOBAL hglb; if (!this->OpenClipboard() || !IsClipboardFormatAvailable(CF_UNICODETEXT)) { @@ -95,7 +96,7 @@ void CEditNumber32::FormatClipboard() lptstr = (LPTSTR)GlobalLock(hglb); for (unsigned int i = 0; i < wcslen(lptstr); i++) { - if (lptstr[i] != L'X'&&lptstr[i] != L'x') + if (lptstr[i] != L'X' && lptstr[i] != L'x') { lptstr[i] = (char)toupper(lptstr[i]); } @@ -123,13 +124,13 @@ void CEditNumber32::FormatClipboard() } } -LRESULT CEditNumber32::OnValidateValue(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) +LRESULT CEditNumber32::OnValidateValue(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & bHandled) { bHandled = true; return true; } -LRESULT CEditNumber32::OnPaste(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) +LRESULT CEditNumber32::OnPaste(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & bHandled) { // Paste bHandled = false; @@ -148,7 +149,7 @@ LRESULT CEditNumber32::OnPaste(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam HGLOBAL hglb = GetClipboardData(CF_UNICODETEXT); if (hglb != nullptr) { - LPTSTR lptstr = (LPTSTR)GlobalLock(hglb); + LPTSTR lptstr = (LPTSTR)GlobalLock(hglb); // Check invalid hex string if (!IsHexConvertableText(lptstr)) { @@ -164,7 +165,7 @@ LRESULT CEditNumber32::OnPaste(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam return true; } -LRESULT CEditNumber32::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +LRESULT CEditNumber32::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled) { int start, end; GetSel(start, end); @@ -192,7 +193,8 @@ LRESULT CEditNumber32::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& // Does not allow to delete '0' before x bHandled = true; } - else { + else + { bHandled = false; } return TRUE; @@ -214,7 +216,8 @@ LRESULT CEditNumber32::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& SendMessage(uMsg, L'x', lParam); bHandled = true; } - else { + else + { bHandled = false; } return true; @@ -324,7 +327,7 @@ void CEditNumber32::SetValue(uint32_t Value, DisplayMode Display) } else { - text.Format("%s%0*X",(Display & DisplayMode::ShowHexIdent) == DisplayMode::ShowHexIdent ? "0x" : "", (Display & DisplayMode::ZeroExtend) == DisplayMode::ZeroExtend ? 8 : 0, Value); + text.Format("%s%0*X", (Display & DisplayMode::ShowHexIdent) == DisplayMode::ShowHexIdent ? "0x" : "", (Display & DisplayMode::ZeroExtend) == DisplayMode::ZeroExtend ? 8 : 0, Value); } SetWindowText(text.ToUTF16().c_str()); } diff --git a/Source/Project64/UserInterface/WTLControls/GetCWindowText.cpp b/Source/Project64/UserInterface/WTLControls/GetCWindowText.cpp index 79596a025..b48ef72e6 100644 --- a/Source/Project64/UserInterface/WTLControls/GetCWindowText.cpp +++ b/Source/Project64/UserInterface/WTLControls/GetCWindowText.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "GetCWindowText.h" #include diff --git a/Source/Project64/UserInterface/WTLControls/HexEditCtrl.cpp b/Source/Project64/UserInterface/WTLControls/HexEditCtrl.cpp index 3e58e9470..8be43d369 100644 --- a/Source/Project64/UserInterface/WTLControls/HexEditCtrl.cpp +++ b/Source/Project64/UserInterface/WTLControls/HexEditCtrl.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" + #include "HexEditCtrl.h" -#include +#include CHexEditCtrl::CHexEditCtrl(void) : m_BaseAddress(0x80000000), @@ -54,9 +55,9 @@ CHexEditCtrl::~CHexEditCtrl(void) { } -int CALLBACK CHexEditCtrl::HaveFontCb(CONST LOGFONTW* lplf, CONST TEXTMETRICW* /*lptm*/, DWORD /*FontType*/, LPARAM lParam) +int CALLBACK CHexEditCtrl::HaveFontCb(CONST LOGFONTW * lplf, CONST TEXTMETRICW * /*lptm*/, DWORD /*FontType*/, LPARAM lParam) { - const wchar_t * name = (const wchar_t*)lParam; + const wchar_t * name = (const wchar_t *)lParam; if (wcscmp(lplf->lfFaceName, name) == 0) { return 0; @@ -64,7 +65,7 @@ int CALLBACK CHexEditCtrl::HaveFontCb(CONST LOGFONTW* lplf, CONST TEXTMETRICW* / return 1; } -bool CHexEditCtrl::HaveFont(HDC hdc, const char* name) +bool CHexEditCtrl::HaveFont(HDC hdc, const char * name) { if (EnumFonts(hdc, stdstr(name).ToUTF16().c_str(), HaveFontCb, (LPARAM)stdstr(name).ToUTF16().c_str()) == 0) { @@ -93,7 +94,7 @@ BOOL CHexEditCtrl::Attach(HWND hWnd) HDC hdc = GetDC(); HBITMAP hOldBMP; - HFONT hOldFont; + HFONT hOldFont; m_BackDC = CreateCompatibleDC(hdc); m_BackBMP = CreateCompatibleBitmap(hdc, wndRc.Width(), wndRc.Height()); @@ -108,16 +109,16 @@ BOOL CHexEditCtrl::Attach(HWND hWnd) if (HaveFont(hdc, "Consolas")) { m_Font = CreateFont((int)(14 * dpiScale), 0, 0, 0, - FW_DONTCARE, - FALSE, - FALSE, - FALSE, - DEFAULT_CHARSET, - OUT_DEFAULT_PRECIS, - CLIP_DEFAULT_PRECIS, - DEFAULT_QUALITY, - FF_DONTCARE | FIXED_PITCH, - L"Consolas"); + FW_DONTCARE, + FALSE, + FALSE, + FALSE, + DEFAULT_CHARSET, + OUT_DEFAULT_PRECIS, + CLIP_DEFAULT_PRECIS, + DEFAULT_QUALITY, + FF_DONTCARE | FIXED_PITCH, + L"Consolas"); } else { @@ -142,7 +143,7 @@ BOOL CHexEditCtrl::Attach(HWND hWnd) SetTimer(TIMER_ID_AUTO_REFRESH, 20, nullptr); SetTimer(TIMER_ID_DRAG_SCROLL, 50, nullptr); - + ReleaseDC(hdc); return TRUE; @@ -163,13 +164,13 @@ HWND CHexEditCtrl::Detach(void) DeleteObject(m_BackBMP); m_BackBMP = nullptr; } - + if (m_BackDC != nullptr) { DeleteObject(m_BackDC); m_BackDC = nullptr; } - + if (m_Font != nullptr) { DeleteObject(m_Font); @@ -194,7 +195,7 @@ HWND CHexEditCtrl::Detach(void) void CHexEditCtrl::Draw(void) { Notify(HXN_REDRAWSTARTED); - + int startCellIndex = 0; uint32_t startAddress = m_BaseAddress; int numBytesToUpdate = m_NumVisibleBytes; @@ -212,7 +213,7 @@ void CHexEditCtrl::Draw(void) int numBytesScrolled = abs(rowDelta) * m_NumBytesPerRow; int numBytesToShift = (m_NumVisibleBytes - numBytesScrolled) - m_NumBytesPerRow; int shiftSrcIndex = 0, shiftDstIndex = 0; - + numBytesToUpdate = numBytesScrolled + m_NumBytesPerRow; CRect rcScrollArea; @@ -278,9 +279,9 @@ void CHexEditCtrl::Draw(void) { uint32_t address = startAddress + i; - HXBYTEINFO* oldByte = &m_OldBytes[startCellIndex + i]; - HXBYTEINFO* newByte = &m_NewBytes[startCellIndex + i]; - + HXBYTEINFO * oldByte = &m_OldBytes[startCellIndex + i]; + HXBYTEINFO * newByte = &m_NewBytes[startCellIndex + i]; + if (IsSelected(address)) { // Override owner-provided colors if selected @@ -311,14 +312,14 @@ void CHexEditCtrl::Draw(void) // Check if a similar HXBYTEINFO has already been drawn std::unordered_map::const_iterator drawnByte = drawnByteRects.find(*newByte); - + if (drawnByte != drawnByteRects.end()) { HXRECTPAIR src = drawnByte->second; BitBlt(m_BackDC, rcHex.left, rcHex.top, src.rcHex.Width(), src.rcHex.Height(), - m_BackDC, src.rcHex.left, src.rcHex.top, SRCCOPY); + m_BackDC, src.rcHex.left, src.rcHex.top, SRCCOPY); BitBlt(m_BackDC, rcAscii.left, rcAscii.top, src.rcAscii.Width(), src.rcAscii.Height(), - m_BackDC, src.rcAscii.left, src.rcAscii.top, SRCCOPY); + m_BackDC, src.rcAscii.left, src.rcAscii.top, SRCCOPY); InvalidateRect(&rcHex, false); InvalidateRect(&rcAscii, false); } @@ -376,13 +377,13 @@ void CHexEditCtrl::Draw(void) UpdateCaretUI(false); } -void CHexEditCtrl::HitTest(int x, int y, HXHITTEST* pht) +void CHexEditCtrl::HitTest(int x, int y, HXHITTEST * pht) { memset(pht, 0, sizeof(HXHITTEST)); pht->column = HX_COL_NONE; CPoint pt(x, y); - + if (PtInRect(&m_AddressColumnRect, pt)) { pht->column = HX_COL_ADDRESS; @@ -396,7 +397,7 @@ void CHexEditCtrl::HitTest(int x, int y, HXHITTEST* pht) row = min(m_NumVisibleRows - 1, row); uint32_t rowAddress = SatAdd32(m_BaseAddress, row * m_NumBytesPerRow); - + if (x >= m_HexDataColumnRect.left && x < m_HexDataColumnRect.right) { if (PtInRect(&m_HexDataColumnRect, pt)) @@ -411,7 +412,7 @@ void CHexEditCtrl::HitTest(int x, int y, HXHITTEST* pht) uint32_t address = SatAdd32(rowAddress, nGroup * m_NumBytesPerGroup + groupCharIdx / 2); pht->hexAddress = address; pht->hexCellSide = (groupCharIdx & 1) ? HX_RIGHT : HX_LEFT; // TODO: Fix for wrap - pht->asciiAddress = address; // Approximate + pht->asciiAddress = address; // Approximate pht->asciiCellSide = HX_LEFT; } else if (x >= m_AsciiColumnRect.left && x < m_AsciiColumnRect.right) @@ -506,7 +507,7 @@ bool CHexEditCtrl::UpdateCaretUI(bool bEnsureVisible, bool bTop) return true; } -void CHexEditCtrl::Text(int x, int y, const char *text, COLORREF bg, COLORREF fg, CRect *rcOut) +void CHexEditCtrl::Text(int x, int y, const char * text, COLORREF bg, COLORREF fg, CRect * rcOut) { std::wstring textOuput = stdstr(text).ToUTF16(CP_ACP); size_t length = textOuput.length(); @@ -551,7 +552,7 @@ void CHexEditCtrl::UpdateRealSelection(void) swap(start, end); } - else if(start == end) + else if (start == end) { if (m_SelStartCellSide == m_SelEndCellSide) { @@ -600,7 +601,7 @@ void CHexEditCtrl::DrawHeader() { CRect rcClient; GetClientRect(&rcClient); - CRect rcHeader = { 0, 0, rcClient.Width(), m_CharHeight }; + CRect rcHeader = {0, 0, rcClient.Width(), m_CharHeight}; HBRUSH br = CreateSolidBrush(BKCOLOR_ADDR); FillRect(m_BackDC, &rcHeader, br); DeleteObject(br); @@ -618,7 +619,7 @@ void CHexEditCtrl::DrawHeader() InvalidateRect(&rcHeader, false); } -void CHexEditCtrl::GetHexCellPos(int index, CRect* rc) +void CHexEditCtrl::GetHexCellPos(int index, CRect * rc) { int nRow = index / m_NumBytesPerRow; int rowOffs = (index % m_NumBytesPerRow); @@ -628,7 +629,7 @@ void CHexEditCtrl::GetHexCellPos(int index, CRect* rc) int addrColumnWidth = (m_CharWidth * 11); int byteWidth = (m_CharWidth * 2); int hexGroupWidth = (byteWidth * m_NumBytesPerGroup) + (m_CharWidth * 1); - + int headerHeight = m_CharHeight; rc->left = addrColumnWidth + (nGroup * hexGroupWidth) + (byteOffs * byteWidth); @@ -637,7 +638,7 @@ void CHexEditCtrl::GetHexCellPos(int index, CRect* rc) rc->bottom = rc->top + m_CharHeight; } -void CHexEditCtrl::GetAsciiCellPos(int index, CRect* rc) +void CHexEditCtrl::GetAsciiCellPos(int index, CRect * rc) { int nRow = index / m_NumBytesPerRow; int rowOffs = (index % m_NumBytesPerRow); @@ -713,7 +714,7 @@ void CHexEditCtrl::OnTimer(UINT_PTR nIDEvent) { int numBytesToScroll = m_DragScrollDelta * m_NumBytesPerRow; int64_t newCaretAddress = (int64_t)m_CaretAddress + numBytesToScroll; - + if (newCaretAddress < 0 && m_BaseAddress == 0) { return; @@ -740,11 +741,11 @@ void CHexEditCtrl::OnPaint(CDCHandle dc) CRect rc = ps.rcPaint; BitBlt(hdc, - rc.left, rc.top, - rc.Width(), rc.Height(), - m_BackDC, - rc.left, rc.top, - SRCCOPY); + rc.left, rc.top, + rc.Width(), rc.Height(), + m_BackDC, + rc.left, rc.top, + SRCCOPY); EndPaint(&ps); } @@ -800,7 +801,7 @@ void CHexEditCtrl::OnLButtonDown(UINT nFlags, CPoint point) HitTest(point.x, point.y, &ht); m_FocusedColumn = ht.column; - + if (m_FocusedColumn == HX_COL_HEXDATA) { m_CaretAddress = ht.hexAddress; @@ -811,7 +812,7 @@ void CHexEditCtrl::OnLButtonDown(UINT nFlags, CPoint point) m_SelEndAddress = ht.hexAddress; m_SelEndCellSide = ht.hexCellSide; UpdateRealSelection(); - + if (GetSelDirection() > 0) { m_CaretAddress = m_RealSelEndAddress + 1; @@ -1080,7 +1081,7 @@ void CHexEditCtrl::OnChar(UINT nChar, UINT /*nRepCnt*/, UINT /*nFlags*/) { m_CaretAddress = m_SelEndAddress; } - else if(selDirection > 0) + else if (selDirection > 0) { m_CaretAddress = m_SelStartAddress; } @@ -1156,7 +1157,7 @@ int CHexEditCtrl::GetNumBytesPerGroup(void) return m_NumBytesPerGroup; } -bool CHexEditCtrl::GetSelectionRange(uint32_t* startAddress, uint32_t* endAddress) +bool CHexEditCtrl::GetSelectionRange(uint32_t * startAddress, uint32_t * endAddress) { *startAddress = m_RealSelStartAddress; *endAddress = m_RealSelEndAddress; @@ -1208,7 +1209,6 @@ void CHexEditCtrl::OnKeyDown(UINT nChar, UINT /*nRepCnt*/, UINT /*nFlags*/) } } - if (nChar == VK_DOWN) { m_CaretAddress = SatAdd32(m_CaretAddress, m_NumBytesPerRow); @@ -1228,7 +1228,7 @@ void CHexEditCtrl::OnKeyDown(UINT nChar, UINT /*nRepCnt*/, UINT /*nFlags*/) { CancelSelection(); } - + UpdateCaretUI(true); } else if (nChar == VK_UP) @@ -1250,7 +1250,7 @@ void CHexEditCtrl::OnKeyDown(UINT nChar, UINT /*nRepCnt*/, UINT /*nFlags*/) { CancelSelection(); } - + UpdateCaretUI(true); } else if (nChar == VK_RIGHT) @@ -1313,7 +1313,7 @@ void CHexEditCtrl::OnKeyDown(UINT nChar, UINT /*nRepCnt*/, UINT /*nFlags*/) { if (m_FocusedColumn == HX_COL_HEXDATA) { - if(GetKeyState(VK_SHIFT) & 0x8000) + if (GetKeyState(VK_SHIFT) & 0x8000) { m_SelEndCellSide = HX_LEFT; m_SelEndAddress--; @@ -1437,10 +1437,10 @@ void CHexEditCtrl::OnKeyDown(UINT nChar, UINT /*nRepCnt*/, UINT /*nFlags*/) int CHexEditCtrl::GetSelDirection(void) { - if (m_SelStartAddress < m_SelEndAddress) return 1; // Right - if (m_SelStartAddress > m_SelEndAddress) return -1; // Left - if (m_SelStartCellSide == m_SelEndCellSide) return 0; // No selection - if (m_SelStartCellSide == HX_LEFT && m_SelEndCellSide == HX_RIGHT) return 1; // Right (single byte) + if (m_SelStartAddress < m_SelEndAddress) return 1; // Right + if (m_SelStartAddress > m_SelEndAddress) return -1; // Left + if (m_SelStartCellSide == m_SelEndCellSide) return 0; // No selection + if (m_SelStartCellSide == HX_LEFT && m_SelEndCellSide == HX_RIGHT) return 1; // Right (single byte) if (m_SelStartCellSide == HX_RIGHT && m_SelEndCellSide == HX_LEFT) return -1; // Left (single byte) return 0; } @@ -1500,56 +1500,56 @@ void CHexEditCtrl::EnsureCaretAddressVisible(bool bTop) LRESULT CHexEditCtrl::Notify(UINT code) { UINT_PTR nID = ::GetDlgCtrlID(m_hWnd); - NMHDR nmh = { m_hWnd, nID, code }; + NMHDR nmh = {m_hWnd, nID, code}; return ::SendMessage(GetParent(), WM_NOTIFY, (WPARAM)nID, (LPARAM)&nmh); } LRESULT CHexEditCtrl::NotifySetByte(uint32_t address, uint8_t value) { UINT_PTR nID = ::GetDlgCtrlID(m_hWnd); - NMHXSETBYTE nmsb = { { m_hWnd, nID, HXN_SETBYTE }, m_bInsertMode, address, value }; + NMHXSETBYTE nmsb = {{m_hWnd, nID, HXN_SETBYTE}, m_bInsertMode, address, value}; return ::SendMessage(GetParent(), WM_NOTIFY, (WPARAM)nID, (LPARAM)&nmsb); } LRESULT CHexEditCtrl::NotifySetNibble(uint32_t address, bool bLoNibble, uint8_t value) { UINT_PTR nID = ::GetDlgCtrlID(m_hWnd); - NMHXSETNIBBLE nmsn = { { m_hWnd, nID, HXN_SETNIBBLE }, m_bInsertMode, address, bLoNibble, value }; + NMHXSETNIBBLE nmsn = {{m_hWnd, nID, HXN_SETNIBBLE}, m_bInsertMode, address, bLoNibble, value}; return ::SendMessage(GetParent(), WM_NOTIFY, (WPARAM)nID, (LPARAM)&nmsn); } LRESULT CHexEditCtrl::NotifyFillRange(uint32_t startAddress, uint32_t endAddress, uint8_t value) { UINT_PTR nID = ::GetDlgCtrlID(m_hWnd); - NMHXFILLRANGE nmfr = { { m_hWnd, nID, HXN_FILLRANGE }, m_bInsertMode, startAddress, endAddress, value }; + NMHXFILLRANGE nmfr = {{m_hWnd, nID, HXN_FILLRANGE}, m_bInsertMode, startAddress, endAddress, value}; return ::SendMessage(GetParent(), WM_NOTIFY, (WPARAM)nID, (LPARAM)&nmfr); } LRESULT CHexEditCtrl::NotifyCtrlKeyPressed(int nChar) { UINT_PTR nID = ::GetDlgCtrlID(m_hWnd); - NMHXCTRLKEYPRESSED nmck = { { m_hWnd, nID, HXN_CTRLKEYPRESSED }, nChar }; + NMHXCTRLKEYPRESSED nmck = {{m_hWnd, nID, HXN_CTRLKEYPRESSED}, nChar}; return ::SendMessage(GetParent(), WM_NOTIFY, (WPARAM)nID, (LPARAM)&nmck); } LRESULT CHexEditCtrl::NotifyPaste(uint32_t address) { UINT_PTR nID = ::GetDlgCtrlID(m_hWnd); - NMHXPASTE nmp = { { m_hWnd, nID, HXN_PASTE }, address, m_FocusedColumn }; + NMHXPASTE nmp = {{m_hWnd, nID, HXN_PASTE}, address, m_FocusedColumn}; return ::SendMessage(GetParent(), WM_NOTIFY, (WPARAM)nID, (LPARAM)&nmp); } LRESULT CHexEditCtrl::NotifyRightClick(uint32_t address) { UINT_PTR nID = ::GetDlgCtrlID(m_hWnd); - NMHXRCLICK nmrc = { { m_hWnd, nID, HXN_RCLICK }, address }; + NMHXRCLICK nmrc = {{m_hWnd, nID, HXN_RCLICK}, address}; return ::SendMessage(GetParent(), WM_NOTIFY, (WPARAM)nID, (LPARAM)&nmrc); } -LRESULT CHexEditCtrl::NotifyGetByteInfo(uint32_t address, size_t numBytes, bool bIgnoreDiff, HXBYTEINFO* oldBytes, HXBYTEINFO* newBytes) +LRESULT CHexEditCtrl::NotifyGetByteInfo(uint32_t address, size_t numBytes, bool bIgnoreDiff, HXBYTEINFO * oldBytes, HXBYTEINFO * newBytes) { UINT_PTR nID = ::GetDlgCtrlID(m_hWnd); - NMHXGETBYTEINFO nmgbi = { { m_hWnd, nID, HXN_GETBYTEINFO }, address, numBytes, bIgnoreDiff, oldBytes, newBytes }; + NMHXGETBYTEINFO nmgbi = {{m_hWnd, nID, HXN_GETBYTEINFO}, address, numBytes, bIgnoreDiff, oldBytes, newBytes}; return ::SendMessage(GetParent(), WM_NOTIFY, nmgbi.nmh.idFrom, (LPARAM)&nmgbi); } @@ -1622,7 +1622,7 @@ COLORREF CHexEditCtrl::BlendColor(COLORREF c1, COLORREF c2) int r2 = GetRValue(c2); int g2 = GetGValue(c2); int b2 = GetBValue(c2); - return RGB((r1+r2*2)/3, (g1+g2*2)/3, (b1+b2*2)/3); + return RGB((r1 + r2 * 2) / 3, (g1 + g2 * 2) / 3, (b1 + b2 * 2) / 3); } void CHexEditCtrl::UpdateLayoutInfo(void) @@ -1654,22 +1654,22 @@ void CHexEditCtrl::UpdateLayoutInfo(void) int columnsTop = 0 + headerHeight; int columnsBottom = columnsTop + m_NumVisibleRows * m_CharHeight; - m_AddressColumnRect = { addressColumnLeft, columnsTop, addressColumnRight, columnsBottom }; - m_HexDataColumnRect = { hexDataColumnLeft, columnsTop, hexDataColumnRight, columnsBottom }; - m_AsciiColumnRect = { asciiColumnLeft, columnsTop, asciiColumnRight, columnsBottom }; + m_AddressColumnRect = {addressColumnLeft, columnsTop, addressColumnRight, columnsBottom}; + m_HexDataColumnRect = {hexDataColumnLeft, columnsTop, hexDataColumnRight, columnsBottom}; + m_AsciiColumnRect = {asciiColumnLeft, columnsTop, asciiColumnRight, columnsBottom}; m_bLayoutChanged = true; } void CHexEditCtrl::ReallocByteBuffers(void) { - m_NewBytes = (HXBYTEINFO*)realloc(m_NewBytes, m_NumVisibleBytes * sizeof(HXBYTEINFO)); - m_OldBytes = (HXBYTEINFO*)realloc(m_OldBytes, m_NumVisibleBytes * sizeof(HXBYTEINFO)); + m_NewBytes = (HXBYTEINFO *)realloc(m_NewBytes, m_NumVisibleBytes * sizeof(HXBYTEINFO)); + m_OldBytes = (HXBYTEINFO *)realloc(m_OldBytes, m_NumVisibleBytes * sizeof(HXBYTEINFO)); for (int i = 0; i < m_NumVisibleBytes; i++) { - m_NewBytes[i] = { 0 }; - m_OldBytes[i] = { 0 }; + m_NewBytes[i] = {0}; + m_OldBytes[i] = {0}; } } @@ -1722,6 +1722,6 @@ void CHexEditCtrl::SetByteGroupSize(int nBytes) int addressColumnWidth = 11 * m_CharWidth; int headerHeight = m_CharHeight; - CRect rcInv = { addressColumnWidth, headerHeight, rc.Width(), rc.Height() }; + CRect rcInv = {addressColumnWidth, headerHeight, rc.Width(), rc.Height()}; InvalidateRect(&rcInv, true); } diff --git a/Source/Project64/UserInterface/WTLControls/HexEditCtrl.h b/Source/Project64/UserInterface/WTLControls/HexEditCtrl.h index c542b9d64..f256bfc52 100644 --- a/Source/Project64/UserInterface/WTLControls/HexEditCtrl.h +++ b/Source/Project64/UserInterface/WTLControls/HexEditCtrl.h @@ -1,5 +1,4 @@ #pragma once -#include enum { diff --git a/Source/Project64/UserInterface/WTLControls/ModifiedEditBox.cpp b/Source/Project64/UserInterface/WTLControls/ModifiedEditBox.cpp index 0c0cc8036..4eb2f4728 100644 --- a/Source/Project64/UserInterface/WTLControls/ModifiedEditBox.cpp +++ b/Source/Project64/UserInterface/WTLControls/ModifiedEditBox.cpp @@ -1,13 +1,13 @@ #include "stdafx.h" CModifiedEditBox::CModifiedEditBox(bool bString /* = true */, HWND hWnd /* = nullptr */) : -CEdit(hWnd), -m_Changed(false), -m_Reset(false), -m_BoldFont(nullptr), -m_OriginalFont(nullptr), -m_TextField(nullptr), -m_bString(bString) + CEdit(hWnd), + m_Changed(false), + m_Reset(false), + m_BoldFont(nullptr), + m_OriginalFont(nullptr), + m_TextField(nullptr), + m_bString(bString) { } diff --git a/Source/Project64/UserInterface/WTLControls/PartialGroupBox.cpp b/Source/Project64/UserInterface/WTLControls/PartialGroupBox.cpp index da51bdd7d..2cf0110b7 100644 --- a/Source/Project64/UserInterface/WTLControls/PartialGroupBox.cpp +++ b/Source/Project64/UserInterface/WTLControls/PartialGroupBox.cpp @@ -2,108 +2,108 @@ BOOL CPartialGroupBox::Attach(HWND hWnd) { - ATLASSUME(m_hWnd == nullptr); - ATLASSERT(::IsWindow(hWnd)); + ATLASSUME(m_hWnd == nullptr); + ATLASSERT(::IsWindow(hWnd)); - // Allocate the thunk structure here, where we can fail gracefully + // Allocate the thunk structure here, where we can fail gracefully - BOOL result = m_thunk.Init(GetWindowProc(), this); - if (result == FALSE) - { - return FALSE; - } - WNDPROC pProc = m_thunk.GetWNDPROC(); - WNDPROC pfnWndProc = (WNDPROC)::SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)pProc); - if (pfnWndProc == nullptr) - return FALSE; - m_pfnSuperWindowProc = pfnWndProc; - m_hWnd = hWnd; - return TRUE; + BOOL result = m_thunk.Init(GetWindowProc(), this); + if (result == FALSE) + { + return FALSE; + } + WNDPROC pProc = m_thunk.GetWNDPROC(); + WNDPROC pfnWndProc = (WNDPROC)::SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)pProc); + if (pfnWndProc == nullptr) + return FALSE; + m_pfnSuperWindowProc = pfnWndProc; + m_hWnd = hWnd; + return TRUE; } BOOL CPartialGroupBox::AttachToDlgItem(HWND parent, UINT dlgID) { - return Attach(::GetDlgItem(parent, dlgID)); + return Attach(::GetDlgItem(parent, dlgID)); } void CPartialGroupBox::Draw3dLine(CPaintDC & dc, LPCRECT lpRect, COLORREF clrTopLeft, COLORREF /*clrBottomRight*/) { - int x = lpRect->left; - int y = lpRect->top; - int cx = lpRect->right - lpRect->left; - //int cy = lpRect->bottom - lpRect->top; + int x = lpRect->left; + int y = lpRect->top; + int cx = lpRect->right - lpRect->left; + //int cy = lpRect->bottom - lpRect->top; - dc.FillSolidRect(x, y, cx - 1, 1, clrTopLeft); - //dc.FillSolidRect(x, y, 1, cy - 1, clrTopLeft); - //dc.FillSolidRect(x + cx, y, -1, cy, clrBottomRight); - //dc.FillSolidRect(x, y + cy, cx, -1, clrBottomRight); + dc.FillSolidRect(x, y, cx - 1, 1, clrTopLeft); + //dc.FillSolidRect(x, y, 1, cy - 1, clrTopLeft); + //dc.FillSolidRect(x + cx, y, -1, cy, clrBottomRight); + //dc.FillSolidRect(x, y + cy, cx, -1, clrBottomRight); } void CPartialGroupBox::OnPaint(HDC /*hDC*/) { - CPaintDC dc(m_hWnd); + CPaintDC dc(m_hWnd); - // Paint group box manually - CRect controlrect; - GetClientRect(controlrect); - //::MapWindowPoints(HWND_DESKTOP, GetParent(), (LPPOINT)(LPRECT)controlrect, (sizeof(RECT)/sizeof(POINT))); + // Paint group box manually + CRect controlrect; + GetClientRect(controlrect); + //::MapWindowPoints(HWND_DESKTOP, GetParent(), (LPPOINT)(LPRECT)controlrect, (sizeof(RECT)/sizeof(POINT))); - CFontHandle font = GetFont(); + CFontHandle font = GetFont(); - dc.SelectFont(font); - dc.SetMapMode(MM_TEXT); - dc.SelectBrush(GetSysColorBrush(COLOR_BTNFACE)); + dc.SelectFont(font); + dc.SetMapMode(MM_TEXT); + dc.SelectBrush(GetSysColorBrush(COLOR_BTNFACE)); stdstr grptext = GetCWindowText(m_hWnd); - CRect fontsizerect(0, 0, 0, 0); - dc.DrawText(grptext.ToUTF16().c_str(), -1, fontsizerect, DT_SINGLELINE | DT_LEFT | DT_CALCRECT); + CRect fontsizerect(0, 0, 0, 0); + dc.DrawText(grptext.ToUTF16().c_str(), -1, fontsizerect, DT_SINGLELINE | DT_LEFT | DT_CALCRECT); - CRect framerect(controlrect); - framerect.top += (fontsizerect.Height()) / 2; - long Style = GetStyle(); + CRect framerect(controlrect); + framerect.top += (fontsizerect.Height()) / 2; + long Style = GetStyle(); - if ((Style & 0xF000) == BS_FLAT) - { - dc.Draw3dRect(framerect, RGB(0, 0, 0), RGB(0, 0, 0)); - framerect.DeflateRect(1, 1); - dc.Draw3dRect(framerect, RGB(255, 255, 255), RGB(255, 255, 255)); - } - else - { - Draw3dLine(dc, framerect, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT)); - framerect.DeflateRect(1, 1); - Draw3dLine(dc, framerect, GetSysColor(COLOR_3DHILIGHT), GetSysColor(COLOR_3DSHADOW)); - } + if ((Style & 0xF000) == BS_FLAT) + { + dc.Draw3dRect(framerect, RGB(0, 0, 0), RGB(0, 0, 0)); + framerect.DeflateRect(1, 1); + dc.Draw3dRect(framerect, RGB(255, 255, 255), RGB(255, 255, 255)); + } + else + { + Draw3dLine(dc, framerect, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT)); + framerect.DeflateRect(1, 1); + Draw3dLine(dc, framerect, GetSysColor(COLOR_3DHILIGHT), GetSysColor(COLOR_3DSHADOW)); + } - if (!grptext.empty()) - { - CRect fontrect(controlrect); - fontrect.bottom = controlrect.top + fontsizerect.Height(); + if (!grptext.empty()) + { + CRect fontrect(controlrect); + fontrect.bottom = controlrect.top + fontsizerect.Height(); - if ((Style & 0xF00) == BS_RIGHT) - { - fontrect.right -= 6; - fontrect.left = fontrect.right - fontsizerect.Width(); - } - else if ((Style & 0xF00) == BS_CENTER) - { - fontrect.left += (controlrect.Width() - fontsizerect.Width()) / 2; - fontrect.right = fontrect.left + fontsizerect.Width(); - } - else //BS_LEFT or default - { - fontrect.left += 6; - fontrect.right = fontrect.left + fontsizerect.Width(); - } + if ((Style & 0xF00) == BS_RIGHT) + { + fontrect.right -= 6; + fontrect.left = fontrect.right - fontsizerect.Width(); + } + else if ((Style & 0xF00) == BS_CENTER) + { + fontrect.left += (controlrect.Width() - fontsizerect.Width()) / 2; + fontrect.right = fontrect.left + fontsizerect.Width(); + } + else //BS_LEFT or default + { + fontrect.left += 6; + fontrect.right = fontrect.left + fontsizerect.Width(); + } - fontrect.InflateRect(2, 0); - dc.FillRect(fontrect, GetSysColor(COLOR_BTNFACE)); - fontrect.DeflateRect(2, 0); + fontrect.InflateRect(2, 0); + dc.FillRect(fontrect, GetSysColor(COLOR_BTNFACE)); + fontrect.DeflateRect(2, 0); - // Draw caption - dc.SetBkMode(OPAQUE); - dc.SetBkColor(GetSysColor(COLOR_BTNFACE)); + // Draw caption + dc.SetBkMode(OPAQUE); + dc.SetBkColor(GetSysColor(COLOR_BTNFACE)); - dc.DrawText(grptext.ToUTF16().c_str(), -1, fontrect, DT_SINGLELINE | DT_LEFT); - } + dc.DrawText(grptext.ToUTF16().c_str(), -1, fontrect, DT_SINGLELINE | DT_LEFT); + } } diff --git a/Source/Project64/UserInterface/WTLControls/TooltipDialog.h b/Source/Project64/UserInterface/WTLControls/TooltipDialog.h index b34fd73ee..ebefb115e 100644 --- a/Source/Project64/UserInterface/WTLControls/TooltipDialog.h +++ b/Source/Project64/UserInterface/WTLControls/TooltipDialog.h @@ -1,7 +1,5 @@ #pragma once -#include "stdafx.h" - typedef struct { WORD ctrlId; char* text; diff --git a/Source/Project64/UserInterface/WTLControls/wtl-BitmapPicture.cpp b/Source/Project64/UserInterface/WTLControls/wtl-BitmapPicture.cpp index cc2f6d81a..6f9c29d2c 100644 --- a/Source/Project64/UserInterface/WTLControls/wtl-BitmapPicture.cpp +++ b/Source/Project64/UserInterface/WTLControls/wtl-BitmapPicture.cpp @@ -1,32 +1,33 @@ #include "stdafx.h" + #include "wtl-BitmapPicture.h" CBitmapPicture::CBitmapPicture() : - m_hBitmap(nullptr), - m_nResourceID(-1), - m_ResourceIcon(false) + m_hBitmap(nullptr), + m_nResourceID(-1), + m_ResourceIcon(false) { - memset(&m_bmInfo, 0, sizeof(m_bmInfo)); - m_BackgroundBrush.CreateSolidBrush(::GetSysColor(COLOR_3DFACE)); + memset(&m_bmInfo, 0, sizeof(m_bmInfo)); + m_BackgroundBrush.CreateSolidBrush(::GetSysColor(COLOR_3DFACE)); } -LRESULT CBitmapPicture::OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL &/*bHandled*/) +LRESULT CBitmapPicture::OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { - CPaintDC dc(m_hWnd); - CRect rect; - GetClientRect(&rect); + CPaintDC dc(m_hWnd); + CRect rect; + GetClientRect(&rect); - CBrush PaintBrush; - HBRUSH OldBrush = dc.SelectBrush(m_BackgroundBrush); - dc.PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATCOPY); - if (m_ResourceIcon) - { - CIcon hIcon = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), m_nResourceID > 0 ? MAKEINTRESOURCE(m_nResourceID) : m_strResourceName.c_str(), IMAGE_ICON, m_IconWidth, m_IconHeight, LR_DEFAULTCOLOR | LR_DEFAULTSIZE); - if (!hIcon.IsNull()) - { - dc.DrawIconEx(0, 0, hIcon, rect.Width(), rect.Height(), 0, nullptr, DI_NORMAL); - } - } + CBrush PaintBrush; + HBRUSH OldBrush = dc.SelectBrush(m_BackgroundBrush); + dc.PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATCOPY); + if (m_ResourceIcon) + { + CIcon hIcon = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), m_nResourceID > 0 ? MAKEINTRESOURCE(m_nResourceID) : m_strResourceName.c_str(), IMAGE_ICON, m_IconWidth, m_IconHeight, LR_DEFAULTCOLOR | LR_DEFAULTSIZE); + if (!hIcon.IsNull()) + { + dc.DrawIconEx(0, 0, hIcon, rect.Width(), rect.Height(), 0, nullptr, DI_NORMAL); + } + } else { CBitmap hBmp = (HBITMAP)::LoadImage(ModuleHelper::GetResourceInstance(), m_nResourceID > 0 ? MAKEINTRESOURCE(m_nResourceID) : m_strResourceName.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS); @@ -38,40 +39,40 @@ LRESULT CBitmapPicture::OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPara dcMem.SelectBitmap(hBmp); dc.StretchBlt(rect.left, rect.top, rect.Width(), rect.Height(), dcMem, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY); } - dc.SelectBrush(OldBrush); - return 0; + dc.SelectBrush(OldBrush); + return 0; } bool CBitmapPicture::SetIcon(LPCWSTR lpszResourceName, uint32_t nWidth, uint32_t nHeight) { - CIcon hIcon = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), lpszResourceName, IMAGE_ICON, nWidth, nHeight, LR_DEFAULTCOLOR | LR_DEFAULTSIZE); - if (hIcon.IsNull()) - { - return false; - } - ICONINFO IconInfo; - if (!hIcon.GetIconInfo(&IconInfo)) - { - return false; - } - if (IS_INTRESOURCE(lpszResourceName)) - { - m_nResourceID = (int)lpszResourceName; - } - else - { - m_strResourceName = lpszResourceName; - } - m_ResourceIcon = true; - m_IconWidth = nWidth; - m_IconHeight = nHeight; - return true; + CIcon hIcon = (HICON)::LoadImage(ModuleHelper::GetResourceInstance(), lpszResourceName, IMAGE_ICON, nWidth, nHeight, LR_DEFAULTCOLOR | LR_DEFAULTSIZE); + if (hIcon.IsNull()) + { + return false; + } + ICONINFO IconInfo; + if (!hIcon.GetIconInfo(&IconInfo)) + { + return false; + } + if (IS_INTRESOURCE(lpszResourceName)) + { + m_nResourceID = (int)lpszResourceName; + } + else + { + m_strResourceName = lpszResourceName; + } + m_ResourceIcon = true; + m_IconWidth = nWidth; + m_IconHeight = nHeight; + return true; } bool CBitmapPicture::SetBitmap(HBITMAP hBitmap) { - m_hBitmap.Attach(hBitmap); - return ::GetObject(m_hBitmap, sizeof(BITMAP), &m_bmInfo) != 0; + m_hBitmap.Attach(hBitmap); + return ::GetObject(m_hBitmap, sizeof(BITMAP), &m_bmInfo) != 0; } void CBitmapPicture::SetBitmap(LPCWSTR lpszResourceName) @@ -89,5 +90,5 @@ void CBitmapPicture::SetBitmap(LPCWSTR lpszResourceName) void CBitmapPicture::SetBackroundBrush(HBRUSH brush) { - m_BackgroundBrush.Attach(brush); + m_BackgroundBrush.Attach(brush); } diff --git a/Source/Project64/UserInterface/WelcomeScreen.cpp b/Source/Project64/UserInterface/WelcomeScreen.cpp index 87ad2d724..2405ff687 100644 --- a/Source/Project64/UserInterface/WelcomeScreen.cpp +++ b/Source/Project64/UserInterface/WelcomeScreen.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "WelcomeScreen.h" #include "resource.h" @@ -35,11 +36,11 @@ void WelcomeScreen::SelectGameDir(UINT /*Code*/, int /*id*/, HWND /*ctl*/) } } -LRESULT WelcomeScreen::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT WelcomeScreen::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/) { m_Logo.SubclassWindow(GetDlgItem(IDC_BMP_LOGO)); m_Logo.SetBitmap(MAKEINTRESOURCE(IDB_ABOUT_LOGO)); - + LanguageList LangList = g_Lang->GetLangList(); CComboBox LangCB(GetDlgItem(IDC_LANG_SEL)); for (LanguageList::iterator Language = LangList.begin(); Language != LangList.end(); Language++) @@ -58,7 +59,7 @@ LRESULT WelcomeScreen::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*l return TRUE; } -LRESULT WelcomeScreen::OnCtlColorStatic(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) +LRESULT WelcomeScreen::OnCtlColorStatic(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL & /*bHandled*/) { HDC hdcStatic = (HDC)wParam; SetTextColor(hdcStatic, RGB(0, 0, 0)); @@ -105,7 +106,8 @@ LRESULT WelcomeScreen::OnOkCmd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCt } string Project64VideoPluginPath = g_Settings->LoadStringVal(Plugin_GFX_Default); - if (Project64VideoPluginPath.find("Project64-Video") == string::npos) { + if (Project64VideoPluginPath.find("Project64-Video") == string::npos) + { Project64VideoPluginPath = "GFX\\Project64-Video.dll"; } g_Settings->SaveString(Plugin_GFX_Default, CButton(GetDlgItem(IDC_RADIO_GLIDEN64)).GetCheck() == BST_CHECKED ? "GFX\\GLideN64\\GLideN64.dll" : Project64VideoPluginPath); diff --git a/Source/Project64/main.cpp b/Source/Project64/main.cpp index e8e72570c..ca8873485 100644 --- a/Source/Project64/main.cpp +++ b/Source/Project64/main.cpp @@ -1,7 +1,8 @@ #include "stdafx.h" -#include -#include "UserInterface/WelcomeScreen.h" + #include "Settings/UISettings.h" +#include "UserInterface/WelcomeScreen.h" +#include int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpszArgs*/, int /*nWinMode*/) { @@ -15,7 +16,7 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR / } // Create the main window with menu - + WriteTrace(TraceUserInterface, TraceDebug, "Create main window"); CMainGui MainWindow(true, stdstr_f("Project64 %s", VER_FILE_VERSION_STR).c_str()), HiddenWindow(false); CMainMenu MainMenu(&MainWindow); @@ -34,13 +35,12 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR / { // Handle combo loading (N64 ROM and 64DD Disk) - MainWindow.Show(true); // Show the main window + MainWindow.Show(true); stdstr extcombo = CPath(g_Settings->LoadStringVal(Cmd_ComboDiskFile)).GetExtension(); stdstr ext = CPath(g_Settings->LoadStringVal(Cmd_RomFile)).GetExtension(); - if (g_Settings->LoadStringVal(Cmd_ComboDiskFile).length() > 0 - && ((_stricmp(extcombo.c_str(), "ndd") == 0) || (_stricmp(extcombo.c_str(), "d64") == 0))) + if (g_Settings->LoadStringVal(Cmd_ComboDiskFile).length() > 0 && ((_stricmp(extcombo.c_str(), "ndd") == 0) || (_stricmp(extcombo.c_str(), "d64") == 0))) { if ((!(_stricmp(ext.c_str(), "ndd") == 0)) && (!(_stricmp(ext.c_str(), "d64") == 0))) { @@ -54,7 +54,7 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR / { // Handle single game (N64 ROM or 64DD Disk) - MainWindow.Show(true); // Show the main window + MainWindow.Show(true); stdstr ext = CPath(g_Settings->LoadStringVal(Cmd_RomFile)).GetExtension(); if ((!(_stricmp(ext.c_str(), "ndd") == 0)) && (!(_stricmp(ext.c_str(), "d64") == 0))) diff --git a/Source/Project64/stdafx.cpp b/Source/Project64/stdafx.cpp index fd4f341c7..1577c4e3b 100644 --- a/Source/Project64/stdafx.cpp +++ b/Source/Project64/stdafx.cpp @@ -1 +1 @@ -#include "stdafx.h" +#include "stdafx.h" \ No newline at end of file