From 6585657d05d2c46db3705398633e7e00d54e047d Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 7 Nov 2015 08:22:02 +1100 Subject: [PATCH] [Project64] Change CDebugger to CDebuggerUI --- Source/Project64/Debugger.h | 1 + .../N64 System/Debugger/Debug Dialog.h | 128 +- .../Debugger/Debugger - Memory Dump.cpp | 681 ++------ .../Debugger/Debugger - Memory Dump.h | 36 +- .../Debugger/Debugger - Memory Search.cpp | 1388 ++++++++--------- .../Debugger/Debugger - Memory Search.h | 94 +- .../N64 System/Debugger/Debugger - TLB.cpp | 474 +++--- .../N64 System/Debugger/Debugger - TLB.h | 19 +- .../Debugger/Debugger - View Memory.cpp | 793 +++++----- .../Debugger/Debugger - View Memory.h | 70 +- .../N64 System/Debugger/Debugger UI.h | 39 +- .../N64 System/Debugger/Debugger.cpp | 202 +-- .../Project64/N64 System/Debugger/debugger.h | 44 +- Source/Project64/N64 System/N64 Class.cpp | 16 +- Source/Project64/N64 System/N64 Class.h | 38 +- .../Project64/N64 System/System Globals.cpp | 1 + Source/Project64/N64 System/System Globals.h | 3 + Source/Project64/Project64.vcproj | 4 + Source/Project64/Settings.h | 33 +- Source/Project64/Settings/Settings Class.cpp | 1 + Source/Project64/User Interface/Gui Class.h | 21 +- .../User Interface/Main Menu Class.cpp | 10 +- 22 files changed, 1821 insertions(+), 2275 deletions(-) create mode 100644 Source/Project64/Debugger.h diff --git a/Source/Project64/Debugger.h b/Source/Project64/Debugger.h new file mode 100644 index 000000000..7b9637ef9 --- /dev/null +++ b/Source/Project64/Debugger.h @@ -0,0 +1 @@ +#pragma once \ No newline at end of file diff --git a/Source/Project64/N64 System/Debugger/Debug Dialog.h b/Source/Project64/N64 System/Debugger/Debug Dialog.h index 519b02338..7e058426e 100644 --- a/Source/Project64/N64 System/Debugger/Debug Dialog.h +++ b/Source/Project64/N64 System/Debugger/Debug Dialog.h @@ -1,76 +1,76 @@ template class CDebugDialog : - public CDialogImpl + public CDialogImpl < T > { protected: - CDebugger * m_Debugger; - HANDLE m_CreatedEvent; - HANDLE m_DialogThread; + CDebuggerUI * m_Debugger; + HANDLE m_CreatedEvent; + HANDLE m_DialogThread; - static DWORD CreateDebuggerWindow (CDebugDialog * pThis) - { - pThis->DoModal(NULL); - pThis->WindowCreated(); - return 0; - } + static DWORD CreateDebuggerWindow(CDebugDialog * pThis) + { + pThis->DoModal(NULL); + pThis->WindowCreated(); + return 0; + } - void WindowCreated ( void ) - { - SetEvent(m_CreatedEvent); - } + void WindowCreated(void) + { + SetEvent(m_CreatedEvent); + } public: - CDebugDialog (CDebugger * debugger) : - m_Debugger(debugger), - m_CreatedEvent(CreateEvent(NULL,true,false,NULL)), - m_DialogThread(NULL) - { - } - virtual ~CDebugDialog (void) - { - HideWindow(); - CloseHandle(m_CreatedEvent); - if (m_DialogThread) - { - CloseHandle(m_DialogThread); - m_DialogThread = NULL; - } - } + CDebugDialog(CDebuggerUI * debugger) : + m_Debugger(debugger), + m_CreatedEvent(CreateEvent(NULL, true, false, NULL)), + m_DialogThread(NULL) + { + } + virtual ~CDebugDialog(void) + { + HideWindow(); + CloseHandle(m_CreatedEvent); + if (m_DialogThread) + { + CloseHandle(m_DialogThread); + m_DialogThread = NULL; + } + } - void HideWindow ( void ) - { - if (m_hWnd && ::IsWindow(m_hWnd)) - { - ::EndDialog(m_hWnd, 0); - } - if (m_DialogThread) - { - if (WaitForSingleObject(m_DialogThread, 5000) == WAIT_TIMEOUT) - { - WriteTrace(TraceError,"CDebugDialog - time out on close"); + void HideWindow(void) + { + if (m_hWnd && ::IsWindow(m_hWnd)) + { + ::EndDialog(m_hWnd, 0); + } + if (m_DialogThread) + { + if (WaitForSingleObject(m_DialogThread, 5000) == WAIT_TIMEOUT) + { + WriteTrace(TraceError, "CDebugDialog - time out on close"); - TerminateThread(m_DialogThread, 1); - } - CloseHandle(m_DialogThread); - m_DialogThread = NULL; - } - } + TerminateThread(m_DialogThread, 1); + } + CloseHandle(m_DialogThread); + m_DialogThread = NULL; + } + } - void ShowWindow ( void ) - { - if (m_hWnd) - { - SetForegroundWindow((HWND)m_hWnd); - } - else - { - DWORD ThreadID; - ResetEvent(m_CreatedEvent); - m_DialogThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)CreateDebuggerWindow,(LPVOID)this,0, &ThreadID); - if (WaitForSingleObject(m_CreatedEvent,20000) == WAIT_TIMEOUT) - { - WriteTrace(TraceError,"Failed to get window create notification"); - } - } - } + void ShowWindow(void) + { + if (m_hWnd) + { + SetForegroundWindow((HWND)m_hWnd); + } + else + { + DWORD ThreadID; + ResetEvent(m_CreatedEvent); + m_DialogThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CreateDebuggerWindow, (LPVOID)this, 0, &ThreadID); + if (WaitForSingleObject(m_CreatedEvent, 20000) == WAIT_TIMEOUT) + { + WriteTrace(TraceError, "Failed to get window create notification"); + } + } + } }; diff --git a/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp b/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp index 8d9ec77df..5921c429a 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp @@ -10,11 +10,10 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Debugger UI.h" -CDumpMemory::CDumpMemory(CDebugger * debugger) : - CDebugDialog(debugger) +CDumpMemory::CDumpMemory(CDebuggerUI * debugger) : + CDebugDialog(debugger) { } @@ -24,575 +23,135 @@ CDumpMemory::~CDumpMemory() LRESULT CDumpMemory::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - m_StartAddress.Attach(GetDlgItem(IDC_E_START_ADDR)); - m_EndAddress.Attach(GetDlgItem(IDC_E_END_ADDR)); - m_PC.Attach(GetDlgItem(IDC_E_ALT_PC)); + m_StartAddress.Attach(GetDlgItem(IDC_E_START_ADDR)); + m_EndAddress.Attach(GetDlgItem(IDC_E_END_ADDR)); + m_PC.Attach(GetDlgItem(IDC_E_ALT_PC)); - m_StartAddress.SetDisplayType(CEditNumber::DisplayHex); - m_EndAddress.SetDisplayType(CEditNumber::DisplayHex); - m_PC.SetDisplayType(CEditNumber::DisplayHex); + m_StartAddress.SetDisplayType(CEditNumber::DisplayHex); + m_EndAddress.SetDisplayType(CEditNumber::DisplayHex); + m_PC.SetDisplayType(CEditNumber::DisplayHex); - m_StartAddress.SetValue(0x80000000,true,true); - m_EndAddress.SetValue(0x803FFFF0,true,true); - m_PC.SetValue(0x80000000); - HWND hFormatList = GetDlgItem(IDC_FORMAT); - int pos = ::SendMessage(hFormatList,CB_ADDSTRING,(WPARAM)0,(LPARAM)"TEXT - Disassembly + PC"); - ::SendMessage(hFormatList,CB_SETITEMDATA,(WPARAM)pos,(LPARAM)DisassemblyWithPC); - ::SendMessage(hFormatList,CB_SETCURSEL,(WPARAM)0,(LPARAM)0); + m_StartAddress.SetValue(0x80000000, true, true); + m_EndAddress.SetValue(0x803FFFF0, true, true); + m_PC.SetValue(0x80000000); + HWND hFormatList = GetDlgItem(IDC_FORMAT); + int pos = ::SendMessage(hFormatList, CB_ADDSTRING, (WPARAM)0, (LPARAM)"TEXT - Disassembly + PC"); + ::SendMessage(hFormatList, CB_SETITEMDATA, (WPARAM)pos, (LPARAM)DisassemblyWithPC); + ::SendMessage(hFormatList, CB_SETCURSEL, (WPARAM)0, (LPARAM)0); - WindowCreated(); - return TRUE; + WindowCreated(); + return TRUE; } LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { - switch(wID) - { - case IDCANCEL: - EndDialog(0); - break; - case IDC_BTN_CHOOSE_FILE: - { - char FileName[_MAX_PATH],Directory[_MAX_PATH]; - OPENFILENAME openfilename; + switch (wID) + { + case IDCANCEL: + EndDialog(0); + break; + case IDC_BTN_CHOOSE_FILE: + { + 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: - { - 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; + 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: + { + 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; } -//#include "..\\..\\User Interface.h" -//#include "..\\..\\N64 System.h" -//#include -// -//DWORD CDumpMemory::m_StartAddress = 0x80000000; -//DWORD CDumpMemory::m_EndAddress = 0x803FFFF0; -//CDumpMemory::CDumpMemory(CMipsMemory * MMU) : -// m_Window(NULL), g_MMU(MMU) -//{ -//} -//CDumpMemory::~CDumpMemory() -//{ -//} -//void CDumpMemory::DisplayDump(HWND & hParent) -//{ -// DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Cheats_DumpMemory), -// (HWND)hParent, (DLGPROC)WinProc,(LPARAM)this); -//} -//DWORD CDumpMemory::AsciiToHex (const char * HexValue) -//{ -// DWORD Count, Finish, Value = 0; -// Finish = strlen(HexValue); -// if (Finish > 8 ) -// { -// Finish = 8; -// } -// for (Count = 0; Count < Finish; Count++ -// { -// Value = (Value << 4); -// switch ( HexValue[Count] ) -// { -// case '0': break; -// case '1': Value += 1; break; -// case '2': Value += 2; break; -// case '3': Value += 3; break; -// case '4': Value += 4; break; -// case '5': Value += 5; break; -// case '6': Value += 6; break; -// case '7': Value += 7; break; -// case '8': Value += 8; break; -// case '9': Value += 9; break; -// case 'A': Value += 10; break; -// case 'a': Value += 10; break; -// case 'B': Value += 11; break; -// case 'b': Value += 11; break; -// case 'C': Value += 12; break; -// case 'c': Value += 12; break; -// case 'D': Value += 13; break; -// case 'd': Value += 13; break; -// case 'E': Value += 14; break; -// case 'e': Value += 14; break; -// case 'F': Value += 15; break; -// case 'f': Value += 15; break; -// default: -// Value = (Value >> 4); -// Count = Finish; -// } -// } -// return Value; -//} -//int CALLBACK CDumpMemory::WinProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam) -//{ -// switch (uMsg) -// { -// case WM_INITDIALOG: -// { -// CDumpMemory * _this = (CDumpMemory *)lParam; -// SetProp(hDlg,"Class",_this); -// _this->m_Window = hDlg; -// SetDlgItemText(hDlg,IDC_E_START_ADDR,stdstr("0x%X",m_StartAddress).c_str()); -// SetDlgItemText(hDlg,IDC_E_END_ADDR,stdstr("0x%X",m_EndAddress).c_str()); -// SetDlgItemText(hDlg,IDC_E_ALT_PC,"0x80000000"); -// HWND hFormatList = GetDlgItem(hDlg,IDC_FORMAT); -// int pos = SendMessage(hFormatList,CB_ADDSTRING,(WPARAM)0,(LPARAM)"TEXT - Disassembly + PC"); -// SendMessage(hFormatList,CB_SETITEMDATA,(WPARAM)pos,(LPARAM)DisassemblyWithPC); -// SendMessage(hFormatList,CB_SETCURSEL,(WPARAM)0,(LPARAM)0); -// } -// break; -// case WM_COMMAND: -// switch (LOWORD(wParam)) -// { -// case IDC_E_START_ADDR: -// case IDC_E_END_ADDR: -// case IDC_E_ALT_PC: -// if (HIWORD(wParam) == EN_UPDATE) -// { -// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class"); -// TCHAR szTmp[20], szTmp2[20]; -// DWORD Value; -// GetDlgItemText(hDlg,LOWORD(wParam),szTmp,sizeof(szTmp)); -// Value = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); -// //if (Value > Stop) -// //{ -// // Value = Stop; -// //} -// //if (Value < Start) -// //{ -// // Value = Start; -// //} -// sprintf(szTmp2,"0x%X",Value); -// if (strcmp(szTmp,szTmp2) != 0) -// { -// SetDlgItemText(hDlg,LOWORD(wParam),szTmp2); -// if (_this->SelStop == 0) -// { -// _this->SelStop = strlen(szTmp2); _this->SelStart = _this->SelStop; -// } -// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_SETSEL,(WPARAM)_this->SelStart,(LPARAM)_this->SelStop); -// } -// else -// { -// WORD NewSelStart, NewSelStop; -// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_GETSEL,(WPARAM)&NewSelStart,(LPARAM)&NewSelStop); -// if (NewSelStart != 0) -// { -// _this->SelStart = NewSelStart; _this->SelStop = NewSelStop; -// } -// } -// } -// break; -// case IDC_BTN_CHOOSE_FILE: -// { -// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class"); -// OPENFILENAME openfilename; -// char FileName[_MAX_PATH],Directory[_MAX_PATH]; -// memset(&FileName, 0, sizeof(FileName)); -// memset(&openfilename, 0, sizeof(openfilename)); -// strcpy(Directory,g_Settings->LoadStringVal(ApplicationDir).c_str()); -// openfilename.lStructSize = sizeof( openfilename ); -// openfilename.hwndOwner = hDlg; -// 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; -// 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(hDlg,IDC_FILENAME,FileName); -// } -// } -// break; -// case IDCANCEL: -// RemoveProp(hDlg,"Class"); -// EndDialog(hDlg,0); -// break; -// case IDOK: -// { -// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class"); -// TCHAR szTmp[20], FileName[MAX_PATH]; -// int CurrentFormatSel = SendDlgItemMessage(hDlg,IDC_FORMAT,CB_GETCURSEL,0,0); -// DumpFormat Format = (DumpFormat)SendDlgItemMessage(hDlg,IDC_FORMAT,CB_GETITEMDATA,CurrentFormatSel,0); -// GetDlgItemText(hDlg,IDC_E_START_ADDR,szTmp,sizeof(szTmp)); -// DWORD StartPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); -// GetDlgItemText(hDlg,IDC_E_END_ADDR,szTmp,sizeof(szTmp)); -// DWORD EndPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); -// GetDlgItemText(hDlg,IDC_E_ALT_PC,szTmp,sizeof(szTmp)); -// DWORD DumpPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); -// GetDlgItemText(hDlg,IDC_FILENAME,FileName,sizeof(FileName)); -// if (strlen(FileName) == 0) -// { -// g_Notify->DisplayError(L"Please Choose target file"); -// SetFocus(GetDlgItem(hDlg,IDC_FILENAME)); -// return false; -// } -// if (SendDlgItemMessage(hDlg,IDC_USE_ALT_PC,BM_GETSTATE, 0,0) != BST_CHECKED) -// { -// DumpPC = _this->g_MMU->SystemRegisters()->PROGRAM_COUNTER; -// } -// //disable buttons -// EnableWindow(GetDlgItem(hDlg,IDC_E_START_ADDR),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_E_END_ADDR),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_E_ALT_PC),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_USE_ALT_PC),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_FILENAME),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_BTN_CHOOSE_FILE),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_FORMAT),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDOK),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDCANCEL),FALSE); -// if (!_this->DumpMemory(FileName,Format,StartPC,EndPC,DumpPC)) -// { -// //enable buttons -// return false; -// } -// } -// RemoveProp(hDlg,"Class"); -// EndDialog(hDlg,0); -// break; -// } -// break; -// default: -// return false; -// } -// return true; -//} - -bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD /*DumpPC*/ ) +bool CDumpMemory::DumpMemory(LPCSTR FileName, DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD /*DumpPC*/) { - switch (Format) - { - case DisassemblyWithPC: - { - 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(__FILEW__,__LINE__); + switch (Format) + { + case DisassemblyWithPC: + { + 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(__FILEW__, __LINE__); #ifdef tofix - 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); - } + 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; + m_StartAddress.SetValue(StartPC, true, true); + m_EndAddress.SetValue(EndPC, true, true); + return true; + } + break; + } + return false; } -// -//CDumpMemory::CDumpMemory(CMipsMemory * MMU) : -// m_Window(NULL), g_MMU(MMU) -//{ -//} -// -//CDumpMemory::~CDumpMemory() -//{ -//} -// -//void CDumpMemory::DisplayDump(HWND & hParent) -//{ -// DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Cheats_DumpMemory), -// (HWND)hParent, (DLGPROC)WinProc,(LPARAM)this); -//} -// -//DWORD CDumpMemory::AsciiToHex (const char * HexValue) -//{ -// DWORD Count, Finish, Value = 0; -// -// Finish = strlen(HexValue); -// if (Finish > 8 ) -// { -// Finish = 8; -// } -// -// for (Count = 0; Count < Finish; Count++) -// { -// Value = (Value << 4); -// switch ( HexValue[Count] ) -// { -// case '0': break; -// case '1': Value += 1; break; -// case '2': Value += 2; break; -// case '3': Value += 3; break; -// case '4': Value += 4; break; -// case '5': Value += 5; break; -// case '6': Value += 6; break; -// case '7': Value += 7; break; -// case '8': Value += 8; break; -// case '9': Value += 9; break; -// case 'A': Value += 10; break; -// case 'a': Value += 10; break; -// case 'B': Value += 11; break; -// case 'b': Value += 11; break; -// case 'C': Value += 12; break; -// case 'c': Value += 12; break; -// case 'D': Value += 13; break; -// case 'd': Value += 13; break; -// case 'E': Value += 14; break; -// case 'e': Value += 14; break; -// case 'F': Value += 15; break; -// case 'f': Value += 15; break; -// default: -// Value = (Value >> 4); -// Count = Finish; -// } -// } -// return Value; -//} -// -//int CALLBACK CDumpMemory::WinProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam) -//{ -// switch (uMsg) -// { -// case WM_INITDIALOG: -// { -// CDumpMemory * _this = (CDumpMemory *)lParam; -// SetProp(hDlg,"Class",_this); -// _this->m_Window = hDlg; -// SetDlgItemText(hDlg,IDC_E_START_ADDR,stdstr("0x%X",m_StartAddress).c_str()); -// SetDlgItemText(hDlg,IDC_E_END_ADDR,stdstr("0x%X",m_EndAddress).c_str()); -// SetDlgItemText(hDlg,IDC_E_ALT_PC,"0x80000000"); -// -// HWND hFormatList = GetDlgItem(hDlg,IDC_FORMAT); -// int pos = SendMessage(hFormatList,CB_ADDSTRING,(WPARAM)0,(LPARAM)"TEXT - Disassembly + PC"); -// SendMessage(hFormatList,CB_SETITEMDATA,(WPARAM)pos,(LPARAM)DisassemblyWithPC); -// SendMessage(hFormatList,CB_SETCURSEL,(WPARAM)0,(LPARAM)0); -// -// } -// break; -// case WM_COMMAND: -// switch (LOWORD(wParam)) -// { -// case IDC_E_START_ADDR: -// case IDC_E_END_ADDR: -// case IDC_E_ALT_PC: -// if (HIWORD(wParam) == EN_UPDATE) -// { -// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class"); -// -// TCHAR szTmp[20], szTmp2[20]; -// DWORD Value; -// -// GetDlgItemText(hDlg,LOWORD(wParam),szTmp,sizeof(szTmp)); -// Value = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); -// //if (Value > Stop) -// //{ -// // Value = Stop; -// //} -// //if (Value < Start) -// //{ -// // Value = Start; -// //} -// sprintf(szTmp2,"0x%X",Value); -// if (strcmp(szTmp,szTmp2) != 0) -// { -// SetDlgItemText(hDlg,LOWORD(wParam),szTmp2); -// if (_this->SelStop == 0) { _this->SelStop = strlen(szTmp2); _this->SelStart = _this->SelStop; } -// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_SETSEL,(WPARAM)_this->SelStart,(LPARAM)_this->SelStop); -// } -// else -// { -// WORD NewSelStart, NewSelStop; -// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_GETSEL,(WPARAM)&NewSelStart,(LPARAM)&NewSelStop); -// if (NewSelStart != 0) -// { -// _this->SelStart = NewSelStart; _this->SelStop = NewSelStop; -// } -// } -// } -// break; -// case IDC_BTN_CHOOSE_FILE: -// { -// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class"); -// -// OPENFILENAME openfilename; -// char FileName[_MAX_PATH],Directory[_MAX_PATH]; -// -// memset(&FileName, 0, sizeof(FileName)); -// memset(&openfilename, 0, sizeof(openfilename)); -// -// strcpy(Directory,g_Settings->LoadStringVal(ApplicationDir).c_str()); -// -// openfilename.lStructSize = sizeof( openfilename ); -// openfilename.hwndOwner = hDlg; -// 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; -// -// 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(hDlg,IDC_FILENAME,FileName); -// } -// } -// break; -// case IDCANCEL: -// RemoveProp(hDlg,"Class"); -// EndDialog(hDlg,0); -// break; -// case IDOK: -// { -// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class"); -// TCHAR szTmp[20], FileName[MAX_PATH]; -// -// int CurrentFormatSel = SendDlgItemMessage(hDlg,IDC_FORMAT,CB_GETCURSEL,0,0); -// DumpFormat Format = (DumpFormat)SendDlgItemMessage(hDlg,IDC_FORMAT,CB_GETITEMDATA,CurrentFormatSel,0); -// -// GetDlgItemText(hDlg,IDC_E_START_ADDR,szTmp,sizeof(szTmp)); -// DWORD StartPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); -// GetDlgItemText(hDlg,IDC_E_END_ADDR,szTmp,sizeof(szTmp)); -// DWORD EndPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); -// GetDlgItemText(hDlg,IDC_E_ALT_PC,szTmp,sizeof(szTmp)); -// DWORD DumpPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); -// GetDlgItemText(hDlg,IDC_FILENAME,FileName,sizeof(FileName)); -// -// if (strlen(FileName) == 0) -// { -// g_Notify->DisplayError(L"Please Choose target file"); -// SetFocus(GetDlgItem(hDlg,IDC_FILENAME)); -// return false; -// } -// -// if (SendDlgItemMessage(hDlg,IDC_USE_ALT_PC,BM_GETSTATE, 0,0) != BST_CHECKED) -// { -// DumpPC = _this->g_MMU->SystemRegisters()->PROGRAM_COUNTER; -// } -// //disable buttons -// EnableWindow(GetDlgItem(hDlg,IDC_E_START_ADDR),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_E_END_ADDR),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_E_ALT_PC),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_USE_ALT_PC),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_FILENAME),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_BTN_CHOOSE_FILE),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_FORMAT),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDOK),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDCANCEL),FALSE); -// if (!_this->DumpMemory(FileName,Format,StartPC,EndPC,DumpPC)) -// { -// //enable buttons -// return false; -// } -// } -// RemoveProp(hDlg,"Class"); -// EndDialog(hDlg,0); -// break; -// } -// break; -// default: -// return false; -// } -// return true; -//} -// -//bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD DumpPC ) -//{ -// switch (Format) -// { -// case DisassemblyWithPC: -// { -// CLog LogFile(FileName); -// if (!LogFile.IsOpen()) -// { -// g_Notify->DisplayError(L"Failed to open\n%s",FileName); -// return false; -// } -// -// for (COpcode OpCode(g_MMU,StartPC); OpCode.PC() < EndPC; OpCode.Next()) -// { -// LogFile.Log("%X: %s",OpCode.PC(),OpCode.Name().c_str()); -// } -// m_StartAddress = StartPC; -// m_EndAddress = EndPC; -// return true; -// } -// break; -// } -// return false; -//} -#endif diff --git a/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.h b/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.h index 129aa4474..274b997ce 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.h +++ b/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.h @@ -11,33 +11,33 @@ #pragma once class CDumpMemory : - public CDebugDialog + public CDebugDialog < CDumpMemory > { -public: - enum { IDD = IDD_Cheats_DumpMemory }; +public: + enum { IDD = IDD_Cheats_DumpMemory }; - CDumpMemory(CDebugger * debugger); - virtual ~CDumpMemory(void); + CDumpMemory(CDebuggerUI * debugger); + virtual ~CDumpMemory(void); private: - CDumpMemory(void); // Disable default constructor - CDumpMemory(const CDumpMemory&); // Disable copy constructor - CDumpMemory& operator=(const CDumpMemory&); // Disable assignment + CDumpMemory(void); // Disable default constructor + CDumpMemory(const CDumpMemory&); // Disable copy constructor + CDumpMemory& operator=(const CDumpMemory&); // Disable assignment - enum DumpFormat - { - DisassemblyWithPC - }; + enum DumpFormat + { + DisassemblyWithPC + }; - BEGIN_MSG_MAP_EX(CDumpMemory) - MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) - COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked) - END_MSG_MAP() + BEGIN_MSG_MAP_EX(CDumpMemory) + MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) + COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked) + END_MSG_MAP() - LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled); - bool DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD DumpPC ); + bool DumpMemory(LPCSTR FileName, DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD DumpPC); CEditNumber m_StartAddress, m_EndAddress, m_PC; }; diff --git a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp index 9ea8ddc66..763371662 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp @@ -10,783 +10,781 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Debugger UI.h" -CDebugMemorySearch::CDebugMemorySearch(CDebugger * debugger) : - CDebugDialog(debugger), - m_MemoryState(NULL), - m_MemoryStateSize(0) +CDebugMemorySearch::CDebugMemorySearch(CDebuggerUI * debugger) : + CDebugDialog(debugger), + m_MemoryState(NULL), + m_MemoryStateSize(0) { } CDebugMemorySearch::~CDebugMemorySearch() { - if (m_MemoryState) - { - delete m_MemoryState; - } + if (m_MemoryState) + { + delete m_MemoryState; + } } -void CDebugMemorySearch::AddAlignmentOptions (CComboBox & ctrl) +void CDebugMemorySearch::AddAlignmentOptions(CComboBox & ctrl) { - int Index = ctrl.AddString("32 bits (aligned)"); - ctrl.SetItemData(Index,_32Bit); - Index = ctrl.AddString("16bits (aligned)"); - ctrl.SetItemData(Index,_16Bit); - Index = ctrl.AddString("8bits"); - ctrl.SetCurSel(Index); - ctrl.SetItemData(Index,_8Bit); + int Index = ctrl.AddString("32 bits (aligned)"); + ctrl.SetItemData(Index, _32Bit); + Index = ctrl.AddString("16bits (aligned)"); + ctrl.SetItemData(Index, _16Bit); + Index = ctrl.AddString("8bits"); + ctrl.SetCurSel(Index); + ctrl.SetItemData(Index, _8Bit); } LRESULT CDebugMemorySearch::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - m_PAddrStart.Attach(GetDlgItem(IDC_PADDR_START)); - m_PAddrStart.SetDisplayType(CEditNumber::DisplayHex); - m_SearchLen.Attach(GetDlgItem(IDC_ADDR_END)); - m_SearchLen.SetDisplayType(CEditNumber::DisplayHex); - m_SearchValue.Attach(GetDlgItem(IDC_SEARCH_VALUE)); - m_SearchValue.SetDisplayType(CEditNumber::DisplayDec); - m_SearchValue.SetValue(0); - m_MaxSearch.Attach(GetDlgItem(IDC_MAX_SEARCH)); - m_MaxSearch.SetDisplayType(CEditNumber::DisplayDec); - m_MaxSearch.SetValue(50000); - m_UnknownSize.Attach(GetDlgItem(IDC_UNKNOWN_ALIGN)); - AddAlignmentOptions(m_UnknownSize); - m_ValueSize.Attach(GetDlgItem(IDC_VALUE_ALIGN)); - AddAlignmentOptions(m_ValueSize); - m_SearchResults.Attach(GetDlgItem(IDC_LST_RESULTS)); - m_SearchResults.AddColumn("ID",0); - m_SearchResults.AddColumn("PAddr",1); - m_SearchResults.AddColumn("Value",2); - m_SearchResults.SetColumnWidth(0,50); - m_SearchResults.SetColumnWidth(1,75); - m_SearchResults.SetColumnWidth(2,75); - m_SearchResults.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT); - m_UnknownOptions.Attach(GetDlgItem(IDC_CMB_UNKNOWN)); - m_HaveResults = false; - FixUnknownOptions(true); + m_PAddrStart.Attach(GetDlgItem(IDC_PADDR_START)); + m_PAddrStart.SetDisplayType(CEditNumber::DisplayHex); + m_SearchLen.Attach(GetDlgItem(IDC_ADDR_END)); + m_SearchLen.SetDisplayType(CEditNumber::DisplayHex); + m_SearchValue.Attach(GetDlgItem(IDC_SEARCH_VALUE)); + m_SearchValue.SetDisplayType(CEditNumber::DisplayDec); + m_SearchValue.SetValue(0); + m_MaxSearch.Attach(GetDlgItem(IDC_MAX_SEARCH)); + m_MaxSearch.SetDisplayType(CEditNumber::DisplayDec); + m_MaxSearch.SetValue(50000); + m_UnknownSize.Attach(GetDlgItem(IDC_UNKNOWN_ALIGN)); + AddAlignmentOptions(m_UnknownSize); + m_ValueSize.Attach(GetDlgItem(IDC_VALUE_ALIGN)); + AddAlignmentOptions(m_ValueSize); + m_SearchResults.Attach(GetDlgItem(IDC_LST_RESULTS)); + m_SearchResults.AddColumn("ID", 0); + m_SearchResults.AddColumn("PAddr", 1); + m_SearchResults.AddColumn("Value", 2); + m_SearchResults.SetColumnWidth(0, 50); + m_SearchResults.SetColumnWidth(1, 75); + m_SearchResults.SetColumnWidth(2, 75); + m_SearchResults.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT); + m_UnknownOptions.Attach(GetDlgItem(IDC_CMB_UNKNOWN)); + m_HaveResults = false; + FixUnknownOptions(true); - SendMessage(GetDlgItem(IDC_RADIO_VALUE),BM_SETCHECK, BST_CHECKED,0); + SendMessage(GetDlgItem(IDC_RADIO_VALUE), BM_SETCHECK, BST_CHECKED, 0); - BOOL bHandled; - OnClicked(0,IDC_BTN_RDRAM,NULL,bHandled); - OnClicked(0,IDC_RADIO_VALUE,NULL,bHandled); - WindowCreated(); - return TRUE; + BOOL bHandled; + OnClicked(0, IDC_BTN_RDRAM, NULL, bHandled); + OnClicked(0, IDC_RADIO_VALUE, NULL, bHandled); + WindowCreated(); + return TRUE; } LRESULT CDebugMemorySearch::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND hWndCtl, BOOL& /*bHandled*/) { - switch(wID) - { - case IDCANCEL: - EndDialog(0); - break; - case IDC_BTN_RDRAM: - m_PAddrStart.SetValue(0,true,true); - m_SearchLen.SetValue(g_MMU->RdramSize(),true,true); - break; - case IDC_BTN_ROM: - m_PAddrStart.SetValue(0x10000000,true,true); - m_SearchLen.SetValue(g_Rom->GetRomSize(),true,true); - break; - case IDC_BTN_SPMEM: - m_PAddrStart.SetValue(0x04000000,true,true); - m_SearchLen.SetValue(0x2000,true,true); - break; - case IDC_SEARCH_HEX: - { - bool bChecked = (SendMessage(hWndCtl, BM_GETSTATE, 0,0) & BST_CHECKED) != 0; - m_SearchValue.SetDisplayType( bChecked ? CEditNumber::DisplayHex : CEditNumber::DisplayDec); - } - break; - case ID_POPUP_SHOWINMEMORYVIEWER: - { - LONG iItem = m_SearchResults.GetNextItem(-1, LVNI_SELECTED); - if (iItem == -1) - { - break; - } + switch (wID) + { + case IDCANCEL: + EndDialog(0); + break; + case IDC_BTN_RDRAM: + m_PAddrStart.SetValue(0, true, true); + m_SearchLen.SetValue(g_MMU->RdramSize(), true, true); + break; + case IDC_BTN_ROM: + m_PAddrStart.SetValue(0x10000000, true, true); + m_SearchLen.SetValue(g_Rom->GetRomSize(), true, true); + break; + case IDC_BTN_SPMEM: + m_PAddrStart.SetValue(0x04000000, true, true); + m_SearchLen.SetValue(0x2000, true, true); + break; + case IDC_SEARCH_HEX: + { + bool bChecked = (SendMessage(hWndCtl, BM_GETSTATE, 0, 0) & BST_CHECKED) != 0; + m_SearchValue.SetDisplayType(bChecked ? CEditNumber::DisplayHex : CEditNumber::DisplayDec); + } + break; + case ID_POPUP_SHOWINMEMORYVIEWER: + { + LONG iItem = m_SearchResults.GetNextItem(-1, LVNI_SELECTED); + if (iItem == -1) + { + break; + } - int ItemId = m_SearchResults.GetItemData(iItem); - SearchResultItem & Result = m_SearchResult[ItemId]; - m_Debugger->Debug_ShowMemoryLocation(Result.PAddr, false); - } - break; - case IDC_RADIO_UNKNOWN: - EnableUnknownOptions(true); - EnableValueOptions(false); - EnableTextOptions(false); - EnableJalOptions(false); - break; - case IDC_RADIO_VALUE: - EnableUnknownOptions(false); - EnableValueOptions(true); - EnableTextOptions(false); - EnableJalOptions(false); - break; - case IDC_RADIO_TEXT: - EnableUnknownOptions(false); - EnableValueOptions(false); - EnableTextOptions(true); - EnableJalOptions(false); - break; - case IDC_RADIO_JAL: - EnableUnknownOptions(false); - EnableValueOptions(false); - EnableTextOptions(false); - EnableJalOptions(true); - break; - case IDC_BTN_SEARCH: - if (SendMessage(GetDlgItem(IDC_RADIO_UNKNOWN),BM_GETSTATE, 0,0) == BST_CHECKED) - { - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory); - SearchForUnknown(); - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory); - break; - } - if (SendMessage(GetDlgItem(IDC_RADIO_VALUE),BM_GETSTATE, 0,0) == BST_CHECKED) - { - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory); - SearchForValue(); - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory); - break; - } - if (SendMessage(GetDlgItem(IDC_RADIO_TEXT),BM_GETSTATE, 0,0) == BST_CHECKED) - { - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory); - SearchForText(); - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory); - break; - } - case IDC_RESET_BUTTON: - Reset(); - break; - } - return FALSE; + int ItemId = m_SearchResults.GetItemData(iItem); + SearchResultItem & Result = m_SearchResult[ItemId]; + m_Debugger->Debug_ShowMemoryLocation(Result.PAddr, false); + } + break; + case IDC_RADIO_UNKNOWN: + EnableUnknownOptions(true); + EnableValueOptions(false); + EnableTextOptions(false); + EnableJalOptions(false); + break; + case IDC_RADIO_VALUE: + EnableUnknownOptions(false); + EnableValueOptions(true); + EnableTextOptions(false); + EnableJalOptions(false); + break; + case IDC_RADIO_TEXT: + EnableUnknownOptions(false); + EnableValueOptions(false); + EnableTextOptions(true); + EnableJalOptions(false); + break; + case IDC_RADIO_JAL: + EnableUnknownOptions(false); + EnableValueOptions(false); + EnableTextOptions(false); + EnableJalOptions(true); + break; + case IDC_BTN_SEARCH: + if (SendMessage(GetDlgItem(IDC_RADIO_UNKNOWN), BM_GETSTATE, 0, 0) == BST_CHECKED) + { + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory); + SearchForUnknown(); + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory); + break; + } + if (SendMessage(GetDlgItem(IDC_RADIO_VALUE), BM_GETSTATE, 0, 0) == BST_CHECKED) + { + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory); + SearchForValue(); + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory); + break; + } + if (SendMessage(GetDlgItem(IDC_RADIO_TEXT), BM_GETSTATE, 0, 0) == BST_CHECKED) + { + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory); + SearchForText(); + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory); + break; + } + case IDC_RESET_BUTTON: + Reset(); + break; + } + return FALSE; } -LRESULT CDebugMemorySearch::OnResultRClick ( LPNMHDR /*lpnmh*/ ) +LRESULT CDebugMemorySearch::OnResultRClick(LPNMHDR /*lpnmh*/) { - LONG iItem = m_SearchResults.GetNextItem(-1, LVNI_SELECTED); - if (iItem == -1) - { - return true; - } + LONG iItem = m_SearchResults.GetNextItem(-1, LVNI_SELECTED); + if (iItem == -1) + { + return true; + } - //Load the menu - HMENU hMenu = LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_MEM_SEARCH)); - HMENU hPopupMenu = GetSubMenu(hMenu,0); + //Load the menu + HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MEM_SEARCH)); + HMENU hPopupMenu = GetSubMenu(hMenu, 0); - //Get the current Mouse location - POINT Mouse; - GetCursorPos(&Mouse); + //Get the current Mouse location + POINT Mouse; + GetCursorPos(&Mouse); - //Show the menu - TrackPopupMenu(hPopupMenu, 0, Mouse.x, Mouse.y, 0,m_hWnd, NULL); - DestroyMenu(hMenu); - return true; + //Show the menu + TrackPopupMenu(hPopupMenu, 0, Mouse.x, Mouse.y, 0, m_hWnd, NULL); + DestroyMenu(hMenu); + return true; } -void CDebugMemorySearch::EnableValueOptions( bool Enable ) +void CDebugMemorySearch::EnableValueOptions(bool Enable) { - if (Enable) - { - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),m_HaveResults ? "Search Results" : "Search"); - } - ::EnableWindow(GetDlgItem(IDC_SEARCH_VALUE),Enable); - ::EnableWindow(GetDlgItem(IDC_SEARCH_HEX),Enable); - ::EnableWindow(GetDlgItem(IDC_VALUE_ALIGN),m_HaveResults ? false : Enable ); + if (Enable) + { + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), m_HaveResults ? "Search Results" : "Search"); + } + ::EnableWindow(GetDlgItem(IDC_SEARCH_VALUE), Enable); + ::EnableWindow(GetDlgItem(IDC_SEARCH_HEX), Enable); + ::EnableWindow(GetDlgItem(IDC_VALUE_ALIGN), m_HaveResults ? false : Enable); } -void CDebugMemorySearch::EnableTextOptions( bool Enable ) +void CDebugMemorySearch::EnableTextOptions(bool Enable) { - if (Enable) - { - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),m_HaveResults ? "Search Results" : "Search"); - } - ::EnableWindow(GetDlgItem(IDC_SEARCH_TEXT),Enable); - ::EnableWindow(GetDlgItem(IDC_CASE_SENSITIVE),Enable); + if (Enable) + { + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), m_HaveResults ? "Search Results" : "Search"); + } + ::EnableWindow(GetDlgItem(IDC_SEARCH_TEXT), Enable); + ::EnableWindow(GetDlgItem(IDC_CASE_SENSITIVE), Enable); } -void CDebugMemorySearch::EnableJalOptions( bool Enable ) +void CDebugMemorySearch::EnableJalOptions(bool Enable) { - if (Enable) - { - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),m_HaveResults ? "Search Results" : "Search"); - } - ::EnableWindow(GetDlgItem(IDC_JAL_ADDR),Enable); + if (Enable) + { + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), m_HaveResults ? "Search Results" : "Search"); + } + ::EnableWindow(GetDlgItem(IDC_JAL_ADDR), Enable); } -void CDebugMemorySearch::EnableUnknownOptions( bool Enable ) +void CDebugMemorySearch::EnableUnknownOptions(bool Enable) { - if (m_UnknownOptions.GetCount() > 1) - { - ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN),m_HaveResults ? false : Enable ); - if (Enable) - { - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), m_HaveResults ? "Search Results" : "Search"); - } - } - else - { - ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN), false ); - if (Enable) - { - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Create"); - } - } - ::EnableWindow(GetDlgItem(IDC_CMB_UNKNOWN),Enable); + if (m_UnknownOptions.GetCount() > 1) + { + ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN), m_HaveResults ? false : Enable); + if (Enable) + { + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), m_HaveResults ? "Search Results" : "Search"); + } + } + else + { + ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN), false); + if (Enable) + { + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Create"); + } + } + ::EnableWindow(GetDlgItem(IDC_CMB_UNKNOWN), Enable); } -void CDebugMemorySearch::SearchForValue( void ) +void CDebugMemorySearch::SearchForValue(void) { - MemorySize Size = (MemorySize)m_ValueSize.GetItemData(m_ValueSize.GetCurSel()); - DWORD Value = m_SearchValue.GetValue(); - DWORD StartAddress = m_PAddrStart.GetValue(); - DWORD Len = m_SearchLen.GetValue(); - DWORD MaxSearch = m_MaxSearch.GetValue(); - - DWORD MoveSize = (Size == _32Bit ? 4 : (Size == _16Bit ? 2 : 1)); - - m_UnknownSize.SetCurSel(m_ValueSize.GetCurSel()); + MemorySize Size = (MemorySize)m_ValueSize.GetItemData(m_ValueSize.GetCurSel()); + DWORD Value = m_SearchValue.GetValue(); + DWORD StartAddress = m_PAddrStart.GetValue(); + DWORD Len = m_SearchLen.GetValue(); + DWORD MaxSearch = m_MaxSearch.GetValue(); - LPCTSTR DisplayStr = "0x%08X"; - if (Size == _16Bit) - { - DisplayStr = "0x%04X"; - } - else if (Size == _8Bit) - { - DisplayStr = "0x%04X"; - } + DWORD MoveSize = (Size == _32Bit ? 4 : (Size == _16Bit ? 2 : 1)); - if (!m_HaveResults) - { - m_HaveResults = true; + m_UnknownSize.SetCurSel(m_ValueSize.GetCurSel()); - FixUnknownOptions(false); - m_SearchResults.DeleteAllItems(); - DWORD ItemsAdded = 0; + LPCTSTR DisplayStr = "0x%08X"; + if (Size == _16Bit) + { + DisplayStr = "0x%04X"; + } + else if (Size == _8Bit) + { + DisplayStr = "0x%04X"; + } - while (SearchForValue(Value,Size,StartAddress,Len)) - { - SearchResultItem Result; - Result.PAddr = StartAddress; - Result.Value = Value; + if (!m_HaveResults) + { + m_HaveResults = true; - char LocationStr[20]; - sprintf(LocationStr,"%d",ItemsAdded + 1); - int Index = m_SearchResults.AddItem(ItemsAdded,0,LocationStr); - m_SearchResults.SetItemData(Index,m_SearchResult.size()); - m_SearchResult.push_back(Result); - sprintf(LocationStr,"0x%08X",StartAddress); - m_SearchResults.SetItemText(Index,1,LocationStr); - sprintf(LocationStr,DisplayStr,Value); - m_SearchResults.SetItemText(Index,2,LocationStr); - sprintf(LocationStr,DisplayStr,Value); - m_SearchResults.SetItemText(Index,3,LocationStr); - StartAddress += MoveSize; - Len -= MoveSize; - ItemsAdded += 1; - if (ItemsAdded >= MaxSearch) - { - break; - } - } - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search Results"); - ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_SHOW); - ::EnableWindow(GetDlgItem(IDC_VALUE_ALIGN),false); - } - else - { - int ItemCount = m_SearchResults.GetItemCount(); - for (int i = ItemCount - 1; i >= 0; i--) - { - int ItemId = m_SearchResults.GetItemData(i); - SearchResultItem & Result = m_SearchResult[ItemId]; - - DWORD NewValue = 0; - bool valid = false; + FixUnknownOptions(false); + m_SearchResults.DeleteAllItems(); + DWORD ItemsAdded = 0; - switch (Size) - { - case _8Bit: - { - BYTE mem = 0; - valid = g_MMU->LB_PAddr(Result.PAddr, mem); - NewValue = mem; - } - break; - case _16Bit: - { - WORD mem = 0; - valid = g_MMU->LH_PAddr(Result.PAddr, mem); - NewValue = mem; - } - break; - case _32Bit: - valid = g_MMU->LW_PAddr(Result.PAddr, NewValue); - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + while (SearchForValue(Value, Size, StartAddress, Len)) + { + SearchResultItem Result; + Result.PAddr = StartAddress; + Result.Value = Value; - if (Value == NewValue) - { - char LocationStr[20]; - sprintf(LocationStr,DisplayStr,NewValue); - m_SearchResults.SetItemText(i,2,LocationStr); - sprintf(LocationStr,DisplayStr,Result.Value); - m_SearchResults.SetItemText(i,3,LocationStr); - Result.Value = NewValue; - } - else - { - m_SearchResults.DeleteItem(i); - } - } - } - ::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS),stdstr_f("Results (%d)",m_SearchResults.GetItemCount()).c_str()); + char LocationStr[20]; + sprintf(LocationStr, "%d", ItemsAdded + 1); + int Index = m_SearchResults.AddItem(ItemsAdded, 0, LocationStr); + m_SearchResults.SetItemData(Index, m_SearchResult.size()); + m_SearchResult.push_back(Result); + sprintf(LocationStr, "0x%08X", StartAddress); + m_SearchResults.SetItemText(Index, 1, LocationStr); + sprintf(LocationStr, DisplayStr, Value); + m_SearchResults.SetItemText(Index, 2, LocationStr); + sprintf(LocationStr, DisplayStr, Value); + m_SearchResults.SetItemText(Index, 3, LocationStr); + StartAddress += MoveSize; + Len -= MoveSize; + ItemsAdded += 1; + if (ItemsAdded >= MaxSearch) + { + break; + } + } + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Search Results"); + ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON), SW_SHOW); + ::EnableWindow(GetDlgItem(IDC_VALUE_ALIGN), false); + } + else + { + int ItemCount = m_SearchResults.GetItemCount(); + for (int i = ItemCount - 1; i >= 0; i--) + { + int ItemId = m_SearchResults.GetItemData(i); + SearchResultItem & Result = m_SearchResult[ItemId]; + + DWORD NewValue = 0; + bool valid = false; + + switch (Size) + { + case _8Bit: + { + BYTE mem = 0; + valid = g_MMU->LB_PAddr(Result.PAddr, mem); + NewValue = mem; + } + break; + case _16Bit: + { + WORD mem = 0; + valid = g_MMU->LH_PAddr(Result.PAddr, mem); + NewValue = mem; + } + break; + case _32Bit: + valid = g_MMU->LW_PAddr(Result.PAddr, NewValue); + break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + + if (Value == NewValue) + { + char LocationStr[20]; + sprintf(LocationStr, DisplayStr, NewValue); + m_SearchResults.SetItemText(i, 2, LocationStr); + sprintf(LocationStr, DisplayStr, Result.Value); + m_SearchResults.SetItemText(i, 3, LocationStr); + Result.Value = NewValue; + } + else + { + m_SearchResults.DeleteItem(i); + } + } + } + ::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS), stdstr_f("Results (%d)", m_SearchResults.GetItemCount()).c_str()); } void CDebugMemorySearch::SearchForUnknown() { - SearchMemChangeState Option = (SearchMemChangeState)m_UnknownOptions.GetItemData(m_UnknownOptions.GetCurSel()); - if (Option == SearchChangeState_Reset) - { - m_SearchResults.DeleteAllItems(); - SearchSetBaseForChanges(); - FixUnknownOptions(false); - ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_SHOW); - ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN),true ); - return; - } - MemorySize Size = (MemorySize)m_UnknownSize.GetItemData(m_UnknownSize.GetCurSel()); - m_ValueSize.SetCurSel(m_UnknownSize.GetCurSel()); - LPCTSTR DisplayStr = "0x%08X"; - if (Size == _16Bit) - { - DisplayStr = "0x%04X"; - } - else if (Size == _8Bit) - { - DisplayStr = "0x%04X"; - } - if (!m_HaveResults) - { - m_HaveResults = true; + SearchMemChangeState Option = (SearchMemChangeState)m_UnknownOptions.GetItemData(m_UnknownOptions.GetCurSel()); + if (Option == SearchChangeState_Reset) + { + m_SearchResults.DeleteAllItems(); + SearchSetBaseForChanges(); + FixUnknownOptions(false); + ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON), SW_SHOW); + ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN), true); + return; + } + MemorySize Size = (MemorySize)m_UnknownSize.GetItemData(m_UnknownSize.GetCurSel()); + m_ValueSize.SetCurSel(m_UnknownSize.GetCurSel()); + LPCTSTR DisplayStr = "0x%08X"; + if (Size == _16Bit) + { + DisplayStr = "0x%04X"; + } + else if (Size == _8Bit) + { + DisplayStr = "0x%04X"; + } + if (!m_HaveResults) + { + m_HaveResults = true; - ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN),false ); - DWORD StartAddress = m_PAddrStart.GetValue(); - DWORD Len = m_SearchLen.GetValue(); - DWORD MaxSearch = m_MaxSearch.GetValue(); + ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN), false); + DWORD StartAddress = m_PAddrStart.GetValue(); + DWORD Len = m_SearchLen.GetValue(); + DWORD MaxSearch = m_MaxSearch.GetValue(); - DWORD MoveSize = (Size == _32Bit ? 4 : (Size == _16Bit ? 2 : 1)); - - for (int i = 2; i < 10; i++) - { - if (!m_SearchResults.DeleteColumn(i)) - { - break; - } - } - m_SearchResults.AddColumn("New Value",2); - m_SearchResults.AddColumn("Old Value",3); - m_SearchResults.SetColumnWidth(0,50); - m_SearchResults.SetColumnWidth(1,75); - m_SearchResults.SetColumnWidth(2,75); - m_SearchResults.SetColumnWidth(3,75); + DWORD MoveSize = (Size == _32Bit ? 4 : (Size == _16Bit ? 2 : 1)); - m_SearchResults.DeleteAllItems(); - DWORD ItemsAdded = 0, OldValue, NewValue; - - while (SearchForChanges(Option,Size,StartAddress,Len,OldValue,NewValue)) - { - SearchResultItem Result; - Result.PAddr = StartAddress; - Result.Value = NewValue; + for (int i = 2; i < 10; i++) + { + if (!m_SearchResults.DeleteColumn(i)) + { + break; + } + } + m_SearchResults.AddColumn("New Value", 2); + m_SearchResults.AddColumn("Old Value", 3); + m_SearchResults.SetColumnWidth(0, 50); + m_SearchResults.SetColumnWidth(1, 75); + m_SearchResults.SetColumnWidth(2, 75); + m_SearchResults.SetColumnWidth(3, 75); - //if list size > max, then break - char LocationStr[20]; - sprintf(LocationStr,"%d",ItemsAdded + 1); - int Index = m_SearchResults.AddItem(ItemsAdded,0,LocationStr); - m_SearchResults.SetItemData(Index,m_SearchResult.size()); - m_SearchResult.push_back(Result); - sprintf(LocationStr,"0x%08X",StartAddress); - m_SearchResults.SetItemText(Index,1,LocationStr); - sprintf(LocationStr,DisplayStr,NewValue); - m_SearchResults.SetItemText(Index,2,LocationStr); - sprintf(LocationStr,DisplayStr,OldValue); - m_SearchResults.SetItemText(Index,3,LocationStr); - StartAddress += MoveSize; - Len -= MoveSize; - ItemsAdded += 1; - if (ItemsAdded >= MaxSearch) - { - break; - } - } - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search Results"); - ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_SHOW); - ::EnableWindow(GetDlgItem(IDC_RADIO_TEXT),false); - ::EnableWindow(GetDlgItem(IDC_RADIO_JAL),false); - } - else - { - int ItemCount = m_SearchResults.GetItemCount(); - for (int i = ItemCount - 1; i >= 0; i--) - { - int ItemId = m_SearchResults.GetItemData(i); - SearchResultItem & Result = m_SearchResult[ItemId]; - - bool UpdateResult = false; - DWORD NewValue = 0; - bool valid = false; + m_SearchResults.DeleteAllItems(); + DWORD ItemsAdded = 0, OldValue, NewValue; - switch (Size) - { - case _8Bit: - { - BYTE mem = 0; - valid = g_MMU->LB_PAddr(Result.PAddr, mem); - NewValue = mem; - } - break; - case _16Bit: - { - WORD mem = 0; - valid = g_MMU->LH_PAddr(Result.PAddr, mem); - NewValue = mem; - } - break; - case _32Bit: - valid = g_MMU->LW_PAddr(Result.PAddr, NewValue); - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + while (SearchForChanges(Option, Size, StartAddress, Len, OldValue, NewValue)) + { + SearchResultItem Result; + Result.PAddr = StartAddress; + Result.Value = NewValue; - switch (Option) - { - case SearchChangeState_Changed: - if (Result.Value != NewValue) - { - UpdateResult = true; - } - break; - case SearchChangeState_Unchanged: - if (Result.Value == NewValue) - { - UpdateResult = true; - } - break; - case SearchChangeState_Greater: - if (NewValue > Result.Value) - { - UpdateResult = true; - } - break; - case SearchChangeState_Lessthan: - if (NewValue < Result.Value) - { - UpdateResult = true; - } - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + //if list size > max, then break + char LocationStr[20]; + sprintf(LocationStr, "%d", ItemsAdded + 1); + int Index = m_SearchResults.AddItem(ItemsAdded, 0, LocationStr); + m_SearchResults.SetItemData(Index, m_SearchResult.size()); + m_SearchResult.push_back(Result); + sprintf(LocationStr, "0x%08X", StartAddress); + m_SearchResults.SetItemText(Index, 1, LocationStr); + sprintf(LocationStr, DisplayStr, NewValue); + m_SearchResults.SetItemText(Index, 2, LocationStr); + sprintf(LocationStr, DisplayStr, OldValue); + m_SearchResults.SetItemText(Index, 3, LocationStr); + StartAddress += MoveSize; + Len -= MoveSize; + ItemsAdded += 1; + if (ItemsAdded >= MaxSearch) + { + break; + } + } + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Search Results"); + ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON), SW_SHOW); + ::EnableWindow(GetDlgItem(IDC_RADIO_TEXT), false); + ::EnableWindow(GetDlgItem(IDC_RADIO_JAL), false); + } + else + { + int ItemCount = m_SearchResults.GetItemCount(); + for (int i = ItemCount - 1; i >= 0; i--) + { + int ItemId = m_SearchResults.GetItemData(i); + SearchResultItem & Result = m_SearchResult[ItemId]; - if (UpdateResult) - { - char LocationStr[20]; - sprintf(LocationStr,DisplayStr,NewValue); - m_SearchResults.SetItemText(i,2,LocationStr); - sprintf(LocationStr,DisplayStr,Result.Value); - m_SearchResults.SetItemText(i,3,LocationStr); - Result.Value = NewValue; - } - else - { - m_SearchResults.DeleteItem(i); - } - } - } - ::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS),stdstr_f("Results (%d)",m_SearchResults.GetItemCount()).c_str()); + bool UpdateResult = false; + DWORD NewValue = 0; + bool valid = false; + + switch (Size) + { + case _8Bit: + { + BYTE mem = 0; + valid = g_MMU->LB_PAddr(Result.PAddr, mem); + NewValue = mem; + } + break; + case _16Bit: + { + WORD mem = 0; + valid = g_MMU->LH_PAddr(Result.PAddr, mem); + NewValue = mem; + } + break; + case _32Bit: + valid = g_MMU->LW_PAddr(Result.PAddr, NewValue); + break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + + switch (Option) + { + case SearchChangeState_Changed: + if (Result.Value != NewValue) + { + UpdateResult = true; + } + break; + case SearchChangeState_Unchanged: + if (Result.Value == NewValue) + { + UpdateResult = true; + } + break; + case SearchChangeState_Greater: + if (NewValue > Result.Value) + { + UpdateResult = true; + } + break; + case SearchChangeState_Lessthan: + if (NewValue < Result.Value) + { + UpdateResult = true; + } + break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + + if (UpdateResult) + { + char LocationStr[20]; + sprintf(LocationStr, DisplayStr, NewValue); + m_SearchResults.SetItemText(i, 2, LocationStr); + sprintf(LocationStr, DisplayStr, Result.Value); + m_SearchResults.SetItemText(i, 3, LocationStr); + Result.Value = NewValue; + } + else + { + m_SearchResults.DeleteItem(i); + } + } + } + ::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS), stdstr_f("Results (%d)", m_SearchResults.GetItemCount()).c_str()); } void CDebugMemorySearch::SearchForText() { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } -void CDebugMemorySearch::Reset ( void ) +void CDebugMemorySearch::Reset(void) { - m_HaveResults = false; - SendMessage(GetDlgItem(IDC_RADIO_VALUE),BM_SETCHECK, BST_CHECKED,0); - EnableUnknownOptions(false); - EnableValueOptions(true); - EnableTextOptions(false); - EnableJalOptions(false); - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search"); - ::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS),"Results"); - ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_HIDE); - ::EnableWindow(GetDlgItem(IDC_RADIO_UNKNOWN),true); - ::EnableWindow(GetDlgItem(IDC_RADIO_VALUE),true); - ::EnableWindow(GetDlgItem(IDC_RADIO_TEXT),false); - ::EnableWindow(GetDlgItem(IDC_RADIO_JAL),false); - for (int i = 1; i < 10; i++) - { - if (!m_SearchResults.DeleteColumn(i)) - { - break; - } - } - m_SearchResults.AddColumn("Value",2); - m_SearchResults.DeleteAllItems(); - m_SearchResults.SetColumnWidth(0,50); - m_SearchResults.SetColumnWidth(1,75); - m_SearchResults.SetColumnWidth(2,75); - m_SearchResults.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT); - FixUnknownOptions(true); + m_HaveResults = false; + SendMessage(GetDlgItem(IDC_RADIO_VALUE), BM_SETCHECK, BST_CHECKED, 0); + EnableUnknownOptions(false); + EnableValueOptions(true); + EnableTextOptions(false); + EnableJalOptions(false); + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Search"); + ::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS), "Results"); + ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON), SW_HIDE); + ::EnableWindow(GetDlgItem(IDC_RADIO_UNKNOWN), true); + ::EnableWindow(GetDlgItem(IDC_RADIO_VALUE), true); + ::EnableWindow(GetDlgItem(IDC_RADIO_TEXT), false); + ::EnableWindow(GetDlgItem(IDC_RADIO_JAL), false); + for (int i = 1; i < 10; i++) + { + if (!m_SearchResults.DeleteColumn(i)) + { + break; + } + } + m_SearchResults.AddColumn("Value", 2); + m_SearchResults.DeleteAllItems(); + m_SearchResults.SetColumnWidth(0, 50); + m_SearchResults.SetColumnWidth(1, 75); + m_SearchResults.SetColumnWidth(2, 75); + m_SearchResults.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT); + FixUnknownOptions(true); } -void CDebugMemorySearch::FixUnknownOptions ( bool Reset ) +void CDebugMemorySearch::FixUnknownOptions(bool Reset) { - CComboBox & cb = m_UnknownOptions ; + CComboBox & cb = m_UnknownOptions; - if (!Reset && cb.GetCount() > 1) - { - return; - } - cb.ResetContent(); - if (Reset) - { - cb.SetItemData(cb.AddString("Create compare base"),SearchChangeState_Reset); - cb.SetCurSel(0); - return; - } - cb.SetItemData(cb.AddString("memory changed"),SearchChangeState_Changed); - cb.SetItemData(cb.AddString("memory unchanged"),SearchChangeState_Unchanged); - cb.SetItemData(cb.AddString("Value has increased"),SearchChangeState_Greater); - cb.SetItemData(cb.AddString("Value has descreased"),SearchChangeState_Lessthan); - cb.SetCurSel(1); - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search"); + if (!Reset && cb.GetCount() > 1) + { + return; + } + cb.ResetContent(); + if (Reset) + { + cb.SetItemData(cb.AddString("Create compare base"), SearchChangeState_Reset); + cb.SetCurSel(0); + return; + } + cb.SetItemData(cb.AddString("memory changed"), SearchChangeState_Changed); + cb.SetItemData(cb.AddString("memory unchanged"), SearchChangeState_Unchanged); + cb.SetItemData(cb.AddString("Value has increased"), SearchChangeState_Greater); + cb.SetItemData(cb.AddString("Value has descreased"), SearchChangeState_Lessthan); + cb.SetCurSel(1); + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Search"); } -bool CDebugMemorySearch::SearchSetBaseForChanges ( void ) +bool CDebugMemorySearch::SearchSetBaseForChanges(void) { - if (m_MemoryState != NULL) - { - delete [] m_MemoryState; - } - m_MemoryStateSize = g_MMU->RdramSize(); - m_MemoryState = new BYTE[m_MemoryStateSize]; - memcpy(m_MemoryState,g_MMU->Rdram(),m_MemoryStateSize); - return true; + if (m_MemoryState != NULL) + { + delete[] m_MemoryState; + } + m_MemoryStateSize = g_MMU->RdramSize(); + m_MemoryState = new BYTE[m_MemoryStateSize]; + memcpy(m_MemoryState, g_MMU->Rdram(), m_MemoryStateSize); + return true; } -bool CDebugMemorySearch::SearchForChanges(SearchMemChangeState SearchType, MemorySize Size, - DWORD &StartAddress, DWORD &Len, - DWORD &OldValue, DWORD &NewValue) +bool CDebugMemorySearch::SearchForChanges(SearchMemChangeState SearchType, MemorySize Size, + DWORD &StartAddress, DWORD &Len, + DWORD &OldValue, DWORD &NewValue) { - if (g_MMU == NULL) - { - return false; - } + if (g_MMU == NULL) + { + return false; + } - if (SearchType == SearchChangeState_Reset) - { - Notify().BreakPoint(__FILEW__,__LINE__); - } - if (Size == _32Bit) { StartAddress = ((StartAddress + 3) & ~3); } - if (Size == _16Bit) { StartAddress = ((StartAddress + 1) & ~1); } + if (SearchType == SearchChangeState_Reset) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (Size == _32Bit) { StartAddress = ((StartAddress + 3) & ~3); } + if (Size == _16Bit) { StartAddress = ((StartAddress + 1) & ~1); } - //search memory - if (StartAddress < g_MMU->RdramSize()) - { - DWORD EndMemSearchAddr = StartAddress + Len; - if (EndMemSearchAddr > g_MMU->RdramSize()) - { - EndMemSearchAddr = g_MMU->RdramSize(); - } - - DWORD pos; - switch (Size) - { - case _32Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos += 4) - { - OldValue = *(DWORD *)(m_MemoryState + pos); - NewValue = *(DWORD *)(g_MMU->Rdram() + pos); - if ((SearchType == SearchChangeState_Changed && NewValue != OldValue) || - (SearchType == SearchChangeState_Unchanged && NewValue == OldValue) || - (SearchType == SearchChangeState_Greater && NewValue > OldValue) || - (SearchType == SearchChangeState_Lessthan && NewValue < OldValue)) - { - *(DWORD *)(m_MemoryState + pos) = NewValue; - Len -= pos - StartAddress; - StartAddress = pos; - return true; - } - } - break; - case _16Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos += 2) - { - OldValue = *(WORD *)(m_MemoryState + (pos ^ 2)); - NewValue = *(WORD *)(g_MMU->Rdram() + (pos ^ 2)); - if ((SearchType == SearchChangeState_Changed && NewValue != OldValue) || - (SearchType == SearchChangeState_Unchanged && NewValue == OldValue) || - (SearchType == SearchChangeState_Greater && NewValue > OldValue) || - (SearchType == SearchChangeState_Lessthan && NewValue < OldValue)) - { - Len -= pos - StartAddress; - StartAddress = pos; - return true; - } - } - break; - case _8Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos ++) - { - OldValue = *(BYTE *)(m_MemoryState + (pos ^ 3)); - NewValue = *(BYTE *)(g_MMU->Rdram() + (pos ^ 3)); - if ((SearchType == SearchChangeState_Changed && NewValue != OldValue) || - (SearchType == SearchChangeState_Unchanged && NewValue == OldValue) || - (SearchType == SearchChangeState_Greater && NewValue > OldValue) || - (SearchType == SearchChangeState_Lessthan && NewValue < OldValue)) - { - Len -= pos - StartAddress; - StartAddress = pos; - return true; - } - } - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } - return false; + //search memory + if (StartAddress < g_MMU->RdramSize()) + { + DWORD EndMemSearchAddr = StartAddress + Len; + if (EndMemSearchAddr > g_MMU->RdramSize()) + { + EndMemSearchAddr = g_MMU->RdramSize(); + } + + DWORD pos; + switch (Size) + { + case _32Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos += 4) + { + OldValue = *(DWORD *)(m_MemoryState + pos); + NewValue = *(DWORD *)(g_MMU->Rdram() + pos); + if ((SearchType == SearchChangeState_Changed && NewValue != OldValue) || + (SearchType == SearchChangeState_Unchanged && NewValue == OldValue) || + (SearchType == SearchChangeState_Greater && NewValue > OldValue) || + (SearchType == SearchChangeState_Lessthan && NewValue < OldValue)) + { + *(DWORD *)(m_MemoryState + pos) = NewValue; + Len -= pos - StartAddress; + StartAddress = pos; + return true; + } + } + break; + case _16Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos += 2) + { + OldValue = *(WORD *)(m_MemoryState + (pos ^ 2)); + NewValue = *(WORD *)(g_MMU->Rdram() + (pos ^ 2)); + if ((SearchType == SearchChangeState_Changed && NewValue != OldValue) || + (SearchType == SearchChangeState_Unchanged && NewValue == OldValue) || + (SearchType == SearchChangeState_Greater && NewValue > OldValue) || + (SearchType == SearchChangeState_Lessthan && NewValue < OldValue)) + { + Len -= pos - StartAddress; + StartAddress = pos; + return true; + } + } + break; + case _8Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos++) + { + OldValue = *(BYTE *)(m_MemoryState + (pos ^ 3)); + NewValue = *(BYTE *)(g_MMU->Rdram() + (pos ^ 3)); + if ((SearchType == SearchChangeState_Changed && NewValue != OldValue) || + (SearchType == SearchChangeState_Unchanged && NewValue == OldValue) || + (SearchType == SearchChangeState_Greater && NewValue > OldValue) || + (SearchType == SearchChangeState_Lessthan && NewValue < OldValue)) + { + Len -= pos - StartAddress; + StartAddress = pos; + return true; + } + } + break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } + return false; } -bool CDebugMemorySearch::SearchForValue (DWORD Value, MemorySize Size, DWORD &StartAddress, DWORD &Len ) +bool CDebugMemorySearch::SearchForValue(DWORD Value, MemorySize Size, DWORD &StartAddress, DWORD &Len) { - if (g_MMU == NULL || g_Rom == NULL) - { - return false; - } + if (g_MMU == NULL || g_Rom == NULL) + { + return false; + } - if (Size == _32Bit) - { - StartAddress = ((StartAddress + 3) & ~3); - } - if (Size == _16Bit) - { - StartAddress = ((StartAddress + 1) & ~1); - } + if (Size == _32Bit) + { + StartAddress = ((StartAddress + 3) & ~3); + } + if (Size == _16Bit) + { + StartAddress = ((StartAddress + 1) & ~1); + } - //search memory - if (StartAddress < g_MMU->RdramSize()) - { - DWORD EndMemSearchAddr = StartAddress + Len; - if (EndMemSearchAddr > g_MMU->RdramSize()) - { - EndMemSearchAddr = g_MMU->RdramSize(); - } - - DWORD pos; - BYTE * RDRAM = g_MMU->Rdram(); - switch (Size) - { - case _32Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos += 4) - { - if (*(DWORD *)(RDRAM + pos) == Value) - { - Len -= pos - StartAddress; - StartAddress = pos; - return true; - } - } - break; - case _16Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos += 2) - { - if (*(WORD *)(RDRAM + (pos ^ 2)) == (WORD)Value) - { - Len -= pos - StartAddress; - StartAddress = pos; - return true; - } - } - break; - case _8Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos ++) - { - if (*(BYTE *)(RDRAM + (pos ^ 3)) == (BYTE)Value) - { - Len -= pos - StartAddress; - StartAddress = pos; - return true; - } - } - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } - if (StartAddress >= 0x10000000) - { - DWORD EndMemSearchAddr = StartAddress + Len - 0x10000000; - if (EndMemSearchAddr > g_Rom->GetRomSize()) - { - EndMemSearchAddr = g_Rom->GetRomSize(); - } - StartAddress -= 0x10000000; - - DWORD pos; - BYTE * ROM = g_Rom->GetRomAddress(); - switch (Size) - { - case _32Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos += 4) - { - if (*(DWORD *)(ROM + pos) == Value) - { - Len -= pos - StartAddress; - StartAddress = pos + 0x10000000; - return true; - } - } - break; - case _16Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos += 2) - { - if (*(WORD *)(ROM + (pos ^ 2)) == (WORD)Value) - { - Len -= pos - StartAddress; - StartAddress = pos + 0x10000000; - return true; - } - } - break; - case _8Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos ++) - { - if (*(BYTE *)(ROM + (pos ^ 3)) == (BYTE)Value) - { - Len -= pos - StartAddress; - StartAddress = pos + 0x10000000; - return true; - } - } - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } - return false; + //search memory + if (StartAddress < g_MMU->RdramSize()) + { + DWORD EndMemSearchAddr = StartAddress + Len; + if (EndMemSearchAddr > g_MMU->RdramSize()) + { + EndMemSearchAddr = g_MMU->RdramSize(); + } + + DWORD pos; + BYTE * RDRAM = g_MMU->Rdram(); + switch (Size) + { + case _32Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos += 4) + { + if (*(DWORD *)(RDRAM + pos) == Value) + { + Len -= pos - StartAddress; + StartAddress = pos; + return true; + } + } + break; + case _16Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos += 2) + { + if (*(WORD *)(RDRAM + (pos ^ 2)) == (WORD)Value) + { + Len -= pos - StartAddress; + StartAddress = pos; + return true; + } + } + break; + case _8Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos++) + { + if (*(BYTE *)(RDRAM + (pos ^ 3)) == (BYTE)Value) + { + Len -= pos - StartAddress; + StartAddress = pos; + return true; + } + } + break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } + if (StartAddress >= 0x10000000) + { + DWORD EndMemSearchAddr = StartAddress + Len - 0x10000000; + if (EndMemSearchAddr > g_Rom->GetRomSize()) + { + EndMemSearchAddr = g_Rom->GetRomSize(); + } + StartAddress -= 0x10000000; + + DWORD pos; + BYTE * ROM = g_Rom->GetRomAddress(); + switch (Size) + { + case _32Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos += 4) + { + if (*(DWORD *)(ROM + pos) == Value) + { + Len -= pos - StartAddress; + StartAddress = pos + 0x10000000; + return true; + } + } + break; + case _16Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos += 2) + { + if (*(WORD *)(ROM + (pos ^ 2)) == (WORD)Value) + { + Len -= pos - StartAddress; + StartAddress = pos + 0x10000000; + return true; + } + } + break; + case _8Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos++) + { + if (*(BYTE *)(ROM + (pos ^ 3)) == (BYTE)Value) + { + Len -= pos - StartAddress; + StartAddress = pos + 0x10000000; + return true; + } + } + break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } + return false; } -#endif diff --git a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.h b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.h index 40e67bd76..478684269 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.h +++ b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.h @@ -11,59 +11,59 @@ #pragma once class CDebugMemorySearch : - public CDebugDialog + public CDebugDialog < CDebugMemorySearch > { -public: - enum { IDD = IDD_Debugger_Search }; +public: + enum { IDD = IDD_Debugger_Search }; - CDebugMemorySearch(CDebugger * debugger); - virtual ~CDebugMemorySearch(void); + CDebugMemorySearch(CDebuggerUI * debugger); + virtual ~CDebugMemorySearch(void); private: - CDebugMemorySearch(void); // Disable default constructor - CDebugMemorySearch(const CDebugMemorySearch&); // Disable copy constructor - CDebugMemorySearch& operator=(const CDebugMemorySearch&); // Disable assignment + CDebugMemorySearch(void); // Disable default constructor + CDebugMemorySearch(const CDebugMemorySearch&); // Disable copy constructor + CDebugMemorySearch& operator=(const CDebugMemorySearch&); // Disable assignment - enum MemorySize - { - _8Bit, - _16Bit, - _32Bit, - }; + enum MemorySize + { + _8Bit, + _16Bit, + _32Bit, + }; - //Searching for value - enum SearchMemChangeState - { - SearchChangeState_Reset, - SearchChangeState_Changed, - SearchChangeState_Unchanged, - SearchChangeState_Greater, - SearchChangeState_Lessthan, - }; + //Searching for value + enum SearchMemChangeState + { + SearchChangeState_Reset, + SearchChangeState_Changed, + SearchChangeState_Unchanged, + SearchChangeState_Greater, + SearchChangeState_Lessthan, + }; - struct SearchResultItem - { - DWORD PAddr; - DWORD Value; - }; + struct SearchResultItem + { + DWORD PAddr; + DWORD Value; + }; - typedef std::vector SearchResult; + typedef std::vector SearchResult; - BEGIN_MSG_MAP_EX(CDebugMemorySearch) - MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) - COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked) - NOTIFY_HANDLER_EX(IDC_LST_RESULTS,NM_RCLICK,OnResultRClick) + BEGIN_MSG_MAP_EX(CDebugMemorySearch) + MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) + COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked) + NOTIFY_HANDLER_EX(IDC_LST_RESULTS, NM_RCLICK, OnResultRClick) END_MSG_MAP() LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled); - LRESULT OnResultRClick ( LPNMHDR lpnmh ); + LRESULT OnResultRClick(LPNMHDR lpnmh); - void EnableUnknownOptions ( bool Enable ); - void EnableValueOptions ( bool Enable ); - void EnableTextOptions ( bool Enable ); - void EnableJalOptions ( bool Enable ); - void AddAlignmentOptions ( CComboBox & ctrl ); + void EnableUnknownOptions(bool Enable); + void EnableValueOptions(bool Enable); + void EnableTextOptions(bool Enable); + void EnableJalOptions(bool Enable); + void AddAlignmentOptions(CComboBox & ctrl); CEditNumber m_PAddrStart, m_SearchLen, m_SearchValue, m_MaxSearch; CComboBox m_UnknownOptions, m_ValueSize, m_UnknownSize; @@ -75,12 +75,12 @@ private: BYTE * m_MemoryState; DWORD m_MemoryStateSize; - void FixUnknownOptions ( bool Reset ); - void SearchForUnknown ( void ); - void SearchForValue ( void ); - void SearchForText ( void ); - void Reset ( void ); - bool SearchSetBaseForChanges ( void ); - bool SearchForChanges ( SearchMemChangeState SearchType, MemorySize Size, DWORD &StartAddress, DWORD &Len, DWORD &OldValue, DWORD &NewValue ); - bool SearchForValue ( DWORD Value, MemorySize Size, DWORD &StartAddress, DWORD &Len ); + void FixUnknownOptions(bool Reset); + void SearchForUnknown(void); + void SearchForValue(void); + void SearchForText(void); + void Reset(void); + bool SearchSetBaseForChanges(void); + bool SearchForChanges(SearchMemChangeState SearchType, MemorySize Size, DWORD &StartAddress, DWORD &Len, DWORD &OldValue, DWORD &NewValue); + bool SearchForValue(DWORD Value, MemorySize Size, DWORD &StartAddress, DWORD &Len); }; diff --git a/Source/Project64/N64 System/Debugger/Debugger - TLB.cpp b/Source/Project64/N64 System/Debugger/Debugger - TLB.cpp index 4662fbb4a..d68f704ca 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - TLB.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - TLB.cpp @@ -10,11 +10,10 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Debugger UI.h" -CDebugTlb::CDebugTlb(CDebugger * debugger) : - CDebugDialog(debugger) +CDebugTlb::CDebugTlb(CDebuggerUI * debugger) : + CDebugDialog(debugger) { } @@ -24,267 +23,266 @@ CDebugTlb::~CDebugTlb() LRESULT CDebugTlb::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - LV_COLUMN col; + LV_COLUMN col; - col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; - col.fmt = LVCFMT_LEFT; + col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + col.fmt = LVCFMT_LEFT; - col.pszText = "Index"; - col.cx = 40; - col.iSubItem = 0; - ListView_InsertColumn ( GetDlgItem(IDC_LIST), 0, &col); + col.pszText = "Index"; + col.cx = 40; + col.iSubItem = 0; + ListView_InsertColumn(GetDlgItem(IDC_LIST), 0, &col); - col.pszText = "Page Mask"; - col.cx = 90; - col.iSubItem = 1; - ListView_InsertColumn ( GetDlgItem(IDC_LIST), 1, &col); + col.pszText = "Page Mask"; + col.cx = 90; + col.iSubItem = 1; + ListView_InsertColumn(GetDlgItem(IDC_LIST), 1, &col); - col.pszText = "Entry Hi"; - col.cx = 90; - col.iSubItem = 2; - ListView_InsertColumn ( GetDlgItem(IDC_LIST), 2, &col); + col.pszText = "Entry Hi"; + col.cx = 90; + col.iSubItem = 2; + ListView_InsertColumn(GetDlgItem(IDC_LIST), 2, &col); - col.pszText = "Entry Lo0"; - col.cx = 90; - col.iSubItem = 3; - ListView_InsertColumn ( GetDlgItem(IDC_LIST), 3, &col); + col.pszText = "Entry Lo0"; + col.cx = 90; + col.iSubItem = 3; + ListView_InsertColumn(GetDlgItem(IDC_LIST), 3, &col); - col.pszText = "Entry Lo1"; - col.cx = 90; - col.iSubItem = 4; - ListView_InsertColumn ( GetDlgItem(IDC_LIST), 4, &col); + col.pszText = "Entry Lo1"; + col.cx = 90; + col.iSubItem = 4; + ListView_InsertColumn(GetDlgItem(IDC_LIST), 4, &col); - col.pszText = "Index"; - col.cx = 40; - col.iSubItem = 0; - ListView_InsertColumn ( GetDlgItem(IDC_LIST2), 0, &col); + col.pszText = "Index"; + col.cx = 40; + col.iSubItem = 0; + ListView_InsertColumn(GetDlgItem(IDC_LIST2), 0, &col); - col.pszText = "Valid"; - col.cx = 40; - col.iSubItem = 1; - ListView_InsertColumn ( GetDlgItem(IDC_LIST2), 1, &col); + col.pszText = "Valid"; + col.cx = 40; + col.iSubItem = 1; + ListView_InsertColumn(GetDlgItem(IDC_LIST2), 1, &col); - col.pszText = "Dirty"; - col.cx = 40; - col.iSubItem = 2; - ListView_InsertColumn ( GetDlgItem(IDC_LIST2), 2, &col); + col.pszText = "Dirty"; + col.cx = 40; + col.iSubItem = 2; + ListView_InsertColumn(GetDlgItem(IDC_LIST2), 2, &col); - col.pszText = "Rule"; - col.cx = 270; - col.iSubItem = 3; - ListView_InsertColumn ( GetDlgItem(IDC_LIST2), 3, &col); + col.pszText = "Rule"; + col.cx = 270; + col.iSubItem = 3; + ListView_InsertColumn(GetDlgItem(IDC_LIST2), 3, &col); - RefreshTLBWindow(); - SendMessage(GetDlgItem(IDC_TLB_ENTRIES),BM_SETCHECK, BST_CHECKED,0); - -// if (Settings().Load(TLBWindowLeft) <= 0) -// { -// SetWindowPos(NULL,Settings().Load(TLBWindowLeft),Settings().Load(TLBWindowTop),0,0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW); -// } - WindowCreated(); - return TRUE; + RefreshTLBWindow(); + SendMessage(GetDlgItem(IDC_TLB_ENTRIES), BM_SETCHECK, BST_CHECKED, 0); + + // if (Settings().Load(TLBWindowLeft) <= 0) + // { + // SetWindowPos(NULL,Settings().Load(TLBWindowLeft),Settings().Load(TLBWindowTop),0,0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW); + // } + WindowCreated(); + return TRUE; } -LRESULT CDebugTlb::OnClicked (WORD /*wNotifyCode*/, WORD wID, HWND , BOOL& /*bHandled*/) +LRESULT CDebugTlb::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/) { - switch(wID) - { - case IDCANCEL: - EndDialog(0); - break; - case IDC_TLB_ENTRIES: - ::ShowWindow(GetDlgItem(IDC_LIST),SW_SHOW); - ::ShowWindow(GetDlgItem(IDC_LIST2),SW_HIDE); - break; - case IDC_TLB_RULES: - ::ShowWindow(GetDlgItem(IDC_LIST),SW_HIDE); - ::ShowWindow(GetDlgItem(IDC_LIST2),SW_SHOW); - break; - } - return FALSE; + switch (wID) + { + case IDCANCEL: + EndDialog(0); + break; + case IDC_TLB_ENTRIES: + ::ShowWindow(GetDlgItem(IDC_LIST), SW_SHOW); + ::ShowWindow(GetDlgItem(IDC_LIST2), SW_HIDE); + break; + case IDC_TLB_RULES: + ::ShowWindow(GetDlgItem(IDC_LIST), SW_HIDE); + ::ShowWindow(GetDlgItem(IDC_LIST2), SW_SHOW); + break; + } + return FALSE; } -void CDebugTlb::RefreshTLBWindow (void) +void CDebugTlb::RefreshTLBWindow(void) { - if (m_hWnd == NULL) - { - return; - } - - HWND hList = GetDlgItem(IDC_LIST); - char Output[100], OldText[100]; - LV_ITEM item, OldItem; - int count; + if (m_hWnd == NULL) + { + return; + } - CTLB::TLB_ENTRY * tlb = g_TLB->m_tlb; - for (count = 0; count < 32; count ++) - { - sprintf(Output,"0x%02X",count); - item.mask = LVIF_TEXT; - item.iItem = count; - item.pszText = Output; - item.iSubItem = 0; + HWND hList = GetDlgItem(IDC_LIST); + char Output[100], OldText[100]; + LV_ITEM item, OldItem; + int count; - OldItem.mask = LVIF_TEXT; - OldItem.iItem = count; - OldItem.pszText = OldText; - OldItem.cchTextMax = sizeof( OldText )-1; - OldItem.iSubItem = 0; + CTLB::TLB_ENTRY * tlb = g_TLB->m_tlb; + for (count = 0; count < 32; count++) + { + sprintf(Output, "0x%02X", count); + item.mask = LVIF_TEXT; + item.iItem = count; + item.pszText = Output; + item.iSubItem = 0; - if (ListView_GetItemCount(hList) <= count) - { - ListView_InsertItem(hList,&item); - } - else - { - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } - } - if (tlb[count].EntryDefined) - { - sprintf(Output,"0x%08X",tlb[count].PageMask.Value); - } - else - { - strcpy(Output,"................"); - } - item.iSubItem = 1; - OldItem.iSubItem = 1; - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } + OldItem.mask = LVIF_TEXT; + OldItem.iItem = count; + OldItem.pszText = OldText; + OldItem.cchTextMax = sizeof(OldText) - 1; + OldItem.iSubItem = 0; - if (tlb[count].EntryDefined) - { - sprintf(Output,"0x%08X",tlb[count].EntryHi.Value); - } - else - { - strcpy(Output,"................"); - } - item.iSubItem = 2; - OldItem.iSubItem = 2; - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } + if (ListView_GetItemCount(hList) <= count) + { + ListView_InsertItem(hList, &item); + } + else + { + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } + } + if (tlb[count].EntryDefined) + { + sprintf(Output, "0x%08X", tlb[count].PageMask.Value); + } + else + { + strcpy(Output, "................"); + } + item.iSubItem = 1; + OldItem.iSubItem = 1; + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } - if (tlb[count].EntryDefined) - { - sprintf(Output,"0x%08X",tlb[count].EntryLo0.Value); - } - else - { - strcpy(Output,"................"); - } - item.iSubItem = 3; - OldItem.iSubItem = 3; - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } + if (tlb[count].EntryDefined) + { + sprintf(Output, "0x%08X", tlb[count].EntryHi.Value); + } + else + { + strcpy(Output, "................"); + } + item.iSubItem = 2; + OldItem.iSubItem = 2; + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } - if (tlb[count].EntryDefined) - { - sprintf(Output,"0x%08X",tlb[count].EntryLo1.Value); - } - else - { - strcpy(Output,"................"); - } - item.iSubItem = 4; - OldItem.iSubItem = 4; - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } - } - - CTLB::FASTTLB * FastTlb = g_TLB->m_FastTlb; - hList = GetDlgItem(IDC_LIST2); - for (count = 0; count < 64; count ++) - { - sprintf(Output,"0x%02X",count); - item.mask = LVIF_TEXT; - item.iItem = count; - item.pszText = Output; - item.iSubItem = 0; + if (tlb[count].EntryDefined) + { + sprintf(Output, "0x%08X", tlb[count].EntryLo0.Value); + } + else + { + strcpy(Output, "................"); + } + item.iSubItem = 3; + OldItem.iSubItem = 3; + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } - OldItem.mask = LVIF_TEXT; - OldItem.iItem = count; - OldItem.pszText = OldText; - OldItem.cchTextMax = sizeof( OldText )-1; - OldItem.iSubItem = 0; + if (tlb[count].EntryDefined) + { + sprintf(Output, "0x%08X", tlb[count].EntryLo1.Value); + } + else + { + strcpy(Output, "................"); + } + item.iSubItem = 4; + OldItem.iSubItem = 4; + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } + } - if (ListView_GetItemCount(hList) <= count) - { - item.iItem = ListView_InsertItem(hList,&item); - } - else - { - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } - } + CTLB::FASTTLB * FastTlb = g_TLB->m_FastTlb; + hList = GetDlgItem(IDC_LIST2); + for (count = 0; count < 64; count++) + { + sprintf(Output, "0x%02X", count); + item.mask = LVIF_TEXT; + item.iItem = count; + item.pszText = Output; + item.iSubItem = 0; - if (FastTlb[count].ValidEntry) - { - sprintf(Output,"%s",FastTlb[count].VALID?"Yes":"No"); - } - else - { - strcpy(Output,"................"); - } - item.iSubItem = 1; - OldItem.iSubItem = 1; - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } + OldItem.mask = LVIF_TEXT; + OldItem.iItem = count; + OldItem.pszText = OldText; + OldItem.cchTextMax = sizeof(OldText) - 1; + OldItem.iSubItem = 0; - if (FastTlb[count].ValidEntry && FastTlb[count].VALID) - { - sprintf(Output,"%s",FastTlb[count].DIRTY?"Yes":"No"); - } - else - { - strcpy(Output,"................"); - } - item.iSubItem = 2; - OldItem.iSubItem = 2; - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } + if (ListView_GetItemCount(hList) <= count) + { + item.iItem = ListView_InsertItem(hList, &item); + } + else + { + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } + } - if (FastTlb[count].ValidEntry && FastTlb[count].VALID) - { - sprintf(Output,"%08X:%08X -> %08X:%08X",FastTlb[count].VSTART,FastTlb[count].VEND, - FastTlb[count].PHYSSTART,FastTlb[count].PHYSEND); - } - else - { - strcpy(Output,"................"); - } - item.iSubItem = 3; - OldItem.iSubItem = 3; - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } - } + if (FastTlb[count].ValidEntry) + { + sprintf(Output, "%s", FastTlb[count].VALID ? "Yes" : "No"); + } + else + { + strcpy(Output, "................"); + } + item.iSubItem = 1; + OldItem.iSubItem = 1; + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } + + if (FastTlb[count].ValidEntry && FastTlb[count].VALID) + { + sprintf(Output, "%s", FastTlb[count].DIRTY ? "Yes" : "No"); + } + else + { + strcpy(Output, "................"); + } + item.iSubItem = 2; + OldItem.iSubItem = 2; + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } + + if (FastTlb[count].ValidEntry && FastTlb[count].VALID) + { + sprintf(Output, "%08X:%08X -> %08X:%08X", FastTlb[count].VSTART, FastTlb[count].VEND, + FastTlb[count].PHYSSTART, FastTlb[count].PHYSEND); + } + else + { + strcpy(Output, "................"); + } + item.iSubItem = 3; + OldItem.iSubItem = 3; + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } + } } -#endif diff --git a/Source/Project64/N64 System/Debugger/Debugger - TLB.h b/Source/Project64/N64 System/Debugger/Debugger - TLB.h index cb818e73e..2588b1f67 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - TLB.h +++ b/Source/Project64/N64 System/Debugger/Debugger - TLB.h @@ -11,22 +11,21 @@ #pragma once class CDebugTlb : - public CDebugDialog + public CDebugDialog < CDebugTlb > { - - BEGIN_MSG_MAP_EX(CDebugTlb) - MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) - COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked) + BEGIN_MSG_MAP_EX(CDebugTlb) + MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) + COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked) END_MSG_MAP() LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled); -public: - enum { IDD = IDD_Debugger_TLB }; +public: + enum { IDD = IDD_Debugger_TLB }; - CDebugTlb(CDebugger * debugger); - virtual ~CDebugTlb(void); + CDebugTlb(CDebuggerUI * debugger); + virtual ~CDebugTlb(void); - void RefreshTLBWindow ( void ); + void RefreshTLBWindow(void); }; diff --git a/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp b/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp index 7973689fb..8c577ab73 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp @@ -10,18 +10,17 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Debugger UI.h" -CDebugMemoryView::CDebugMemoryView(CDebugger * debugger) : - CDebugDialog(debugger), - m_MemoryList(NULL) +CDebugMemoryView::CDebugMemoryView(CDebuggerUI * debugger) : + CDebugDialog(debugger), + m_MemoryList(NULL) { - if (m_MemoryList== NULL) - { - m_MemoryList = new CListCtrl; - m_MemoryList->RegisterClass(); - } + if (m_MemoryList== NULL) + { + m_MemoryList = new CListCtrl; + m_MemoryList->RegisterClass(); + } } CDebugMemoryView::~CDebugMemoryView() @@ -30,446 +29,444 @@ CDebugMemoryView::~CDebugMemoryView() LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - m_DataStartLoc = (DWORD)-1; - m_CompareStartLoc = (DWORD)-1; - memset(m_CompareData,0,sizeof(m_CompareData)); - memset(m_CompareValid,0,sizeof(m_CompareValid)); + m_DataStartLoc = (DWORD)-1; + m_CompareStartLoc = (DWORD)-1; + memset(m_CompareData, 0, sizeof(m_CompareData)); + memset(m_CompareValid, 0, sizeof(m_CompareValid)); - HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR); - if (hScrlBar) - { - SCROLLINFO si; + HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR); + if (hScrlBar) + { + SCROLLINFO si; - si.cbSize = sizeof(si); - si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; - si.nMin = 0; - si.nMax = 0xFFFF; - si.nPos = 0x8000; - si.nPage = 100; - ::SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE); - } + si.cbSize = sizeof(si); + si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; + si.nMin = 0; + si.nMax = 0xFFFF; + si.nPos = 0x8000; + si.nPage = 100; + ::SetScrollInfo(hScrlBar, SB_CTL, &si, TRUE); + } - m_MemAddr.Attach(GetDlgItem(IDC_ADDR_EDIT)); - m_MemAddr.SetDisplayType(CEditNumber::DisplayHex); - m_MemAddr.SetValue(0x80000000,true,true); + m_MemAddr.Attach(GetDlgItem(IDC_ADDR_EDIT)); + m_MemAddr.SetDisplayType(CEditNumber::DisplayHex); + m_MemAddr.SetValue(0x80000000, true, true); - SendDlgItemMessage( IDC_CHK_VADDR, BM_SETCHECK, BST_CHECKED,0); + SendDlgItemMessage(IDC_CHK_VADDR, BM_SETCHECK, BST_CHECKED, 0); - if (m_MemoryList== NULL) - { - m_MemoryList = new CListCtrl; - m_MemoryList->RegisterClass(); - } - m_MemoryList->SubclassWindow( GetDlgItem( IDC_MEM_DETAILS ) ); - m_MemoryList->ShowHeader(false); - m_MemoryList->SetSortEnabled(FALSE); - m_MemoryList->AddColumn( _T( "Address" ), 90 ); - m_MemoryList->AddColumn( _T( "1" ), 20 ); - m_MemoryList->AddColumn( _T( "2" ), 20 ); - m_MemoryList->AddColumn( _T( "3" ), 20 ); - m_MemoryList->AddColumn( _T( "4" ), 20 ); - m_MemoryList->AddColumn( _T( "-" ), 10 ); - m_MemoryList->AddColumn( _T( "5" ), 20 ); - m_MemoryList->AddColumn( _T( "6" ), 20 ); - m_MemoryList->AddColumn( _T( "7" ), 20 ); - m_MemoryList->AddColumn( _T( "8" ), 20 ); - m_MemoryList->AddColumn( _T( "-" ), 10 ); - m_MemoryList->AddColumn( _T( "9" ), 20 ); - m_MemoryList->AddColumn( _T( "10" ), 20 ); - m_MemoryList->AddColumn( _T( "11" ), 20 ); - m_MemoryList->AddColumn( _T( "12" ), 20 ); - m_MemoryList->AddColumn( _T( "-" ), 10 ); - m_MemoryList->AddColumn( _T( "13" ), 20 ); - m_MemoryList->AddColumn( _T( "14" ), 20 ); - m_MemoryList->AddColumn( _T( "15" ), 20 ); - m_MemoryList->AddColumn( _T( "16" ), 35 ); - m_MemoryList->AddColumn( _T( "Memory Ascii" ), 140 ); - ::SetWindowLongPtr(m_MemoryList->m_hWnd, GWL_EXSTYLE, WS_EX_CLIENTEDGE); - RefreshMemory(false); - int height = m_MemoryList->GetTotalHeight(); - - RECT MemoryListRect = {0}; - ::GetClientRect(GetDlgItem( IDC_MEM_DETAILS ), &MemoryListRect); + if (m_MemoryList == NULL) + { + m_MemoryList = new CListCtrl; + m_MemoryList->RegisterClass(); + } + m_MemoryList->SubclassWindow(GetDlgItem(IDC_MEM_DETAILS)); + m_MemoryList->ShowHeader(false); + m_MemoryList->SetSortEnabled(FALSE); + m_MemoryList->AddColumn(_T("Address"), 90); + m_MemoryList->AddColumn(_T("1"), 20); + m_MemoryList->AddColumn(_T("2"), 20); + m_MemoryList->AddColumn(_T("3"), 20); + m_MemoryList->AddColumn(_T("4"), 20); + m_MemoryList->AddColumn(_T("-"), 10); + m_MemoryList->AddColumn(_T("5"), 20); + m_MemoryList->AddColumn(_T("6"), 20); + m_MemoryList->AddColumn(_T("7"), 20); + m_MemoryList->AddColumn(_T("8"), 20); + m_MemoryList->AddColumn(_T("-"), 10); + m_MemoryList->AddColumn(_T("9"), 20); + m_MemoryList->AddColumn(_T("10"), 20); + m_MemoryList->AddColumn(_T("11"), 20); + m_MemoryList->AddColumn(_T("12"), 20); + m_MemoryList->AddColumn(_T("-"), 10); + m_MemoryList->AddColumn(_T("13"), 20); + m_MemoryList->AddColumn(_T("14"), 20); + m_MemoryList->AddColumn(_T("15"), 20); + m_MemoryList->AddColumn(_T("16"), 35); + m_MemoryList->AddColumn(_T("Memory Ascii"), 140); + ::SetWindowLongPtr(m_MemoryList->m_hWnd, GWL_EXSTYLE, WS_EX_CLIENTEDGE); + RefreshMemory(false); + int height = m_MemoryList->GetTotalHeight(); - if (height > MemoryListRect.bottom) - { - RECT MemoryListWindow = {0}; - GetWindowRect(&MemoryListWindow); - SetWindowPos(NULL,0,0,MemoryListWindow.right - MemoryListWindow.left,(MemoryListWindow.bottom - MemoryListWindow.top) + (height - MemoryListRect.bottom), SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOZORDER); + RECT MemoryListRect = { 0 }; + ::GetClientRect(GetDlgItem(IDC_MEM_DETAILS), &MemoryListRect); - RECT DlgItemRect = {0}; - ::GetWindowRect(GetDlgItem( IDC_BORDER ), &DlgItemRect); - ::SetWindowPos(GetDlgItem( IDC_BORDER ), NULL,0,0,DlgItemRect.right - DlgItemRect.left,(DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE); + if (height > MemoryListRect.bottom) + { + RECT MemoryListWindow = { 0 }; + GetWindowRect(&MemoryListWindow); + SetWindowPos(NULL, 0, 0, MemoryListWindow.right - MemoryListWindow.left, (MemoryListWindow.bottom - MemoryListWindow.top) + (height - MemoryListRect.bottom), SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOZORDER); - ::GetWindowRect(GetDlgItem( IDC_MEM_DETAILS ), &DlgItemRect); - ::SetWindowPos(GetDlgItem( IDC_MEM_DETAILS ), NULL,0,0,DlgItemRect.right - DlgItemRect.left,(DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE); + RECT DlgItemRect = { 0 }; + ::GetWindowRect(GetDlgItem(IDC_BORDER), &DlgItemRect); + ::SetWindowPos(GetDlgItem(IDC_BORDER), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE); - ::GetWindowRect(GetDlgItem( IDC_SCRL_BAR ), &DlgItemRect); - ::SetWindowPos(GetDlgItem( IDC_SCRL_BAR ), NULL,0,0,DlgItemRect.right - DlgItemRect.left,(DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE); - } - WindowCreated(); - return TRUE; + ::GetWindowRect(GetDlgItem(IDC_MEM_DETAILS), &DlgItemRect); + ::SetWindowPos(GetDlgItem(IDC_MEM_DETAILS), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE); + + ::GetWindowRect(GetDlgItem(IDC_SCRL_BAR), &DlgItemRect); + ::SetWindowPos(GetDlgItem(IDC_SCRL_BAR), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE); + } + WindowCreated(); + return TRUE; } -LRESULT CDebugMemoryView::OnDestroy ( void ) +LRESULT CDebugMemoryView::OnDestroy(void) { - if (m_MemoryList) - { - m_MemoryList->UnsubclassWindow(); - delete m_MemoryList; - m_MemoryList = NULL; - } - return 0; + if (m_MemoryList) + { + m_MemoryList->UnsubclassWindow(); + delete m_MemoryList; + m_MemoryList = NULL; + } + return 0; } -LRESULT CDebugMemoryView::OnClicked (WORD /*wNotifyCode*/, WORD wID, HWND , BOOL& /*bHandled*/) +LRESULT CDebugMemoryView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/) { - switch (wID) - { - case IDC_REFRSH_MEM: - RefreshMemory(true); - break; - case IDC_CHK_VADDR: - RefreshMemory(false); - break; - case IDC_DUMP_MEM: - m_Debugger->Debug_ShowMemoryDump(); - break; - case IDC_SEARCH_MEM: - m_Debugger->Debug_ShowMemorySearch(); - break; - case IDCANCEL: - EndDialog(0); - break; - } - return FALSE; + switch (wID) + { + case IDC_REFRSH_MEM: + RefreshMemory(true); + break; + case IDC_CHK_VADDR: + RefreshMemory(false); + break; + case IDC_DUMP_MEM: + m_Debugger->Debug_ShowMemoryDump(); + break; + case IDC_SEARCH_MEM: + m_Debugger->Debug_ShowMemorySearch(); + break; + case IDCANCEL: + EndDialog(0); + break; + } + return FALSE; } -LRESULT CDebugMemoryView::OnMemoryModified ( LPNMHDR lpNMHDR ) +LRESULT CDebugMemoryView::OnMemoryModified(LPNMHDR lpNMHDR) { - CListNotify *pListNotify = reinterpret_cast( lpNMHDR ); - int LineNumber = pListNotify->m_nItem; - int Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 1)); - if (pListNotify->m_nSubItem >= 6 && pListNotify->m_nSubItem < 10) - { - Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 2)); - } - if (pListNotify->m_nSubItem >= 11 && pListNotify->m_nSubItem < 15) - { - Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 3)); - } - if (pListNotify->m_nSubItem >= 16 && pListNotify->m_nSubItem < 20) - { - Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 4)); - } + CListNotify *pListNotify = reinterpret_cast(lpNMHDR); + int LineNumber = pListNotify->m_nItem; + int Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 1)); + if (pListNotify->m_nSubItem >= 6 && pListNotify->m_nSubItem < 10) + { + Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 2)); + } + if (pListNotify->m_nSubItem >= 11 && pListNotify->m_nSubItem < 15) + { + Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 3)); + } + if (pListNotify->m_nSubItem >= 16 && pListNotify->m_nSubItem < 20) + { + Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 4)); + } - LPCSTR strValue = m_MemoryList->GetItemText(pListNotify->m_nItem,pListNotify->m_nSubItem); - int Finish = strlen(strValue); - if (Finish > 8) - { - Finish = 8; - } - DWORD Value = 0; - for (int i = 0; i < Finish; i++) - { - Value = (Value << 4); - if (strValue[i] <= '9' && strValue[i] >= '0') - { - Value |= strValue[i] - '0'; - } - else if (strValue[i] <= 'f' && strValue[i] >= 'a') - { - Value |= strValue[i] - 'a' + 10; - } - else if (strValue[i] <= 'F' && strValue[i] >= 'A') - { - Value |= strValue[i] - 'A' + 10; - } - } + LPCSTR strValue = m_MemoryList->GetItemText(pListNotify->m_nItem, pListNotify->m_nSubItem); + int Finish = strlen(strValue); + if (Finish > 8) + { + Finish = 8; + } + DWORD Value = 0; + for (int i = 0; i < Finish; i++) + { + Value = (Value << 4); + if (strValue[i] <= '9' && strValue[i] >= '0') + { + Value |= strValue[i] - '0'; + } + else if (strValue[i] <= 'f' && strValue[i] >= 'a') + { + Value |= strValue[i] - 'a' + 10; + } + else if (strValue[i] <= 'F' && strValue[i] >= 'A') + { + Value |= strValue[i] - 'A' + 10; + } + } - if (m_CurrentData[Pos] == Value) - { - return 0; - } + if (m_CurrentData[Pos] == Value) + { + return 0; + } - if (m_CompareStartLoc != m_DataStartLoc || - m_CompareVAddrr != m_DataVAddrr) - { - // copy current data for change comparison - m_CompareStartLoc = m_DataStartLoc; - m_CompareVAddrr = m_DataVAddrr; - memcpy(m_CompareData,m_CurrentData,sizeof(m_CurrentData)); - memcpy(m_CompareValid,m_DataValid,sizeof(m_CompareValid)); - } + if (m_CompareStartLoc != m_DataStartLoc || + m_CompareVAddrr != m_DataVAddrr) + { + // copy current data for change comparison + m_CompareStartLoc = m_DataStartLoc; + m_CompareVAddrr = m_DataVAddrr; + memcpy(m_CompareData, m_CurrentData, sizeof(m_CurrentData)); + memcpy(m_CompareValid, m_DataValid, sizeof(m_CompareValid)); + } - m_CompareData[Pos] = m_CurrentData[Pos]; - m_CurrentData[Pos] = (BYTE)Value; + m_CompareData[Pos] = m_CurrentData[Pos]; + m_CurrentData[Pos] = (BYTE)Value; - //sb - if ( m_DataVAddrr ) - { - if (!g_MMU->SB_VAddr(m_DataStartLoc + Pos,(BYTE)Value)) - { - WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos); - } - } - else - { - if (!g_MMU->SB_PAddr(m_DataStartLoc + Pos,(BYTE)Value)) - { - WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos); - } - } - Insert_MemoryLineDump(LineNumber); + //sb + if (m_DataVAddrr) + { + if (!g_MMU->SB_VAddr(m_DataStartLoc + Pos, (BYTE)Value)) + { + WriteTraceF(TraceError, __FUNCTION__ ": failed to store at %X", m_DataStartLoc + Pos); + } + } + else + { + if (!g_MMU->SB_PAddr(m_DataStartLoc + Pos, (BYTE)Value)) + { + WriteTraceF(TraceError, __FUNCTION__ ": failed to store at %X", m_DataStartLoc + Pos); + } + } + Insert_MemoryLineDump(LineNumber); - return 0; + return 0; } void CDebugMemoryView::ShowAddress(DWORD Address, bool VAddr) { - if (m_hWnd == NULL) - { - return; - } + if (m_hWnd == NULL) + { + return; + } - SendDlgItemMessage( IDC_CHK_VADDR, BM_SETCHECK, VAddr ? BST_CHECKED : BST_UNCHECKED,0); - m_MemAddr.SetValue(Address,true,true); - RefreshMemory (true); + SendDlgItemMessage(IDC_CHK_VADDR, BM_SETCHECK, VAddr ? BST_CHECKED : BST_UNCHECKED, 0); + m_MemAddr.SetValue(Address, true, true); + RefreshMemory(true); } -void CDebugMemoryView::Insert_MemoryLineDump ( int LineNumber ) +void CDebugMemoryView::Insert_MemoryLineDump(int LineNumber) { - if (m_MemoryList == NULL || m_MemoryList->GetColumnCount() == 0) - { - return; - } - char Output[20], Hex[60], Ascii[20], AsciiAddOn[15]; - sprintf(Output,"0x%08X",m_DataStartLoc + (LineNumber << 4)); - if (m_MemoryList->GetItemCount() <= LineNumber) - { - HFONT hFont = (HFONT)GetStockObject(ANSI_FIXED_FONT); - m_MemoryList->AddItemAt( LineNumber, Output); - for (int i = 0; i < m_MemoryList->GetColumnCount(); i++) - { - m_MemoryList->SetItemFont( LineNumber, i, hFont ); - if (i == 5 || i == 10 || i == 15) - { - m_MemoryList->SetItemText(LineNumber,i,"-"); - } - } - } - else - { - if ( strcmp( Output, m_MemoryList->GetItemText(LineNumber, 0) ) != 0 ) - { - m_MemoryList->SetItemText(LineNumber,0,Output); - } - } + if (m_MemoryList == NULL || m_MemoryList->GetColumnCount() == 0) + { + return; + } + char Output[20], Hex[60], Ascii[20], AsciiAddOn[15]; + sprintf(Output, "0x%08X", m_DataStartLoc + (LineNumber << 4)); + if (m_MemoryList->GetItemCount() <= LineNumber) + { + HFONT hFont = (HFONT)GetStockObject(ANSI_FIXED_FONT); + m_MemoryList->AddItemAt(LineNumber, Output); + for (int i = 0; i < m_MemoryList->GetColumnCount(); i++) + { + m_MemoryList->SetItemFont(LineNumber, i, hFont); + if (i == 5 || i == 10 || i == 15) + { + m_MemoryList->SetItemText(LineNumber, i, "-"); + } + } + } + else + { + if (strcmp(Output, m_MemoryList->GetItemText(LineNumber, 0)) != 0) + { + m_MemoryList->SetItemText(LineNumber, 0, Output); + } + } - Hex[0] = 0; - Ascii[0] = 0; - int CompareStartPos = m_DataStartLoc - m_CompareStartLoc; + Hex[0] = 0; + Ascii[0] = 0; + int CompareStartPos = m_DataStartLoc - m_CompareStartLoc; - for (int i = 0, col = 1; i < 0x10; i ++, col ++) - { - int Pos = ((LineNumber << 4) + i); - if (m_DataValid[Pos]) - { - int ComparePos = CompareStartPos + Pos; - bool Changed = false; + for (int i = 0, col = 1; i < 0x10; i++, col++) + { + int Pos = ((LineNumber << 4) + i); + if (m_DataValid[Pos]) + { + int ComparePos = CompareStartPos + Pos; + bool Changed = false; - if (ComparePos >= 0 && ComparePos < MemoryToDisplay && - m_DataVAddrr == m_CompareVAddrr && - m_DataValid[ComparePos] && - m_CurrentData[Pos] != m_CompareData[ComparePos]) - { - Changed = true; - } - sprintf(Hex,"%02X",m_CurrentData[Pos]); - m_MemoryList->SetItemText(LineNumber,col,Hex); - m_MemoryList->SetItemFormat( LineNumber,col, ITEM_FORMAT_EDIT, ITEM_FLAGS_EDIT_HEX ); - m_MemoryList->SetItemMaxEditLen( LineNumber,col , 2); - m_MemoryList->SetItemColours( LineNumber, col, GetSysColor( COLOR_WINDOW ), - Changed ? RGB( 255, 0, 0 ) : GetSysColor( COLOR_WINDOWTEXT ) ); - m_MemoryList->SetItemHighlightColours( LineNumber, col, - Changed ? RGB( 255, 0, 0 ) : GetSysColor( COLOR_HIGHLIGHTTEXT ) ); - if (m_CurrentData[Pos] < 30) - { - strcat(Ascii,"."); - } - else - { - sprintf(AsciiAddOn,"%c",m_CurrentData[Pos]); - strcat(Ascii,AsciiAddOn); - } - } - else - { - m_MemoryList->SetItemText(LineNumber,col,"**"); - m_MemoryList->SetItemFormat( LineNumber,col, ITEM_FORMAT_NONE, ITEM_FLAGS_NONE ); - m_MemoryList->SetItemColours( LineNumber, col, GetSysColor( COLOR_WINDOW ), GetSysColor( COLOR_WINDOWTEXT ) ); - strcat(Ascii,"*"); - } - if (i != 0xF) - { - if ((i & 3) == 3) - { - col += 1; - } - } - } - - if ( strcmp( Ascii, m_MemoryList->GetItemText(LineNumber, 20) ) != 0 ) - { - m_MemoryList->SetItemText(LineNumber,20,Ascii); - } + if (ComparePos >= 0 && ComparePos < MemoryToDisplay && + m_DataVAddrr == m_CompareVAddrr && + m_DataValid[ComparePos] && + m_CurrentData[Pos] != m_CompareData[ComparePos]) + { + Changed = true; + } + sprintf(Hex, "%02X", m_CurrentData[Pos]); + m_MemoryList->SetItemText(LineNumber, col, Hex); + m_MemoryList->SetItemFormat(LineNumber, col, ITEM_FORMAT_EDIT, ITEM_FLAGS_EDIT_HEX); + m_MemoryList->SetItemMaxEditLen(LineNumber, col, 2); + m_MemoryList->SetItemColours(LineNumber, col, GetSysColor(COLOR_WINDOW), + Changed ? RGB(255, 0, 0) : GetSysColor(COLOR_WINDOWTEXT)); + m_MemoryList->SetItemHighlightColours(LineNumber, col, + Changed ? RGB(255, 0, 0) : GetSysColor(COLOR_HIGHLIGHTTEXT)); + if (m_CurrentData[Pos] < 30) + { + strcat(Ascii, "."); + } + else + { + sprintf(AsciiAddOn, "%c", m_CurrentData[Pos]); + strcat(Ascii, AsciiAddOn); + } + } + else + { + m_MemoryList->SetItemText(LineNumber, col, "**"); + m_MemoryList->SetItemFormat(LineNumber, col, ITEM_FORMAT_NONE, ITEM_FLAGS_NONE); + m_MemoryList->SetItemColours(LineNumber, col, GetSysColor(COLOR_WINDOW), GetSysColor(COLOR_WINDOWTEXT)); + strcat(Ascii, "*"); + } + if (i != 0xF) + { + if ((i & 3) == 3) + { + col += 1; + } + } + } + + if (strcmp(Ascii, m_MemoryList->GetItemText(LineNumber, 20)) != 0) + { + m_MemoryList->SetItemText(LineNumber, 20, Ascii); + } } -void CDebugMemoryView::OnAddrChanged( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void CDebugMemoryView::OnAddrChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - RefreshMemory(false); + RefreshMemory(false); } -void CDebugMemoryView::OnVScroll(int request, short Pos, HWND ctrl ) +void CDebugMemoryView::OnVScroll(int request, short Pos, HWND ctrl) { - if (ctrl != GetDlgItem(IDC_SCRL_BAR)) - { - return; - } - DWORD Location = m_MemAddr.GetValue(); - switch (request) - { - case SB_LINEDOWN: - m_MemAddr.SetValue(Location < 0xFFFFFFEF ? Location + 0x10 : 0xFFFFFFFF,true,true); - break; - case SB_LINEUP: - m_MemAddr.SetValue(Location > 0x10 ? Location - 0x10 : 0,true,true); - break; - case SB_PAGEDOWN: - m_MemAddr.SetValue(Location < 0xFFFFFEFF ? Location + 0x100 : 0xFFFFFFFF,true,true); - break; - case SB_PAGEUP: - m_MemAddr.SetValue(Location > 0x100 ? Location - 0x100 : 0,true,true); - break; - case SB_THUMBPOSITION: - m_MemAddr.SetValue((DWORD)Pos << 0x10,true,true); - break; - default: - break; - } + if (ctrl != GetDlgItem(IDC_SCRL_BAR)) + { + return; + } + DWORD Location = m_MemAddr.GetValue(); + switch (request) + { + case SB_LINEDOWN: + m_MemAddr.SetValue(Location < 0xFFFFFFEF ? Location + 0x10 : 0xFFFFFFFF, true, true); + break; + case SB_LINEUP: + m_MemAddr.SetValue(Location > 0x10 ? Location - 0x10 : 0, true, true); + break; + case SB_PAGEDOWN: + m_MemAddr.SetValue(Location < 0xFFFFFEFF ? Location + 0x100 : 0xFFFFFFFF, true, true); + break; + case SB_PAGEUP: + m_MemAddr.SetValue(Location > 0x100 ? Location - 0x100 : 0, true, true); + break; + case SB_THUMBPOSITION: + m_MemAddr.SetValue((DWORD)Pos << 0x10, true, true); + break; + default: + break; + } } -void CDebugMemoryView::RefreshMemory ( bool ResetCompare ) +void CDebugMemoryView::RefreshMemory(bool ResetCompare) { - if (m_MemoryList && m_MemoryList->GetHasEditItem()) - { - m_MemoryList->SetFocus(); - } + if (m_MemoryList && m_MemoryList->GetHasEditItem()) + { + m_MemoryList->SetFocus(); + } - DWORD NewAddress = m_MemAddr.GetValue(); - if (NewAddress != m_DataStartLoc) - { - HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR); - if (hScrlBar) - { - SCROLLINFO si; + DWORD NewAddress = m_MemAddr.GetValue(); + if (NewAddress != m_DataStartLoc) + { + HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR); + if (hScrlBar) + { + SCROLLINFO si; - si.cbSize = sizeof(si); - si.fMask = SIF_POS; - si.nPos = NewAddress >> 0x10; - ::SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE); - } - } + si.cbSize = sizeof(si); + si.fMask = SIF_POS; + si.nPos = NewAddress >> 0x10; + ::SetScrollInfo(hScrlBar, SB_CTL, &si, TRUE); + } + } - if (ResetCompare) - { - // copy current data for change comparison - m_CompareStartLoc = m_DataStartLoc; - m_CompareVAddrr = m_DataVAddrr; - memcpy(m_CompareData,m_CurrentData,sizeof(m_CurrentData)); - memcpy(m_CompareValid,m_DataValid,sizeof(m_CompareValid)); - } - - m_DataStartLoc = m_MemAddr.GetValue(); - if (m_DataStartLoc > 0xFFFFFF00) { m_DataStartLoc = 0xFFFFFF00; } - int WritePos = 0; + if (ResetCompare) + { + // copy current data for change comparison + m_CompareStartLoc = m_DataStartLoc; + m_CompareVAddrr = m_DataVAddrr; + memcpy(m_CompareData, m_CurrentData, sizeof(m_CurrentData)); + memcpy(m_CompareValid, m_DataValid, sizeof(m_CompareValid)); + } - m_DataVAddrr = (SendDlgItemMessage( IDC_CHK_VADDR, BM_GETCHECK, 0,0) & BST_CHECKED) != 0; + m_DataStartLoc = m_MemAddr.GetValue(); + if (m_DataStartLoc > 0xFFFFFF00) { m_DataStartLoc = 0xFFFFFF00; } + int WritePos = 0; - if ((m_DataStartLoc & 3) != 0) - { - MIPS_WORD word; - bool ValidData = true; - - if ( m_DataVAddrr ) - { - if (!g_MMU->LW_VAddr(m_DataStartLoc & ~3, word.UW)) - { - ValidData = false; - } - } - else - { - if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW)) - { - ValidData = false; - } - } + m_DataVAddrr = (SendDlgItemMessage(IDC_CHK_VADDR, BM_GETCHECK, 0, 0) & BST_CHECKED) != 0; - int Offset = (m_DataStartLoc & 3); - for (int i = 0; i < (4 - Offset); i++) - { - if (WritePos >= MemoryToDisplay) - { - break; - } - m_DataValid[WritePos + i] = ValidData; - if (ValidData) - { - m_CurrentData[WritePos + i] = word.UB[3 - (i + Offset)]; - } - } - WritePos = 4 - Offset; - - } + if ((m_DataStartLoc & 3) != 0) + { + MIPS_WORD word; + bool ValidData = true; - for (DWORD Pos = ((m_DataStartLoc + 3) & ~3); Pos < (m_DataStartLoc + MemoryToDisplay); WritePos += 4, Pos += 4) - { - MIPS_WORD word; - bool ValidData = true; - - if ( m_DataVAddrr ) - { - if (!g_MMU->LW_VAddr(Pos, word.UW)) - { - ValidData = false; - } - } - else - { - if (!g_MMU->LW_PAddr(Pos, word.UW)) - { - ValidData = false; - } - } + if (m_DataVAddrr) + { + if (!g_MMU->LW_VAddr(m_DataStartLoc & ~3, word.UW)) + { + ValidData = false; + } + } + else + { + if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW)) + { + ValidData = false; + } + } - for (int i = 0; i < 4; i++) - { - if ((WritePos + i)>= MemoryToDisplay) - { - break; - } - m_DataValid[WritePos + i] = ValidData; - if (ValidData) - { - m_CurrentData[WritePos + i] = word.UB[3 - i]; - } - } - } + int Offset = (m_DataStartLoc & 3); + for (int i = 0; i < (4 - Offset); i++) + { + if (WritePos >= MemoryToDisplay) + { + break; + } + m_DataValid[WritePos + i] = ValidData; + if (ValidData) + { + m_CurrentData[WritePos + i] = word.UB[3 - (i + Offset)]; + } + } + WritePos = 4 - Offset; + } - for (int count = 0 ; count < 16;count ++) - { - Insert_MemoryLineDump ( count ); - } + for (DWORD Pos = ((m_DataStartLoc + 3) & ~3); Pos < (m_DataStartLoc + MemoryToDisplay); WritePos += 4, Pos += 4) + { + MIPS_WORD word; + bool ValidData = true; + + if (m_DataVAddrr) + { + if (!g_MMU->LW_VAddr(Pos, word.UW)) + { + ValidData = false; + } + } + else + { + if (!g_MMU->LW_PAddr(Pos, word.UW)) + { + ValidData = false; + } + } + + for (int i = 0; i < 4; i++) + { + if ((WritePos + i) >= MemoryToDisplay) + { + break; + } + m_DataValid[WritePos + i] = ValidData; + if (ValidData) + { + m_CurrentData[WritePos + i] = word.UB[3 - i]; + } + } + } + + for (int count = 0; count < 16; count++) + { + Insert_MemoryLineDump(count); + } } -#endif diff --git a/Source/Project64/N64 System/Debugger/Debugger - View Memory.h b/Source/Project64/N64 System/Debugger/Debugger - View Memory.h index 03b1f8c29..4c48ad5b6 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - View Memory.h +++ b/Source/Project64/N64 System/Debugger/Debugger - View Memory.h @@ -11,48 +11,48 @@ #pragma once class CDebugMemoryView : - public CDebugDialog + public CDebugDialog < CDebugMemoryView > { +public: + enum { IDD = IDD_Debugger_Memory }; - BEGIN_MSG_MAP_EX(CDebugMemoryView) - MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) - COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked) - COMMAND_HANDLER_EX(IDC_ADDR_EDIT,EN_CHANGE,OnAddrChanged) - NOTIFY_HANDLER_EX(IDC_MEM_DETAILS, LCN_MODIFIED, OnMemoryModified) - MSG_WM_DESTROY(OnDestroy) - MSG_WM_VSCROLL(OnVScroll) - END_MSG_MAP() + CDebugMemoryView(CDebuggerUI * debugger); + virtual ~CDebugMemoryView(void); - LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); - LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled); - void OnAddrChanged( UINT Code, int id, HWND ctl ); - void OnVScroll(int request, short Pos, HWND ctrl ); - LRESULT OnMemoryModified ( LPNMHDR lpNMHDR ); - LRESULT OnDestroy ( void ); + void ShowAddress(DWORD Address, bool VAddr); - void Insert_MemoryLineDump ( int LineNumber ); - void RefreshMemory ( bool ResetCompare ); - - enum { MemoryToDisplay = 0x100}; +private: + BEGIN_MSG_MAP_EX(CDebugMemoryView) + MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) + COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked) + COMMAND_HANDLER_EX(IDC_ADDR_EDIT, EN_CHANGE, OnAddrChanged) + NOTIFY_HANDLER_EX(IDC_MEM_DETAILS, LCN_MODIFIED, OnMemoryModified) + MSG_WM_DESTROY(OnDestroy) + MSG_WM_VSCROLL(OnVScroll) + END_MSG_MAP() - CEditNumber m_MemAddr; - CListCtrl * m_MemoryList; + LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled); + void OnAddrChanged(UINT Code, int id, HWND ctl); + void OnVScroll(int request, short Pos, HWND ctrl); + LRESULT OnMemoryModified(LPNMHDR lpNMHDR); + LRESULT OnDestroy(void); - DWORD m_DataStartLoc; - bool m_DataVAddrr; - BYTE m_CurrentData[MemoryToDisplay]; - bool m_DataValid[MemoryToDisplay]; + void Insert_MemoryLineDump(int LineNumber); + void RefreshMemory(bool ResetCompare); - DWORD m_CompareStartLoc; - bool m_CompareVAddrr; - BYTE m_CompareData[MemoryToDisplay]; - bool m_CompareValid[MemoryToDisplay]; - -public: - enum { IDD = IDD_Debugger_Memory }; + enum { MemoryToDisplay = 0x100 }; - CDebugMemoryView(CDebugger * debugger); - virtual ~CDebugMemoryView(void); + CEditNumber m_MemAddr; + CListCtrl * m_MemoryList; - void ShowAddress (DWORD Address, bool VAddr); + DWORD m_DataStartLoc; + bool m_DataVAddrr; + BYTE m_CurrentData[MemoryToDisplay]; + bool m_DataValid[MemoryToDisplay]; + + DWORD m_CompareStartLoc; + bool m_CompareVAddrr; + BYTE m_CompareData[MemoryToDisplay]; + bool m_CompareValid[MemoryToDisplay]; }; diff --git a/Source/Project64/N64 System/Debugger/Debugger UI.h b/Source/Project64/N64 System/Debugger/Debugger UI.h index 0884e6cf4..ec2bfaf2b 100644 --- a/Source/Project64/N64 System/Debugger/Debugger UI.h +++ b/Source/Project64/N64 System/Debugger/Debugger UI.h @@ -1,41 +1,4 @@ -////#define _WIN32_WINNT 0x0500 - -//#include -//#include - -////#include -////#include - -//class CPj64Module : -// public CAppModule -//{ -//public: -// CPj64Module(void) -// { -// Init(NULL, GetModuleHandle(NULL)); -// } -// virtual ~CPj64Module(void) -// { -// Term(); -// } -//}; -// -// -//extern CPj64Module _Module; -// -//#define _WTL_NO_CSTRING -// -//#include -//#include -//#include -// -//#include -//#include -//#include -// -//#include "../../Support.h" -//#include "Control/numberctrl.h" -//#include "Control/ClistCtrl/ListCtrl.h" +#pragma once #include "../../WTL App.h" #include "../../N64 System.h" diff --git a/Source/Project64/N64 System/Debugger/Debugger.cpp b/Source/Project64/N64 System/Debugger/Debugger.cpp index ea190aaf3..433b7bf97 100644 --- a/Source/Project64/N64 System/Debugger/Debugger.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger.cpp @@ -9,127 +9,141 @@ * * ****************************************************************************/ #include "stdafx.h" - -#ifdef WINDOWS_UI #include "Debugger UI.h" CPj64Module _Module; -CDebugger::CDebugger () : - m_MemoryDump(NULL), - m_MemoryView(NULL), - m_MemorySearch(NULL), - m_DebugTLB(NULL) +CDebuggerUI::CDebuggerUI () : + m_MemoryDump(NULL), + m_MemoryView(NULL), + m_MemorySearch(NULL), + m_DebugTLB(NULL) { + g_Settings->RegisterChangeCB(GameRunning_InReset,this,(CSettings::SettingChangedFunc)GameReset); + g_Debugger = this; } -CDebugger::~CDebugger (void) +CDebuggerUI::~CDebuggerUI (void) { - Debug_Reset(); + g_Settings->UnregisterChangeCB(GameRunning_InReset,this,(CSettings::SettingChangedFunc)GameReset); + Debug_Reset(); } -void CDebugger::Debug_Reset ( void ) +void CDebuggerUI::GameReset ( CDebuggerUI * _this ) { - if (m_MemoryDump) - { - m_MemoryDump->HideWindow(); - delete m_MemoryDump; - m_MemoryDump = NULL; - } - if (m_MemoryView) - { - m_MemoryView->HideWindow(); - delete m_MemoryView; - m_MemoryView = NULL; - } - if (m_MemorySearch) - { - m_MemorySearch->HideWindow(); - delete m_MemorySearch; - m_MemorySearch = NULL; - } - if (m_DebugTLB) - { - m_DebugTLB->HideWindow(); - delete m_DebugTLB; - m_DebugTLB = NULL; - } -} - -void CDebugger::Debug_ShowMemoryDump() -{ - if (g_MMU == NULL) + if (!g_Settings->LoadBool(GameRunning_InReset)) { return; } - if (m_MemoryDump == NULL) - { - m_MemoryDump = new CDumpMemory(this); - } - if (m_MemoryDump) - { - m_MemoryDump->ShowWindow(); - } + _this->Debug_Reset(); } -void CDebugger::Debug_ShowMemoryWindow ( void ) +void CDebuggerUI::Debug_Reset ( void ) { - if (g_MMU == NULL) - { - return; - } - if (m_MemoryView == NULL) - { - m_MemoryView = new CDebugMemoryView(this); - } - if (m_MemoryView) - { - m_MemoryView->ShowWindow(); - } + if (m_MemoryDump) + { + m_MemoryDump->HideWindow(); + delete m_MemoryDump; + m_MemoryDump = NULL; + } + if (m_MemoryView) + { + m_MemoryView->HideWindow(); + delete m_MemoryView; + m_MemoryView = NULL; + } + if (m_MemorySearch) + { + m_MemorySearch->HideWindow(); + delete m_MemorySearch; + m_MemorySearch = NULL; + } + if (m_DebugTLB) + { + m_DebugTLB->HideWindow(); + delete m_DebugTLB; + m_DebugTLB = NULL; + } } -void CDebugger::Debug_ShowMemoryLocation ( DWORD Address, bool VAddr ) +void CDebuggerUI::Debug_ShowMemoryDump() { - Debug_ShowMemoryWindow(); - if (m_MemoryView) - { - m_MemoryView->ShowAddress(Address,VAddr); - } + if (g_MMU == NULL) + { + return; + } + if (m_MemoryDump == NULL) + { + m_MemoryDump = new CDumpMemory(this); + } + if (m_MemoryDump) + { + m_MemoryDump->ShowWindow(); + } } -void CDebugger::Debug_ShowTLBWindow (void) +void CDebuggerUI::Debug_ShowMemoryWindow ( void ) { - if (g_MMU == NULL) - { - return; - } - if (m_DebugTLB == NULL) - { - m_DebugTLB = new CDebugTlb(this); - } - if (m_DebugTLB) - { - m_DebugTLB->ShowWindow(); - } + if (g_MMU == NULL) + { + return; + } + if (m_MemoryView == NULL) + { + m_MemoryView = new CDebugMemoryView(this); + } + if (m_MemoryView) + { + m_MemoryView->ShowWindow(); + } } -void CDebugger::Debug_RefreshTLBWindow(void) +void CDebuggerUI::Debug_ShowMemoryLocation ( uint32_t Address, bool VAddr ) { - if (m_DebugTLB) - { - m_DebugTLB->RefreshTLBWindow(); - } + Debug_ShowMemoryWindow(); + if (m_MemoryView) + { + m_MemoryView->ShowAddress(Address,VAddr); + } } -void CDebugger::Debug_ShowMemorySearch() +void CDebuggerUI::Debug_ShowTLBWindow (void) { - if (m_MemorySearch == NULL) - { - m_MemorySearch = new CDebugMemorySearch(this); - } - if (m_MemorySearch) - { - m_MemorySearch->ShowWindow(); - } + if (g_MMU == NULL) + { + return; + } + if (m_DebugTLB == NULL) + { + m_DebugTLB = new CDebugTlb(this); + } + if (m_DebugTLB) + { + m_DebugTLB->ShowWindow(); + } } -#endif + +void CDebuggerUI::Debug_RefreshTLBWindow(void) +{ + if (m_DebugTLB) + { + m_DebugTLB->RefreshTLBWindow(); + } +} + +void CDebuggerUI::Debug_ShowMemorySearch() +{ + if (m_MemorySearch == NULL) + { + m_MemorySearch = new CDebugMemorySearch(this); + } + if (m_MemorySearch) + { + m_MemorySearch->ShowWindow(); + } +} + +void CDebuggerUI::TLBChanged() +{ + Debug_RefreshTLBWindow(); +} \ No newline at end of file diff --git a/Source/Project64/N64 System/Debugger/debugger.h b/Source/Project64/N64 System/Debugger/debugger.h index dfa53181a..e8e48f1c0 100644 --- a/Source/Project64/N64 System/Debugger/debugger.h +++ b/Source/Project64/N64 System/Debugger/debugger.h @@ -13,25 +13,35 @@ class CDumpMemory; class CDebugMemoryView; class CDebugMemorySearch; +class CDebugTlb; -class CDebugger +__interface CDebugger { - CDumpMemory * m_MemoryDump; - CDebugMemoryView * m_MemoryView; - CDebugMemorySearch * m_MemorySearch; - CDebugTlb * m_DebugTLB; + virtual void TLBChanged ( void ) = 0; +}; + +class CDebuggerUI : + public CDebugger +{ + CDumpMemory * m_MemoryDump; + CDebugMemoryView * m_MemoryView; + CDebugMemorySearch * m_MemorySearch; + CDebugTlb * m_DebugTLB; protected: - CDebugger(); - virtual ~CDebugger(); - -public: - - void Debug_Reset ( void ); - void Debug_ShowMemoryDump ( void ); - void Debug_ShowMemoryWindow ( void ); - void Debug_ShowMemoryLocation ( DWORD Address, bool VAddr ); - void Debug_ShowMemorySearch ( void ); - void Debug_ShowTLBWindow ( void ); - void Debug_RefreshTLBWindow ( void ); + CDebuggerUI(); + virtual ~CDebuggerUI(); + + void TLBChanged ( void ); + +public: + void Debug_Reset ( void ); + void Debug_ShowMemoryDump ( void ); + void Debug_ShowMemoryWindow ( void ); + void Debug_ShowMemoryLocation ( uint32_t Address, bool VAddr ); + void Debug_ShowMemorySearch ( void ); + void Debug_ShowTLBWindow ( void ); + void Debug_RefreshTLBWindow ( void ); + + static void GameReset ( CDebuggerUI * _this ); }; diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index e4ac22b6c..8ae0ec6ee 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -567,14 +567,10 @@ void CN64System::PluginReset() void CN64System::Reset (bool bInitReg, bool ClearMenory) { + g_Settings->SaveBool(GameRunning_InReset,true); RefreshGameSettings(); m_Audio.Reset(); m_MMU_VM.Reset(ClearMenory); -#if defined(WINDOWS_UI) - Debug_Reset(); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif Mempak::Close(); m_CyclesToSkip = 0; @@ -617,6 +613,7 @@ void CN64System::Reset (bool bInitReg, bool ClearMenory) { m_SyncCPU->Reset(bInitReg,ClearMenory); } + g_Settings->SaveBool(GameRunning_InReset,true); } bool CN64System::SetActiveSystem( bool bActive ) @@ -2098,9 +2095,8 @@ void CN64System::TLB_Unmaped ( DWORD VAddr, DWORD Len ) void CN64System::TLB_Changed() { -#if defined(WINDOWS_UI) - Debug_RefreshTLBWindow(); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif + if (g_Debugger) + { + g_Debugger->TLBChanged(); + } } diff --git a/Source/Project64/N64 System/N64 Class.h b/Source/Project64/N64 System/N64 Class.h index f8a99de24..7c6c8700c 100644 --- a/Source/Project64/N64 System/N64 Class.h +++ b/Source/Project64/N64 System/N64 Class.h @@ -16,40 +16,36 @@ typedef std::map FUNC_CALLS; class CPlugins; class CRSP_Plugin; +class CRecompiler; //#define TEST_SP_TRACKING //track the SP to make sure all ops pick it up fine class CN64System : - private CMipsMemory_CallBack, - private CTLB_CB, - private CSystemEvents, - protected CN64SystemSettings, - public CGameSettings, -#if defined(WINDOWS_UI) - protected CDebugSettings, - public CDebugger -#else - protected CDebugSettings -#endif + public CMipsMemory_CallBack, + public CTLB_CB, + private CSystemEvents, + protected CN64SystemSettings, + public CGameSettings, + protected CDebugSettings { public: - CN64System ( CPlugins * Plugins, bool SavesReadOnly ); - virtual ~CN64System ( void ); + CN64System(CPlugins * Plugins, bool SavesReadOnly); + virtual ~CN64System(void); struct ThreadInfo { HANDLE * ThreadHandle; DWORD ThreadID; }; - CProfiling m_Profile; - CCheats m_Cheats; - bool m_EndEmulation; - SAVE_CHIP_TYPE m_SaveUsing; + CProfiling m_Profile; + CCheats m_Cheats; + bool m_EndEmulation; + SAVE_CHIP_TYPE m_SaveUsing; + + //Methods + static bool RunFileImage(const char * FileLoc); + static void CloseSystem(void); - //Methods - static bool RunFileImage ( const char * FileLoc ); - static void CloseSystem ( void ); - void CloseCpu (); void ExternalEvent ( SystemEvent action ); //covers gui interacting and timers etc.. stdstr ChooseFileToOpen ( HWND hParent ); diff --git a/Source/Project64/N64 System/System Globals.cpp b/Source/Project64/N64 System/System Globals.cpp index 83f7ffdb8..ea221e17d 100644 --- a/Source/Project64/N64 System/System Globals.cpp +++ b/Source/Project64/N64 System/System Globals.cpp @@ -26,6 +26,7 @@ CTransVaddr * g_TransVaddr = NULL; CSystemEvents * g_SystemEvents = NULL; DWORD * g_TLBLoadAddress = NULL; DWORD * g_TLBStoreAddress = NULL; +CDebugger * g_Debugger = NULL; int * g_NextTimer; diff --git a/Source/Project64/N64 System/System Globals.h b/Source/Project64/N64 System/System Globals.h index 0c7319b5c..12f993a58 100644 --- a/Source/Project64/N64 System/System Globals.h +++ b/Source/Project64/N64 System/System Globals.h @@ -29,3 +29,6 @@ extern CSystemEvents * g_SystemEvents; extern int * g_NextTimer; extern DWORD * g_TLBLoadAddress; extern DWORD * g_TLBStoreAddress; + +__interface CDebugger; +extern CDebugger * g_Debugger; diff --git a/Source/Project64/Project64.vcproj b/Source/Project64/Project64.vcproj index e76138d2c..75471d983 100644 --- a/Source/Project64/Project64.vcproj +++ b/Source/Project64/Project64.vcproj @@ -1064,6 +1064,10 @@ RelativePath="N64 System\Cheat Class.h" > + + diff --git a/Source/Project64/Settings.h b/Source/Project64/Settings.h index 94b407a72..869efbfa6 100644 --- a/Source/Project64/Settings.h +++ b/Source/Project64/Settings.h @@ -10,19 +10,23 @@ ****************************************************************************/ #pragma once -#define MaxPluginSetting 65535 +enum +{ + MaxPluginSetting = 65535 +}; -enum SettingID { +enum SettingID +{ //Default values Default_None, Default_Constant, - + //information - temp keys Info_ShortCutsChanged, //Support Files - SupportFile_Settings, - SupportFile_SettingsDefault, + SupportFile_Settings, + SupportFile_SettingsDefault, SupportFile_RomDatabase, SupportFile_RomDatabaseDefault, SupportFile_Glide64RDB, @@ -51,7 +55,7 @@ enum SettingID { Setting_AutoFullscreen, Setting_CheckEmuRunning, Setting_EraseGameDefaults, - + Setting_AutoZipInstantSave, Setting_RememberCheats, Setting_LanguageDir, @@ -154,7 +158,8 @@ enum SettingID { GameRunning_InstantSaveFile, GameRunning_LimitFPS, GameRunning_ScreenHertz, - + GameRunning_InReset, + //User Interface UserInterface_BasicMode, UserInterface_ShowCPUPer, @@ -248,14 +253,14 @@ enum SettingID { Cheat_Range, Cheat_RangeNotes, - FirstRSPDefaultSet, LastRSPDefaultSet = FirstRSPDefaultSet + MaxPluginSetting, - FirstRSPSettings, LastRSPSettings = FirstRSPSettings + MaxPluginSetting, - FirstGfxDefaultSet, LastGfxDefaultSet = FirstGfxDefaultSet + MaxPluginSetting, - FirstGfxSettings, LastGfxSettings = FirstGfxSettings + MaxPluginSetting, + FirstRSPDefaultSet, LastRSPDefaultSet = FirstRSPDefaultSet + MaxPluginSetting, + FirstRSPSettings, LastRSPSettings = FirstRSPSettings + MaxPluginSetting, + FirstGfxDefaultSet, LastGfxDefaultSet = FirstGfxDefaultSet + MaxPluginSetting, + FirstGfxSettings, LastGfxSettings = FirstGfxSettings + MaxPluginSetting, FirstAudioDefaultSet, LastAudioDefaultSet = FirstAudioDefaultSet + MaxPluginSetting, - FirstAudioSettings, LastAudioSettings = FirstAudioSettings + MaxPluginSetting, - FirstCtrlDefaultSet, LastCtrlDefaultSet = FirstCtrlDefaultSet + MaxPluginSetting, - FirstCtrlSettings, LastCtrlSettings = FirstCtrlSettings + MaxPluginSetting, + FirstAudioSettings, LastAudioSettings = FirstAudioSettings + MaxPluginSetting, + FirstCtrlDefaultSet, LastCtrlDefaultSet = FirstCtrlDefaultSet + MaxPluginSetting, + FirstCtrlSettings, LastCtrlSettings = FirstCtrlSettings + MaxPluginSetting, }; #include "Support.h" diff --git a/Source/Project64/Settings/Settings Class.cpp b/Source/Project64/Settings/Settings Class.cpp index ac680db6a..c083a3341 100644 --- a/Source/Project64/Settings/Settings Class.cpp +++ b/Source/Project64/Settings/Settings Class.cpp @@ -291,6 +291,7 @@ void CSettings::AddHowToHandleSetting () AddHandler(GameRunning_InstantSaveFile, new CSettingTypeTempString("")); AddHandler(GameRunning_LimitFPS, new CSettingTypeTempBool(true)); AddHandler(GameRunning_ScreenHertz, new CSettingTypeTempNumber(60)); + AddHandler(GameRunning_InReset, new CSettingTypeTempBool(false)); AddHandler(File_RecentGameFileCount, new CSettingTypeApplication("","Remembered Rom Files",(uint32_t)10)); AddHandler(File_RecentGameFileIndex, new CSettingTypeApplicationIndex("Recent File","Recent Rom",Default_None)); diff --git a/Source/Project64/User Interface/Gui Class.h b/Source/Project64/User Interface/Gui Class.h index 30dcca993..52bed2dde 100644 --- a/Source/Project64/User Interface/Gui Class.h +++ b/Source/Project64/User Interface/Gui Class.h @@ -10,24 +10,27 @@ ****************************************************************************/ #pragma once +#include + class CGfxPlugin; //Plugin that controls the rendering class CAudioPlugin; //Plugin for audio, need the hwnd class CControl_Plugin; //Controller needs hwnd to see if it is the focused window class CBaseMenu; //Menu for the gui -class CN64System; -class CNotification; +class CN64System; class CriticalSection; -enum { - WM_HIDE_CUROSR = WM_USER + 10, - WM_MAKE_FOCUS = WM_USER + 17, - WM_RESET_PLUGIN = WM_USER + 18, - WM_BORWSER_TOP = WM_USER + 40, +enum +{ + WM_HIDE_CUROSR = WM_USER + 10, + WM_MAKE_FOCUS = WM_USER + 17, + WM_RESET_PLUGIN = WM_USER + 18, + WM_BORWSER_TOP = WM_USER + 40, }; class CMainGui : - public CRomBrowser, - private CGuiSettings + public CRomBrowser, + public CDebuggerUI, + private CGuiSettings { enum { StatusBarID = 400 }; diff --git a/Source/Project64/User Interface/Main Menu Class.cpp b/Source/Project64/User Interface/Main Menu Class.cpp index 54cacfe09..5430c47b4 100644 --- a/Source/Project64/User Interface/Main Menu Class.cpp +++ b/Source/Project64/User Interface/Main Menu Class.cpp @@ -458,12 +458,10 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI case ID_DEBUGGER_GENERATELOG: g_Settings->SaveBool(Debugger_GenerateDebugLog,!g_Settings->LoadBool(Debugger_GenerateDebugLog)); break; - case ID_DEBUGGER_DUMPMEMORY: - g_BaseSystem->Debug_ShowMemoryDump(); - break; - case ID_DEBUGGER_SEARCHMEMORY: g_BaseSystem->Debug_ShowMemorySearch(); break; - case ID_DEBUGGER_MEMORY: g_BaseSystem->Debug_ShowMemoryWindow(); break; - case ID_DEBUGGER_TLBENTRIES: g_BaseSystem->Debug_ShowTLBWindow(); break; + case ID_DEBUGGER_DUMPMEMORY: _Gui->Debug_ShowMemoryDump(); break; + case ID_DEBUGGER_SEARCHMEMORY: _Gui->Debug_ShowMemorySearch(); break; + case ID_DEBUGGER_MEMORY: _Gui->Debug_ShowMemoryWindow(); break; + case ID_DEBUGGER_TLBENTRIES: _Gui->Debug_ShowTLBWindow(); break; case ID_DEBUGGER_INTERRUPT_SP: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_SP); break; case ID_DEBUGGER_INTERRUPT_SI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_SI); break; case ID_DEBUGGER_INTERRUPT_AI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_AI); break;