[Project64] Change CDebugger to CDebuggerUI

This commit is contained in:
zilmar 2015-11-07 08:22:02 +11:00
parent d56236356a
commit 6585657d05
22 changed files with 1821 additions and 2275 deletions

View File

@ -0,0 +1 @@
#pragma once

View File

@ -1,32 +1,32 @@
template <class T> template <class T>
class CDebugDialog : class CDebugDialog :
public CDialogImpl<T> public CDialogImpl < T >
{ {
protected: protected:
CDebugger * m_Debugger; CDebuggerUI * m_Debugger;
HANDLE m_CreatedEvent; HANDLE m_CreatedEvent;
HANDLE m_DialogThread; HANDLE m_DialogThread;
static DWORD CreateDebuggerWindow (CDebugDialog<T> * pThis) static DWORD CreateDebuggerWindow(CDebugDialog<T> * pThis)
{ {
pThis->DoModal(NULL); pThis->DoModal(NULL);
pThis->WindowCreated(); pThis->WindowCreated();
return 0; return 0;
} }
void WindowCreated ( void ) void WindowCreated(void)
{ {
SetEvent(m_CreatedEvent); SetEvent(m_CreatedEvent);
} }
public: public:
CDebugDialog (CDebugger * debugger) : CDebugDialog(CDebuggerUI * debugger) :
m_Debugger(debugger), m_Debugger(debugger),
m_CreatedEvent(CreateEvent(NULL,true,false,NULL)), m_CreatedEvent(CreateEvent(NULL, true, false, NULL)),
m_DialogThread(NULL) m_DialogThread(NULL)
{ {
} }
virtual ~CDebugDialog (void) virtual ~CDebugDialog(void)
{ {
HideWindow(); HideWindow();
CloseHandle(m_CreatedEvent); CloseHandle(m_CreatedEvent);
@ -37,7 +37,7 @@ public:
} }
} }
void HideWindow ( void ) void HideWindow(void)
{ {
if (m_hWnd && ::IsWindow(m_hWnd)) if (m_hWnd && ::IsWindow(m_hWnd))
{ {
@ -47,7 +47,7 @@ public:
{ {
if (WaitForSingleObject(m_DialogThread, 5000) == WAIT_TIMEOUT) if (WaitForSingleObject(m_DialogThread, 5000) == WAIT_TIMEOUT)
{ {
WriteTrace(TraceError,"CDebugDialog - time out on close"); WriteTrace(TraceError, "CDebugDialog - time out on close");
TerminateThread(m_DialogThread, 1); TerminateThread(m_DialogThread, 1);
} }
@ -56,7 +56,7 @@ public:
} }
} }
void ShowWindow ( void ) void ShowWindow(void)
{ {
if (m_hWnd) if (m_hWnd)
{ {
@ -66,10 +66,10 @@ public:
{ {
DWORD ThreadID; DWORD ThreadID;
ResetEvent(m_CreatedEvent); ResetEvent(m_CreatedEvent);
m_DialogThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)CreateDebuggerWindow,(LPVOID)this,0, &ThreadID); m_DialogThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CreateDebuggerWindow, (LPVOID)this, 0, &ThreadID);
if (WaitForSingleObject(m_CreatedEvent,20000) == WAIT_TIMEOUT) if (WaitForSingleObject(m_CreatedEvent, 20000) == WAIT_TIMEOUT)
{ {
WriteTrace(TraceError,"Failed to get window create notification"); WriteTrace(TraceError, "Failed to get window create notification");
} }
} }
} }

View File

@ -10,10 +10,9 @@
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#ifdef WINDOWS_UI
#include "Debugger UI.h" #include "Debugger UI.h"
CDumpMemory::CDumpMemory(CDebugger * debugger) : CDumpMemory::CDumpMemory(CDebuggerUI * debugger) :
CDebugDialog<CDumpMemory>(debugger) CDebugDialog<CDumpMemory>(debugger)
{ {
} }
@ -32,13 +31,13 @@ LRESULT CDumpMemory::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPa
m_EndAddress.SetDisplayType(CEditNumber::DisplayHex); m_EndAddress.SetDisplayType(CEditNumber::DisplayHex);
m_PC.SetDisplayType(CEditNumber::DisplayHex); m_PC.SetDisplayType(CEditNumber::DisplayHex);
m_StartAddress.SetValue(0x80000000,true,true); m_StartAddress.SetValue(0x80000000, true, true);
m_EndAddress.SetValue(0x803FFFF0,true,true); m_EndAddress.SetValue(0x803FFFF0, true, true);
m_PC.SetValue(0x80000000); m_PC.SetValue(0x80000000);
HWND hFormatList = GetDlgItem(IDC_FORMAT); HWND hFormatList = GetDlgItem(IDC_FORMAT);
int pos = ::SendMessage(hFormatList,CB_ADDSTRING,(WPARAM)0,(LPARAM)"TEXT - Disassembly + PC"); int pos = ::SendMessage(hFormatList, CB_ADDSTRING, (WPARAM)0, (LPARAM)"TEXT - Disassembly + PC");
::SendMessage(hFormatList,CB_SETITEMDATA,(WPARAM)pos,(LPARAM)DisassemblyWithPC); ::SendMessage(hFormatList, CB_SETITEMDATA, (WPARAM)pos, (LPARAM)DisassemblyWithPC);
::SendMessage(hFormatList,CB_SETCURSEL,(WPARAM)0,(LPARAM)0); ::SendMessage(hFormatList, CB_SETCURSEL, (WPARAM)0, (LPARAM)0);
WindowCreated(); WindowCreated();
return TRUE; return TRUE;
@ -46,20 +45,20 @@ LRESULT CDumpMemory::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPa
LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{ {
switch(wID) switch (wID)
{ {
case IDCANCEL: case IDCANCEL:
EndDialog(0); EndDialog(0);
break; break;
case IDC_BTN_CHOOSE_FILE: case IDC_BTN_CHOOSE_FILE:
{ {
char FileName[_MAX_PATH],Directory[_MAX_PATH]; char FileName[_MAX_PATH], Directory[_MAX_PATH];
OPENFILENAME openfilename; OPENFILENAME openfilename;
memset(&FileName, 0, sizeof(FileName)); memset(&FileName, 0, sizeof(FileName));
memset(&openfilename, 0, sizeof(openfilename)); memset(&openfilename, 0, sizeof(openfilename));
strcpy(Directory,CPath(CPath::MODULE_DIRECTORY)); strcpy(Directory, CPath(CPath::MODULE_DIRECTORY));
openfilename.lStructSize = sizeof( openfilename ); openfilename.lStructSize = sizeof(openfilename);
openfilename.hwndOwner = m_hWnd; openfilename.hwndOwner = m_hWnd;
openfilename.lpstrFilter = "Text file (*.txt)\0*.txt;\0All files (*.*)\0*.*\0"; openfilename.lpstrFilter = "Text file (*.txt)\0*.txt;\0All files (*.*)\0*.*\0";
openfilename.lpstrFile = FileName; openfilename.lpstrFile = FileName;
@ -67,15 +66,15 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/,
openfilename.nMaxFile = MAX_PATH; openfilename.nMaxFile = MAX_PATH;
openfilename.Flags = OFN_HIDEREADONLY; openfilename.Flags = OFN_HIDEREADONLY;
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory); g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory);
if (GetOpenFileName (&openfilename)) if (GetOpenFileName(&openfilename))
{ {
char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
_splitpath( FileName, drive, dir, fname, ext ); _splitpath(FileName, drive, dir, fname, ext);
if (strlen(ext) == 0) if (strlen(ext) == 0)
{ {
strcat(FileName,".txt"); strcat(FileName, ".txt");
} }
SetDlgItemText(IDC_FILENAME,FileName); SetDlgItemText(IDC_FILENAME, FileName);
} }
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
} }
@ -83,34 +82,34 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/,
case IDOK: case IDOK:
{ {
TCHAR FileName[MAX_PATH]; TCHAR FileName[MAX_PATH];
int CurrentFormatSel = SendDlgItemMessage(IDC_FORMAT,CB_GETCURSEL,0,0); int CurrentFormatSel = SendDlgItemMessage(IDC_FORMAT, CB_GETCURSEL, 0, 0);
DumpFormat Format = (DumpFormat)SendDlgItemMessage(IDC_FORMAT,CB_GETITEMDATA,CurrentFormatSel,0); DumpFormat Format = (DumpFormat)SendDlgItemMessage(IDC_FORMAT, CB_GETITEMDATA, CurrentFormatSel, 0);
DWORD StartPC =m_StartAddress.GetValue(); DWORD StartPC = m_StartAddress.GetValue();
DWORD EndPC = m_EndAddress.GetValue(); DWORD EndPC = m_EndAddress.GetValue();
DWORD DumpPC = m_PC.GetValue(); DWORD DumpPC = m_PC.GetValue();
GetDlgItemText(IDC_FILENAME,FileName,sizeof(FileName)); GetDlgItemText(IDC_FILENAME, FileName, sizeof(FileName));
if (strlen(FileName) == 0) if (strlen(FileName) == 0)
{ {
g_Notify->DisplayError(L"Please Choose target file"); g_Notify->DisplayError(L"Please Choose target file");
::SetFocus(GetDlgItem(IDC_FILENAME)); ::SetFocus(GetDlgItem(IDC_FILENAME));
return false; return false;
} }
if (SendDlgItemMessage(IDC_USE_ALT_PC,BM_GETSTATE, 0,0) != BST_CHECKED) if (SendDlgItemMessage(IDC_USE_ALT_PC, BM_GETSTATE, 0, 0) != BST_CHECKED)
{ {
DumpPC = g_Reg->m_PROGRAM_COUNTER; DumpPC = g_Reg->m_PROGRAM_COUNTER;
} }
//disable buttons //disable buttons
::EnableWindow(GetDlgItem(IDC_E_START_ADDR),FALSE); ::EnableWindow(GetDlgItem(IDC_E_START_ADDR), FALSE);
::EnableWindow(GetDlgItem(IDC_E_END_ADDR),FALSE); ::EnableWindow(GetDlgItem(IDC_E_END_ADDR), FALSE);
::EnableWindow(GetDlgItem(IDC_E_ALT_PC),FALSE); ::EnableWindow(GetDlgItem(IDC_E_ALT_PC), FALSE);
::EnableWindow(GetDlgItem(IDC_USE_ALT_PC),FALSE); ::EnableWindow(GetDlgItem(IDC_USE_ALT_PC), FALSE);
::EnableWindow(GetDlgItem(IDC_FILENAME),FALSE); ::EnableWindow(GetDlgItem(IDC_FILENAME), FALSE);
::EnableWindow(GetDlgItem(IDC_BTN_CHOOSE_FILE),FALSE); ::EnableWindow(GetDlgItem(IDC_BTN_CHOOSE_FILE), FALSE);
::EnableWindow(GetDlgItem(IDC_FORMAT),FALSE); ::EnableWindow(GetDlgItem(IDC_FORMAT), FALSE);
::EnableWindow(GetDlgItem(IDOK),FALSE); ::EnableWindow(GetDlgItem(IDOK), FALSE);
::EnableWindow(GetDlgItem(IDCANCEL),FALSE); ::EnableWindow(GetDlgItem(IDCANCEL), FALSE);
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory); g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory);
if (!DumpMemory(FileName,Format,StartPC,EndPC,DumpPC)) if (!DumpMemory(FileName, Format, StartPC, EndPC, DumpPC))
{ {
//enable buttons //enable buttons
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
@ -124,208 +123,7 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/,
return FALSE; return FALSE;
} }
//#include "..\\..\\User Interface.h" bool CDumpMemory::DumpMemory(LPCSTR FileName, DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD /*DumpPC*/)
//#include "..\\..\\N64 System.h"
//#include <windows.h>
//
//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*/ )
{ {
switch (Format) switch (Format)
{ {
@ -334,12 +132,12 @@ bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC,
CLog LogFile; CLog LogFile;
if (!LogFile.Open(FileName)) if (!LogFile.Open(FileName))
{ {
g_Notify->DisplayError(stdstr_f("Failed to open\n%s",FileName).ToUTF16().c_str()); g_Notify->DisplayError(stdstr_f("Failed to open\n%s", FileName).ToUTF16().c_str());
return false; return false;
} }
LogFile.SetFlush(false); LogFile.SetFlush(false);
LogFile.SetTruncateFile(false); LogFile.SetTruncateFile(false);
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
#ifdef tofix #ifdef tofix
char Command[200]; char Command[200];
for (COpcode OpCode(StartPC); OpCode.PC() < EndPC; OpCode.Next()) for (COpcode OpCode(StartPC); OpCode.PC() < EndPC; OpCode.Next())
@ -349,250 +147,11 @@ bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC,
LogFile.LogF("%X: %-15s%s\r\n",OpCode.PC(),szOpName,Command); LogFile.LogF("%X: %-15s%s\r\n",OpCode.PC(),szOpName,Command);
} }
#endif #endif
m_StartAddress.SetValue(StartPC,true,true); m_StartAddress.SetValue(StartPC, true, true);
m_EndAddress.SetValue(EndPC,true,true); m_EndAddress.SetValue(EndPC, true, true);
return true; return true;
} }
break; break;
} }
return false; 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

View File

@ -11,12 +11,12 @@
#pragma once #pragma once
class CDumpMemory : class CDumpMemory :
public CDebugDialog<CDumpMemory> public CDebugDialog < CDumpMemory >
{ {
public: public:
enum { IDD = IDD_Cheats_DumpMemory }; enum { IDD = IDD_Cheats_DumpMemory };
CDumpMemory(CDebugger * debugger); CDumpMemory(CDebuggerUI * debugger);
virtual ~CDumpMemory(void); virtual ~CDumpMemory(void);
private: private:
@ -31,13 +31,13 @@ private:
BEGIN_MSG_MAP_EX(CDumpMemory) BEGIN_MSG_MAP_EX(CDumpMemory)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked) COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
END_MSG_MAP() 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); 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; CEditNumber m_StartAddress, m_EndAddress, m_PC;
}; };

View File

@ -10,10 +10,9 @@
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#ifdef WINDOWS_UI
#include "Debugger UI.h" #include "Debugger UI.h"
CDebugMemorySearch::CDebugMemorySearch(CDebugger * debugger) : CDebugMemorySearch::CDebugMemorySearch(CDebuggerUI * debugger) :
CDebugDialog<CDebugMemorySearch>(debugger), CDebugDialog<CDebugMemorySearch>(debugger),
m_MemoryState(NULL), m_MemoryState(NULL),
m_MemoryStateSize(0) m_MemoryStateSize(0)
@ -28,15 +27,15 @@ CDebugMemorySearch::~CDebugMemorySearch()
} }
} }
void CDebugMemorySearch::AddAlignmentOptions (CComboBox & ctrl) void CDebugMemorySearch::AddAlignmentOptions(CComboBox & ctrl)
{ {
int Index = ctrl.AddString("32 bits (aligned)"); int Index = ctrl.AddString("32 bits (aligned)");
ctrl.SetItemData(Index,_32Bit); ctrl.SetItemData(Index, _32Bit);
Index = ctrl.AddString("16bits (aligned)"); Index = ctrl.AddString("16bits (aligned)");
ctrl.SetItemData(Index,_16Bit); ctrl.SetItemData(Index, _16Bit);
Index = ctrl.AddString("8bits"); Index = ctrl.AddString("8bits");
ctrl.SetCurSel(Index); ctrl.SetCurSel(Index);
ctrl.SetItemData(Index,_8Bit); ctrl.SetItemData(Index, _8Bit);
} }
LRESULT CDebugMemorySearch::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) LRESULT CDebugMemorySearch::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
@ -56,49 +55,49 @@ LRESULT CDebugMemorySearch::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA
m_ValueSize.Attach(GetDlgItem(IDC_VALUE_ALIGN)); m_ValueSize.Attach(GetDlgItem(IDC_VALUE_ALIGN));
AddAlignmentOptions(m_ValueSize); AddAlignmentOptions(m_ValueSize);
m_SearchResults.Attach(GetDlgItem(IDC_LST_RESULTS)); m_SearchResults.Attach(GetDlgItem(IDC_LST_RESULTS));
m_SearchResults.AddColumn("ID",0); m_SearchResults.AddColumn("ID", 0);
m_SearchResults.AddColumn("PAddr",1); m_SearchResults.AddColumn("PAddr", 1);
m_SearchResults.AddColumn("Value",2); m_SearchResults.AddColumn("Value", 2);
m_SearchResults.SetColumnWidth(0,50); m_SearchResults.SetColumnWidth(0, 50);
m_SearchResults.SetColumnWidth(1,75); m_SearchResults.SetColumnWidth(1, 75);
m_SearchResults.SetColumnWidth(2,75); m_SearchResults.SetColumnWidth(2, 75);
m_SearchResults.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT); m_SearchResults.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT);
m_UnknownOptions.Attach(GetDlgItem(IDC_CMB_UNKNOWN)); m_UnknownOptions.Attach(GetDlgItem(IDC_CMB_UNKNOWN));
m_HaveResults = false; m_HaveResults = false;
FixUnknownOptions(true); FixUnknownOptions(true);
SendMessage(GetDlgItem(IDC_RADIO_VALUE),BM_SETCHECK, BST_CHECKED,0); SendMessage(GetDlgItem(IDC_RADIO_VALUE), BM_SETCHECK, BST_CHECKED, 0);
BOOL bHandled; BOOL bHandled;
OnClicked(0,IDC_BTN_RDRAM,NULL,bHandled); OnClicked(0, IDC_BTN_RDRAM, NULL, bHandled);
OnClicked(0,IDC_RADIO_VALUE,NULL,bHandled); OnClicked(0, IDC_RADIO_VALUE, NULL, bHandled);
WindowCreated(); WindowCreated();
return TRUE; return TRUE;
} }
LRESULT CDebugMemorySearch::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND hWndCtl, BOOL& /*bHandled*/) LRESULT CDebugMemorySearch::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND hWndCtl, BOOL& /*bHandled*/)
{ {
switch(wID) switch (wID)
{ {
case IDCANCEL: case IDCANCEL:
EndDialog(0); EndDialog(0);
break; break;
case IDC_BTN_RDRAM: case IDC_BTN_RDRAM:
m_PAddrStart.SetValue(0,true,true); m_PAddrStart.SetValue(0, true, true);
m_SearchLen.SetValue(g_MMU->RdramSize(),true,true); m_SearchLen.SetValue(g_MMU->RdramSize(), true, true);
break; break;
case IDC_BTN_ROM: case IDC_BTN_ROM:
m_PAddrStart.SetValue(0x10000000,true,true); m_PAddrStart.SetValue(0x10000000, true, true);
m_SearchLen.SetValue(g_Rom->GetRomSize(),true,true); m_SearchLen.SetValue(g_Rom->GetRomSize(), true, true);
break; break;
case IDC_BTN_SPMEM: case IDC_BTN_SPMEM:
m_PAddrStart.SetValue(0x04000000,true,true); m_PAddrStart.SetValue(0x04000000, true, true);
m_SearchLen.SetValue(0x2000,true,true); m_SearchLen.SetValue(0x2000, true, true);
break; break;
case IDC_SEARCH_HEX: case IDC_SEARCH_HEX:
{ {
bool bChecked = (SendMessage(hWndCtl, BM_GETSTATE, 0,0) & BST_CHECKED) != 0; bool bChecked = (SendMessage(hWndCtl, BM_GETSTATE, 0, 0) & BST_CHECKED) != 0;
m_SearchValue.SetDisplayType( bChecked ? CEditNumber::DisplayHex : CEditNumber::DisplayDec); m_SearchValue.SetDisplayType(bChecked ? CEditNumber::DisplayHex : CEditNumber::DisplayDec);
} }
break; break;
case ID_POPUP_SHOWINMEMORYVIEWER: case ID_POPUP_SHOWINMEMORYVIEWER:
@ -139,21 +138,21 @@ LRESULT CDebugMemorySearch::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND hWndC
EnableJalOptions(true); EnableJalOptions(true);
break; break;
case IDC_BTN_SEARCH: case IDC_BTN_SEARCH:
if (SendMessage(GetDlgItem(IDC_RADIO_UNKNOWN),BM_GETSTATE, 0,0) == BST_CHECKED) if (SendMessage(GetDlgItem(IDC_RADIO_UNKNOWN), BM_GETSTATE, 0, 0) == BST_CHECKED)
{ {
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory); g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory);
SearchForUnknown(); SearchForUnknown();
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory); g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory);
break; break;
} }
if (SendMessage(GetDlgItem(IDC_RADIO_VALUE),BM_GETSTATE, 0,0) == BST_CHECKED) if (SendMessage(GetDlgItem(IDC_RADIO_VALUE), BM_GETSTATE, 0, 0) == BST_CHECKED)
{ {
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory); g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory);
SearchForValue(); SearchForValue();
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory); g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory);
break; break;
} }
if (SendMessage(GetDlgItem(IDC_RADIO_TEXT),BM_GETSTATE, 0,0) == BST_CHECKED) if (SendMessage(GetDlgItem(IDC_RADIO_TEXT), BM_GETSTATE, 0, 0) == BST_CHECKED)
{ {
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory); g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory);
SearchForText(); SearchForText();
@ -167,7 +166,7 @@ LRESULT CDebugMemorySearch::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND hWndC
return FALSE; return FALSE;
} }
LRESULT CDebugMemorySearch::OnResultRClick ( LPNMHDR /*lpnmh*/ ) LRESULT CDebugMemorySearch::OnResultRClick(LPNMHDR /*lpnmh*/)
{ {
LONG iItem = m_SearchResults.GetNextItem(-1, LVNI_SELECTED); LONG iItem = m_SearchResults.GetNextItem(-1, LVNI_SELECTED);
if (iItem == -1) if (iItem == -1)
@ -176,54 +175,54 @@ LRESULT CDebugMemorySearch::OnResultRClick ( LPNMHDR /*lpnmh*/ )
} }
//Load the menu //Load the menu
HMENU hMenu = LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_MEM_SEARCH)); HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MEM_SEARCH));
HMENU hPopupMenu = GetSubMenu(hMenu,0); HMENU hPopupMenu = GetSubMenu(hMenu, 0);
//Get the current Mouse location //Get the current Mouse location
POINT Mouse; POINT Mouse;
GetCursorPos(&Mouse); GetCursorPos(&Mouse);
//Show the menu //Show the menu
TrackPopupMenu(hPopupMenu, 0, Mouse.x, Mouse.y, 0,m_hWnd, NULL); TrackPopupMenu(hPopupMenu, 0, Mouse.x, Mouse.y, 0, m_hWnd, NULL);
DestroyMenu(hMenu); DestroyMenu(hMenu);
return true; return true;
} }
void CDebugMemorySearch::EnableValueOptions( bool Enable ) void CDebugMemorySearch::EnableValueOptions(bool Enable)
{ {
if (Enable) if (Enable)
{ {
::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),m_HaveResults ? "Search Results" : "Search"); ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), m_HaveResults ? "Search Results" : "Search");
} }
::EnableWindow(GetDlgItem(IDC_SEARCH_VALUE),Enable); ::EnableWindow(GetDlgItem(IDC_SEARCH_VALUE), Enable);
::EnableWindow(GetDlgItem(IDC_SEARCH_HEX),Enable); ::EnableWindow(GetDlgItem(IDC_SEARCH_HEX), Enable);
::EnableWindow(GetDlgItem(IDC_VALUE_ALIGN),m_HaveResults ? false : Enable ); ::EnableWindow(GetDlgItem(IDC_VALUE_ALIGN), m_HaveResults ? false : Enable);
} }
void CDebugMemorySearch::EnableTextOptions( bool Enable ) void CDebugMemorySearch::EnableTextOptions(bool Enable)
{ {
if (Enable) if (Enable)
{ {
::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),m_HaveResults ? "Search Results" : "Search"); ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), m_HaveResults ? "Search Results" : "Search");
} }
::EnableWindow(GetDlgItem(IDC_SEARCH_TEXT),Enable); ::EnableWindow(GetDlgItem(IDC_SEARCH_TEXT), Enable);
::EnableWindow(GetDlgItem(IDC_CASE_SENSITIVE),Enable); ::EnableWindow(GetDlgItem(IDC_CASE_SENSITIVE), Enable);
} }
void CDebugMemorySearch::EnableJalOptions( bool Enable ) void CDebugMemorySearch::EnableJalOptions(bool Enable)
{ {
if (Enable) if (Enable)
{ {
::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),m_HaveResults ? "Search Results" : "Search"); ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), m_HaveResults ? "Search Results" : "Search");
} }
::EnableWindow(GetDlgItem(IDC_JAL_ADDR),Enable); ::EnableWindow(GetDlgItem(IDC_JAL_ADDR), Enable);
} }
void CDebugMemorySearch::EnableUnknownOptions( bool Enable ) void CDebugMemorySearch::EnableUnknownOptions(bool Enable)
{ {
if (m_UnknownOptions.GetCount() > 1) if (m_UnknownOptions.GetCount() > 1)
{ {
::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN),m_HaveResults ? false : Enable ); ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN), m_HaveResults ? false : Enable);
if (Enable) if (Enable)
{ {
::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), m_HaveResults ? "Search Results" : "Search"); ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), m_HaveResults ? "Search Results" : "Search");
@ -231,16 +230,16 @@ void CDebugMemorySearch::EnableUnknownOptions( bool Enable )
} }
else else
{ {
::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN), false ); ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN), false);
if (Enable) if (Enable)
{ {
::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Create"); ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Create");
} }
} }
::EnableWindow(GetDlgItem(IDC_CMB_UNKNOWN),Enable); ::EnableWindow(GetDlgItem(IDC_CMB_UNKNOWN), Enable);
} }
void CDebugMemorySearch::SearchForValue( void ) void CDebugMemorySearch::SearchForValue(void)
{ {
MemorySize Size = (MemorySize)m_ValueSize.GetItemData(m_ValueSize.GetCurSel()); MemorySize Size = (MemorySize)m_ValueSize.GetItemData(m_ValueSize.GetCurSel());
DWORD Value = m_SearchValue.GetValue(); DWORD Value = m_SearchValue.GetValue();
@ -270,23 +269,23 @@ void CDebugMemorySearch::SearchForValue( void )
m_SearchResults.DeleteAllItems(); m_SearchResults.DeleteAllItems();
DWORD ItemsAdded = 0; DWORD ItemsAdded = 0;
while (SearchForValue(Value,Size,StartAddress,Len)) while (SearchForValue(Value, Size, StartAddress, Len))
{ {
SearchResultItem Result; SearchResultItem Result;
Result.PAddr = StartAddress; Result.PAddr = StartAddress;
Result.Value = Value; Result.Value = Value;
char LocationStr[20]; char LocationStr[20];
sprintf(LocationStr,"%d",ItemsAdded + 1); sprintf(LocationStr, "%d", ItemsAdded + 1);
int Index = m_SearchResults.AddItem(ItemsAdded,0,LocationStr); int Index = m_SearchResults.AddItem(ItemsAdded, 0, LocationStr);
m_SearchResults.SetItemData(Index,m_SearchResult.size()); m_SearchResults.SetItemData(Index, m_SearchResult.size());
m_SearchResult.push_back(Result); m_SearchResult.push_back(Result);
sprintf(LocationStr,"0x%08X",StartAddress); sprintf(LocationStr, "0x%08X", StartAddress);
m_SearchResults.SetItemText(Index,1,LocationStr); m_SearchResults.SetItemText(Index, 1, LocationStr);
sprintf(LocationStr,DisplayStr,Value); sprintf(LocationStr, DisplayStr, Value);
m_SearchResults.SetItemText(Index,2,LocationStr); m_SearchResults.SetItemText(Index, 2, LocationStr);
sprintf(LocationStr,DisplayStr,Value); sprintf(LocationStr, DisplayStr, Value);
m_SearchResults.SetItemText(Index,3,LocationStr); m_SearchResults.SetItemText(Index, 3, LocationStr);
StartAddress += MoveSize; StartAddress += MoveSize;
Len -= MoveSize; Len -= MoveSize;
ItemsAdded += 1; ItemsAdded += 1;
@ -295,9 +294,9 @@ void CDebugMemorySearch::SearchForValue( void )
break; break;
} }
} }
::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search Results"); ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Search Results");
::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_SHOW); ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON), SW_SHOW);
::EnableWindow(GetDlgItem(IDC_VALUE_ALIGN),false); ::EnableWindow(GetDlgItem(IDC_VALUE_ALIGN), false);
} }
else else
{ {
@ -330,16 +329,16 @@ void CDebugMemorySearch::SearchForValue( void )
valid = g_MMU->LW_PAddr(Result.PAddr, NewValue); valid = g_MMU->LW_PAddr(Result.PAddr, NewValue);
break; break;
default: default:
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
if (Value == NewValue) if (Value == NewValue)
{ {
char LocationStr[20]; char LocationStr[20];
sprintf(LocationStr,DisplayStr,NewValue); sprintf(LocationStr, DisplayStr, NewValue);
m_SearchResults.SetItemText(i,2,LocationStr); m_SearchResults.SetItemText(i, 2, LocationStr);
sprintf(LocationStr,DisplayStr,Result.Value); sprintf(LocationStr, DisplayStr, Result.Value);
m_SearchResults.SetItemText(i,3,LocationStr); m_SearchResults.SetItemText(i, 3, LocationStr);
Result.Value = NewValue; Result.Value = NewValue;
} }
else else
@ -348,7 +347,7 @@ void CDebugMemorySearch::SearchForValue( void )
} }
} }
} }
::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS),stdstr_f("Results (%d)",m_SearchResults.GetItemCount()).c_str()); ::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS), stdstr_f("Results (%d)", m_SearchResults.GetItemCount()).c_str());
} }
void CDebugMemorySearch::SearchForUnknown() void CDebugMemorySearch::SearchForUnknown()
@ -359,8 +358,8 @@ void CDebugMemorySearch::SearchForUnknown()
m_SearchResults.DeleteAllItems(); m_SearchResults.DeleteAllItems();
SearchSetBaseForChanges(); SearchSetBaseForChanges();
FixUnknownOptions(false); FixUnknownOptions(false);
::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_SHOW); ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON), SW_SHOW);
::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN),true ); ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN), true);
return; return;
} }
MemorySize Size = (MemorySize)m_UnknownSize.GetItemData(m_UnknownSize.GetCurSel()); MemorySize Size = (MemorySize)m_UnknownSize.GetItemData(m_UnknownSize.GetCurSel());
@ -378,7 +377,7 @@ void CDebugMemorySearch::SearchForUnknown()
{ {
m_HaveResults = true; m_HaveResults = true;
::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN),false ); ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN), false);
DWORD StartAddress = m_PAddrStart.GetValue(); DWORD StartAddress = m_PAddrStart.GetValue();
DWORD Len = m_SearchLen.GetValue(); DWORD Len = m_SearchLen.GetValue();
DWORD MaxSearch = m_MaxSearch.GetValue(); DWORD MaxSearch = m_MaxSearch.GetValue();
@ -392,17 +391,17 @@ void CDebugMemorySearch::SearchForUnknown()
break; break;
} }
} }
m_SearchResults.AddColumn("New Value",2); m_SearchResults.AddColumn("New Value", 2);
m_SearchResults.AddColumn("Old Value",3); m_SearchResults.AddColumn("Old Value", 3);
m_SearchResults.SetColumnWidth(0,50); m_SearchResults.SetColumnWidth(0, 50);
m_SearchResults.SetColumnWidth(1,75); m_SearchResults.SetColumnWidth(1, 75);
m_SearchResults.SetColumnWidth(2,75); m_SearchResults.SetColumnWidth(2, 75);
m_SearchResults.SetColumnWidth(3,75); m_SearchResults.SetColumnWidth(3, 75);
m_SearchResults.DeleteAllItems(); m_SearchResults.DeleteAllItems();
DWORD ItemsAdded = 0, OldValue, NewValue; DWORD ItemsAdded = 0, OldValue, NewValue;
while (SearchForChanges(Option,Size,StartAddress,Len,OldValue,NewValue)) while (SearchForChanges(Option, Size, StartAddress, Len, OldValue, NewValue))
{ {
SearchResultItem Result; SearchResultItem Result;
Result.PAddr = StartAddress; Result.PAddr = StartAddress;
@ -410,16 +409,16 @@ void CDebugMemorySearch::SearchForUnknown()
//if list size > max, then break //if list size > max, then break
char LocationStr[20]; char LocationStr[20];
sprintf(LocationStr,"%d",ItemsAdded + 1); sprintf(LocationStr, "%d", ItemsAdded + 1);
int Index = m_SearchResults.AddItem(ItemsAdded,0,LocationStr); int Index = m_SearchResults.AddItem(ItemsAdded, 0, LocationStr);
m_SearchResults.SetItemData(Index,m_SearchResult.size()); m_SearchResults.SetItemData(Index, m_SearchResult.size());
m_SearchResult.push_back(Result); m_SearchResult.push_back(Result);
sprintf(LocationStr,"0x%08X",StartAddress); sprintf(LocationStr, "0x%08X", StartAddress);
m_SearchResults.SetItemText(Index,1,LocationStr); m_SearchResults.SetItemText(Index, 1, LocationStr);
sprintf(LocationStr,DisplayStr,NewValue); sprintf(LocationStr, DisplayStr, NewValue);
m_SearchResults.SetItemText(Index,2,LocationStr); m_SearchResults.SetItemText(Index, 2, LocationStr);
sprintf(LocationStr,DisplayStr,OldValue); sprintf(LocationStr, DisplayStr, OldValue);
m_SearchResults.SetItemText(Index,3,LocationStr); m_SearchResults.SetItemText(Index, 3, LocationStr);
StartAddress += MoveSize; StartAddress += MoveSize;
Len -= MoveSize; Len -= MoveSize;
ItemsAdded += 1; ItemsAdded += 1;
@ -428,10 +427,10 @@ void CDebugMemorySearch::SearchForUnknown()
break; break;
} }
} }
::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search Results"); ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Search Results");
::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_SHOW); ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON), SW_SHOW);
::EnableWindow(GetDlgItem(IDC_RADIO_TEXT),false); ::EnableWindow(GetDlgItem(IDC_RADIO_TEXT), false);
::EnableWindow(GetDlgItem(IDC_RADIO_JAL),false); ::EnableWindow(GetDlgItem(IDC_RADIO_JAL), false);
} }
else else
{ {
@ -465,7 +464,7 @@ void CDebugMemorySearch::SearchForUnknown()
valid = g_MMU->LW_PAddr(Result.PAddr, NewValue); valid = g_MMU->LW_PAddr(Result.PAddr, NewValue);
break; break;
default: default:
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
switch (Option) switch (Option)
@ -495,16 +494,16 @@ void CDebugMemorySearch::SearchForUnknown()
} }
break; break;
default: default:
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
if (UpdateResult) if (UpdateResult)
{ {
char LocationStr[20]; char LocationStr[20];
sprintf(LocationStr,DisplayStr,NewValue); sprintf(LocationStr, DisplayStr, NewValue);
m_SearchResults.SetItemText(i,2,LocationStr); m_SearchResults.SetItemText(i, 2, LocationStr);
sprintf(LocationStr,DisplayStr,Result.Value); sprintf(LocationStr, DisplayStr, Result.Value);
m_SearchResults.SetItemText(i,3,LocationStr); m_SearchResults.SetItemText(i, 3, LocationStr);
Result.Value = NewValue; Result.Value = NewValue;
} }
else else
@ -513,29 +512,29 @@ void CDebugMemorySearch::SearchForUnknown()
} }
} }
} }
::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS),stdstr_f("Results (%d)",m_SearchResults.GetItemCount()).c_str()); ::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS), stdstr_f("Results (%d)", m_SearchResults.GetItemCount()).c_str());
} }
void CDebugMemorySearch::SearchForText() void CDebugMemorySearch::SearchForText()
{ {
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
void CDebugMemorySearch::Reset ( void ) void CDebugMemorySearch::Reset(void)
{ {
m_HaveResults = false; m_HaveResults = false;
SendMessage(GetDlgItem(IDC_RADIO_VALUE),BM_SETCHECK, BST_CHECKED,0); SendMessage(GetDlgItem(IDC_RADIO_VALUE), BM_SETCHECK, BST_CHECKED, 0);
EnableUnknownOptions(false); EnableUnknownOptions(false);
EnableValueOptions(true); EnableValueOptions(true);
EnableTextOptions(false); EnableTextOptions(false);
EnableJalOptions(false); EnableJalOptions(false);
::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search"); ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Search");
::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS),"Results"); ::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS), "Results");
::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_HIDE); ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON), SW_HIDE);
::EnableWindow(GetDlgItem(IDC_RADIO_UNKNOWN),true); ::EnableWindow(GetDlgItem(IDC_RADIO_UNKNOWN), true);
::EnableWindow(GetDlgItem(IDC_RADIO_VALUE),true); ::EnableWindow(GetDlgItem(IDC_RADIO_VALUE), true);
::EnableWindow(GetDlgItem(IDC_RADIO_TEXT),false); ::EnableWindow(GetDlgItem(IDC_RADIO_TEXT), false);
::EnableWindow(GetDlgItem(IDC_RADIO_JAL),false); ::EnableWindow(GetDlgItem(IDC_RADIO_JAL), false);
for (int i = 1; i < 10; i++) for (int i = 1; i < 10; i++)
{ {
if (!m_SearchResults.DeleteColumn(i)) if (!m_SearchResults.DeleteColumn(i))
@ -543,18 +542,18 @@ void CDebugMemorySearch::Reset ( void )
break; break;
} }
} }
m_SearchResults.AddColumn("Value",2); m_SearchResults.AddColumn("Value", 2);
m_SearchResults.DeleteAllItems(); m_SearchResults.DeleteAllItems();
m_SearchResults.SetColumnWidth(0,50); m_SearchResults.SetColumnWidth(0, 50);
m_SearchResults.SetColumnWidth(1,75); m_SearchResults.SetColumnWidth(1, 75);
m_SearchResults.SetColumnWidth(2,75); m_SearchResults.SetColumnWidth(2, 75);
m_SearchResults.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT); m_SearchResults.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT);
FixUnknownOptions(true); 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) if (!Reset && cb.GetCount() > 1)
{ {
@ -563,27 +562,27 @@ void CDebugMemorySearch::FixUnknownOptions ( bool Reset )
cb.ResetContent(); cb.ResetContent();
if (Reset) if (Reset)
{ {
cb.SetItemData(cb.AddString("Create compare base"),SearchChangeState_Reset); cb.SetItemData(cb.AddString("Create compare base"), SearchChangeState_Reset);
cb.SetCurSel(0); cb.SetCurSel(0);
return; return;
} }
cb.SetItemData(cb.AddString("memory changed"),SearchChangeState_Changed); cb.SetItemData(cb.AddString("memory changed"), SearchChangeState_Changed);
cb.SetItemData(cb.AddString("memory unchanged"),SearchChangeState_Unchanged); cb.SetItemData(cb.AddString("memory unchanged"), SearchChangeState_Unchanged);
cb.SetItemData(cb.AddString("Value has increased"),SearchChangeState_Greater); cb.SetItemData(cb.AddString("Value has increased"), SearchChangeState_Greater);
cb.SetItemData(cb.AddString("Value has descreased"),SearchChangeState_Lessthan); cb.SetItemData(cb.AddString("Value has descreased"), SearchChangeState_Lessthan);
cb.SetCurSel(1); cb.SetCurSel(1);
::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search"); ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Search");
} }
bool CDebugMemorySearch::SearchSetBaseForChanges ( void ) bool CDebugMemorySearch::SearchSetBaseForChanges(void)
{ {
if (m_MemoryState != NULL) if (m_MemoryState != NULL)
{ {
delete [] m_MemoryState; delete[] m_MemoryState;
} }
m_MemoryStateSize = g_MMU->RdramSize(); m_MemoryStateSize = g_MMU->RdramSize();
m_MemoryState = new BYTE[m_MemoryStateSize]; m_MemoryState = new BYTE[m_MemoryStateSize];
memcpy(m_MemoryState,g_MMU->Rdram(),m_MemoryStateSize); memcpy(m_MemoryState, g_MMU->Rdram(), m_MemoryStateSize);
return true; return true;
} }
@ -598,7 +597,7 @@ bool CDebugMemorySearch::SearchForChanges(SearchMemChangeState SearchType, Memor
if (SearchType == SearchChangeState_Reset) if (SearchType == SearchChangeState_Reset)
{ {
Notify().BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
if (Size == _32Bit) { StartAddress = ((StartAddress + 3) & ~3); } if (Size == _32Bit) { StartAddress = ((StartAddress + 3) & ~3); }
if (Size == _16Bit) { StartAddress = ((StartAddress + 1) & ~1); } if (Size == _16Bit) { StartAddress = ((StartAddress + 1) & ~1); }
@ -649,7 +648,7 @@ bool CDebugMemorySearch::SearchForChanges(SearchMemChangeState SearchType, Memor
} }
break; break;
case _8Bit: case _8Bit:
for (pos = StartAddress; pos < EndMemSearchAddr; pos ++) for (pos = StartAddress; pos < EndMemSearchAddr; pos++)
{ {
OldValue = *(BYTE *)(m_MemoryState + (pos ^ 3)); OldValue = *(BYTE *)(m_MemoryState + (pos ^ 3));
NewValue = *(BYTE *)(g_MMU->Rdram() + (pos ^ 3)); NewValue = *(BYTE *)(g_MMU->Rdram() + (pos ^ 3));
@ -665,13 +664,13 @@ bool CDebugMemorySearch::SearchForChanges(SearchMemChangeState SearchType, Memor
} }
break; break;
default: default:
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
} }
return false; 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) if (g_MMU == NULL || g_Rom == NULL)
{ {
@ -723,7 +722,7 @@ bool CDebugMemorySearch::SearchForValue (DWORD Value, MemorySize Size, DWORD &St
} }
break; break;
case _8Bit: case _8Bit:
for (pos = StartAddress; pos < EndMemSearchAddr; pos ++) for (pos = StartAddress; pos < EndMemSearchAddr; pos++)
{ {
if (*(BYTE *)(RDRAM + (pos ^ 3)) == (BYTE)Value) if (*(BYTE *)(RDRAM + (pos ^ 3)) == (BYTE)Value)
{ {
@ -734,7 +733,7 @@ bool CDebugMemorySearch::SearchForValue (DWORD Value, MemorySize Size, DWORD &St
} }
break; break;
default: default:
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
} }
if (StartAddress >= 0x10000000) if (StartAddress >= 0x10000000)
@ -773,7 +772,7 @@ bool CDebugMemorySearch::SearchForValue (DWORD Value, MemorySize Size, DWORD &St
} }
break; break;
case _8Bit: case _8Bit:
for (pos = StartAddress; pos < EndMemSearchAddr; pos ++) for (pos = StartAddress; pos < EndMemSearchAddr; pos++)
{ {
if (*(BYTE *)(ROM + (pos ^ 3)) == (BYTE)Value) if (*(BYTE *)(ROM + (pos ^ 3)) == (BYTE)Value)
{ {
@ -784,9 +783,8 @@ bool CDebugMemorySearch::SearchForValue (DWORD Value, MemorySize Size, DWORD &St
} }
break; break;
default: default:
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
} }
return false; return false;
} }
#endif

View File

@ -11,12 +11,12 @@
#pragma once #pragma once
class CDebugMemorySearch : class CDebugMemorySearch :
public CDebugDialog<CDebugMemorySearch> public CDebugDialog < CDebugMemorySearch >
{ {
public: public:
enum { IDD = IDD_Debugger_Search }; enum { IDD = IDD_Debugger_Search };
CDebugMemorySearch(CDebugger * debugger); CDebugMemorySearch(CDebuggerUI * debugger);
virtual ~CDebugMemorySearch(void); virtual ~CDebugMemorySearch(void);
private: private:
@ -51,19 +51,19 @@ private:
BEGIN_MSG_MAP_EX(CDebugMemorySearch) BEGIN_MSG_MAP_EX(CDebugMemorySearch)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked) COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
NOTIFY_HANDLER_EX(IDC_LST_RESULTS,NM_RCLICK,OnResultRClick) NOTIFY_HANDLER_EX(IDC_LST_RESULTS, NM_RCLICK, OnResultRClick)
END_MSG_MAP() 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); LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
LRESULT OnResultRClick ( LPNMHDR lpnmh ); LRESULT OnResultRClick(LPNMHDR lpnmh);
void EnableUnknownOptions ( bool Enable ); void EnableUnknownOptions(bool Enable);
void EnableValueOptions ( bool Enable ); void EnableValueOptions(bool Enable);
void EnableTextOptions ( bool Enable ); void EnableTextOptions(bool Enable);
void EnableJalOptions ( bool Enable ); void EnableJalOptions(bool Enable);
void AddAlignmentOptions ( CComboBox & ctrl ); void AddAlignmentOptions(CComboBox & ctrl);
CEditNumber m_PAddrStart, m_SearchLen, m_SearchValue, m_MaxSearch; CEditNumber m_PAddrStart, m_SearchLen, m_SearchValue, m_MaxSearch;
CComboBox m_UnknownOptions, m_ValueSize, m_UnknownSize; CComboBox m_UnknownOptions, m_ValueSize, m_UnknownSize;
@ -75,12 +75,12 @@ private:
BYTE * m_MemoryState; BYTE * m_MemoryState;
DWORD m_MemoryStateSize; DWORD m_MemoryStateSize;
void FixUnknownOptions ( bool Reset ); void FixUnknownOptions(bool Reset);
void SearchForUnknown ( void ); void SearchForUnknown(void);
void SearchForValue ( void ); void SearchForValue(void);
void SearchForText ( void ); void SearchForText(void);
void Reset ( void ); void Reset(void);
bool SearchSetBaseForChanges ( void ); bool SearchSetBaseForChanges(void);
bool SearchForChanges ( SearchMemChangeState SearchType, MemorySize Size, DWORD &StartAddress, DWORD &Len, DWORD &OldValue, DWORD &NewValue ); bool SearchForChanges(SearchMemChangeState SearchType, MemorySize Size, DWORD &StartAddress, DWORD &Len, DWORD &OldValue, DWORD &NewValue);
bool SearchForValue ( DWORD Value, MemorySize Size, DWORD &StartAddress, DWORD &Len ); bool SearchForValue(DWORD Value, MemorySize Size, DWORD &StartAddress, DWORD &Len);
}; };

View File

@ -10,10 +10,9 @@
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#ifdef WINDOWS_UI
#include "Debugger UI.h" #include "Debugger UI.h"
CDebugTlb::CDebugTlb(CDebugger * debugger) : CDebugTlb::CDebugTlb(CDebuggerUI * debugger) :
CDebugDialog<CDebugTlb>(debugger) CDebugDialog<CDebugTlb>(debugger)
{ {
} }
@ -32,79 +31,79 @@ LRESULT CDebugTlb::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPara
col.pszText = "Index"; col.pszText = "Index";
col.cx = 40; col.cx = 40;
col.iSubItem = 0; col.iSubItem = 0;
ListView_InsertColumn ( GetDlgItem(IDC_LIST), 0, &col); ListView_InsertColumn(GetDlgItem(IDC_LIST), 0, &col);
col.pszText = "Page Mask"; col.pszText = "Page Mask";
col.cx = 90; col.cx = 90;
col.iSubItem = 1; col.iSubItem = 1;
ListView_InsertColumn ( GetDlgItem(IDC_LIST), 1, &col); ListView_InsertColumn(GetDlgItem(IDC_LIST), 1, &col);
col.pszText = "Entry Hi"; col.pszText = "Entry Hi";
col.cx = 90; col.cx = 90;
col.iSubItem = 2; col.iSubItem = 2;
ListView_InsertColumn ( GetDlgItem(IDC_LIST), 2, &col); ListView_InsertColumn(GetDlgItem(IDC_LIST), 2, &col);
col.pszText = "Entry Lo0"; col.pszText = "Entry Lo0";
col.cx = 90; col.cx = 90;
col.iSubItem = 3; col.iSubItem = 3;
ListView_InsertColumn ( GetDlgItem(IDC_LIST), 3, &col); ListView_InsertColumn(GetDlgItem(IDC_LIST), 3, &col);
col.pszText = "Entry Lo1"; col.pszText = "Entry Lo1";
col.cx = 90; col.cx = 90;
col.iSubItem = 4; col.iSubItem = 4;
ListView_InsertColumn ( GetDlgItem(IDC_LIST), 4, &col); ListView_InsertColumn(GetDlgItem(IDC_LIST), 4, &col);
col.pszText = "Index"; col.pszText = "Index";
col.cx = 40; col.cx = 40;
col.iSubItem = 0; col.iSubItem = 0;
ListView_InsertColumn ( GetDlgItem(IDC_LIST2), 0, &col); ListView_InsertColumn(GetDlgItem(IDC_LIST2), 0, &col);
col.pszText = "Valid"; col.pszText = "Valid";
col.cx = 40; col.cx = 40;
col.iSubItem = 1; col.iSubItem = 1;
ListView_InsertColumn ( GetDlgItem(IDC_LIST2), 1, &col); ListView_InsertColumn(GetDlgItem(IDC_LIST2), 1, &col);
col.pszText = "Dirty"; col.pszText = "Dirty";
col.cx = 40; col.cx = 40;
col.iSubItem = 2; col.iSubItem = 2;
ListView_InsertColumn ( GetDlgItem(IDC_LIST2), 2, &col); ListView_InsertColumn(GetDlgItem(IDC_LIST2), 2, &col);
col.pszText = "Rule"; col.pszText = "Rule";
col.cx = 270; col.cx = 270;
col.iSubItem = 3; col.iSubItem = 3;
ListView_InsertColumn ( GetDlgItem(IDC_LIST2), 3, &col); ListView_InsertColumn(GetDlgItem(IDC_LIST2), 3, &col);
RefreshTLBWindow(); RefreshTLBWindow();
SendMessage(GetDlgItem(IDC_TLB_ENTRIES),BM_SETCHECK, BST_CHECKED,0); SendMessage(GetDlgItem(IDC_TLB_ENTRIES), BM_SETCHECK, BST_CHECKED, 0);
// if (Settings().Load(TLBWindowLeft) <= 0) // if (Settings().Load(TLBWindowLeft) <= 0)
// { // {
// SetWindowPos(NULL,Settings().Load(TLBWindowLeft),Settings().Load(TLBWindowTop),0,0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW); // SetWindowPos(NULL,Settings().Load(TLBWindowLeft),Settings().Load(TLBWindowTop),0,0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW);
// } // }
WindowCreated(); WindowCreated();
return TRUE; return TRUE;
} }
LRESULT CDebugTlb::OnClicked (WORD /*wNotifyCode*/, WORD wID, HWND , BOOL& /*bHandled*/) LRESULT CDebugTlb::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/)
{ {
switch(wID) switch (wID)
{ {
case IDCANCEL: case IDCANCEL:
EndDialog(0); EndDialog(0);
break; break;
case IDC_TLB_ENTRIES: case IDC_TLB_ENTRIES:
::ShowWindow(GetDlgItem(IDC_LIST),SW_SHOW); ::ShowWindow(GetDlgItem(IDC_LIST), SW_SHOW);
::ShowWindow(GetDlgItem(IDC_LIST2),SW_HIDE); ::ShowWindow(GetDlgItem(IDC_LIST2), SW_HIDE);
break; break;
case IDC_TLB_RULES: case IDC_TLB_RULES:
::ShowWindow(GetDlgItem(IDC_LIST),SW_HIDE); ::ShowWindow(GetDlgItem(IDC_LIST), SW_HIDE);
::ShowWindow(GetDlgItem(IDC_LIST2),SW_SHOW); ::ShowWindow(GetDlgItem(IDC_LIST2), SW_SHOW);
break; break;
} }
return FALSE; return FALSE;
} }
void CDebugTlb::RefreshTLBWindow (void) void CDebugTlb::RefreshTLBWindow(void)
{ {
if (m_hWnd == NULL) if (m_hWnd == NULL)
{ {
@ -117,9 +116,9 @@ void CDebugTlb::RefreshTLBWindow (void)
int count; int count;
CTLB::TLB_ENTRY * tlb = g_TLB->m_tlb; CTLB::TLB_ENTRY * tlb = g_TLB->m_tlb;
for (count = 0; count < 32; count ++) for (count = 0; count < 32; count++)
{ {
sprintf(Output,"0x%02X",count); sprintf(Output, "0x%02X", count);
item.mask = LVIF_TEXT; item.mask = LVIF_TEXT;
item.iItem = count; item.iItem = count;
item.pszText = Output; item.pszText = Output;
@ -128,91 +127,91 @@ void CDebugTlb::RefreshTLBWindow (void)
OldItem.mask = LVIF_TEXT; OldItem.mask = LVIF_TEXT;
OldItem.iItem = count; OldItem.iItem = count;
OldItem.pszText = OldText; OldItem.pszText = OldText;
OldItem.cchTextMax = sizeof( OldText )-1; OldItem.cchTextMax = sizeof(OldText) - 1;
OldItem.iSubItem = 0; OldItem.iSubItem = 0;
if (ListView_GetItemCount(hList) <= count) if (ListView_GetItemCount(hList) <= count)
{ {
ListView_InsertItem(hList,&item); ListView_InsertItem(hList, &item);
} }
else else
{ {
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList, &OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) if (strcmp(item.pszText, OldItem.pszText) != 0)
{ {
ListView_SetItem(hList,&item); ListView_SetItem(hList, &item);
} }
} }
if (tlb[count].EntryDefined) if (tlb[count].EntryDefined)
{ {
sprintf(Output,"0x%08X",tlb[count].PageMask.Value); sprintf(Output, "0x%08X", tlb[count].PageMask.Value);
} }
else else
{ {
strcpy(Output,"................"); strcpy(Output, "................");
} }
item.iSubItem = 1; item.iSubItem = 1;
OldItem.iSubItem = 1; OldItem.iSubItem = 1;
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList, &OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) if (strcmp(item.pszText, OldItem.pszText) != 0)
{ {
ListView_SetItem(hList,&item); ListView_SetItem(hList, &item);
} }
if (tlb[count].EntryDefined) if (tlb[count].EntryDefined)
{ {
sprintf(Output,"0x%08X",tlb[count].EntryHi.Value); sprintf(Output, "0x%08X", tlb[count].EntryHi.Value);
} }
else else
{ {
strcpy(Output,"................"); strcpy(Output, "................");
} }
item.iSubItem = 2; item.iSubItem = 2;
OldItem.iSubItem = 2; OldItem.iSubItem = 2;
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList, &OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) if (strcmp(item.pszText, OldItem.pszText) != 0)
{ {
ListView_SetItem(hList,&item); ListView_SetItem(hList, &item);
} }
if (tlb[count].EntryDefined) if (tlb[count].EntryDefined)
{ {
sprintf(Output,"0x%08X",tlb[count].EntryLo0.Value); sprintf(Output, "0x%08X", tlb[count].EntryLo0.Value);
} }
else else
{ {
strcpy(Output,"................"); strcpy(Output, "................");
} }
item.iSubItem = 3; item.iSubItem = 3;
OldItem.iSubItem = 3; OldItem.iSubItem = 3;
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList, &OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) if (strcmp(item.pszText, OldItem.pszText) != 0)
{ {
ListView_SetItem(hList,&item); ListView_SetItem(hList, &item);
} }
if (tlb[count].EntryDefined) if (tlb[count].EntryDefined)
{ {
sprintf(Output,"0x%08X",tlb[count].EntryLo1.Value); sprintf(Output, "0x%08X", tlb[count].EntryLo1.Value);
} }
else else
{ {
strcpy(Output,"................"); strcpy(Output, "................");
} }
item.iSubItem = 4; item.iSubItem = 4;
OldItem.iSubItem = 4; OldItem.iSubItem = 4;
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList, &OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) if (strcmp(item.pszText, OldItem.pszText) != 0)
{ {
ListView_SetItem(hList,&item); ListView_SetItem(hList, &item);
} }
} }
CTLB::FASTTLB * FastTlb = g_TLB->m_FastTlb; CTLB::FASTTLB * FastTlb = g_TLB->m_FastTlb;
hList = GetDlgItem(IDC_LIST2); hList = GetDlgItem(IDC_LIST2);
for (count = 0; count < 64; count ++) for (count = 0; count < 64; count++)
{ {
sprintf(Output,"0x%02X",count); sprintf(Output, "0x%02X", count);
item.mask = LVIF_TEXT; item.mask = LVIF_TEXT;
item.iItem = count; item.iItem = count;
item.pszText = Output; item.pszText = Output;
@ -221,70 +220,69 @@ void CDebugTlb::RefreshTLBWindow (void)
OldItem.mask = LVIF_TEXT; OldItem.mask = LVIF_TEXT;
OldItem.iItem = count; OldItem.iItem = count;
OldItem.pszText = OldText; OldItem.pszText = OldText;
OldItem.cchTextMax = sizeof( OldText )-1; OldItem.cchTextMax = sizeof(OldText) - 1;
OldItem.iSubItem = 0; OldItem.iSubItem = 0;
if (ListView_GetItemCount(hList) <= count) if (ListView_GetItemCount(hList) <= count)
{ {
item.iItem = ListView_InsertItem(hList,&item); item.iItem = ListView_InsertItem(hList, &item);
} }
else else
{ {
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList, &OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) if (strcmp(item.pszText, OldItem.pszText) != 0)
{ {
ListView_SetItem(hList,&item); ListView_SetItem(hList, &item);
} }
} }
if (FastTlb[count].ValidEntry) if (FastTlb[count].ValidEntry)
{ {
sprintf(Output,"%s",FastTlb[count].VALID?"Yes":"No"); sprintf(Output, "%s", FastTlb[count].VALID ? "Yes" : "No");
} }
else else
{ {
strcpy(Output,"................"); strcpy(Output, "................");
} }
item.iSubItem = 1; item.iSubItem = 1;
OldItem.iSubItem = 1; OldItem.iSubItem = 1;
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList, &OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) if (strcmp(item.pszText, OldItem.pszText) != 0)
{ {
ListView_SetItem(hList,&item); ListView_SetItem(hList, &item);
} }
if (FastTlb[count].ValidEntry && FastTlb[count].VALID) if (FastTlb[count].ValidEntry && FastTlb[count].VALID)
{ {
sprintf(Output,"%s",FastTlb[count].DIRTY?"Yes":"No"); sprintf(Output, "%s", FastTlb[count].DIRTY ? "Yes" : "No");
} }
else else
{ {
strcpy(Output,"................"); strcpy(Output, "................");
} }
item.iSubItem = 2; item.iSubItem = 2;
OldItem.iSubItem = 2; OldItem.iSubItem = 2;
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList, &OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) if (strcmp(item.pszText, OldItem.pszText) != 0)
{ {
ListView_SetItem(hList,&item); ListView_SetItem(hList, &item);
} }
if (FastTlb[count].ValidEntry && FastTlb[count].VALID) if (FastTlb[count].ValidEntry && FastTlb[count].VALID)
{ {
sprintf(Output,"%08X:%08X -> %08X:%08X",FastTlb[count].VSTART,FastTlb[count].VEND, sprintf(Output, "%08X:%08X -> %08X:%08X", FastTlb[count].VSTART, FastTlb[count].VEND,
FastTlb[count].PHYSSTART,FastTlb[count].PHYSEND); FastTlb[count].PHYSSTART, FastTlb[count].PHYSEND);
} }
else else
{ {
strcpy(Output,"................"); strcpy(Output, "................");
} }
item.iSubItem = 3; item.iSubItem = 3;
OldItem.iSubItem = 3; OldItem.iSubItem = 3;
ListView_GetItem(hList,&OldItem); ListView_GetItem(hList, &OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) if (strcmp(item.pszText, OldItem.pszText) != 0)
{ {
ListView_SetItem(hList,&item); ListView_SetItem(hList, &item);
} }
} }
} }
#endif

View File

@ -11,12 +11,11 @@
#pragma once #pragma once
class CDebugTlb : class CDebugTlb :
public CDebugDialog<CDebugTlb> public CDebugDialog < CDebugTlb >
{ {
BEGIN_MSG_MAP_EX(CDebugTlb) BEGIN_MSG_MAP_EX(CDebugTlb)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked) COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
END_MSG_MAP() END_MSG_MAP()
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
@ -25,8 +24,8 @@ class CDebugTlb :
public: public:
enum { IDD = IDD_Debugger_TLB }; enum { IDD = IDD_Debugger_TLB };
CDebugTlb(CDebugger * debugger); CDebugTlb(CDebuggerUI * debugger);
virtual ~CDebugTlb(void); virtual ~CDebugTlb(void);
void RefreshTLBWindow ( void ); void RefreshTLBWindow(void);
}; };

View File

@ -10,10 +10,9 @@
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#ifdef WINDOWS_UI
#include "Debugger UI.h" #include "Debugger UI.h"
CDebugMemoryView::CDebugMemoryView(CDebugger * debugger) : CDebugMemoryView::CDebugMemoryView(CDebuggerUI * debugger) :
CDebugDialog<CDebugMemoryView>(debugger), CDebugDialog<CDebugMemoryView>(debugger),
m_MemoryList(NULL) m_MemoryList(NULL)
{ {
@ -32,8 +31,8 @@ LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM
{ {
m_DataStartLoc = (DWORD)-1; m_DataStartLoc = (DWORD)-1;
m_CompareStartLoc = (DWORD)-1; m_CompareStartLoc = (DWORD)-1;
memset(m_CompareData,0,sizeof(m_CompareData)); memset(m_CompareData, 0, sizeof(m_CompareData));
memset(m_CompareValid,0,sizeof(m_CompareValid)); memset(m_CompareValid, 0, sizeof(m_CompareValid));
HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR); HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR);
if (hScrlBar) if (hScrlBar)
@ -46,72 +45,72 @@ LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM
si.nMax = 0xFFFF; si.nMax = 0xFFFF;
si.nPos = 0x8000; si.nPos = 0x8000;
si.nPage = 100; si.nPage = 100;
::SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE); ::SetScrollInfo(hScrlBar, SB_CTL, &si, TRUE);
} }
m_MemAddr.Attach(GetDlgItem(IDC_ADDR_EDIT)); m_MemAddr.Attach(GetDlgItem(IDC_ADDR_EDIT));
m_MemAddr.SetDisplayType(CEditNumber::DisplayHex); m_MemAddr.SetDisplayType(CEditNumber::DisplayHex);
m_MemAddr.SetValue(0x80000000,true,true); 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) if (m_MemoryList == NULL)
{ {
m_MemoryList = new CListCtrl; m_MemoryList = new CListCtrl;
m_MemoryList->RegisterClass(); m_MemoryList->RegisterClass();
} }
m_MemoryList->SubclassWindow( GetDlgItem( IDC_MEM_DETAILS ) ); m_MemoryList->SubclassWindow(GetDlgItem(IDC_MEM_DETAILS));
m_MemoryList->ShowHeader(false); m_MemoryList->ShowHeader(false);
m_MemoryList->SetSortEnabled(FALSE); m_MemoryList->SetSortEnabled(FALSE);
m_MemoryList->AddColumn( _T( "Address" ), 90 ); m_MemoryList->AddColumn(_T("Address"), 90);
m_MemoryList->AddColumn( _T( "1" ), 20 ); m_MemoryList->AddColumn(_T("1"), 20);
m_MemoryList->AddColumn( _T( "2" ), 20 ); m_MemoryList->AddColumn(_T("2"), 20);
m_MemoryList->AddColumn( _T( "3" ), 20 ); m_MemoryList->AddColumn(_T("3"), 20);
m_MemoryList->AddColumn( _T( "4" ), 20 ); m_MemoryList->AddColumn(_T("4"), 20);
m_MemoryList->AddColumn( _T( "-" ), 10 ); m_MemoryList->AddColumn(_T("-"), 10);
m_MemoryList->AddColumn( _T( "5" ), 20 ); m_MemoryList->AddColumn(_T("5"), 20);
m_MemoryList->AddColumn( _T( "6" ), 20 ); m_MemoryList->AddColumn(_T("6"), 20);
m_MemoryList->AddColumn( _T( "7" ), 20 ); m_MemoryList->AddColumn(_T("7"), 20);
m_MemoryList->AddColumn( _T( "8" ), 20 ); m_MemoryList->AddColumn(_T("8"), 20);
m_MemoryList->AddColumn( _T( "-" ), 10 ); m_MemoryList->AddColumn(_T("-"), 10);
m_MemoryList->AddColumn( _T( "9" ), 20 ); m_MemoryList->AddColumn(_T("9"), 20);
m_MemoryList->AddColumn( _T( "10" ), 20 ); m_MemoryList->AddColumn(_T("10"), 20);
m_MemoryList->AddColumn( _T( "11" ), 20 ); m_MemoryList->AddColumn(_T("11"), 20);
m_MemoryList->AddColumn( _T( "12" ), 20 ); m_MemoryList->AddColumn(_T("12"), 20);
m_MemoryList->AddColumn( _T( "-" ), 10 ); m_MemoryList->AddColumn(_T("-"), 10);
m_MemoryList->AddColumn( _T( "13" ), 20 ); m_MemoryList->AddColumn(_T("13"), 20);
m_MemoryList->AddColumn( _T( "14" ), 20 ); m_MemoryList->AddColumn(_T("14"), 20);
m_MemoryList->AddColumn( _T( "15" ), 20 ); m_MemoryList->AddColumn(_T("15"), 20);
m_MemoryList->AddColumn( _T( "16" ), 35 ); m_MemoryList->AddColumn(_T("16"), 35);
m_MemoryList->AddColumn( _T( "Memory Ascii" ), 140 ); m_MemoryList->AddColumn(_T("Memory Ascii"), 140);
::SetWindowLongPtr(m_MemoryList->m_hWnd, GWL_EXSTYLE, WS_EX_CLIENTEDGE); ::SetWindowLongPtr(m_MemoryList->m_hWnd, GWL_EXSTYLE, WS_EX_CLIENTEDGE);
RefreshMemory(false); RefreshMemory(false);
int height = m_MemoryList->GetTotalHeight(); int height = m_MemoryList->GetTotalHeight();
RECT MemoryListRect = {0}; RECT MemoryListRect = { 0 };
::GetClientRect(GetDlgItem( IDC_MEM_DETAILS ), &MemoryListRect); ::GetClientRect(GetDlgItem(IDC_MEM_DETAILS), &MemoryListRect);
if (height > MemoryListRect.bottom) if (height > MemoryListRect.bottom)
{ {
RECT MemoryListWindow = {0}; RECT MemoryListWindow = { 0 };
GetWindowRect(&MemoryListWindow); GetWindowRect(&MemoryListWindow);
SetWindowPos(NULL,0,0,MemoryListWindow.right - MemoryListWindow.left,(MemoryListWindow.bottom - MemoryListWindow.top) + (height - MemoryListRect.bottom), SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOZORDER); SetWindowPos(NULL, 0, 0, MemoryListWindow.right - MemoryListWindow.left, (MemoryListWindow.bottom - MemoryListWindow.top) + (height - MemoryListRect.bottom), SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOZORDER);
RECT DlgItemRect = {0}; RECT DlgItemRect = { 0 };
::GetWindowRect(GetDlgItem( IDC_BORDER ), &DlgItemRect); ::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); ::SetWindowPos(GetDlgItem(IDC_BORDER), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
::GetWindowRect(GetDlgItem( IDC_MEM_DETAILS ), &DlgItemRect); ::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); ::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); ::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); ::SetWindowPos(GetDlgItem(IDC_SCRL_BAR), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
} }
WindowCreated(); WindowCreated();
return TRUE; return TRUE;
} }
LRESULT CDebugMemoryView::OnDestroy ( void ) LRESULT CDebugMemoryView::OnDestroy(void)
{ {
if (m_MemoryList) if (m_MemoryList)
{ {
@ -122,7 +121,7 @@ LRESULT CDebugMemoryView::OnDestroy ( void )
return 0; return 0;
} }
LRESULT CDebugMemoryView::OnClicked (WORD /*wNotifyCode*/, WORD wID, HWND , BOOL& /*bHandled*/) LRESULT CDebugMemoryView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/)
{ {
switch (wID) switch (wID)
{ {
@ -145,9 +144,9 @@ LRESULT CDebugMemoryView::OnClicked (WORD /*wNotifyCode*/, WORD wID, HWND , BOOL
return FALSE; return FALSE;
} }
LRESULT CDebugMemoryView::OnMemoryModified ( LPNMHDR lpNMHDR ) LRESULT CDebugMemoryView::OnMemoryModified(LPNMHDR lpNMHDR)
{ {
CListNotify *pListNotify = reinterpret_cast<CListNotify *>( lpNMHDR ); CListNotify *pListNotify = reinterpret_cast<CListNotify *>(lpNMHDR);
int LineNumber = pListNotify->m_nItem; int LineNumber = pListNotify->m_nItem;
int Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 1)); int Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 1));
if (pListNotify->m_nSubItem >= 6 && pListNotify->m_nSubItem < 10) if (pListNotify->m_nSubItem >= 6 && pListNotify->m_nSubItem < 10)
@ -163,7 +162,7 @@ LRESULT CDebugMemoryView::OnMemoryModified ( LPNMHDR lpNMHDR )
Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 4)); Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 4));
} }
LPCSTR strValue = m_MemoryList->GetItemText(pListNotify->m_nItem,pListNotify->m_nSubItem); LPCSTR strValue = m_MemoryList->GetItemText(pListNotify->m_nItem, pListNotify->m_nSubItem);
int Finish = strlen(strValue); int Finish = strlen(strValue);
if (Finish > 8) if (Finish > 8)
{ {
@ -198,26 +197,26 @@ LRESULT CDebugMemoryView::OnMemoryModified ( LPNMHDR lpNMHDR )
// copy current data for change comparison // copy current data for change comparison
m_CompareStartLoc = m_DataStartLoc; m_CompareStartLoc = m_DataStartLoc;
m_CompareVAddrr = m_DataVAddrr; m_CompareVAddrr = m_DataVAddrr;
memcpy(m_CompareData,m_CurrentData,sizeof(m_CurrentData)); memcpy(m_CompareData, m_CurrentData, sizeof(m_CurrentData));
memcpy(m_CompareValid,m_DataValid,sizeof(m_CompareValid)); memcpy(m_CompareValid, m_DataValid, sizeof(m_CompareValid));
} }
m_CompareData[Pos] = m_CurrentData[Pos]; m_CompareData[Pos] = m_CurrentData[Pos];
m_CurrentData[Pos] = (BYTE)Value; m_CurrentData[Pos] = (BYTE)Value;
//sb //sb
if ( m_DataVAddrr ) if (m_DataVAddrr)
{ {
if (!g_MMU->SB_VAddr(m_DataStartLoc + Pos,(BYTE)Value)) if (!g_MMU->SB_VAddr(m_DataStartLoc + Pos, (BYTE)Value))
{ {
WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos); WriteTraceF(TraceError, __FUNCTION__ ": failed to store at %X", m_DataStartLoc + Pos);
} }
} }
else else
{ {
if (!g_MMU->SB_PAddr(m_DataStartLoc + Pos,(BYTE)Value)) if (!g_MMU->SB_PAddr(m_DataStartLoc + Pos, (BYTE)Value))
{ {
WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos); WriteTraceF(TraceError, __FUNCTION__ ": failed to store at %X", m_DataStartLoc + Pos);
} }
} }
Insert_MemoryLineDump(LineNumber); Insert_MemoryLineDump(LineNumber);
@ -232,37 +231,37 @@ void CDebugMemoryView::ShowAddress(DWORD Address, bool VAddr)
return; return;
} }
SendDlgItemMessage( IDC_CHK_VADDR, BM_SETCHECK, VAddr ? BST_CHECKED : BST_UNCHECKED,0); SendDlgItemMessage(IDC_CHK_VADDR, BM_SETCHECK, VAddr ? BST_CHECKED : BST_UNCHECKED, 0);
m_MemAddr.SetValue(Address,true,true); m_MemAddr.SetValue(Address, true, true);
RefreshMemory (true); RefreshMemory(true);
} }
void CDebugMemoryView::Insert_MemoryLineDump ( int LineNumber ) void CDebugMemoryView::Insert_MemoryLineDump(int LineNumber)
{ {
if (m_MemoryList == NULL || m_MemoryList->GetColumnCount() == 0) if (m_MemoryList == NULL || m_MemoryList->GetColumnCount() == 0)
{ {
return; return;
} }
char Output[20], Hex[60], Ascii[20], AsciiAddOn[15]; char Output[20], Hex[60], Ascii[20], AsciiAddOn[15];
sprintf(Output,"0x%08X",m_DataStartLoc + (LineNumber << 4)); sprintf(Output, "0x%08X", m_DataStartLoc + (LineNumber << 4));
if (m_MemoryList->GetItemCount() <= LineNumber) if (m_MemoryList->GetItemCount() <= LineNumber)
{ {
HFONT hFont = (HFONT)GetStockObject(ANSI_FIXED_FONT); HFONT hFont = (HFONT)GetStockObject(ANSI_FIXED_FONT);
m_MemoryList->AddItemAt( LineNumber, Output); m_MemoryList->AddItemAt(LineNumber, Output);
for (int i = 0; i < m_MemoryList->GetColumnCount(); i++) for (int i = 0; i < m_MemoryList->GetColumnCount(); i++)
{ {
m_MemoryList->SetItemFont( LineNumber, i, hFont ); m_MemoryList->SetItemFont(LineNumber, i, hFont);
if (i == 5 || i == 10 || i == 15) if (i == 5 || i == 10 || i == 15)
{ {
m_MemoryList->SetItemText(LineNumber,i,"-"); m_MemoryList->SetItemText(LineNumber, i, "-");
} }
} }
} }
else else
{ {
if ( strcmp( Output, m_MemoryList->GetItemText(LineNumber, 0) ) != 0 ) if (strcmp(Output, m_MemoryList->GetItemText(LineNumber, 0)) != 0)
{ {
m_MemoryList->SetItemText(LineNumber,0,Output); m_MemoryList->SetItemText(LineNumber, 0, Output);
} }
} }
@ -270,7 +269,7 @@ void CDebugMemoryView::Insert_MemoryLineDump ( int LineNumber )
Ascii[0] = 0; Ascii[0] = 0;
int CompareStartPos = m_DataStartLoc - m_CompareStartLoc; int CompareStartPos = m_DataStartLoc - m_CompareStartLoc;
for (int i = 0, col = 1; i < 0x10; i ++, col ++) for (int i = 0, col = 1; i < 0x10; i++, col++)
{ {
int Pos = ((LineNumber << 4) + i); int Pos = ((LineNumber << 4) + i);
if (m_DataValid[Pos]) if (m_DataValid[Pos])
@ -285,30 +284,30 @@ void CDebugMemoryView::Insert_MemoryLineDump ( int LineNumber )
{ {
Changed = true; Changed = true;
} }
sprintf(Hex,"%02X",m_CurrentData[Pos]); sprintf(Hex, "%02X", m_CurrentData[Pos]);
m_MemoryList->SetItemText(LineNumber,col,Hex); m_MemoryList->SetItemText(LineNumber, col, Hex);
m_MemoryList->SetItemFormat( LineNumber,col, ITEM_FORMAT_EDIT, ITEM_FLAGS_EDIT_HEX ); m_MemoryList->SetItemFormat(LineNumber, col, ITEM_FORMAT_EDIT, ITEM_FLAGS_EDIT_HEX);
m_MemoryList->SetItemMaxEditLen( LineNumber,col , 2); m_MemoryList->SetItemMaxEditLen(LineNumber, col, 2);
m_MemoryList->SetItemColours( LineNumber, col, GetSysColor( COLOR_WINDOW ), m_MemoryList->SetItemColours(LineNumber, col, GetSysColor(COLOR_WINDOW),
Changed ? RGB( 255, 0, 0 ) : GetSysColor( COLOR_WINDOWTEXT ) ); Changed ? RGB(255, 0, 0) : GetSysColor(COLOR_WINDOWTEXT));
m_MemoryList->SetItemHighlightColours( LineNumber, col, m_MemoryList->SetItemHighlightColours(LineNumber, col,
Changed ? RGB( 255, 0, 0 ) : GetSysColor( COLOR_HIGHLIGHTTEXT ) ); Changed ? RGB(255, 0, 0) : GetSysColor(COLOR_HIGHLIGHTTEXT));
if (m_CurrentData[Pos] < 30) if (m_CurrentData[Pos] < 30)
{ {
strcat(Ascii,"."); strcat(Ascii, ".");
} }
else else
{ {
sprintf(AsciiAddOn,"%c",m_CurrentData[Pos]); sprintf(AsciiAddOn, "%c", m_CurrentData[Pos]);
strcat(Ascii,AsciiAddOn); strcat(Ascii, AsciiAddOn);
} }
} }
else else
{ {
m_MemoryList->SetItemText(LineNumber,col,"**"); m_MemoryList->SetItemText(LineNumber, col, "**");
m_MemoryList->SetItemFormat( LineNumber,col, ITEM_FORMAT_NONE, ITEM_FLAGS_NONE ); m_MemoryList->SetItemFormat(LineNumber, col, ITEM_FORMAT_NONE, ITEM_FLAGS_NONE);
m_MemoryList->SetItemColours( LineNumber, col, GetSysColor( COLOR_WINDOW ), GetSysColor( COLOR_WINDOWTEXT ) ); m_MemoryList->SetItemColours(LineNumber, col, GetSysColor(COLOR_WINDOW), GetSysColor(COLOR_WINDOWTEXT));
strcat(Ascii,"*"); strcat(Ascii, "*");
} }
if (i != 0xF) if (i != 0xF)
{ {
@ -319,18 +318,18 @@ void CDebugMemoryView::Insert_MemoryLineDump ( int LineNumber )
} }
} }
if ( strcmp( Ascii, m_MemoryList->GetItemText(LineNumber, 20) ) != 0 ) if (strcmp(Ascii, m_MemoryList->GetItemText(LineNumber, 20)) != 0)
{ {
m_MemoryList->SetItemText(LineNumber,20,Ascii); 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)) if (ctrl != GetDlgItem(IDC_SCRL_BAR))
{ {
@ -340,26 +339,26 @@ void CDebugMemoryView::OnVScroll(int request, short Pos, HWND ctrl )
switch (request) switch (request)
{ {
case SB_LINEDOWN: case SB_LINEDOWN:
m_MemAddr.SetValue(Location < 0xFFFFFFEF ? Location + 0x10 : 0xFFFFFFFF,true,true); m_MemAddr.SetValue(Location < 0xFFFFFFEF ? Location + 0x10 : 0xFFFFFFFF, true, true);
break; break;
case SB_LINEUP: case SB_LINEUP:
m_MemAddr.SetValue(Location > 0x10 ? Location - 0x10 : 0,true,true); m_MemAddr.SetValue(Location > 0x10 ? Location - 0x10 : 0, true, true);
break; break;
case SB_PAGEDOWN: case SB_PAGEDOWN:
m_MemAddr.SetValue(Location < 0xFFFFFEFF ? Location + 0x100 : 0xFFFFFFFF,true,true); m_MemAddr.SetValue(Location < 0xFFFFFEFF ? Location + 0x100 : 0xFFFFFFFF, true, true);
break; break;
case SB_PAGEUP: case SB_PAGEUP:
m_MemAddr.SetValue(Location > 0x100 ? Location - 0x100 : 0,true,true); m_MemAddr.SetValue(Location > 0x100 ? Location - 0x100 : 0, true, true);
break; break;
case SB_THUMBPOSITION: case SB_THUMBPOSITION:
m_MemAddr.SetValue((DWORD)Pos << 0x10,true,true); m_MemAddr.SetValue((DWORD)Pos << 0x10, true, true);
break; break;
default: default:
break; break;
} }
} }
void CDebugMemoryView::RefreshMemory ( bool ResetCompare ) void CDebugMemoryView::RefreshMemory(bool ResetCompare)
{ {
if (m_MemoryList && m_MemoryList->GetHasEditItem()) if (m_MemoryList && m_MemoryList->GetHasEditItem())
{ {
@ -377,7 +376,7 @@ void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
si.cbSize = sizeof(si); si.cbSize = sizeof(si);
si.fMask = SIF_POS; si.fMask = SIF_POS;
si.nPos = NewAddress >> 0x10; si.nPos = NewAddress >> 0x10;
::SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE); ::SetScrollInfo(hScrlBar, SB_CTL, &si, TRUE);
} }
} }
@ -386,22 +385,22 @@ void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
// copy current data for change comparison // copy current data for change comparison
m_CompareStartLoc = m_DataStartLoc; m_CompareStartLoc = m_DataStartLoc;
m_CompareVAddrr = m_DataVAddrr; m_CompareVAddrr = m_DataVAddrr;
memcpy(m_CompareData,m_CurrentData,sizeof(m_CurrentData)); memcpy(m_CompareData, m_CurrentData, sizeof(m_CurrentData));
memcpy(m_CompareValid,m_DataValid,sizeof(m_CompareValid)); memcpy(m_CompareValid, m_DataValid, sizeof(m_CompareValid));
} }
m_DataStartLoc = m_MemAddr.GetValue(); m_DataStartLoc = m_MemAddr.GetValue();
if (m_DataStartLoc > 0xFFFFFF00) { m_DataStartLoc = 0xFFFFFF00; } if (m_DataStartLoc > 0xFFFFFF00) { m_DataStartLoc = 0xFFFFFF00; }
int WritePos = 0; int WritePos = 0;
m_DataVAddrr = (SendDlgItemMessage( IDC_CHK_VADDR, BM_GETCHECK, 0,0) & BST_CHECKED) != 0; m_DataVAddrr = (SendDlgItemMessage(IDC_CHK_VADDR, BM_GETCHECK, 0, 0) & BST_CHECKED) != 0;
if ((m_DataStartLoc & 3) != 0) if ((m_DataStartLoc & 3) != 0)
{ {
MIPS_WORD word; MIPS_WORD word;
bool ValidData = true; bool ValidData = true;
if ( m_DataVAddrr ) if (m_DataVAddrr)
{ {
if (!g_MMU->LW_VAddr(m_DataStartLoc & ~3, word.UW)) if (!g_MMU->LW_VAddr(m_DataStartLoc & ~3, word.UW))
{ {
@ -430,7 +429,6 @@ void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
} }
} }
WritePos = 4 - Offset; WritePos = 4 - Offset;
} }
for (DWORD Pos = ((m_DataStartLoc + 3) & ~3); Pos < (m_DataStartLoc + MemoryToDisplay); WritePos += 4, Pos += 4) for (DWORD Pos = ((m_DataStartLoc + 3) & ~3); Pos < (m_DataStartLoc + MemoryToDisplay); WritePos += 4, Pos += 4)
@ -438,7 +436,7 @@ void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
MIPS_WORD word; MIPS_WORD word;
bool ValidData = true; bool ValidData = true;
if ( m_DataVAddrr ) if (m_DataVAddrr)
{ {
if (!g_MMU->LW_VAddr(Pos, word.UW)) if (!g_MMU->LW_VAddr(Pos, word.UW))
{ {
@ -455,7 +453,7 @@ void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
if ((WritePos + i)>= MemoryToDisplay) if ((WritePos + i) >= MemoryToDisplay)
{ {
break; break;
} }
@ -467,9 +465,8 @@ void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
} }
} }
for (int count = 0 ; count < 16;count ++) for (int count = 0; count < 16; count++)
{ {
Insert_MemoryLineDump ( count ); Insert_MemoryLineDump(count);
} }
} }
#endif

View File

@ -11,13 +11,21 @@
#pragma once #pragma once
class CDebugMemoryView : class CDebugMemoryView :
public CDebugDialog<CDebugMemoryView> public CDebugDialog < CDebugMemoryView >
{ {
public:
enum { IDD = IDD_Debugger_Memory };
CDebugMemoryView(CDebuggerUI * debugger);
virtual ~CDebugMemoryView(void);
void ShowAddress(DWORD Address, bool VAddr);
private:
BEGIN_MSG_MAP_EX(CDebugMemoryView) BEGIN_MSG_MAP_EX(CDebugMemoryView)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked) COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
COMMAND_HANDLER_EX(IDC_ADDR_EDIT,EN_CHANGE,OnAddrChanged) COMMAND_HANDLER_EX(IDC_ADDR_EDIT, EN_CHANGE, OnAddrChanged)
NOTIFY_HANDLER_EX(IDC_MEM_DETAILS, LCN_MODIFIED, OnMemoryModified) NOTIFY_HANDLER_EX(IDC_MEM_DETAILS, LCN_MODIFIED, OnMemoryModified)
MSG_WM_DESTROY(OnDestroy) MSG_WM_DESTROY(OnDestroy)
MSG_WM_VSCROLL(OnVScroll) MSG_WM_VSCROLL(OnVScroll)
@ -25,15 +33,15 @@ class CDebugMemoryView :
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); LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
void OnAddrChanged( UINT Code, int id, HWND ctl ); void OnAddrChanged(UINT Code, int id, HWND ctl);
void OnVScroll(int request, short Pos, HWND ctrl ); void OnVScroll(int request, short Pos, HWND ctrl);
LRESULT OnMemoryModified ( LPNMHDR lpNMHDR ); LRESULT OnMemoryModified(LPNMHDR lpNMHDR);
LRESULT OnDestroy ( void ); LRESULT OnDestroy(void);
void Insert_MemoryLineDump ( int LineNumber ); void Insert_MemoryLineDump(int LineNumber);
void RefreshMemory ( bool ResetCompare ); void RefreshMemory(bool ResetCompare);
enum { MemoryToDisplay = 0x100}; enum { MemoryToDisplay = 0x100 };
CEditNumber m_MemAddr; CEditNumber m_MemAddr;
CListCtrl * m_MemoryList; CListCtrl * m_MemoryList;
@ -47,12 +55,4 @@ class CDebugMemoryView :
bool m_CompareVAddrr; bool m_CompareVAddrr;
BYTE m_CompareData[MemoryToDisplay]; BYTE m_CompareData[MemoryToDisplay];
bool m_CompareValid[MemoryToDisplay]; bool m_CompareValid[MemoryToDisplay];
public:
enum { IDD = IDD_Debugger_Memory };
CDebugMemoryView(CDebugger * debugger);
virtual ~CDebugMemoryView(void);
void ShowAddress (DWORD Address, bool VAddr);
}; };

View File

@ -1,41 +1,4 @@
////#define _WIN32_WINNT 0x0500 #pragma once
//#include <atlbase.h>
//#include <wtl/atlapp.h>
////#include <atlbase.h>
////#include <atlapp.h>
//class CPj64Module :
// public CAppModule
//{
//public:
// CPj64Module(void)
// {
// Init(NULL, GetModuleHandle(NULL));
// }
// virtual ~CPj64Module(void)
// {
// Term();
// }
//};
//
//
//extern CPj64Module _Module;
//
//#define _WTL_NO_CSTRING
//
//#include <atlwin.h>
//#include <wtl/atlmisc.h>
//#include <wtl/atlcrack.h>
//
//#include <wtl/atlframe.h>
//#include <wtl/atlctrls.h>
//#include <wtl/atldlgs.h>
//
//#include "../../Support.h"
//#include "Control/numberctrl.h"
//#include "Control/ClistCtrl/ListCtrl.h"
#include "../../WTL App.h" #include "../../WTL App.h"
#include "../../N64 System.h" #include "../../N64 System.h"

View File

@ -9,26 +9,36 @@
* * * *
****************************************************************************/ ****************************************************************************/
#include "stdafx.h" #include "stdafx.h"
#ifdef WINDOWS_UI
#include "Debugger UI.h" #include "Debugger UI.h"
CPj64Module _Module; CPj64Module _Module;
CDebugger::CDebugger () : CDebuggerUI::CDebuggerUI () :
m_MemoryDump(NULL), m_MemoryDump(NULL),
m_MemoryView(NULL), m_MemoryView(NULL),
m_MemorySearch(NULL), m_MemorySearch(NULL),
m_DebugTLB(NULL) m_DebugTLB(NULL)
{ {
g_Settings->RegisterChangeCB(GameRunning_InReset,this,(CSettings::SettingChangedFunc)GameReset);
g_Debugger = this;
} }
CDebugger::~CDebugger (void) CDebuggerUI::~CDebuggerUI (void)
{ {
g_Settings->UnregisterChangeCB(GameRunning_InReset,this,(CSettings::SettingChangedFunc)GameReset);
Debug_Reset(); Debug_Reset();
} }
void CDebugger::Debug_Reset ( void ) void CDebuggerUI::GameReset ( CDebuggerUI * _this )
{
if (!g_Settings->LoadBool(GameRunning_InReset))
{
return;
}
_this->Debug_Reset();
}
void CDebuggerUI::Debug_Reset ( void )
{ {
if (m_MemoryDump) if (m_MemoryDump)
{ {
@ -56,7 +66,7 @@ void CDebugger::Debug_Reset ( void )
} }
} }
void CDebugger::Debug_ShowMemoryDump() void CDebuggerUI::Debug_ShowMemoryDump()
{ {
if (g_MMU == NULL) if (g_MMU == NULL)
{ {
@ -72,7 +82,7 @@ void CDebugger::Debug_ShowMemoryDump()
} }
} }
void CDebugger::Debug_ShowMemoryWindow ( void ) void CDebuggerUI::Debug_ShowMemoryWindow ( void )
{ {
if (g_MMU == NULL) if (g_MMU == NULL)
{ {
@ -88,7 +98,7 @@ void CDebugger::Debug_ShowMemoryWindow ( void )
} }
} }
void CDebugger::Debug_ShowMemoryLocation ( DWORD Address, bool VAddr ) void CDebuggerUI::Debug_ShowMemoryLocation ( uint32_t Address, bool VAddr )
{ {
Debug_ShowMemoryWindow(); Debug_ShowMemoryWindow();
if (m_MemoryView) if (m_MemoryView)
@ -97,7 +107,7 @@ void CDebugger::Debug_ShowMemoryLocation ( DWORD Address, bool VAddr )
} }
} }
void CDebugger::Debug_ShowTLBWindow (void) void CDebuggerUI::Debug_ShowTLBWindow (void)
{ {
if (g_MMU == NULL) if (g_MMU == NULL)
{ {
@ -113,7 +123,7 @@ void CDebugger::Debug_ShowTLBWindow (void)
} }
} }
void CDebugger::Debug_RefreshTLBWindow(void) void CDebuggerUI::Debug_RefreshTLBWindow(void)
{ {
if (m_DebugTLB) if (m_DebugTLB)
{ {
@ -121,7 +131,7 @@ void CDebugger::Debug_RefreshTLBWindow(void)
} }
} }
void CDebugger::Debug_ShowMemorySearch() void CDebuggerUI::Debug_ShowMemorySearch()
{ {
if (m_MemorySearch == NULL) if (m_MemorySearch == NULL)
{ {
@ -132,4 +142,8 @@ void CDebugger::Debug_ShowMemorySearch()
m_MemorySearch->ShowWindow(); m_MemorySearch->ShowWindow();
} }
} }
#endif
void CDebuggerUI::TLBChanged()
{
Debug_RefreshTLBWindow();
}

View File

@ -13,8 +13,15 @@
class CDumpMemory; class CDumpMemory;
class CDebugMemoryView; class CDebugMemoryView;
class CDebugMemorySearch; class CDebugMemorySearch;
class CDebugTlb;
class CDebugger __interface CDebugger
{
virtual void TLBChanged ( void ) = 0;
};
class CDebuggerUI :
public CDebugger
{ {
CDumpMemory * m_MemoryDump; CDumpMemory * m_MemoryDump;
CDebugMemoryView * m_MemoryView; CDebugMemoryView * m_MemoryView;
@ -22,16 +29,19 @@ class CDebugger
CDebugTlb * m_DebugTLB; CDebugTlb * m_DebugTLB;
protected: protected:
CDebugger(); CDebuggerUI();
virtual ~CDebugger(); virtual ~CDebuggerUI();
void TLBChanged ( void );
public: public:
void Debug_Reset ( void ); void Debug_Reset ( void );
void Debug_ShowMemoryDump ( void ); void Debug_ShowMemoryDump ( void );
void Debug_ShowMemoryWindow ( void ); void Debug_ShowMemoryWindow ( void );
void Debug_ShowMemoryLocation ( DWORD Address, bool VAddr ); void Debug_ShowMemoryLocation ( uint32_t Address, bool VAddr );
void Debug_ShowMemorySearch ( void ); void Debug_ShowMemorySearch ( void );
void Debug_ShowTLBWindow ( void ); void Debug_ShowTLBWindow ( void );
void Debug_RefreshTLBWindow ( void ); void Debug_RefreshTLBWindow ( void );
static void GameReset ( CDebuggerUI * _this );
}; };

View File

@ -567,14 +567,10 @@ void CN64System::PluginReset()
void CN64System::Reset (bool bInitReg, bool ClearMenory) void CN64System::Reset (bool bInitReg, bool ClearMenory)
{ {
g_Settings->SaveBool(GameRunning_InReset,true);
RefreshGameSettings(); RefreshGameSettings();
m_Audio.Reset(); m_Audio.Reset();
m_MMU_VM.Reset(ClearMenory); m_MMU_VM.Reset(ClearMenory);
#if defined(WINDOWS_UI)
Debug_Reset();
#else
g_Notify -> BreakPoint(__FILEW__, __LINE__);
#endif
Mempak::Close(); Mempak::Close();
m_CyclesToSkip = 0; m_CyclesToSkip = 0;
@ -617,6 +613,7 @@ void CN64System::Reset (bool bInitReg, bool ClearMenory)
{ {
m_SyncCPU->Reset(bInitReg,ClearMenory); m_SyncCPU->Reset(bInitReg,ClearMenory);
} }
g_Settings->SaveBool(GameRunning_InReset,true);
} }
bool CN64System::SetActiveSystem( bool bActive ) bool CN64System::SetActiveSystem( bool bActive )
@ -2098,9 +2095,8 @@ void CN64System::TLB_Unmaped ( DWORD VAddr, DWORD Len )
void CN64System::TLB_Changed() void CN64System::TLB_Changed()
{ {
#if defined(WINDOWS_UI) if (g_Debugger)
Debug_RefreshTLBWindow(); {
#else g_Debugger->TLBChanged();
g_Notify -> BreakPoint(__FILEW__, __LINE__); }
#endif
} }

View File

@ -16,25 +16,21 @@ typedef std::map<DWORD, DWORD> FUNC_CALLS;
class CPlugins; class CPlugins;
class CRSP_Plugin; class CRSP_Plugin;
class CRecompiler;
//#define TEST_SP_TRACKING //track the SP to make sure all ops pick it up fine //#define TEST_SP_TRACKING //track the SP to make sure all ops pick it up fine
class CN64System : class CN64System :
private CMipsMemory_CallBack, public CMipsMemory_CallBack,
private CTLB_CB, public CTLB_CB,
private CSystemEvents, private CSystemEvents,
protected CN64SystemSettings, protected CN64SystemSettings,
public CGameSettings, public CGameSettings,
#if defined(WINDOWS_UI)
protected CDebugSettings,
public CDebugger
#else
protected CDebugSettings protected CDebugSettings
#endif
{ {
public: public:
CN64System ( CPlugins * Plugins, bool SavesReadOnly ); CN64System(CPlugins * Plugins, bool SavesReadOnly);
virtual ~CN64System ( void ); virtual ~CN64System(void);
struct ThreadInfo { struct ThreadInfo {
HANDLE * ThreadHandle; HANDLE * ThreadHandle;
@ -47,8 +43,8 @@ public:
SAVE_CHIP_TYPE m_SaveUsing; SAVE_CHIP_TYPE m_SaveUsing;
//Methods //Methods
static bool RunFileImage ( const char * FileLoc ); static bool RunFileImage(const char * FileLoc);
static void CloseSystem ( void ); static void CloseSystem(void);
void CloseCpu (); void CloseCpu ();
void ExternalEvent ( SystemEvent action ); //covers gui interacting and timers etc.. void ExternalEvent ( SystemEvent action ); //covers gui interacting and timers etc..

View File

@ -26,6 +26,7 @@ CTransVaddr * g_TransVaddr = NULL;
CSystemEvents * g_SystemEvents = NULL; CSystemEvents * g_SystemEvents = NULL;
DWORD * g_TLBLoadAddress = NULL; DWORD * g_TLBLoadAddress = NULL;
DWORD * g_TLBStoreAddress = NULL; DWORD * g_TLBStoreAddress = NULL;
CDebugger * g_Debugger = NULL;
int * g_NextTimer; int * g_NextTimer;

View File

@ -29,3 +29,6 @@ extern CSystemEvents * g_SystemEvents;
extern int * g_NextTimer; extern int * g_NextTimer;
extern DWORD * g_TLBLoadAddress; extern DWORD * g_TLBLoadAddress;
extern DWORD * g_TLBStoreAddress; extern DWORD * g_TLBStoreAddress;
__interface CDebugger;
extern CDebugger * g_Debugger;

View File

@ -1064,6 +1064,10 @@
RelativePath="N64 System\Cheat Class.h" RelativePath="N64 System\Cheat Class.h"
> >
</File> </File>
<File
RelativePath=".\Debugger.h"
>
</File>
<File <File
RelativePath="N64 System\N64 Class.h" RelativePath="N64 System\N64 Class.h"
> >

View File

@ -10,9 +10,13 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#define MaxPluginSetting 65535 enum
{
MaxPluginSetting = 65535
};
enum SettingID { enum SettingID
{
//Default values //Default values
Default_None, Default_None,
Default_Constant, Default_Constant,
@ -154,6 +158,7 @@ enum SettingID {
GameRunning_InstantSaveFile, GameRunning_InstantSaveFile,
GameRunning_LimitFPS, GameRunning_LimitFPS,
GameRunning_ScreenHertz, GameRunning_ScreenHertz,
GameRunning_InReset,
//User Interface //User Interface
UserInterface_BasicMode, UserInterface_BasicMode,

View File

@ -291,6 +291,7 @@ void CSettings::AddHowToHandleSetting ()
AddHandler(GameRunning_InstantSaveFile, new CSettingTypeTempString("")); AddHandler(GameRunning_InstantSaveFile, new CSettingTypeTempString(""));
AddHandler(GameRunning_LimitFPS, new CSettingTypeTempBool(true)); AddHandler(GameRunning_LimitFPS, new CSettingTypeTempBool(true));
AddHandler(GameRunning_ScreenHertz, new CSettingTypeTempNumber(60)); 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_RecentGameFileCount, new CSettingTypeApplication("","Remembered Rom Files",(uint32_t)10));
AddHandler(File_RecentGameFileIndex, new CSettingTypeApplicationIndex("Recent File","Recent Rom",Default_None)); AddHandler(File_RecentGameFileIndex, new CSettingTypeApplicationIndex("Recent File","Recent Rom",Default_None));

View File

@ -10,15 +10,17 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <Project64\N64 System\Debugger\debugger.h>
class CGfxPlugin; //Plugin that controls the rendering class CGfxPlugin; //Plugin that controls the rendering
class CAudioPlugin; //Plugin for audio, need the hwnd class CAudioPlugin; //Plugin for audio, need the hwnd
class CControl_Plugin; //Controller needs hwnd to see if it is the focused window class CControl_Plugin; //Controller needs hwnd to see if it is the focused window
class CBaseMenu; //Menu for the gui class CBaseMenu; //Menu for the gui
class CN64System; class CN64System;
class CNotification;
class CriticalSection; class CriticalSection;
enum { enum
{
WM_HIDE_CUROSR = WM_USER + 10, WM_HIDE_CUROSR = WM_USER + 10,
WM_MAKE_FOCUS = WM_USER + 17, WM_MAKE_FOCUS = WM_USER + 17,
WM_RESET_PLUGIN = WM_USER + 18, WM_RESET_PLUGIN = WM_USER + 18,
@ -27,6 +29,7 @@ enum {
class CMainGui : class CMainGui :
public CRomBrowser, public CRomBrowser,
public CDebuggerUI,
private CGuiSettings private CGuiSettings
{ {
enum { StatusBarID = 400 }; enum { StatusBarID = 400 };

View File

@ -458,12 +458,10 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
case ID_DEBUGGER_GENERATELOG: case ID_DEBUGGER_GENERATELOG:
g_Settings->SaveBool(Debugger_GenerateDebugLog,!g_Settings->LoadBool(Debugger_GenerateDebugLog)); g_Settings->SaveBool(Debugger_GenerateDebugLog,!g_Settings->LoadBool(Debugger_GenerateDebugLog));
break; break;
case ID_DEBUGGER_DUMPMEMORY: case ID_DEBUGGER_DUMPMEMORY: _Gui->Debug_ShowMemoryDump(); break;
g_BaseSystem->Debug_ShowMemoryDump(); case ID_DEBUGGER_SEARCHMEMORY: _Gui->Debug_ShowMemorySearch(); break;
break; case ID_DEBUGGER_MEMORY: _Gui->Debug_ShowMemoryWindow(); break;
case ID_DEBUGGER_SEARCHMEMORY: g_BaseSystem->Debug_ShowMemorySearch(); break; case ID_DEBUGGER_TLBENTRIES: _Gui->Debug_ShowTLBWindow(); break;
case ID_DEBUGGER_MEMORY: g_BaseSystem->Debug_ShowMemoryWindow(); break;
case ID_DEBUGGER_TLBENTRIES: g_BaseSystem->Debug_ShowTLBWindow(); break;
case ID_DEBUGGER_INTERRUPT_SP: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_SP); 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_SI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_SI); break;
case ID_DEBUGGER_INTERRUPT_AI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_AI); break; case ID_DEBUGGER_INTERRUPT_AI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_AI); break;