[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,76 +1,76 @@
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);
if (m_DialogThread) if (m_DialogThread)
{ {
CloseHandle(m_DialogThread); CloseHandle(m_DialogThread);
m_DialogThread = NULL; m_DialogThread = NULL;
} }
} }
void HideWindow ( void ) void HideWindow(void)
{ {
if (m_hWnd && ::IsWindow(m_hWnd)) if (m_hWnd && ::IsWindow(m_hWnd))
{ {
::EndDialog(m_hWnd, 0); ::EndDialog(m_hWnd, 0);
} }
if (m_DialogThread) if (m_DialogThread)
{ {
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);
} }
CloseHandle(m_DialogThread); CloseHandle(m_DialogThread);
m_DialogThread = NULL; m_DialogThread = NULL;
} }
} }
void ShowWindow ( void ) void ShowWindow(void)
{ {
if (m_hWnd) if (m_hWnd)
{ {
SetForegroundWindow((HWND)m_hWnd); SetForegroundWindow((HWND)m_hWnd);
} }
else else
{ {
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,11 +10,10 @@
****************************************************************************/ ****************************************************************************/
#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)
{ {
} }
@ -24,575 +23,135 @@ CDumpMemory::~CDumpMemory()
LRESULT CDumpMemory::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) LRESULT CDumpMemory::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{ {
m_StartAddress.Attach(GetDlgItem(IDC_E_START_ADDR)); m_StartAddress.Attach(GetDlgItem(IDC_E_START_ADDR));
m_EndAddress.Attach(GetDlgItem(IDC_E_END_ADDR)); m_EndAddress.Attach(GetDlgItem(IDC_E_END_ADDR));
m_PC.Attach(GetDlgItem(IDC_E_ALT_PC)); m_PC.Attach(GetDlgItem(IDC_E_ALT_PC));
m_StartAddress.SetDisplayType(CEditNumber::DisplayHex); m_StartAddress.SetDisplayType(CEditNumber::DisplayHex);
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;
} }
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;
openfilename.lpstrInitialDir = Directory; openfilename.lpstrInitialDir = Directory;
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);
} }
break; break;
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);
return false; return false;
} }
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
} }
EndDialog(0); EndDialog(0);
break; break;
} }
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)
{ {
case DisassemblyWithPC: case DisassemblyWithPC:
{ {
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())
{ {
const char * szOpName = OpCode.OpcodeName(); const char * szOpName = OpCode.OpcodeName();
OpCode.OpcodeParam(Command); OpCode.OpcodeParam(Command);
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,33 +11,33 @@
#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:
CDumpMemory(void); // Disable default constructor CDumpMemory(void); // Disable default constructor
CDumpMemory(const CDumpMemory&); // Disable copy constructor CDumpMemory(const CDumpMemory&); // Disable copy constructor
CDumpMemory& operator=(const CDumpMemory&); // Disable assignment CDumpMemory& operator=(const CDumpMemory&); // Disable assignment
enum DumpFormat enum DumpFormat
{ {
DisassemblyWithPC DisassemblyWithPC
}; };
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

@ -11,59 +11,59 @@
#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:
CDebugMemorySearch(void); // Disable default constructor CDebugMemorySearch(void); // Disable default constructor
CDebugMemorySearch(const CDebugMemorySearch&); // Disable copy constructor CDebugMemorySearch(const CDebugMemorySearch&); // Disable copy constructor
CDebugMemorySearch& operator=(const CDebugMemorySearch&); // Disable assignment CDebugMemorySearch& operator=(const CDebugMemorySearch&); // Disable assignment
enum MemorySize enum MemorySize
{ {
_8Bit, _8Bit,
_16Bit, _16Bit,
_32Bit, _32Bit,
}; };
//Searching for value //Searching for value
enum SearchMemChangeState enum SearchMemChangeState
{ {
SearchChangeState_Reset, SearchChangeState_Reset,
SearchChangeState_Changed, SearchChangeState_Changed,
SearchChangeState_Unchanged, SearchChangeState_Unchanged,
SearchChangeState_Greater, SearchChangeState_Greater,
SearchChangeState_Lessthan, SearchChangeState_Lessthan,
}; };
struct SearchResultItem struct SearchResultItem
{ {
DWORD PAddr; DWORD PAddr;
DWORD Value; DWORD Value;
}; };
typedef std::vector<SearchResultItem> SearchResult; typedef std::vector<SearchResultItem> SearchResult;
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,11 +10,10 @@
****************************************************************************/ ****************************************************************************/
#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)
{ {
} }
@ -24,267 +23,266 @@ CDebugTlb::~CDebugTlb()
LRESULT CDebugTlb::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) LRESULT CDebugTlb::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{ {
LV_COLUMN col; LV_COLUMN col;
col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
col.fmt = LVCFMT_LEFT; col.fmt = LVCFMT_LEFT;
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)
{ {
return; return;
} }
HWND hList = GetDlgItem(IDC_LIST);
char Output[100], OldText[100];
LV_ITEM item, OldItem;
int count;
CTLB::TLB_ENTRY * tlb = g_TLB->m_tlb; HWND hList = GetDlgItem(IDC_LIST);
for (count = 0; count < 32; count ++) char Output[100], OldText[100];
{ LV_ITEM item, OldItem;
sprintf(Output,"0x%02X",count); int count;
item.mask = LVIF_TEXT;
item.iItem = count;
item.pszText = Output;
item.iSubItem = 0;
OldItem.mask = LVIF_TEXT; CTLB::TLB_ENTRY * tlb = g_TLB->m_tlb;
OldItem.iItem = count; for (count = 0; count < 32; count++)
OldItem.pszText = OldText; {
OldItem.cchTextMax = sizeof( OldText )-1; sprintf(Output, "0x%02X", count);
OldItem.iSubItem = 0; item.mask = LVIF_TEXT;
item.iItem = count;
item.pszText = Output;
item.iSubItem = 0;
if (ListView_GetItemCount(hList) <= count) OldItem.mask = LVIF_TEXT;
{ OldItem.iItem = count;
ListView_InsertItem(hList,&item); OldItem.pszText = OldText;
} OldItem.cchTextMax = sizeof(OldText) - 1;
else OldItem.iSubItem = 0;
{
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
}
if (tlb[count].EntryDefined)
{
sprintf(Output,"0x%08X",tlb[count].PageMask.Value);
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 1;
OldItem.iSubItem = 1;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
if (tlb[count].EntryDefined) if (ListView_GetItemCount(hList) <= count)
{ {
sprintf(Output,"0x%08X",tlb[count].EntryHi.Value); ListView_InsertItem(hList, &item);
} }
else else
{ {
strcpy(Output,"................"); ListView_GetItem(hList, &OldItem);
} if (strcmp(item.pszText, OldItem.pszText) != 0)
item.iSubItem = 2; {
OldItem.iSubItem = 2; ListView_SetItem(hList, &item);
ListView_GetItem(hList,&OldItem); }
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) }
{ if (tlb[count].EntryDefined)
ListView_SetItem(hList,&item); {
} sprintf(Output, "0x%08X", tlb[count].PageMask.Value);
}
else
{
strcpy(Output, "................");
}
item.iSubItem = 1;
OldItem.iSubItem = 1;
ListView_GetItem(hList, &OldItem);
if (strcmp(item.pszText, OldItem.pszText) != 0)
{
ListView_SetItem(hList, &item);
}
if (tlb[count].EntryDefined) if (tlb[count].EntryDefined)
{ {
sprintf(Output,"0x%08X",tlb[count].EntryLo0.Value); sprintf(Output, "0x%08X", tlb[count].EntryHi.Value);
} }
else else
{ {
strcpy(Output,"................"); strcpy(Output, "................");
} }
item.iSubItem = 3; item.iSubItem = 2;
OldItem.iSubItem = 3; 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].EntryLo1.Value); sprintf(Output, "0x%08X", tlb[count].EntryLo0.Value);
} }
else else
{ {
strcpy(Output,"................"); strcpy(Output, "................");
} }
item.iSubItem = 4; item.iSubItem = 3;
OldItem.iSubItem = 4; 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);
} }
}
CTLB::FASTTLB * FastTlb = g_TLB->m_FastTlb;
hList = GetDlgItem(IDC_LIST2);
for (count = 0; count < 64; count ++)
{
sprintf(Output,"0x%02X",count);
item.mask = LVIF_TEXT;
item.iItem = count;
item.pszText = Output;
item.iSubItem = 0;
OldItem.mask = LVIF_TEXT; if (tlb[count].EntryDefined)
OldItem.iItem = count; {
OldItem.pszText = OldText; sprintf(Output, "0x%08X", tlb[count].EntryLo1.Value);
OldItem.cchTextMax = sizeof( OldText )-1; }
OldItem.iSubItem = 0; else
{
strcpy(Output, "................");
}
item.iSubItem = 4;
OldItem.iSubItem = 4;
ListView_GetItem(hList, &OldItem);
if (strcmp(item.pszText, OldItem.pszText) != 0)
{
ListView_SetItem(hList, &item);
}
}
if (ListView_GetItemCount(hList) <= count) CTLB::FASTTLB * FastTlb = g_TLB->m_FastTlb;
{ hList = GetDlgItem(IDC_LIST2);
item.iItem = ListView_InsertItem(hList,&item); for (count = 0; count < 64; count++)
} {
else sprintf(Output, "0x%02X", count);
{ item.mask = LVIF_TEXT;
ListView_GetItem(hList,&OldItem); item.iItem = count;
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) item.pszText = Output;
{ item.iSubItem = 0;
ListView_SetItem(hList,&item);
}
}
if (FastTlb[count].ValidEntry) OldItem.mask = LVIF_TEXT;
{ OldItem.iItem = count;
sprintf(Output,"%s",FastTlb[count].VALID?"Yes":"No"); OldItem.pszText = OldText;
} OldItem.cchTextMax = sizeof(OldText) - 1;
else OldItem.iSubItem = 0;
{
strcpy(Output,"................");
}
item.iSubItem = 1;
OldItem.iSubItem = 1;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
if (FastTlb[count].ValidEntry && FastTlb[count].VALID) if (ListView_GetItemCount(hList) <= count)
{ {
sprintf(Output,"%s",FastTlb[count].DIRTY?"Yes":"No"); item.iItem = ListView_InsertItem(hList, &item);
} }
else else
{ {
strcpy(Output,"................"); ListView_GetItem(hList, &OldItem);
} if (strcmp(item.pszText, OldItem.pszText) != 0)
item.iSubItem = 2; {
OldItem.iSubItem = 2; ListView_SetItem(hList, &item);
ListView_GetItem(hList,&OldItem); }
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) }
{
ListView_SetItem(hList,&item);
}
if (FastTlb[count].ValidEntry && FastTlb[count].VALID) if (FastTlb[count].ValidEntry)
{ {
sprintf(Output,"%08X:%08X -> %08X:%08X",FastTlb[count].VSTART,FastTlb[count].VEND, sprintf(Output, "%s", FastTlb[count].VALID ? "Yes" : "No");
FastTlb[count].PHYSSTART,FastTlb[count].PHYSEND); }
} else
else {
{ strcpy(Output, "................");
strcpy(Output,"................"); }
} item.iSubItem = 1;
item.iSubItem = 3; OldItem.iSubItem = 1;
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 (FastTlb[count].ValidEntry && FastTlb[count].VALID)
{
sprintf(Output, "%s", FastTlb[count].DIRTY ? "Yes" : "No");
}
else
{
strcpy(Output, "................");
}
item.iSubItem = 2;
OldItem.iSubItem = 2;
ListView_GetItem(hList, &OldItem);
if (strcmp(item.pszText, OldItem.pszText) != 0)
{
ListView_SetItem(hList, &item);
}
if (FastTlb[count].ValidEntry && FastTlb[count].VALID)
{
sprintf(Output, "%08X:%08X -> %08X:%08X", FastTlb[count].VSTART, FastTlb[count].VEND,
FastTlb[count].PHYSSTART, FastTlb[count].PHYSEND);
}
else
{
strcpy(Output, "................");
}
item.iSubItem = 3;
OldItem.iSubItem = 3;
ListView_GetItem(hList, &OldItem);
if (strcmp(item.pszText, OldItem.pszText) != 0)
{
ListView_SetItem(hList, &item);
}
}
} }
#endif

View File

@ -11,22 +11,21 @@
#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*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled); LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
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,18 +10,17 @@
****************************************************************************/ ****************************************************************************/
#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)
{ {
if (m_MemoryList== NULL) if (m_MemoryList== NULL)
{ {
m_MemoryList = new CListCtrl; m_MemoryList = new CListCtrl;
m_MemoryList->RegisterClass(); m_MemoryList->RegisterClass();
} }
} }
CDebugMemoryView::~CDebugMemoryView() CDebugMemoryView::~CDebugMemoryView()
@ -30,446 +29,444 @@ CDebugMemoryView::~CDebugMemoryView()
LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{ {
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)
{ {
SCROLLINFO si; SCROLLINFO si;
si.cbSize = sizeof(si); si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
si.nMin = 0; si.nMin = 0;
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};
::GetClientRect(GetDlgItem( IDC_MEM_DETAILS ), &MemoryListRect);
if (height > MemoryListRect.bottom) RECT MemoryListRect = { 0 };
{ ::GetClientRect(GetDlgItem(IDC_MEM_DETAILS), &MemoryListRect);
RECT MemoryListWindow = {0};
GetWindowRect(&MemoryListWindow);
SetWindowPos(NULL,0,0,MemoryListWindow.right - MemoryListWindow.left,(MemoryListWindow.bottom - MemoryListWindow.top) + (height - MemoryListRect.bottom), SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOZORDER);
RECT DlgItemRect = {0}; if (height > MemoryListRect.bottom)
::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); RECT MemoryListWindow = { 0 };
GetWindowRect(&MemoryListWindow);
SetWindowPos(NULL, 0, 0, MemoryListWindow.right - MemoryListWindow.left, (MemoryListWindow.bottom - MemoryListWindow.top) + (height - MemoryListRect.bottom), SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOZORDER);
::GetWindowRect(GetDlgItem( IDC_MEM_DETAILS ), &DlgItemRect); RECT DlgItemRect = { 0 };
::SetWindowPos(GetDlgItem( IDC_MEM_DETAILS ), NULL,0,0,DlgItemRect.right - DlgItemRect.left,(DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE); ::GetWindowRect(GetDlgItem(IDC_BORDER), &DlgItemRect);
::SetWindowPos(GetDlgItem(IDC_BORDER), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
::GetWindowRect(GetDlgItem( IDC_SCRL_BAR ), &DlgItemRect); ::GetWindowRect(GetDlgItem(IDC_MEM_DETAILS), &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_MEM_DETAILS), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
}
WindowCreated(); ::GetWindowRect(GetDlgItem(IDC_SCRL_BAR), &DlgItemRect);
return TRUE; ::SetWindowPos(GetDlgItem(IDC_SCRL_BAR), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
}
WindowCreated();
return TRUE;
} }
LRESULT CDebugMemoryView::OnDestroy ( void ) LRESULT CDebugMemoryView::OnDestroy(void)
{ {
if (m_MemoryList) if (m_MemoryList)
{ {
m_MemoryList->UnsubclassWindow(); m_MemoryList->UnsubclassWindow();
delete m_MemoryList; delete m_MemoryList;
m_MemoryList = NULL; m_MemoryList = NULL;
} }
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)
{ {
case IDC_REFRSH_MEM: case IDC_REFRSH_MEM:
RefreshMemory(true); RefreshMemory(true);
break; break;
case IDC_CHK_VADDR: case IDC_CHK_VADDR:
RefreshMemory(false); RefreshMemory(false);
break; break;
case IDC_DUMP_MEM: case IDC_DUMP_MEM:
m_Debugger->Debug_ShowMemoryDump(); m_Debugger->Debug_ShowMemoryDump();
break; break;
case IDC_SEARCH_MEM: case IDC_SEARCH_MEM:
m_Debugger->Debug_ShowMemorySearch(); m_Debugger->Debug_ShowMemorySearch();
break; break;
case IDCANCEL: case IDCANCEL:
EndDialog(0); EndDialog(0);
break; break;
} }
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)
{ {
Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 2)); Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 2));
} }
if (pListNotify->m_nSubItem >= 11 && pListNotify->m_nSubItem < 15) if (pListNotify->m_nSubItem >= 11 && pListNotify->m_nSubItem < 15)
{ {
Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 3)); Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 3));
} }
if (pListNotify->m_nSubItem >= 16 && pListNotify->m_nSubItem < 20) if (pListNotify->m_nSubItem >= 16 && pListNotify->m_nSubItem < 20)
{ {
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)
{ {
Finish = 8; Finish = 8;
} }
DWORD Value = 0; DWORD Value = 0;
for (int i = 0; i < Finish; i++) for (int i = 0; i < Finish; i++)
{ {
Value = (Value << 4); Value = (Value << 4);
if (strValue[i] <= '9' && strValue[i] >= '0') if (strValue[i] <= '9' && strValue[i] >= '0')
{ {
Value |= strValue[i] - '0'; Value |= strValue[i] - '0';
} }
else if (strValue[i] <= 'f' && strValue[i] >= 'a') else if (strValue[i] <= 'f' && strValue[i] >= 'a')
{ {
Value |= strValue[i] - 'a' + 10; Value |= strValue[i] - 'a' + 10;
} }
else if (strValue[i] <= 'F' && strValue[i] >= 'A') else if (strValue[i] <= 'F' && strValue[i] >= 'A')
{ {
Value |= strValue[i] - 'A' + 10; Value |= strValue[i] - 'A' + 10;
} }
} }
if (m_CurrentData[Pos] == Value) if (m_CurrentData[Pos] == Value)
{ {
return 0; return 0;
} }
if (m_CompareStartLoc != m_DataStartLoc || if (m_CompareStartLoc != m_DataStartLoc ||
m_CompareVAddrr != m_DataVAddrr) m_CompareVAddrr != m_DataVAddrr)
{ {
// 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);
return 0; return 0;
} }
void CDebugMemoryView::ShowAddress(DWORD Address, bool VAddr) void CDebugMemoryView::ShowAddress(DWORD Address, bool VAddr)
{ {
if (m_hWnd == NULL) if (m_hWnd == NULL)
{ {
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);
} }
} }
Hex[0] = 0; Hex[0] = 0;
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])
{ {
int ComparePos = CompareStartPos + Pos; int ComparePos = CompareStartPos + Pos;
bool Changed = false; bool Changed = false;
if (ComparePos >= 0 && ComparePos < MemoryToDisplay && if (ComparePos >= 0 && ComparePos < MemoryToDisplay &&
m_DataVAddrr == m_CompareVAddrr && m_DataVAddrr == m_CompareVAddrr &&
m_DataValid[ComparePos] && m_DataValid[ComparePos] &&
m_CurrentData[Pos] != m_CompareData[ComparePos]) m_CurrentData[Pos] != m_CompareData[ComparePos])
{ {
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)
{ {
if ((i & 3) == 3) if ((i & 3) == 3)
{ {
col += 1; col += 1;
} }
} }
} }
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))
{ {
return; return;
} }
DWORD Location = m_MemAddr.GetValue(); DWORD Location = m_MemAddr.GetValue();
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())
{ {
m_MemoryList->SetFocus(); m_MemoryList->SetFocus();
} }
DWORD NewAddress = m_MemAddr.GetValue(); DWORD NewAddress = m_MemAddr.GetValue();
if (NewAddress != m_DataStartLoc) if (NewAddress != m_DataStartLoc)
{ {
HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR); HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR);
if (hScrlBar) if (hScrlBar)
{ {
SCROLLINFO si; SCROLLINFO si;
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);
} }
} }
if (ResetCompare) if (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();
if (m_DataStartLoc > 0xFFFFFF00) { m_DataStartLoc = 0xFFFFFF00; }
int WritePos = 0;
m_DataVAddrr = (SendDlgItemMessage( IDC_CHK_VADDR, BM_GETCHECK, 0,0) & BST_CHECKED) != 0; m_DataStartLoc = m_MemAddr.GetValue();
if (m_DataStartLoc > 0xFFFFFF00) { m_DataStartLoc = 0xFFFFFF00; }
int WritePos = 0;
if ((m_DataStartLoc & 3) != 0) m_DataVAddrr = (SendDlgItemMessage(IDC_CHK_VADDR, BM_GETCHECK, 0, 0) & BST_CHECKED) != 0;
{
MIPS_WORD word;
bool ValidData = true;
if ( m_DataVAddrr )
{
if (!g_MMU->LW_VAddr(m_DataStartLoc & ~3, word.UW))
{
ValidData = false;
}
}
else
{
if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW))
{
ValidData = false;
}
}
int Offset = (m_DataStartLoc & 3); if ((m_DataStartLoc & 3) != 0)
for (int i = 0; i < (4 - Offset); i++) {
{ MIPS_WORD word;
if (WritePos >= MemoryToDisplay) bool ValidData = true;
{
break;
}
m_DataValid[WritePos + i] = ValidData;
if (ValidData)
{
m_CurrentData[WritePos + i] = word.UB[3 - (i + Offset)];
}
}
WritePos = 4 - Offset;
}
for (DWORD Pos = ((m_DataStartLoc + 3) & ~3); Pos < (m_DataStartLoc + MemoryToDisplay); WritePos += 4, Pos += 4) if (m_DataVAddrr)
{ {
MIPS_WORD word; if (!g_MMU->LW_VAddr(m_DataStartLoc & ~3, word.UW))
bool ValidData = true; {
ValidData = false;
if ( m_DataVAddrr ) }
{ }
if (!g_MMU->LW_VAddr(Pos, word.UW)) else
{ {
ValidData = false; if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW))
} {
} ValidData = false;
else }
{ }
if (!g_MMU->LW_PAddr(Pos, word.UW))
{
ValidData = false;
}
}
for (int i = 0; i < 4; i++) int Offset = (m_DataStartLoc & 3);
{ for (int i = 0; i < (4 - Offset); i++)
if ((WritePos + i)>= MemoryToDisplay) {
{ if (WritePos >= MemoryToDisplay)
break; {
} break;
m_DataValid[WritePos + i] = ValidData; }
if (ValidData) m_DataValid[WritePos + i] = ValidData;
{ if (ValidData)
m_CurrentData[WritePos + i] = word.UB[3 - i]; {
} m_CurrentData[WritePos + i] = word.UB[3 - (i + Offset)];
} }
} }
WritePos = 4 - Offset;
}
for (int count = 0 ; count < 16;count ++) for (DWORD Pos = ((m_DataStartLoc + 3) & ~3); Pos < (m_DataStartLoc + MemoryToDisplay); WritePos += 4, Pos += 4)
{ {
Insert_MemoryLineDump ( count ); MIPS_WORD word;
} bool ValidData = true;
if (m_DataVAddrr)
{
if (!g_MMU->LW_VAddr(Pos, word.UW))
{
ValidData = false;
}
}
else
{
if (!g_MMU->LW_PAddr(Pos, word.UW))
{
ValidData = false;
}
}
for (int i = 0; i < 4; i++)
{
if ((WritePos + i) >= MemoryToDisplay)
{
break;
}
m_DataValid[WritePos + i] = ValidData;
if (ValidData)
{
m_CurrentData[WritePos + i] = word.UB[3 - i];
}
}
}
for (int count = 0; count < 16; count++)
{
Insert_MemoryLineDump(count);
}
} }
#endif

View File

@ -11,48 +11,48 @@
#pragma once #pragma once
class CDebugMemoryView : class CDebugMemoryView :
public CDebugDialog<CDebugMemoryView> public CDebugDialog < CDebugMemoryView >
{ {
public:
enum { IDD = IDD_Debugger_Memory };
BEGIN_MSG_MAP_EX(CDebugMemoryView) CDebugMemoryView(CDebuggerUI * debugger);
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) virtual ~CDebugMemoryView(void);
COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked)
COMMAND_HANDLER_EX(IDC_ADDR_EDIT,EN_CHANGE,OnAddrChanged)
NOTIFY_HANDLER_EX(IDC_MEM_DETAILS, LCN_MODIFIED, OnMemoryModified)
MSG_WM_DESTROY(OnDestroy)
MSG_WM_VSCROLL(OnVScroll)
END_MSG_MAP()
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); void ShowAddress(DWORD Address, bool VAddr);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
void OnAddrChanged( UINT Code, int id, HWND ctl );
void OnVScroll(int request, short Pos, HWND ctrl );
LRESULT OnMemoryModified ( LPNMHDR lpNMHDR );
LRESULT OnDestroy ( void );
void Insert_MemoryLineDump ( int LineNumber ); private:
void RefreshMemory ( bool ResetCompare ); BEGIN_MSG_MAP_EX(CDebugMemoryView)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
enum { MemoryToDisplay = 0x100}; COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
COMMAND_HANDLER_EX(IDC_ADDR_EDIT, EN_CHANGE, OnAddrChanged)
NOTIFY_HANDLER_EX(IDC_MEM_DETAILS, LCN_MODIFIED, OnMemoryModified)
MSG_WM_DESTROY(OnDestroy)
MSG_WM_VSCROLL(OnVScroll)
END_MSG_MAP()
CEditNumber m_MemAddr; LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
CListCtrl * m_MemoryList; LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
void OnAddrChanged(UINT Code, int id, HWND ctl);
void OnVScroll(int request, short Pos, HWND ctrl);
LRESULT OnMemoryModified(LPNMHDR lpNMHDR);
LRESULT OnDestroy(void);
DWORD m_DataStartLoc; void Insert_MemoryLineDump(int LineNumber);
bool m_DataVAddrr; void RefreshMemory(bool ResetCompare);
BYTE m_CurrentData[MemoryToDisplay];
bool m_DataValid[MemoryToDisplay];
DWORD m_CompareStartLoc; enum { MemoryToDisplay = 0x100 };
bool m_CompareVAddrr;
BYTE m_CompareData[MemoryToDisplay];
bool m_CompareValid[MemoryToDisplay];
public:
enum { IDD = IDD_Debugger_Memory };
CDebugMemoryView(CDebugger * debugger); CEditNumber m_MemAddr;
virtual ~CDebugMemoryView(void); CListCtrl * m_MemoryList;
void ShowAddress (DWORD Address, bool VAddr); DWORD m_DataStartLoc;
bool m_DataVAddrr;
BYTE m_CurrentData[MemoryToDisplay];
bool m_DataValid[MemoryToDisplay];
DWORD m_CompareStartLoc;
bool m_CompareVAddrr;
BYTE m_CompareData[MemoryToDisplay];
bool m_CompareValid[MemoryToDisplay];
}; };

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,127 +9,141 @@
* * * *
****************************************************************************/ ****************************************************************************/
#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)
{ {
Debug_Reset(); g_Settings->UnregisterChangeCB(GameRunning_InReset,this,(CSettings::SettingChangedFunc)GameReset);
Debug_Reset();
} }
void CDebugger::Debug_Reset ( void ) void CDebuggerUI::GameReset ( CDebuggerUI * _this )
{ {
if (m_MemoryDump) if (!g_Settings->LoadBool(GameRunning_InReset))
{
m_MemoryDump->HideWindow();
delete m_MemoryDump;
m_MemoryDump = NULL;
}
if (m_MemoryView)
{
m_MemoryView->HideWindow();
delete m_MemoryView;
m_MemoryView = NULL;
}
if (m_MemorySearch)
{
m_MemorySearch->HideWindow();
delete m_MemorySearch;
m_MemorySearch = NULL;
}
if (m_DebugTLB)
{
m_DebugTLB->HideWindow();
delete m_DebugTLB;
m_DebugTLB = NULL;
}
}
void CDebugger::Debug_ShowMemoryDump()
{
if (g_MMU == NULL)
{ {
return; return;
} }
if (m_MemoryDump == NULL) _this->Debug_Reset();
{
m_MemoryDump = new CDumpMemory(this);
}
if (m_MemoryDump)
{
m_MemoryDump->ShowWindow();
}
} }
void CDebugger::Debug_ShowMemoryWindow ( void ) void CDebuggerUI::Debug_Reset ( void )
{ {
if (g_MMU == NULL) if (m_MemoryDump)
{ {
return; m_MemoryDump->HideWindow();
} delete m_MemoryDump;
if (m_MemoryView == NULL) m_MemoryDump = NULL;
{ }
m_MemoryView = new CDebugMemoryView(this); if (m_MemoryView)
} {
if (m_MemoryView) m_MemoryView->HideWindow();
{ delete m_MemoryView;
m_MemoryView->ShowWindow(); m_MemoryView = NULL;
} }
if (m_MemorySearch)
{
m_MemorySearch->HideWindow();
delete m_MemorySearch;
m_MemorySearch = NULL;
}
if (m_DebugTLB)
{
m_DebugTLB->HideWindow();
delete m_DebugTLB;
m_DebugTLB = NULL;
}
} }
void CDebugger::Debug_ShowMemoryLocation ( DWORD Address, bool VAddr ) void CDebuggerUI::Debug_ShowMemoryDump()
{ {
Debug_ShowMemoryWindow(); if (g_MMU == NULL)
if (m_MemoryView) {
{ return;
m_MemoryView->ShowAddress(Address,VAddr); }
} if (m_MemoryDump == NULL)
{
m_MemoryDump = new CDumpMemory(this);
}
if (m_MemoryDump)
{
m_MemoryDump->ShowWindow();
}
} }
void CDebugger::Debug_ShowTLBWindow (void) void CDebuggerUI::Debug_ShowMemoryWindow ( void )
{ {
if (g_MMU == NULL) if (g_MMU == NULL)
{ {
return; return;
} }
if (m_DebugTLB == NULL) if (m_MemoryView == NULL)
{ {
m_DebugTLB = new CDebugTlb(this); m_MemoryView = new CDebugMemoryView(this);
} }
if (m_DebugTLB) if (m_MemoryView)
{ {
m_DebugTLB->ShowWindow(); m_MemoryView->ShowWindow();
} }
} }
void CDebugger::Debug_RefreshTLBWindow(void) void CDebuggerUI::Debug_ShowMemoryLocation ( uint32_t Address, bool VAddr )
{ {
if (m_DebugTLB) Debug_ShowMemoryWindow();
{ if (m_MemoryView)
m_DebugTLB->RefreshTLBWindow(); {
} m_MemoryView->ShowAddress(Address,VAddr);
}
} }
void CDebugger::Debug_ShowMemorySearch() void CDebuggerUI::Debug_ShowTLBWindow (void)
{ {
if (m_MemorySearch == NULL) if (g_MMU == NULL)
{ {
m_MemorySearch = new CDebugMemorySearch(this); return;
} }
if (m_MemorySearch) if (m_DebugTLB == NULL)
{ {
m_MemorySearch->ShowWindow(); m_DebugTLB = new CDebugTlb(this);
} }
if (m_DebugTLB)
{
m_DebugTLB->ShowWindow();
}
} }
#endif
void CDebuggerUI::Debug_RefreshTLBWindow(void)
{
if (m_DebugTLB)
{
m_DebugTLB->RefreshTLBWindow();
}
}
void CDebuggerUI::Debug_ShowMemorySearch()
{
if (m_MemorySearch == NULL)
{
m_MemorySearch = new CDebugMemorySearch(this);
}
if (m_MemorySearch)
{
m_MemorySearch->ShowWindow();
}
}
void CDebuggerUI::TLBChanged()
{
Debug_RefreshTLBWindow();
}

View File

@ -13,25 +13,35 @@
class CDumpMemory; class CDumpMemory;
class CDebugMemoryView; class CDebugMemoryView;
class CDebugMemorySearch; class CDebugMemorySearch;
class CDebugTlb;
class CDebugger __interface CDebugger
{ {
CDumpMemory * m_MemoryDump; virtual void TLBChanged ( void ) = 0;
CDebugMemoryView * m_MemoryView; };
CDebugMemorySearch * m_MemorySearch;
CDebugTlb * m_DebugTLB; class CDebuggerUI :
public CDebugger
{
CDumpMemory * m_MemoryDump;
CDebugMemoryView * m_MemoryView;
CDebugMemorySearch * m_MemorySearch;
CDebugTlb * m_DebugTLB;
protected: protected:
CDebugger(); CDebuggerUI();
virtual ~CDebugger(); virtual ~CDebuggerUI();
public: void TLBChanged ( void );
void Debug_Reset ( void ); public:
void Debug_ShowMemoryDump ( void ); void Debug_Reset ( void );
void Debug_ShowMemoryWindow ( void ); void Debug_ShowMemoryDump ( void );
void Debug_ShowMemoryLocation ( DWORD Address, bool VAddr ); void Debug_ShowMemoryWindow ( void );
void Debug_ShowMemorySearch ( void ); void Debug_ShowMemoryLocation ( uint32_t Address, bool VAddr );
void Debug_ShowTLBWindow ( void ); void Debug_ShowMemorySearch ( void );
void Debug_RefreshTLBWindow ( void ); void Debug_ShowTLBWindow ( 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,40 +16,36 @@ 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
protected CDebugSettings,
public CDebugger
#else
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;
DWORD ThreadID; DWORD ThreadID;
}; };
CProfiling m_Profile; CProfiling m_Profile;
CCheats m_Cheats; CCheats m_Cheats;
bool m_EndEmulation; bool m_EndEmulation;
SAVE_CHIP_TYPE m_SaveUsing; SAVE_CHIP_TYPE m_SaveUsing;
//Methods
static bool RunFileImage(const char * FileLoc);
static void CloseSystem(void);
//Methods
static bool RunFileImage ( const char * FileLoc );
static void CloseSystem ( void );
void CloseCpu (); void CloseCpu ();
void ExternalEvent ( SystemEvent action ); //covers gui interacting and timers etc.. void ExternalEvent ( SystemEvent action ); //covers gui interacting and timers etc..
stdstr ChooseFileToOpen ( HWND hParent ); stdstr ChooseFileToOpen ( HWND hParent );

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,19 +10,23 @@
****************************************************************************/ ****************************************************************************/
#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,
//information - temp keys //information - temp keys
Info_ShortCutsChanged, Info_ShortCutsChanged,
//Support Files //Support Files
SupportFile_Settings, SupportFile_Settings,
SupportFile_SettingsDefault, SupportFile_SettingsDefault,
SupportFile_RomDatabase, SupportFile_RomDatabase,
SupportFile_RomDatabaseDefault, SupportFile_RomDatabaseDefault,
SupportFile_Glide64RDB, SupportFile_Glide64RDB,
@ -51,7 +55,7 @@ enum SettingID {
Setting_AutoFullscreen, Setting_AutoFullscreen,
Setting_CheckEmuRunning, Setting_CheckEmuRunning,
Setting_EraseGameDefaults, Setting_EraseGameDefaults,
Setting_AutoZipInstantSave, Setting_AutoZipInstantSave,
Setting_RememberCheats, Setting_RememberCheats,
Setting_LanguageDir, Setting_LanguageDir,
@ -154,7 +158,8 @@ enum SettingID {
GameRunning_InstantSaveFile, GameRunning_InstantSaveFile,
GameRunning_LimitFPS, GameRunning_LimitFPS,
GameRunning_ScreenHertz, GameRunning_ScreenHertz,
GameRunning_InReset,
//User Interface //User Interface
UserInterface_BasicMode, UserInterface_BasicMode,
UserInterface_ShowCPUPer, UserInterface_ShowCPUPer,
@ -248,14 +253,14 @@ enum SettingID {
Cheat_Range, Cheat_Range,
Cheat_RangeNotes, Cheat_RangeNotes,
FirstRSPDefaultSet, LastRSPDefaultSet = FirstRSPDefaultSet + MaxPluginSetting, FirstRSPDefaultSet, LastRSPDefaultSet = FirstRSPDefaultSet + MaxPluginSetting,
FirstRSPSettings, LastRSPSettings = FirstRSPSettings + MaxPluginSetting, FirstRSPSettings, LastRSPSettings = FirstRSPSettings + MaxPluginSetting,
FirstGfxDefaultSet, LastGfxDefaultSet = FirstGfxDefaultSet + MaxPluginSetting, FirstGfxDefaultSet, LastGfxDefaultSet = FirstGfxDefaultSet + MaxPluginSetting,
FirstGfxSettings, LastGfxSettings = FirstGfxSettings + MaxPluginSetting, FirstGfxSettings, LastGfxSettings = FirstGfxSettings + MaxPluginSetting,
FirstAudioDefaultSet, LastAudioDefaultSet = FirstAudioDefaultSet + MaxPluginSetting, FirstAudioDefaultSet, LastAudioDefaultSet = FirstAudioDefaultSet + MaxPluginSetting,
FirstAudioSettings, LastAudioSettings = FirstAudioSettings + MaxPluginSetting, FirstAudioSettings, LastAudioSettings = FirstAudioSettings + MaxPluginSetting,
FirstCtrlDefaultSet, LastCtrlDefaultSet = FirstCtrlDefaultSet + MaxPluginSetting, FirstCtrlDefaultSet, LastCtrlDefaultSet = FirstCtrlDefaultSet + MaxPluginSetting,
FirstCtrlSettings, LastCtrlSettings = FirstCtrlSettings + MaxPluginSetting, FirstCtrlSettings, LastCtrlSettings = FirstCtrlSettings + MaxPluginSetting,
}; };
#include "Support.h" #include "Support.h"

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,24 +10,27 @@
****************************************************************************/ ****************************************************************************/
#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_MAKE_FOCUS = WM_USER + 17, WM_HIDE_CUROSR = WM_USER + 10,
WM_RESET_PLUGIN = WM_USER + 18, WM_MAKE_FOCUS = WM_USER + 17,
WM_BORWSER_TOP = WM_USER + 40, WM_RESET_PLUGIN = WM_USER + 18,
WM_BORWSER_TOP = WM_USER + 40,
}; };
class CMainGui : class CMainGui :
public CRomBrowser, public CRomBrowser,
private CGuiSettings public CDebuggerUI,
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;