diff --git a/Source/Project64/N64System/Debugger/Debugger-MemoryDump.cpp b/Source/Project64/N64System/Debugger/Debugger-MemoryDump.cpp index b9bf033f6..75356dec1 100644 --- a/Source/Project64/N64System/Debugger/Debugger-MemoryDump.cpp +++ b/Source/Project64/N64System/Debugger/Debugger-MemoryDump.cpp @@ -13,7 +13,7 @@ #include "DebuggerUI.h" CDumpMemory::CDumpMemory(CDebuggerUI * debugger) : - CDebugDialog(debugger) +CDebugDialog(debugger) { } @@ -51,74 +51,74 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, EndDialog(0); break; case IDC_BTN_CHOOSE_FILE: - { - char FileName[_MAX_PATH], Directory[_MAX_PATH]; - OPENFILENAME openfilename; + { + char FileName[_MAX_PATH], Directory[_MAX_PATH]; + OPENFILENAME openfilename; - memset(&FileName, 0, sizeof(FileName)); - memset(&openfilename, 0, sizeof(openfilename)); - strcpy(Directory, CPath(CPath::MODULE_DIRECTORY)); - openfilename.lStructSize = sizeof(openfilename); - openfilename.hwndOwner = m_hWnd; - openfilename.lpstrFilter = "Text file (*.txt)\0*.txt;\0All files (*.*)\0*.*\0"; - openfilename.lpstrFile = FileName; - openfilename.lpstrInitialDir = Directory; - openfilename.nMaxFile = MAX_PATH; - openfilename.Flags = OFN_HIDEREADONLY; - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory); - if (GetOpenFileName(&openfilename)) - { - char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; - _splitpath(FileName, drive, dir, fname, ext); - if (strlen(ext) == 0) - { - strcat(FileName, ".txt"); - } - SetDlgItemText(IDC_FILENAME, FileName); - } - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); - } - break; - case IDOK: + memset(&FileName, 0, sizeof(FileName)); + memset(&openfilename, 0, sizeof(openfilename)); + strcpy(Directory, CPath(CPath::MODULE_DIRECTORY)); + openfilename.lStructSize = sizeof(openfilename); + openfilename.hwndOwner = m_hWnd; + openfilename.lpstrFilter = "Text file (*.txt)\0*.txt;\0All files (*.*)\0*.*\0"; + openfilename.lpstrFile = FileName; + openfilename.lpstrInitialDir = Directory; + openfilename.nMaxFile = MAX_PATH; + openfilename.Flags = OFN_HIDEREADONLY; + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory); + if (GetOpenFileName(&openfilename)) { - TCHAR FileName[MAX_PATH]; - int CurrentFormatSel = SendDlgItemMessage(IDC_FORMAT, CB_GETCURSEL, 0, 0); - DumpFormat Format = (DumpFormat)SendDlgItemMessage(IDC_FORMAT, CB_GETITEMDATA, CurrentFormatSel, 0); - DWORD StartPC = m_StartAddress.GetValue(); - DWORD EndPC = m_EndAddress.GetValue(); - DWORD DumpPC = m_PC.GetValue(); - GetDlgItemText(IDC_FILENAME, FileName, sizeof(FileName)); - if (strlen(FileName) == 0) + char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; + _splitpath(FileName, drive, dir, fname, ext); + if (strlen(ext) == 0) { - g_Notify->DisplayError(L"Please Choose target file"); - ::SetFocus(GetDlgItem(IDC_FILENAME)); - return false; + strcat(FileName, ".txt"); } - if (SendDlgItemMessage(IDC_USE_ALT_PC, BM_GETSTATE, 0, 0) != BST_CHECKED) - { - DumpPC = g_Reg->m_PROGRAM_COUNTER; - } - //disable buttons - ::EnableWindow(GetDlgItem(IDC_E_START_ADDR), FALSE); - ::EnableWindow(GetDlgItem(IDC_E_END_ADDR), FALSE); - ::EnableWindow(GetDlgItem(IDC_E_ALT_PC), FALSE); - ::EnableWindow(GetDlgItem(IDC_USE_ALT_PC), FALSE); - ::EnableWindow(GetDlgItem(IDC_FILENAME), FALSE); - ::EnableWindow(GetDlgItem(IDC_BTN_CHOOSE_FILE), FALSE); - ::EnableWindow(GetDlgItem(IDC_FORMAT), FALSE); - ::EnableWindow(GetDlgItem(IDOK), FALSE); - ::EnableWindow(GetDlgItem(IDCANCEL), FALSE); - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory); - if (!DumpMemory(FileName, Format, StartPC, EndPC, DumpPC)) - { - //enable buttons - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); - return false; - } - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); + SetDlgItemText(IDC_FILENAME, FileName); } - EndDialog(0); - break; + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); + } + break; + case IDOK: + { + TCHAR FileName[MAX_PATH]; + int CurrentFormatSel = SendDlgItemMessage(IDC_FORMAT, CB_GETCURSEL, 0, 0); + DumpFormat Format = (DumpFormat)SendDlgItemMessage(IDC_FORMAT, CB_GETITEMDATA, CurrentFormatSel, 0); + DWORD StartPC = m_StartAddress.GetValue(); + DWORD EndPC = m_EndAddress.GetValue(); + DWORD DumpPC = m_PC.GetValue(); + GetDlgItemText(IDC_FILENAME, FileName, sizeof(FileName)); + if (strlen(FileName) == 0) + { + g_Notify->DisplayError(L"Please Choose target file"); + ::SetFocus(GetDlgItem(IDC_FILENAME)); + return false; + } + if (SendDlgItemMessage(IDC_USE_ALT_PC, BM_GETSTATE, 0, 0) != BST_CHECKED) + { + DumpPC = g_Reg->m_PROGRAM_COUNTER; + } + //disable buttons + ::EnableWindow(GetDlgItem(IDC_E_START_ADDR), FALSE); + ::EnableWindow(GetDlgItem(IDC_E_END_ADDR), FALSE); + ::EnableWindow(GetDlgItem(IDC_E_ALT_PC), FALSE); + ::EnableWindow(GetDlgItem(IDC_USE_ALT_PC), FALSE); + ::EnableWindow(GetDlgItem(IDC_FILENAME), FALSE); + ::EnableWindow(GetDlgItem(IDC_BTN_CHOOSE_FILE), FALSE); + ::EnableWindow(GetDlgItem(IDC_FORMAT), FALSE); + ::EnableWindow(GetDlgItem(IDOK), FALSE); + ::EnableWindow(GetDlgItem(IDCANCEL), FALSE); + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory); + if (!DumpMemory(FileName, Format, StartPC, EndPC, DumpPC)) + { + //enable buttons + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); + return false; + } + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); + } + EndDialog(0); + break; } return FALSE; } @@ -128,30 +128,30 @@ bool CDumpMemory::DumpMemory(LPCSTR FileName, DumpFormat Format, DWORD StartPC, switch (Format) { case DisassemblyWithPC: + { + CLog LogFile; + if (!LogFile.Open(FileName)) { - CLog LogFile; - if (!LogFile.Open(FileName)) - { - g_Notify->DisplayError(stdstr_f("Failed to open\n%s", FileName).ToUTF16().c_str()); - return false; - } - LogFile.SetFlush(false); - LogFile.SetTruncateFile(false); - g_Notify->BreakPoint(__FILE__, __LINE__); -#ifdef legacycode - char Command[200]; - for (COpcode OpCode(StartPC); OpCode.PC() < EndPC; OpCode.Next()) - { - const char * szOpName = OpCode.OpcodeName(); - OpCode.OpcodeParam(Command); - LogFile.LogF("%X: %-15s%s\r\n",OpCode.PC(),szOpName,Command); - } -#endif - m_StartAddress.SetValue(StartPC, true, true); - m_EndAddress.SetValue(EndPC, true, true); - return true; + g_Notify->DisplayError(stdstr_f("Failed to open\n%s", FileName).ToUTF16().c_str()); + return false; } - break; + LogFile.SetFlush(false); + LogFile.SetTruncateFile(false); + g_Notify->BreakPoint(__FILE__, __LINE__); +#ifdef legacycode + char Command[200]; + for (COpcode OpCode(StartPC); OpCode.PC() < EndPC; OpCode.Next()) + { + const char * szOpName = OpCode.OpcodeName(); + OpCode.OpcodeParam(Command); + LogFile.LogF("%X: %-15s%s\r\n",OpCode.PC(),szOpName,Command); + } +#endif + m_StartAddress.SetValue(StartPC, true, true); + m_EndAddress.SetValue(EndPC, true, true); + return true; + } + break; } return false; } \ No newline at end of file