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

View File

@ -10,11 +10,10 @@
****************************************************************************/
#include "stdafx.h"
#ifdef WINDOWS_UI
#include "Debugger UI.h"
CDumpMemory::CDumpMemory(CDebugger * debugger) :
CDebugDialog<CDumpMemory>(debugger)
CDumpMemory::CDumpMemory(CDebuggerUI * debugger) :
CDebugDialog<CDumpMemory>(debugger)
{
}
@ -24,575 +23,135 @@ CDumpMemory::~CDumpMemory()
LRESULT CDumpMemory::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
m_StartAddress.Attach(GetDlgItem(IDC_E_START_ADDR));
m_EndAddress.Attach(GetDlgItem(IDC_E_END_ADDR));
m_PC.Attach(GetDlgItem(IDC_E_ALT_PC));
m_StartAddress.Attach(GetDlgItem(IDC_E_START_ADDR));
m_EndAddress.Attach(GetDlgItem(IDC_E_END_ADDR));
m_PC.Attach(GetDlgItem(IDC_E_ALT_PC));
m_StartAddress.SetDisplayType(CEditNumber::DisplayHex);
m_EndAddress.SetDisplayType(CEditNumber::DisplayHex);
m_PC.SetDisplayType(CEditNumber::DisplayHex);
m_StartAddress.SetDisplayType(CEditNumber::DisplayHex);
m_EndAddress.SetDisplayType(CEditNumber::DisplayHex);
m_PC.SetDisplayType(CEditNumber::DisplayHex);
m_StartAddress.SetValue(0x80000000,true,true);
m_EndAddress.SetValue(0x803FFFF0,true,true);
m_PC.SetValue(0x80000000);
HWND hFormatList = GetDlgItem(IDC_FORMAT);
int pos = ::SendMessage(hFormatList,CB_ADDSTRING,(WPARAM)0,(LPARAM)"TEXT - Disassembly + PC");
::SendMessage(hFormatList,CB_SETITEMDATA,(WPARAM)pos,(LPARAM)DisassemblyWithPC);
::SendMessage(hFormatList,CB_SETCURSEL,(WPARAM)0,(LPARAM)0);
m_StartAddress.SetValue(0x80000000, true, true);
m_EndAddress.SetValue(0x803FFFF0, true, true);
m_PC.SetValue(0x80000000);
HWND hFormatList = GetDlgItem(IDC_FORMAT);
int pos = ::SendMessage(hFormatList, CB_ADDSTRING, (WPARAM)0, (LPARAM)"TEXT - Disassembly + PC");
::SendMessage(hFormatList, CB_SETITEMDATA, (WPARAM)pos, (LPARAM)DisassemblyWithPC);
::SendMessage(hFormatList, CB_SETCURSEL, (WPARAM)0, (LPARAM)0);
WindowCreated();
return TRUE;
WindowCreated();
return TRUE;
}
LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
switch(wID)
{
case IDCANCEL:
EndDialog(0);
break;
case IDC_BTN_CHOOSE_FILE:
{
char FileName[_MAX_PATH],Directory[_MAX_PATH];
OPENFILENAME openfilename;
switch (wID)
{
case IDCANCEL:
EndDialog(0);
break;
case IDC_BTN_CHOOSE_FILE:
{
char FileName[_MAX_PATH], Directory[_MAX_PATH];
OPENFILENAME openfilename;
memset(&FileName, 0, sizeof(FileName));
memset(&openfilename, 0, sizeof(openfilename));
strcpy(Directory,CPath(CPath::MODULE_DIRECTORY));
openfilename.lStructSize = sizeof( openfilename );
openfilename.hwndOwner = m_hWnd;
openfilename.lpstrFilter = "Text file (*.txt)\0*.txt;\0All files (*.*)\0*.*\0";
openfilename.lpstrFile = FileName;
openfilename.lpstrInitialDir = Directory;
openfilename.nMaxFile = MAX_PATH;
openfilename.Flags = OFN_HIDEREADONLY;
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory);
if (GetOpenFileName (&openfilename))
{
char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
_splitpath( FileName, drive, dir, fname, ext );
if (strlen(ext) == 0)
{
strcat(FileName,".txt");
}
SetDlgItemText(IDC_FILENAME,FileName);
}
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
}
break;
case IDOK:
{
TCHAR FileName[MAX_PATH];
int CurrentFormatSel = SendDlgItemMessage(IDC_FORMAT,CB_GETCURSEL,0,0);
DumpFormat Format = (DumpFormat)SendDlgItemMessage(IDC_FORMAT,CB_GETITEMDATA,CurrentFormatSel,0);
DWORD StartPC =m_StartAddress.GetValue();
DWORD EndPC = m_EndAddress.GetValue();
DWORD DumpPC = m_PC.GetValue();
GetDlgItemText(IDC_FILENAME,FileName,sizeof(FileName));
if (strlen(FileName) == 0)
{
g_Notify->DisplayError(L"Please Choose target file");
::SetFocus(GetDlgItem(IDC_FILENAME));
return false;
}
if (SendDlgItemMessage(IDC_USE_ALT_PC,BM_GETSTATE, 0,0) != BST_CHECKED)
{
DumpPC = g_Reg->m_PROGRAM_COUNTER;
}
//disable buttons
::EnableWindow(GetDlgItem(IDC_E_START_ADDR),FALSE);
::EnableWindow(GetDlgItem(IDC_E_END_ADDR),FALSE);
::EnableWindow(GetDlgItem(IDC_E_ALT_PC),FALSE);
::EnableWindow(GetDlgItem(IDC_USE_ALT_PC),FALSE);
::EnableWindow(GetDlgItem(IDC_FILENAME),FALSE);
::EnableWindow(GetDlgItem(IDC_BTN_CHOOSE_FILE),FALSE);
::EnableWindow(GetDlgItem(IDC_FORMAT),FALSE);
::EnableWindow(GetDlgItem(IDOK),FALSE);
::EnableWindow(GetDlgItem(IDCANCEL),FALSE);
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory);
if (!DumpMemory(FileName,Format,StartPC,EndPC,DumpPC))
{
//enable buttons
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
return false;
}
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
}
EndDialog(0);
break;
}
return FALSE;
memset(&FileName, 0, sizeof(FileName));
memset(&openfilename, 0, sizeof(openfilename));
strcpy(Directory, CPath(CPath::MODULE_DIRECTORY));
openfilename.lStructSize = sizeof(openfilename);
openfilename.hwndOwner = m_hWnd;
openfilename.lpstrFilter = "Text file (*.txt)\0*.txt;\0All files (*.*)\0*.*\0";
openfilename.lpstrFile = FileName;
openfilename.lpstrInitialDir = Directory;
openfilename.nMaxFile = MAX_PATH;
openfilename.Flags = OFN_HIDEREADONLY;
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory);
if (GetOpenFileName(&openfilename))
{
char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
_splitpath(FileName, drive, dir, fname, ext);
if (strlen(ext) == 0)
{
strcat(FileName, ".txt");
}
SetDlgItemText(IDC_FILENAME, FileName);
}
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
}
break;
case IDOK:
{
TCHAR FileName[MAX_PATH];
int CurrentFormatSel = SendDlgItemMessage(IDC_FORMAT, CB_GETCURSEL, 0, 0);
DumpFormat Format = (DumpFormat)SendDlgItemMessage(IDC_FORMAT, CB_GETITEMDATA, CurrentFormatSel, 0);
DWORD StartPC = m_StartAddress.GetValue();
DWORD EndPC = m_EndAddress.GetValue();
DWORD DumpPC = m_PC.GetValue();
GetDlgItemText(IDC_FILENAME, FileName, sizeof(FileName));
if (strlen(FileName) == 0)
{
g_Notify->DisplayError(L"Please Choose target file");
::SetFocus(GetDlgItem(IDC_FILENAME));
return false;
}
if (SendDlgItemMessage(IDC_USE_ALT_PC, BM_GETSTATE, 0, 0) != BST_CHECKED)
{
DumpPC = g_Reg->m_PROGRAM_COUNTER;
}
//disable buttons
::EnableWindow(GetDlgItem(IDC_E_START_ADDR), FALSE);
::EnableWindow(GetDlgItem(IDC_E_END_ADDR), FALSE);
::EnableWindow(GetDlgItem(IDC_E_ALT_PC), FALSE);
::EnableWindow(GetDlgItem(IDC_USE_ALT_PC), FALSE);
::EnableWindow(GetDlgItem(IDC_FILENAME), FALSE);
::EnableWindow(GetDlgItem(IDC_BTN_CHOOSE_FILE), FALSE);
::EnableWindow(GetDlgItem(IDC_FORMAT), FALSE);
::EnableWindow(GetDlgItem(IDOK), FALSE);
::EnableWindow(GetDlgItem(IDCANCEL), FALSE);
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory);
if (!DumpMemory(FileName, Format, StartPC, EndPC, DumpPC))
{
//enable buttons
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
return false;
}
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
}
EndDialog(0);
break;
}
return FALSE;
}
//#include "..\\..\\User Interface.h"
//#include "..\\..\\N64 System.h"
//#include <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*/ )
bool CDumpMemory::DumpMemory(LPCSTR FileName, DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD /*DumpPC*/)
{
switch (Format)
{
case DisassemblyWithPC:
{
CLog LogFile;
if (!LogFile.Open(FileName))
{
g_Notify->DisplayError(stdstr_f("Failed to open\n%s",FileName).ToUTF16().c_str());
return false;
}
LogFile.SetFlush(false);
LogFile.SetTruncateFile(false);
g_Notify->BreakPoint(__FILEW__,__LINE__);
switch (Format)
{
case DisassemblyWithPC:
{
CLog LogFile;
if (!LogFile.Open(FileName))
{
g_Notify->DisplayError(stdstr_f("Failed to open\n%s", FileName).ToUTF16().c_str());
return false;
}
LogFile.SetFlush(false);
LogFile.SetTruncateFile(false);
g_Notify->BreakPoint(__FILEW__, __LINE__);
#ifdef tofix
char Command[200];
for (COpcode OpCode(StartPC); OpCode.PC() < EndPC; OpCode.Next())
{
const char * szOpName = OpCode.OpcodeName();
OpCode.OpcodeParam(Command);
LogFile.LogF("%X: %-15s%s\r\n",OpCode.PC(),szOpName,Command);
}
char Command[200];
for (COpcode OpCode(StartPC); OpCode.PC() < EndPC; OpCode.Next())
{
const char * szOpName = OpCode.OpcodeName();
OpCode.OpcodeParam(Command);
LogFile.LogF("%X: %-15s%s\r\n",OpCode.PC(),szOpName,Command);
}
#endif
m_StartAddress.SetValue(StartPC,true,true);
m_EndAddress.SetValue(EndPC,true,true);
return true;
}
break;
}
return false;
m_StartAddress.SetValue(StartPC, true, true);
m_EndAddress.SetValue(EndPC, true, true);
return true;
}
break;
}
return false;
}
//
//CDumpMemory::CDumpMemory(CMipsMemory * MMU) :
// m_Window(NULL), g_MMU(MMU)
//{
//}
//
//CDumpMemory::~CDumpMemory()
//{
//}
//
//void CDumpMemory::DisplayDump(HWND & hParent)
//{
// DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Cheats_DumpMemory),
// (HWND)hParent, (DLGPROC)WinProc,(LPARAM)this);
//}
//
//DWORD CDumpMemory::AsciiToHex (const char * HexValue)
//{
// DWORD Count, Finish, Value = 0;
//
// Finish = strlen(HexValue);
// if (Finish > 8 )
// {
// Finish = 8;
// }
//
// for (Count = 0; Count < Finish; Count++)
// {
// Value = (Value << 4);
// switch ( HexValue[Count] )
// {
// case '0': break;
// case '1': Value += 1; break;
// case '2': Value += 2; break;
// case '3': Value += 3; break;
// case '4': Value += 4; break;
// case '5': Value += 5; break;
// case '6': Value += 6; break;
// case '7': Value += 7; break;
// case '8': Value += 8; break;
// case '9': Value += 9; break;
// case 'A': Value += 10; break;
// case 'a': Value += 10; break;
// case 'B': Value += 11; break;
// case 'b': Value += 11; break;
// case 'C': Value += 12; break;
// case 'c': Value += 12; break;
// case 'D': Value += 13; break;
// case 'd': Value += 13; break;
// case 'E': Value += 14; break;
// case 'e': Value += 14; break;
// case 'F': Value += 15; break;
// case 'f': Value += 15; break;
// default:
// Value = (Value >> 4);
// Count = Finish;
// }
// }
// return Value;
//}
//
//int CALLBACK CDumpMemory::WinProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam)
//{
// switch (uMsg)
// {
// case WM_INITDIALOG:
// {
// CDumpMemory * _this = (CDumpMemory *)lParam;
// SetProp(hDlg,"Class",_this);
// _this->m_Window = hDlg;
// SetDlgItemText(hDlg,IDC_E_START_ADDR,stdstr("0x%X",m_StartAddress).c_str());
// SetDlgItemText(hDlg,IDC_E_END_ADDR,stdstr("0x%X",m_EndAddress).c_str());
// SetDlgItemText(hDlg,IDC_E_ALT_PC,"0x80000000");
//
// HWND hFormatList = GetDlgItem(hDlg,IDC_FORMAT);
// int pos = SendMessage(hFormatList,CB_ADDSTRING,(WPARAM)0,(LPARAM)"TEXT - Disassembly + PC");
// SendMessage(hFormatList,CB_SETITEMDATA,(WPARAM)pos,(LPARAM)DisassemblyWithPC);
// SendMessage(hFormatList,CB_SETCURSEL,(WPARAM)0,(LPARAM)0);
//
// }
// break;
// case WM_COMMAND:
// switch (LOWORD(wParam))
// {
// case IDC_E_START_ADDR:
// case IDC_E_END_ADDR:
// case IDC_E_ALT_PC:
// if (HIWORD(wParam) == EN_UPDATE)
// {
// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class");
//
// TCHAR szTmp[20], szTmp2[20];
// DWORD Value;
//
// GetDlgItemText(hDlg,LOWORD(wParam),szTmp,sizeof(szTmp));
// Value = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp);
// //if (Value > Stop)
// //{
// // Value = Stop;
// //}
// //if (Value < Start)
// //{
// // Value = Start;
// //}
// sprintf(szTmp2,"0x%X",Value);
// if (strcmp(szTmp,szTmp2) != 0)
// {
// SetDlgItemText(hDlg,LOWORD(wParam),szTmp2);
// if (_this->SelStop == 0) { _this->SelStop = strlen(szTmp2); _this->SelStart = _this->SelStop; }
// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_SETSEL,(WPARAM)_this->SelStart,(LPARAM)_this->SelStop);
// }
// else
// {
// WORD NewSelStart, NewSelStop;
// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_GETSEL,(WPARAM)&NewSelStart,(LPARAM)&NewSelStop);
// if (NewSelStart != 0)
// {
// _this->SelStart = NewSelStart; _this->SelStop = NewSelStop;
// }
// }
// }
// break;
// case IDC_BTN_CHOOSE_FILE:
// {
// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class");
//
// OPENFILENAME openfilename;
// char FileName[_MAX_PATH],Directory[_MAX_PATH];
//
// memset(&FileName, 0, sizeof(FileName));
// memset(&openfilename, 0, sizeof(openfilename));
//
// strcpy(Directory,g_Settings->LoadStringVal(ApplicationDir).c_str());
//
// openfilename.lStructSize = sizeof( openfilename );
// openfilename.hwndOwner = hDlg;
// openfilename.lpstrFilter = "Text file (*.txt)\0*.txt;\0All files (*.*)\0*.*\0";
// openfilename.lpstrFile = FileName;
// openfilename.lpstrInitialDir = Directory;
// openfilename.nMaxFile = MAX_PATH;
// openfilename.Flags = OFN_HIDEREADONLY;
//
// if (GetOpenFileName (&openfilename))
// {
// char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
//
// _splitpath( FileName, drive, dir, fname, ext );
// if (strlen(ext) == 0)
// {
// strcat(FileName,".txt");
// }
// SetDlgItemText(hDlg,IDC_FILENAME,FileName);
// }
// }
// break;
// case IDCANCEL:
// RemoveProp(hDlg,"Class");
// EndDialog(hDlg,0);
// break;
// case IDOK:
// {
// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class");
// TCHAR szTmp[20], FileName[MAX_PATH];
//
// int CurrentFormatSel = SendDlgItemMessage(hDlg,IDC_FORMAT,CB_GETCURSEL,0,0);
// DumpFormat Format = (DumpFormat)SendDlgItemMessage(hDlg,IDC_FORMAT,CB_GETITEMDATA,CurrentFormatSel,0);
//
// GetDlgItemText(hDlg,IDC_E_START_ADDR,szTmp,sizeof(szTmp));
// DWORD StartPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp);
// GetDlgItemText(hDlg,IDC_E_END_ADDR,szTmp,sizeof(szTmp));
// DWORD EndPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp);
// GetDlgItemText(hDlg,IDC_E_ALT_PC,szTmp,sizeof(szTmp));
// DWORD DumpPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp);
// GetDlgItemText(hDlg,IDC_FILENAME,FileName,sizeof(FileName));
//
// if (strlen(FileName) == 0)
// {
// g_Notify->DisplayError(L"Please Choose target file");
// SetFocus(GetDlgItem(hDlg,IDC_FILENAME));
// return false;
// }
//
// if (SendDlgItemMessage(hDlg,IDC_USE_ALT_PC,BM_GETSTATE, 0,0) != BST_CHECKED)
// {
// DumpPC = _this->g_MMU->SystemRegisters()->PROGRAM_COUNTER;
// }
// //disable buttons
// EnableWindow(GetDlgItem(hDlg,IDC_E_START_ADDR),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_E_END_ADDR),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_E_ALT_PC),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_USE_ALT_PC),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_FILENAME),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_BTN_CHOOSE_FILE),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDC_FORMAT),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDOK),FALSE);
// EnableWindow(GetDlgItem(hDlg,IDCANCEL),FALSE);
// if (!_this->DumpMemory(FileName,Format,StartPC,EndPC,DumpPC))
// {
// //enable buttons
// return false;
// }
// }
// RemoveProp(hDlg,"Class");
// EndDialog(hDlg,0);
// break;
// }
// break;
// default:
// return false;
// }
// return true;
//}
//
//bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD DumpPC )
//{
// switch (Format)
// {
// case DisassemblyWithPC:
// {
// CLog LogFile(FileName);
// if (!LogFile.IsOpen())
// {
// g_Notify->DisplayError(L"Failed to open\n%s",FileName);
// return false;
// }
//
// for (COpcode OpCode(g_MMU,StartPC); OpCode.PC() < EndPC; OpCode.Next())
// {
// LogFile.Log("%X: %s",OpCode.PC(),OpCode.Name().c_str());
// }
// m_StartAddress = StartPC;
// m_EndAddress = EndPC;
// return true;
// }
// break;
// }
// return false;
//}
#endif

View File

@ -11,33 +11,33 @@
#pragma once
class CDumpMemory :
public CDebugDialog<CDumpMemory>
public CDebugDialog < CDumpMemory >
{
public:
enum { IDD = IDD_Cheats_DumpMemory };
public:
enum { IDD = IDD_Cheats_DumpMemory };
CDumpMemory(CDebugger * debugger);
virtual ~CDumpMemory(void);
CDumpMemory(CDebuggerUI * debugger);
virtual ~CDumpMemory(void);
private:
CDumpMemory(void); // Disable default constructor
CDumpMemory(const CDumpMemory&); // Disable copy constructor
CDumpMemory& operator=(const CDumpMemory&); // Disable assignment
CDumpMemory(void); // Disable default constructor
CDumpMemory(const CDumpMemory&); // Disable copy constructor
CDumpMemory& operator=(const CDumpMemory&); // Disable assignment
enum DumpFormat
{
DisassemblyWithPC
};
enum DumpFormat
{
DisassemblyWithPC
};
BEGIN_MSG_MAP_EX(CDumpMemory)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked)
END_MSG_MAP()
BEGIN_MSG_MAP_EX(CDumpMemory)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
END_MSG_MAP()
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
bool DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD DumpPC );
bool DumpMemory(LPCSTR FileName, DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD DumpPC);
CEditNumber m_StartAddress, m_EndAddress, m_PC;
};

View File

@ -11,59 +11,59 @@
#pragma once
class CDebugMemorySearch :
public CDebugDialog<CDebugMemorySearch>
public CDebugDialog < CDebugMemorySearch >
{
public:
enum { IDD = IDD_Debugger_Search };
public:
enum { IDD = IDD_Debugger_Search };
CDebugMemorySearch(CDebugger * debugger);
virtual ~CDebugMemorySearch(void);
CDebugMemorySearch(CDebuggerUI * debugger);
virtual ~CDebugMemorySearch(void);
private:
CDebugMemorySearch(void); // Disable default constructor
CDebugMemorySearch(const CDebugMemorySearch&); // Disable copy constructor
CDebugMemorySearch& operator=(const CDebugMemorySearch&); // Disable assignment
CDebugMemorySearch(void); // Disable default constructor
CDebugMemorySearch(const CDebugMemorySearch&); // Disable copy constructor
CDebugMemorySearch& operator=(const CDebugMemorySearch&); // Disable assignment
enum MemorySize
{
_8Bit,
_16Bit,
_32Bit,
};
enum MemorySize
{
_8Bit,
_16Bit,
_32Bit,
};
//Searching for value
enum SearchMemChangeState
{
SearchChangeState_Reset,
SearchChangeState_Changed,
SearchChangeState_Unchanged,
SearchChangeState_Greater,
SearchChangeState_Lessthan,
};
//Searching for value
enum SearchMemChangeState
{
SearchChangeState_Reset,
SearchChangeState_Changed,
SearchChangeState_Unchanged,
SearchChangeState_Greater,
SearchChangeState_Lessthan,
};
struct SearchResultItem
{
DWORD PAddr;
DWORD Value;
};
struct SearchResultItem
{
DWORD PAddr;
DWORD Value;
};
typedef std::vector<SearchResultItem> SearchResult;
typedef std::vector<SearchResultItem> SearchResult;
BEGIN_MSG_MAP_EX(CDebugMemorySearch)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked)
NOTIFY_HANDLER_EX(IDC_LST_RESULTS,NM_RCLICK,OnResultRClick)
BEGIN_MSG_MAP_EX(CDebugMemorySearch)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
NOTIFY_HANDLER_EX(IDC_LST_RESULTS, NM_RCLICK, OnResultRClick)
END_MSG_MAP()
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
LRESULT OnResultRClick ( LPNMHDR lpnmh );
LRESULT OnResultRClick(LPNMHDR lpnmh);
void EnableUnknownOptions ( bool Enable );
void EnableValueOptions ( bool Enable );
void EnableTextOptions ( bool Enable );
void EnableJalOptions ( bool Enable );
void AddAlignmentOptions ( CComboBox & ctrl );
void EnableUnknownOptions(bool Enable);
void EnableValueOptions(bool Enable);
void EnableTextOptions(bool Enable);
void EnableJalOptions(bool Enable);
void AddAlignmentOptions(CComboBox & ctrl);
CEditNumber m_PAddrStart, m_SearchLen, m_SearchValue, m_MaxSearch;
CComboBox m_UnknownOptions, m_ValueSize, m_UnknownSize;
@ -75,12 +75,12 @@ private:
BYTE * m_MemoryState;
DWORD m_MemoryStateSize;
void FixUnknownOptions ( bool Reset );
void SearchForUnknown ( void );
void SearchForValue ( void );
void SearchForText ( void );
void Reset ( void );
bool SearchSetBaseForChanges ( void );
bool SearchForChanges ( SearchMemChangeState SearchType, MemorySize Size, DWORD &StartAddress, DWORD &Len, DWORD &OldValue, DWORD &NewValue );
bool SearchForValue ( DWORD Value, MemorySize Size, DWORD &StartAddress, DWORD &Len );
void FixUnknownOptions(bool Reset);
void SearchForUnknown(void);
void SearchForValue(void);
void SearchForText(void);
void Reset(void);
bool SearchSetBaseForChanges(void);
bool SearchForChanges(SearchMemChangeState SearchType, MemorySize Size, DWORD &StartAddress, DWORD &Len, DWORD &OldValue, DWORD &NewValue);
bool SearchForValue(DWORD Value, MemorySize Size, DWORD &StartAddress, DWORD &Len);
};

View File

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

View File

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

View File

@ -10,18 +10,17 @@
****************************************************************************/
#include "stdafx.h"
#ifdef WINDOWS_UI
#include "Debugger UI.h"
CDebugMemoryView::CDebugMemoryView(CDebugger * debugger) :
CDebugDialog<CDebugMemoryView>(debugger),
m_MemoryList(NULL)
CDebugMemoryView::CDebugMemoryView(CDebuggerUI * debugger) :
CDebugDialog<CDebugMemoryView>(debugger),
m_MemoryList(NULL)
{
if (m_MemoryList== NULL)
{
m_MemoryList = new CListCtrl;
m_MemoryList->RegisterClass();
}
if (m_MemoryList== NULL)
{
m_MemoryList = new CListCtrl;
m_MemoryList->RegisterClass();
}
}
CDebugMemoryView::~CDebugMemoryView()
@ -30,446 +29,444 @@ CDebugMemoryView::~CDebugMemoryView()
LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
m_DataStartLoc = (DWORD)-1;
m_CompareStartLoc = (DWORD)-1;
memset(m_CompareData,0,sizeof(m_CompareData));
memset(m_CompareValid,0,sizeof(m_CompareValid));
m_DataStartLoc = (DWORD)-1;
m_CompareStartLoc = (DWORD)-1;
memset(m_CompareData, 0, sizeof(m_CompareData));
memset(m_CompareValid, 0, sizeof(m_CompareValid));
HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR);
if (hScrlBar)
{
SCROLLINFO si;
HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR);
if (hScrlBar)
{
SCROLLINFO si;
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
si.nMin = 0;
si.nMax = 0xFFFF;
si.nPos = 0x8000;
si.nPage = 100;
::SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE);
}
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
si.nMin = 0;
si.nMax = 0xFFFF;
si.nPos = 0x8000;
si.nPage = 100;
::SetScrollInfo(hScrlBar, SB_CTL, &si, TRUE);
}
m_MemAddr.Attach(GetDlgItem(IDC_ADDR_EDIT));
m_MemAddr.SetDisplayType(CEditNumber::DisplayHex);
m_MemAddr.SetValue(0x80000000,true,true);
m_MemAddr.Attach(GetDlgItem(IDC_ADDR_EDIT));
m_MemAddr.SetDisplayType(CEditNumber::DisplayHex);
m_MemAddr.SetValue(0x80000000, true, true);
SendDlgItemMessage( IDC_CHK_VADDR, BM_SETCHECK, BST_CHECKED,0);
SendDlgItemMessage(IDC_CHK_VADDR, BM_SETCHECK, BST_CHECKED, 0);
if (m_MemoryList== NULL)
{
m_MemoryList = new CListCtrl;
m_MemoryList->RegisterClass();
}
m_MemoryList->SubclassWindow( GetDlgItem( IDC_MEM_DETAILS ) );
m_MemoryList->ShowHeader(false);
m_MemoryList->SetSortEnabled(FALSE);
m_MemoryList->AddColumn( _T( "Address" ), 90 );
m_MemoryList->AddColumn( _T( "1" ), 20 );
m_MemoryList->AddColumn( _T( "2" ), 20 );
m_MemoryList->AddColumn( _T( "3" ), 20 );
m_MemoryList->AddColumn( _T( "4" ), 20 );
m_MemoryList->AddColumn( _T( "-" ), 10 );
m_MemoryList->AddColumn( _T( "5" ), 20 );
m_MemoryList->AddColumn( _T( "6" ), 20 );
m_MemoryList->AddColumn( _T( "7" ), 20 );
m_MemoryList->AddColumn( _T( "8" ), 20 );
m_MemoryList->AddColumn( _T( "-" ), 10 );
m_MemoryList->AddColumn( _T( "9" ), 20 );
m_MemoryList->AddColumn( _T( "10" ), 20 );
m_MemoryList->AddColumn( _T( "11" ), 20 );
m_MemoryList->AddColumn( _T( "12" ), 20 );
m_MemoryList->AddColumn( _T( "-" ), 10 );
m_MemoryList->AddColumn( _T( "13" ), 20 );
m_MemoryList->AddColumn( _T( "14" ), 20 );
m_MemoryList->AddColumn( _T( "15" ), 20 );
m_MemoryList->AddColumn( _T( "16" ), 35 );
m_MemoryList->AddColumn( _T( "Memory Ascii" ), 140 );
::SetWindowLongPtr(m_MemoryList->m_hWnd, GWL_EXSTYLE, WS_EX_CLIENTEDGE);
RefreshMemory(false);
int height = m_MemoryList->GetTotalHeight();
RECT MemoryListRect = {0};
::GetClientRect(GetDlgItem( IDC_MEM_DETAILS ), &MemoryListRect);
if (m_MemoryList == NULL)
{
m_MemoryList = new CListCtrl;
m_MemoryList->RegisterClass();
}
m_MemoryList->SubclassWindow(GetDlgItem(IDC_MEM_DETAILS));
m_MemoryList->ShowHeader(false);
m_MemoryList->SetSortEnabled(FALSE);
m_MemoryList->AddColumn(_T("Address"), 90);
m_MemoryList->AddColumn(_T("1"), 20);
m_MemoryList->AddColumn(_T("2"), 20);
m_MemoryList->AddColumn(_T("3"), 20);
m_MemoryList->AddColumn(_T("4"), 20);
m_MemoryList->AddColumn(_T("-"), 10);
m_MemoryList->AddColumn(_T("5"), 20);
m_MemoryList->AddColumn(_T("6"), 20);
m_MemoryList->AddColumn(_T("7"), 20);
m_MemoryList->AddColumn(_T("8"), 20);
m_MemoryList->AddColumn(_T("-"), 10);
m_MemoryList->AddColumn(_T("9"), 20);
m_MemoryList->AddColumn(_T("10"), 20);
m_MemoryList->AddColumn(_T("11"), 20);
m_MemoryList->AddColumn(_T("12"), 20);
m_MemoryList->AddColumn(_T("-"), 10);
m_MemoryList->AddColumn(_T("13"), 20);
m_MemoryList->AddColumn(_T("14"), 20);
m_MemoryList->AddColumn(_T("15"), 20);
m_MemoryList->AddColumn(_T("16"), 35);
m_MemoryList->AddColumn(_T("Memory Ascii"), 140);
::SetWindowLongPtr(m_MemoryList->m_hWnd, GWL_EXSTYLE, WS_EX_CLIENTEDGE);
RefreshMemory(false);
int height = m_MemoryList->GetTotalHeight();
if (height > MemoryListRect.bottom)
{
RECT MemoryListWindow = {0};
GetWindowRect(&MemoryListWindow);
SetWindowPos(NULL,0,0,MemoryListWindow.right - MemoryListWindow.left,(MemoryListWindow.bottom - MemoryListWindow.top) + (height - MemoryListRect.bottom), SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOZORDER);
RECT MemoryListRect = { 0 };
::GetClientRect(GetDlgItem(IDC_MEM_DETAILS), &MemoryListRect);
RECT DlgItemRect = {0};
::GetWindowRect(GetDlgItem( IDC_BORDER ), &DlgItemRect);
::SetWindowPos(GetDlgItem( IDC_BORDER ), NULL,0,0,DlgItemRect.right - DlgItemRect.left,(DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
if (height > MemoryListRect.bottom)
{
RECT MemoryListWindow = { 0 };
GetWindowRect(&MemoryListWindow);
SetWindowPos(NULL, 0, 0, MemoryListWindow.right - MemoryListWindow.left, (MemoryListWindow.bottom - MemoryListWindow.top) + (height - MemoryListRect.bottom), SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOZORDER);
::GetWindowRect(GetDlgItem( IDC_MEM_DETAILS ), &DlgItemRect);
::SetWindowPos(GetDlgItem( IDC_MEM_DETAILS ), NULL,0,0,DlgItemRect.right - DlgItemRect.left,(DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
RECT DlgItemRect = { 0 };
::GetWindowRect(GetDlgItem(IDC_BORDER), &DlgItemRect);
::SetWindowPos(GetDlgItem(IDC_BORDER), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
::GetWindowRect(GetDlgItem( IDC_SCRL_BAR ), &DlgItemRect);
::SetWindowPos(GetDlgItem( IDC_SCRL_BAR ), NULL,0,0,DlgItemRect.right - DlgItemRect.left,(DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
}
WindowCreated();
return TRUE;
::GetWindowRect(GetDlgItem(IDC_MEM_DETAILS), &DlgItemRect);
::SetWindowPos(GetDlgItem(IDC_MEM_DETAILS), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
::GetWindowRect(GetDlgItem(IDC_SCRL_BAR), &DlgItemRect);
::SetWindowPos(GetDlgItem(IDC_SCRL_BAR), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
}
WindowCreated();
return TRUE;
}
LRESULT CDebugMemoryView::OnDestroy ( void )
LRESULT CDebugMemoryView::OnDestroy(void)
{
if (m_MemoryList)
{
m_MemoryList->UnsubclassWindow();
delete m_MemoryList;
m_MemoryList = NULL;
}
return 0;
if (m_MemoryList)
{
m_MemoryList->UnsubclassWindow();
delete m_MemoryList;
m_MemoryList = NULL;
}
return 0;
}
LRESULT CDebugMemoryView::OnClicked (WORD /*wNotifyCode*/, WORD wID, HWND , BOOL& /*bHandled*/)
LRESULT CDebugMemoryView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/)
{
switch (wID)
{
case IDC_REFRSH_MEM:
RefreshMemory(true);
break;
case IDC_CHK_VADDR:
RefreshMemory(false);
break;
case IDC_DUMP_MEM:
m_Debugger->Debug_ShowMemoryDump();
break;
case IDC_SEARCH_MEM:
m_Debugger->Debug_ShowMemorySearch();
break;
case IDCANCEL:
EndDialog(0);
break;
}
return FALSE;
switch (wID)
{
case IDC_REFRSH_MEM:
RefreshMemory(true);
break;
case IDC_CHK_VADDR:
RefreshMemory(false);
break;
case IDC_DUMP_MEM:
m_Debugger->Debug_ShowMemoryDump();
break;
case IDC_SEARCH_MEM:
m_Debugger->Debug_ShowMemorySearch();
break;
case IDCANCEL:
EndDialog(0);
break;
}
return FALSE;
}
LRESULT CDebugMemoryView::OnMemoryModified ( LPNMHDR lpNMHDR )
LRESULT CDebugMemoryView::OnMemoryModified(LPNMHDR lpNMHDR)
{
CListNotify *pListNotify = reinterpret_cast<CListNotify *>( lpNMHDR );
int LineNumber = pListNotify->m_nItem;
int Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 1));
if (pListNotify->m_nSubItem >= 6 && pListNotify->m_nSubItem < 10)
{
Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 2));
}
if (pListNotify->m_nSubItem >= 11 && pListNotify->m_nSubItem < 15)
{
Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 3));
}
if (pListNotify->m_nSubItem >= 16 && pListNotify->m_nSubItem < 20)
{
Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 4));
}
CListNotify *pListNotify = reinterpret_cast<CListNotify *>(lpNMHDR);
int LineNumber = pListNotify->m_nItem;
int Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 1));
if (pListNotify->m_nSubItem >= 6 && pListNotify->m_nSubItem < 10)
{
Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 2));
}
if (pListNotify->m_nSubItem >= 11 && pListNotify->m_nSubItem < 15)
{
Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 3));
}
if (pListNotify->m_nSubItem >= 16 && pListNotify->m_nSubItem < 20)
{
Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 4));
}
LPCSTR strValue = m_MemoryList->GetItemText(pListNotify->m_nItem,pListNotify->m_nSubItem);
int Finish = strlen(strValue);
if (Finish > 8)
{
Finish = 8;
}
DWORD Value = 0;
for (int i = 0; i < Finish; i++)
{
Value = (Value << 4);
if (strValue[i] <= '9' && strValue[i] >= '0')
{
Value |= strValue[i] - '0';
}
else if (strValue[i] <= 'f' && strValue[i] >= 'a')
{
Value |= strValue[i] - 'a' + 10;
}
else if (strValue[i] <= 'F' && strValue[i] >= 'A')
{
Value |= strValue[i] - 'A' + 10;
}
}
LPCSTR strValue = m_MemoryList->GetItemText(pListNotify->m_nItem, pListNotify->m_nSubItem);
int Finish = strlen(strValue);
if (Finish > 8)
{
Finish = 8;
}
DWORD Value = 0;
for (int i = 0; i < Finish; i++)
{
Value = (Value << 4);
if (strValue[i] <= '9' && strValue[i] >= '0')
{
Value |= strValue[i] - '0';
}
else if (strValue[i] <= 'f' && strValue[i] >= 'a')
{
Value |= strValue[i] - 'a' + 10;
}
else if (strValue[i] <= 'F' && strValue[i] >= 'A')
{
Value |= strValue[i] - 'A' + 10;
}
}
if (m_CurrentData[Pos] == Value)
{
return 0;
}
if (m_CurrentData[Pos] == Value)
{
return 0;
}
if (m_CompareStartLoc != m_DataStartLoc ||
m_CompareVAddrr != m_DataVAddrr)
{
// copy current data for change comparison
m_CompareStartLoc = m_DataStartLoc;
m_CompareVAddrr = m_DataVAddrr;
memcpy(m_CompareData,m_CurrentData,sizeof(m_CurrentData));
memcpy(m_CompareValid,m_DataValid,sizeof(m_CompareValid));
}
if (m_CompareStartLoc != m_DataStartLoc ||
m_CompareVAddrr != m_DataVAddrr)
{
// copy current data for change comparison
m_CompareStartLoc = m_DataStartLoc;
m_CompareVAddrr = m_DataVAddrr;
memcpy(m_CompareData, m_CurrentData, sizeof(m_CurrentData));
memcpy(m_CompareValid, m_DataValid, sizeof(m_CompareValid));
}
m_CompareData[Pos] = m_CurrentData[Pos];
m_CurrentData[Pos] = (BYTE)Value;
m_CompareData[Pos] = m_CurrentData[Pos];
m_CurrentData[Pos] = (BYTE)Value;
//sb
if ( m_DataVAddrr )
{
if (!g_MMU->SB_VAddr(m_DataStartLoc + Pos,(BYTE)Value))
{
WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos);
}
}
else
{
if (!g_MMU->SB_PAddr(m_DataStartLoc + Pos,(BYTE)Value))
{
WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos);
}
}
Insert_MemoryLineDump(LineNumber);
//sb
if (m_DataVAddrr)
{
if (!g_MMU->SB_VAddr(m_DataStartLoc + Pos, (BYTE)Value))
{
WriteTraceF(TraceError, __FUNCTION__ ": failed to store at %X", m_DataStartLoc + Pos);
}
}
else
{
if (!g_MMU->SB_PAddr(m_DataStartLoc + Pos, (BYTE)Value))
{
WriteTraceF(TraceError, __FUNCTION__ ": failed to store at %X", m_DataStartLoc + Pos);
}
}
Insert_MemoryLineDump(LineNumber);
return 0;
return 0;
}
void CDebugMemoryView::ShowAddress(DWORD Address, bool VAddr)
{
if (m_hWnd == NULL)
{
return;
}
if (m_hWnd == NULL)
{
return;
}
SendDlgItemMessage( IDC_CHK_VADDR, BM_SETCHECK, VAddr ? BST_CHECKED : BST_UNCHECKED,0);
m_MemAddr.SetValue(Address,true,true);
RefreshMemory (true);
SendDlgItemMessage(IDC_CHK_VADDR, BM_SETCHECK, VAddr ? BST_CHECKED : BST_UNCHECKED, 0);
m_MemAddr.SetValue(Address, true, true);
RefreshMemory(true);
}
void CDebugMemoryView::Insert_MemoryLineDump ( int LineNumber )
void CDebugMemoryView::Insert_MemoryLineDump(int LineNumber)
{
if (m_MemoryList == NULL || m_MemoryList->GetColumnCount() == 0)
{
return;
}
char Output[20], Hex[60], Ascii[20], AsciiAddOn[15];
sprintf(Output,"0x%08X",m_DataStartLoc + (LineNumber << 4));
if (m_MemoryList->GetItemCount() <= LineNumber)
{
HFONT hFont = (HFONT)GetStockObject(ANSI_FIXED_FONT);
m_MemoryList->AddItemAt( LineNumber, Output);
for (int i = 0; i < m_MemoryList->GetColumnCount(); i++)
{
m_MemoryList->SetItemFont( LineNumber, i, hFont );
if (i == 5 || i == 10 || i == 15)
{
m_MemoryList->SetItemText(LineNumber,i,"-");
}
}
}
else
{
if ( strcmp( Output, m_MemoryList->GetItemText(LineNumber, 0) ) != 0 )
{
m_MemoryList->SetItemText(LineNumber,0,Output);
}
}
if (m_MemoryList == NULL || m_MemoryList->GetColumnCount() == 0)
{
return;
}
char Output[20], Hex[60], Ascii[20], AsciiAddOn[15];
sprintf(Output, "0x%08X", m_DataStartLoc + (LineNumber << 4));
if (m_MemoryList->GetItemCount() <= LineNumber)
{
HFONT hFont = (HFONT)GetStockObject(ANSI_FIXED_FONT);
m_MemoryList->AddItemAt(LineNumber, Output);
for (int i = 0; i < m_MemoryList->GetColumnCount(); i++)
{
m_MemoryList->SetItemFont(LineNumber, i, hFont);
if (i == 5 || i == 10 || i == 15)
{
m_MemoryList->SetItemText(LineNumber, i, "-");
}
}
}
else
{
if (strcmp(Output, m_MemoryList->GetItemText(LineNumber, 0)) != 0)
{
m_MemoryList->SetItemText(LineNumber, 0, Output);
}
}
Hex[0] = 0;
Ascii[0] = 0;
int CompareStartPos = m_DataStartLoc - m_CompareStartLoc;
Hex[0] = 0;
Ascii[0] = 0;
int CompareStartPos = m_DataStartLoc - m_CompareStartLoc;
for (int i = 0, col = 1; i < 0x10; i ++, col ++)
{
int Pos = ((LineNumber << 4) + i);
if (m_DataValid[Pos])
{
int ComparePos = CompareStartPos + Pos;
bool Changed = false;
for (int i = 0, col = 1; i < 0x10; i++, col++)
{
int Pos = ((LineNumber << 4) + i);
if (m_DataValid[Pos])
{
int ComparePos = CompareStartPos + Pos;
bool Changed = false;
if (ComparePos >= 0 && ComparePos < MemoryToDisplay &&
m_DataVAddrr == m_CompareVAddrr &&
m_DataValid[ComparePos] &&
m_CurrentData[Pos] != m_CompareData[ComparePos])
{
Changed = true;
}
sprintf(Hex,"%02X",m_CurrentData[Pos]);
m_MemoryList->SetItemText(LineNumber,col,Hex);
m_MemoryList->SetItemFormat( LineNumber,col, ITEM_FORMAT_EDIT, ITEM_FLAGS_EDIT_HEX );
m_MemoryList->SetItemMaxEditLen( LineNumber,col , 2);
m_MemoryList->SetItemColours( LineNumber, col, GetSysColor( COLOR_WINDOW ),
Changed ? RGB( 255, 0, 0 ) : GetSysColor( COLOR_WINDOWTEXT ) );
m_MemoryList->SetItemHighlightColours( LineNumber, col,
Changed ? RGB( 255, 0, 0 ) : GetSysColor( COLOR_HIGHLIGHTTEXT ) );
if (m_CurrentData[Pos] < 30)
{
strcat(Ascii,".");
}
else
{
sprintf(AsciiAddOn,"%c",m_CurrentData[Pos]);
strcat(Ascii,AsciiAddOn);
}
}
else
{
m_MemoryList->SetItemText(LineNumber,col,"**");
m_MemoryList->SetItemFormat( LineNumber,col, ITEM_FORMAT_NONE, ITEM_FLAGS_NONE );
m_MemoryList->SetItemColours( LineNumber, col, GetSysColor( COLOR_WINDOW ), GetSysColor( COLOR_WINDOWTEXT ) );
strcat(Ascii,"*");
}
if (i != 0xF)
{
if ((i & 3) == 3)
{
col += 1;
}
}
}
if ( strcmp( Ascii, m_MemoryList->GetItemText(LineNumber, 20) ) != 0 )
{
m_MemoryList->SetItemText(LineNumber,20,Ascii);
}
if (ComparePos >= 0 && ComparePos < MemoryToDisplay &&
m_DataVAddrr == m_CompareVAddrr &&
m_DataValid[ComparePos] &&
m_CurrentData[Pos] != m_CompareData[ComparePos])
{
Changed = true;
}
sprintf(Hex, "%02X", m_CurrentData[Pos]);
m_MemoryList->SetItemText(LineNumber, col, Hex);
m_MemoryList->SetItemFormat(LineNumber, col, ITEM_FORMAT_EDIT, ITEM_FLAGS_EDIT_HEX);
m_MemoryList->SetItemMaxEditLen(LineNumber, col, 2);
m_MemoryList->SetItemColours(LineNumber, col, GetSysColor(COLOR_WINDOW),
Changed ? RGB(255, 0, 0) : GetSysColor(COLOR_WINDOWTEXT));
m_MemoryList->SetItemHighlightColours(LineNumber, col,
Changed ? RGB(255, 0, 0) : GetSysColor(COLOR_HIGHLIGHTTEXT));
if (m_CurrentData[Pos] < 30)
{
strcat(Ascii, ".");
}
else
{
sprintf(AsciiAddOn, "%c", m_CurrentData[Pos]);
strcat(Ascii, AsciiAddOn);
}
}
else
{
m_MemoryList->SetItemText(LineNumber, col, "**");
m_MemoryList->SetItemFormat(LineNumber, col, ITEM_FORMAT_NONE, ITEM_FLAGS_NONE);
m_MemoryList->SetItemColours(LineNumber, col, GetSysColor(COLOR_WINDOW), GetSysColor(COLOR_WINDOWTEXT));
strcat(Ascii, "*");
}
if (i != 0xF)
{
if ((i & 3) == 3)
{
col += 1;
}
}
}
if (strcmp(Ascii, m_MemoryList->GetItemText(LineNumber, 20)) != 0)
{
m_MemoryList->SetItemText(LineNumber, 20, Ascii);
}
}
void CDebugMemoryView::OnAddrChanged( UINT /*Code*/, int /*id*/, HWND /*ctl*/ )
void CDebugMemoryView::OnAddrChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/)
{
RefreshMemory(false);
RefreshMemory(false);
}
void CDebugMemoryView::OnVScroll(int request, short Pos, HWND ctrl )
void CDebugMemoryView::OnVScroll(int request, short Pos, HWND ctrl)
{
if (ctrl != GetDlgItem(IDC_SCRL_BAR))
{
return;
}
DWORD Location = m_MemAddr.GetValue();
switch (request)
{
case SB_LINEDOWN:
m_MemAddr.SetValue(Location < 0xFFFFFFEF ? Location + 0x10 : 0xFFFFFFFF,true,true);
break;
case SB_LINEUP:
m_MemAddr.SetValue(Location > 0x10 ? Location - 0x10 : 0,true,true);
break;
case SB_PAGEDOWN:
m_MemAddr.SetValue(Location < 0xFFFFFEFF ? Location + 0x100 : 0xFFFFFFFF,true,true);
break;
case SB_PAGEUP:
m_MemAddr.SetValue(Location > 0x100 ? Location - 0x100 : 0,true,true);
break;
case SB_THUMBPOSITION:
m_MemAddr.SetValue((DWORD)Pos << 0x10,true,true);
break;
default:
break;
}
if (ctrl != GetDlgItem(IDC_SCRL_BAR))
{
return;
}
DWORD Location = m_MemAddr.GetValue();
switch (request)
{
case SB_LINEDOWN:
m_MemAddr.SetValue(Location < 0xFFFFFFEF ? Location + 0x10 : 0xFFFFFFFF, true, true);
break;
case SB_LINEUP:
m_MemAddr.SetValue(Location > 0x10 ? Location - 0x10 : 0, true, true);
break;
case SB_PAGEDOWN:
m_MemAddr.SetValue(Location < 0xFFFFFEFF ? Location + 0x100 : 0xFFFFFFFF, true, true);
break;
case SB_PAGEUP:
m_MemAddr.SetValue(Location > 0x100 ? Location - 0x100 : 0, true, true);
break;
case SB_THUMBPOSITION:
m_MemAddr.SetValue((DWORD)Pos << 0x10, true, true);
break;
default:
break;
}
}
void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
void CDebugMemoryView::RefreshMemory(bool ResetCompare)
{
if (m_MemoryList && m_MemoryList->GetHasEditItem())
{
m_MemoryList->SetFocus();
}
if (m_MemoryList && m_MemoryList->GetHasEditItem())
{
m_MemoryList->SetFocus();
}
DWORD NewAddress = m_MemAddr.GetValue();
if (NewAddress != m_DataStartLoc)
{
HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR);
if (hScrlBar)
{
SCROLLINFO si;
DWORD NewAddress = m_MemAddr.GetValue();
if (NewAddress != m_DataStartLoc)
{
HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR);
if (hScrlBar)
{
SCROLLINFO si;
si.cbSize = sizeof(si);
si.fMask = SIF_POS;
si.nPos = NewAddress >> 0x10;
::SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE);
}
}
si.cbSize = sizeof(si);
si.fMask = SIF_POS;
si.nPos = NewAddress >> 0x10;
::SetScrollInfo(hScrlBar, SB_CTL, &si, TRUE);
}
}
if (ResetCompare)
{
// copy current data for change comparison
m_CompareStartLoc = m_DataStartLoc;
m_CompareVAddrr = m_DataVAddrr;
memcpy(m_CompareData,m_CurrentData,sizeof(m_CurrentData));
memcpy(m_CompareValid,m_DataValid,sizeof(m_CompareValid));
}
m_DataStartLoc = m_MemAddr.GetValue();
if (m_DataStartLoc > 0xFFFFFF00) { m_DataStartLoc = 0xFFFFFF00; }
int WritePos = 0;
if (ResetCompare)
{
// copy current data for change comparison
m_CompareStartLoc = m_DataStartLoc;
m_CompareVAddrr = m_DataVAddrr;
memcpy(m_CompareData, m_CurrentData, sizeof(m_CurrentData));
memcpy(m_CompareValid, m_DataValid, sizeof(m_CompareValid));
}
m_DataVAddrr = (SendDlgItemMessage( IDC_CHK_VADDR, BM_GETCHECK, 0,0) & BST_CHECKED) != 0;
m_DataStartLoc = m_MemAddr.GetValue();
if (m_DataStartLoc > 0xFFFFFF00) { m_DataStartLoc = 0xFFFFFF00; }
int WritePos = 0;
if ((m_DataStartLoc & 3) != 0)
{
MIPS_WORD word;
bool ValidData = true;
if ( m_DataVAddrr )
{
if (!g_MMU->LW_VAddr(m_DataStartLoc & ~3, word.UW))
{
ValidData = false;
}
}
else
{
if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW))
{
ValidData = false;
}
}
m_DataVAddrr = (SendDlgItemMessage(IDC_CHK_VADDR, BM_GETCHECK, 0, 0) & BST_CHECKED) != 0;
int Offset = (m_DataStartLoc & 3);
for (int i = 0; i < (4 - Offset); i++)
{
if (WritePos >= MemoryToDisplay)
{
break;
}
m_DataValid[WritePos + i] = ValidData;
if (ValidData)
{
m_CurrentData[WritePos + i] = word.UB[3 - (i + Offset)];
}
}
WritePos = 4 - Offset;
}
if ((m_DataStartLoc & 3) != 0)
{
MIPS_WORD word;
bool ValidData = true;
for (DWORD Pos = ((m_DataStartLoc + 3) & ~3); Pos < (m_DataStartLoc + MemoryToDisplay); WritePos += 4, Pos += 4)
{
MIPS_WORD word;
bool ValidData = true;
if ( m_DataVAddrr )
{
if (!g_MMU->LW_VAddr(Pos, word.UW))
{
ValidData = false;
}
}
else
{
if (!g_MMU->LW_PAddr(Pos, word.UW))
{
ValidData = false;
}
}
if (m_DataVAddrr)
{
if (!g_MMU->LW_VAddr(m_DataStartLoc & ~3, word.UW))
{
ValidData = false;
}
}
else
{
if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW))
{
ValidData = false;
}
}
for (int i = 0; i < 4; i++)
{
if ((WritePos + i)>= MemoryToDisplay)
{
break;
}
m_DataValid[WritePos + i] = ValidData;
if (ValidData)
{
m_CurrentData[WritePos + i] = word.UB[3 - i];
}
}
}
int Offset = (m_DataStartLoc & 3);
for (int i = 0; i < (4 - Offset); i++)
{
if (WritePos >= MemoryToDisplay)
{
break;
}
m_DataValid[WritePos + i] = ValidData;
if (ValidData)
{
m_CurrentData[WritePos + i] = word.UB[3 - (i + Offset)];
}
}
WritePos = 4 - Offset;
}
for (int count = 0 ; count < 16;count ++)
{
Insert_MemoryLineDump ( count );
}
for (DWORD Pos = ((m_DataStartLoc + 3) & ~3); Pos < (m_DataStartLoc + MemoryToDisplay); WritePos += 4, Pos += 4)
{
MIPS_WORD word;
bool ValidData = true;
if (m_DataVAddrr)
{
if (!g_MMU->LW_VAddr(Pos, word.UW))
{
ValidData = false;
}
}
else
{
if (!g_MMU->LW_PAddr(Pos, word.UW))
{
ValidData = false;
}
}
for (int i = 0; i < 4; i++)
{
if ((WritePos + i) >= MemoryToDisplay)
{
break;
}
m_DataValid[WritePos + i] = ValidData;
if (ValidData)
{
m_CurrentData[WritePos + i] = word.UB[3 - i];
}
}
}
for (int count = 0; count < 16; count++)
{
Insert_MemoryLineDump(count);
}
}
#endif

View File

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

View File

@ -1,41 +1,4 @@
////#define _WIN32_WINNT 0x0500
//#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"
#pragma once
#include "../../WTL App.h"
#include "../../N64 System.h"

View File

@ -9,127 +9,141 @@
* *
****************************************************************************/
#include "stdafx.h"
#ifdef WINDOWS_UI
#include "Debugger UI.h"
CPj64Module _Module;
CDebugger::CDebugger () :
m_MemoryDump(NULL),
m_MemoryView(NULL),
m_MemorySearch(NULL),
m_DebugTLB(NULL)
CDebuggerUI::CDebuggerUI () :
m_MemoryDump(NULL),
m_MemoryView(NULL),
m_MemorySearch(NULL),
m_DebugTLB(NULL)
{
g_Settings->RegisterChangeCB(GameRunning_InReset,this,(CSettings::SettingChangedFunc)GameReset);
g_Debugger = this;
}
CDebugger::~CDebugger (void)
CDebuggerUI::~CDebuggerUI (void)
{
Debug_Reset();
g_Settings->UnregisterChangeCB(GameRunning_InReset,this,(CSettings::SettingChangedFunc)GameReset);
Debug_Reset();
}
void CDebugger::Debug_Reset ( void )
void CDebuggerUI::GameReset ( CDebuggerUI * _this )
{
if (m_MemoryDump)
{
m_MemoryDump->HideWindow();
delete m_MemoryDump;
m_MemoryDump = NULL;
}
if (m_MemoryView)
{
m_MemoryView->HideWindow();
delete m_MemoryView;
m_MemoryView = NULL;
}
if (m_MemorySearch)
{
m_MemorySearch->HideWindow();
delete m_MemorySearch;
m_MemorySearch = NULL;
}
if (m_DebugTLB)
{
m_DebugTLB->HideWindow();
delete m_DebugTLB;
m_DebugTLB = NULL;
}
}
void CDebugger::Debug_ShowMemoryDump()
{
if (g_MMU == NULL)
if (!g_Settings->LoadBool(GameRunning_InReset))
{
return;
}
if (m_MemoryDump == NULL)
{
m_MemoryDump = new CDumpMemory(this);
}
if (m_MemoryDump)
{
m_MemoryDump->ShowWindow();
}
_this->Debug_Reset();
}
void CDebugger::Debug_ShowMemoryWindow ( void )
void CDebuggerUI::Debug_Reset ( void )
{
if (g_MMU == NULL)
{
return;
}
if (m_MemoryView == NULL)
{
m_MemoryView = new CDebugMemoryView(this);
}
if (m_MemoryView)
{
m_MemoryView->ShowWindow();
}
if (m_MemoryDump)
{
m_MemoryDump->HideWindow();
delete m_MemoryDump;
m_MemoryDump = NULL;
}
if (m_MemoryView)
{
m_MemoryView->HideWindow();
delete m_MemoryView;
m_MemoryView = NULL;
}
if (m_MemorySearch)
{
m_MemorySearch->HideWindow();
delete m_MemorySearch;
m_MemorySearch = NULL;
}
if (m_DebugTLB)
{
m_DebugTLB->HideWindow();
delete m_DebugTLB;
m_DebugTLB = NULL;
}
}
void CDebugger::Debug_ShowMemoryLocation ( DWORD Address, bool VAddr )
void CDebuggerUI::Debug_ShowMemoryDump()
{
Debug_ShowMemoryWindow();
if (m_MemoryView)
{
m_MemoryView->ShowAddress(Address,VAddr);
}
if (g_MMU == NULL)
{
return;
}
if (m_MemoryDump == NULL)
{
m_MemoryDump = new CDumpMemory(this);
}
if (m_MemoryDump)
{
m_MemoryDump->ShowWindow();
}
}
void CDebugger::Debug_ShowTLBWindow (void)
void CDebuggerUI::Debug_ShowMemoryWindow ( void )
{
if (g_MMU == NULL)
{
return;
}
if (m_DebugTLB == NULL)
{
m_DebugTLB = new CDebugTlb(this);
}
if (m_DebugTLB)
{
m_DebugTLB->ShowWindow();
}
if (g_MMU == NULL)
{
return;
}
if (m_MemoryView == NULL)
{
m_MemoryView = new CDebugMemoryView(this);
}
if (m_MemoryView)
{
m_MemoryView->ShowWindow();
}
}
void CDebugger::Debug_RefreshTLBWindow(void)
void CDebuggerUI::Debug_ShowMemoryLocation ( uint32_t Address, bool VAddr )
{
if (m_DebugTLB)
{
m_DebugTLB->RefreshTLBWindow();
}
Debug_ShowMemoryWindow();
if (m_MemoryView)
{
m_MemoryView->ShowAddress(Address,VAddr);
}
}
void CDebugger::Debug_ShowMemorySearch()
void CDebuggerUI::Debug_ShowTLBWindow (void)
{
if (m_MemorySearch == NULL)
{
m_MemorySearch = new CDebugMemorySearch(this);
}
if (m_MemorySearch)
{
m_MemorySearch->ShowWindow();
}
if (g_MMU == NULL)
{
return;
}
if (m_DebugTLB == NULL)
{
m_DebugTLB = new CDebugTlb(this);
}
if (m_DebugTLB)
{
m_DebugTLB->ShowWindow();
}
}
#endif
void CDebuggerUI::Debug_RefreshTLBWindow(void)
{
if (m_DebugTLB)
{
m_DebugTLB->RefreshTLBWindow();
}
}
void CDebuggerUI::Debug_ShowMemorySearch()
{
if (m_MemorySearch == NULL)
{
m_MemorySearch = new CDebugMemorySearch(this);
}
if (m_MemorySearch)
{
m_MemorySearch->ShowWindow();
}
}
void CDebuggerUI::TLBChanged()
{
Debug_RefreshTLBWindow();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -291,6 +291,7 @@ void CSettings::AddHowToHandleSetting ()
AddHandler(GameRunning_InstantSaveFile, new CSettingTypeTempString(""));
AddHandler(GameRunning_LimitFPS, new CSettingTypeTempBool(true));
AddHandler(GameRunning_ScreenHertz, new CSettingTypeTempNumber(60));
AddHandler(GameRunning_InReset, new CSettingTypeTempBool(false));
AddHandler(File_RecentGameFileCount, new CSettingTypeApplication("","Remembered Rom Files",(uint32_t)10));
AddHandler(File_RecentGameFileIndex, new CSettingTypeApplicationIndex("Recent File","Recent Rom",Default_None));

View File

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

View File

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