Update the N64 System/Debugger files to allman

This commit is contained in:
Ryan Collins 2015-03-25 18:26:02 -04:00
parent 117c1ef3fc
commit 1c044867ae
7 changed files with 208 additions and 80 deletions

View File

@ -61,7 +61,9 @@ public:
if (m_hWnd)
{
SetForegroundWindow((HWND)m_hWnd);
} else {
}
else
{
DWORD ThreadID;
ResetEvent(m_CreatedEvent);
m_DialogThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)CreateDebuggerWindow,(LPVOID)this,0, &ThreadID);

View File

@ -140,13 +140,19 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/,
// DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Cheats_DumpMemory),
// (HWND)hParent, (DLGPROC)WinProc,(LPARAM)this);
//}
//DWORD CDumpMemory::AsciiToHex (const char * HexValue) {
//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++){
// if (Finish > 8 )
// {
// Finish = 8;
// }
// for (Count = 0; Count < Finish; Count++
// {
// Value = (Value << 4);
// switch( HexValue[Count] ) {
// switch ( HexValue[Count] )
// {
// case '0': break;
// case '1': Value += 1; break;
// case '2': Value += 2; break;
@ -178,7 +184,8 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/,
//}
//int CALLBACK CDumpMemory::WinProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam)
//{
// switch (uMsg) {
// switch (uMsg)
// {
// case WM_INITDIALOG:
// {
// CDumpMemory * _this = (CDumpMemory *)lParam;
@ -199,23 +206,39 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/,
// case IDC_E_START_ADDR:
// case IDC_E_END_ADDR:
// case IDC_E_ALT_PC:
// if (HIWORD(wParam) == EN_UPDATE) {
// 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; }
// //if (Value > Stop)
// //{
// // Value = Stop;
// //}
// //if (Value < Start)
// //{
// // Value = Start;
// //}
// sprintf(szTmp2,"0x%X",Value);
// if (strcmp(szTmp,szTmp2) != 0) {
// if (strcmp(szTmp,szTmp2) != 0)
// {
// SetDlgItemText(hDlg,LOWORD(wParam),szTmp2);
// if (_this->SelStop == 0) { _this->SelStop = strlen(szTmp2); _this->SelStart = _this->SelStop; }
// 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 {
// }
// else
// {
// WORD NewSelStart, NewSelStop;
// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_GETSEL,(WPARAM)&NewSelStart,(LPARAM)&NewSelStop);
// if (NewSelStart != 0) { _this->SelStart = NewSelStart; _this->SelStop = NewSelStop; }
// if (NewSelStart != 0)
// {
// _this->SelStart = NewSelStart; _this->SelStop = NewSelStop;
// }
// }
// }
// break;
@ -348,15 +371,21 @@ bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC,
// (HWND)hParent, (DLGPROC)WinProc,(LPARAM)this);
//}
//
//DWORD CDumpMemory::AsciiToHex (const char * HexValue) {
//DWORD CDumpMemory::AsciiToHex (const char * HexValue)
//{
// DWORD Count, Finish, Value = 0;
//
// Finish = strlen(HexValue);
// if (Finish > 8 ) { Finish = 8; }
// if (Finish > 8 )
// {
// Finish = 8;
// }
//
// for (Count = 0; Count < Finish; Count++){
// for (Count = 0; Count < Finish; Count++)
// {
// Value = (Value << 4);
// switch( HexValue[Count] ) {
// switch ( HexValue[Count] )
// {
// case '0': break;
// case '1': Value += 1; break;
// case '2': Value += 2; break;
@ -389,7 +418,8 @@ bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC,
//
//int CALLBACK CDumpMemory::WinProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam)
//{
// switch (uMsg) {
// switch (uMsg)
// {
// case WM_INITDIALOG:
// {
// CDumpMemory * _this = (CDumpMemory *)lParam;
@ -412,7 +442,8 @@ bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC,
// case IDC_E_START_ADDR:
// case IDC_E_END_ADDR:
// case IDC_E_ALT_PC:
// if (HIWORD(wParam) == EN_UPDATE) {
// if (HIWORD(wParam) == EN_UPDATE)
// {
// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class");
//
// TCHAR szTmp[20], szTmp2[20];
@ -420,17 +451,29 @@ bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC,
//
// 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; }
// //if (Value > Stop)
// //{
// // Value = Stop;
// //}
// //if (Value < Start)
// //{
// // Value = Start;
// //}
// sprintf(szTmp2,"0x%X",Value);
// if (strcmp(szTmp,szTmp2) != 0) {
// 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 {
// }
// else
// {
// WORD NewSelStart, NewSelStop;
// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_GETSEL,(WPARAM)&NewSelStart,(LPARAM)&NewSelStop);
// if (NewSelStart != 0) { _this->SelStart = NewSelStart; _this->SelStop = NewSelStop; }
// if (NewSelStart != 0)
// {
// _this->SelStart = NewSelStart; _this->SelStop = NewSelStop;
// }
// }
// }
// break;

View File

@ -226,7 +226,9 @@ void CDebugMemorySearch::EnableUnknownOptions( bool Enable )
{
::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), m_HaveResults ? "Search Results" : "Search");
}
} else {
}
else
{
::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN), false );
if (Enable)
{
@ -249,8 +251,14 @@ void CDebugMemorySearch::SearchForValue( void )
m_UnknownSize.SetCurSel(m_ValueSize.GetCurSel());
LPCTSTR DisplayStr = "0x%08X";
if (Size == _16Bit) { DisplayStr = "0x%04X"; }
else if (Size == _8Bit) { DisplayStr = "0x%04X"; }
if (Size == _16Bit)
{
DisplayStr = "0x%04X";
}
else if (Size == _8Bit)
{
DisplayStr = "0x%04X";
}
if (!m_HaveResults)
{
@ -288,7 +296,9 @@ void CDebugMemorySearch::SearchForValue( void )
::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search Results");
::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_SHOW);
::EnableWindow(GetDlgItem(IDC_VALUE_ALIGN),false);
} else {
}
else
{
int ItemCount = m_SearchResults.GetItemCount();
for (int i = ItemCount - 1; i >= 0; i--)
{
@ -298,7 +308,8 @@ void CDebugMemorySearch::SearchForValue( void )
DWORD NewValue = 0;
BOOL valid = false;
switch (Size) {
switch (Size)
{
case _8Bit:
{
BYTE mem = 0;
@ -328,7 +339,9 @@ void CDebugMemorySearch::SearchForValue( void )
sprintf(LocationStr,DisplayStr,Result.Value);
m_SearchResults.SetItemText(i,3,LocationStr);
Result.Value = NewValue;
} else {
}
else
{
m_SearchResults.DeleteItem(i);
}
}
@ -351,8 +364,14 @@ void CDebugMemorySearch::SearchForUnknown()
MemorySize Size = (MemorySize)m_UnknownSize.GetItemData(m_UnknownSize.GetCurSel());
m_ValueSize.SetCurSel(m_UnknownSize.GetCurSel());
LPCTSTR DisplayStr = "0x%08X";
if (Size == _16Bit) { DisplayStr = "0x%04X"; }
else if (Size == _8Bit) { DisplayStr = "0x%04X"; }
if (Size == _16Bit)
{
DisplayStr = "0x%04X";
}
else if (Size == _8Bit)
{
DisplayStr = "0x%04X";
}
if (!m_HaveResults)
{
m_HaveResults = true;
@ -411,7 +430,9 @@ void CDebugMemorySearch::SearchForUnknown()
::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_SHOW);
::EnableWindow(GetDlgItem(IDC_RADIO_TEXT),false);
::EnableWindow(GetDlgItem(IDC_RADIO_JAL),false);
} else {
}
else
{
int ItemCount = m_SearchResults.GetItemCount();
for (int i = ItemCount - 1; i >= 0; i--)
{
@ -422,7 +443,8 @@ void CDebugMemorySearch::SearchForUnknown()
DWORD NewValue = 0;
BOOL valid = false;
switch (Size) {
switch (Size)
{
case _8Bit:
{
BYTE mem = 0;
@ -482,7 +504,9 @@ void CDebugMemorySearch::SearchForUnknown()
sprintf(LocationStr,DisplayStr,Result.Value);
m_SearchResults.SetItemText(i,3,LocationStr);
Result.Value = NewValue;
} else {
}
else
{
m_SearchResults.DeleteItem(i);
}
}
@ -652,8 +676,14 @@ bool CDebugMemorySearch::SearchForValue (DWORD Value, MemorySize Size, DWORD &St
return false;
}
if (Size == _32Bit) { StartAddress = ((StartAddress + 3) & ~3); }
if (Size == _16Bit) { StartAddress = ((StartAddress + 1) & ~1); }
if (Size == _32Bit)
{
StartAddress = ((StartAddress + 3) & ~3);
}
if (Size == _16Bit)
{
StartAddress = ((StartAddress + 1) & ~1);
}
//search memory
if (StartAddress < g_MMU->RdramSize())
@ -757,4 +787,3 @@ bool CDebugMemorySearch::SearchForValue (DWORD Value, MemorySize Size, DWORD &St
}
return false;
}

View File

@ -41,7 +41,8 @@ private:
SearchChangeState_Lessthan,
};
typedef struct {
typedef struct
{
DWORD PAddr;
DWORD Value;
} SearchResultItem;

View File

@ -115,7 +115,8 @@ void CDebugTlb::RefreshTLBWindow (void)
int count;
CTLB::TLB_ENTRY * tlb = g_TLB->m_tlb;
for (count = 0; count < 32; count ++) {
for (count = 0; count < 32; count ++)
{
sprintf(Output,"0x%02X",count);
item.mask = LVIF_TEXT;
item.iItem = count;
@ -128,66 +129,87 @@ void CDebugTlb::RefreshTLBWindow (void)
OldItem.cchTextMax = sizeof( OldText )-1;
OldItem.iSubItem = 0;
if (ListView_GetItemCount(hList) <= count) {
if (ListView_GetItemCount(hList) <= count)
{
ListView_InsertItem(hList,&item);
} else {
}
else
{
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
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].PageMask.Value);
} else {
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 1;
OldItem.iSubItem = 1;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
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].EntryHi.Value);
} else {
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 2;
OldItem.iSubItem = 2;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
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);
} else {
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 3;
OldItem.iSubItem = 3;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
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].EntryLo1.Value);
} else {
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 4;
OldItem.iSubItem = 4;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
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 ++) {
for (count = 0; count < 64; count ++)
{
sprintf(Output,"0x%02X",count);
item.mask = LVIF_TEXT;
item.iItem = count;
@ -200,49 +222,65 @@ void CDebugTlb::RefreshTLBWindow (void)
OldItem.cchTextMax = sizeof( OldText )-1;
OldItem.iSubItem = 0;
if (ListView_GetItemCount(hList) <= count) {
if (ListView_GetItemCount(hList) <= count)
{
item.iItem = ListView_InsertItem(hList,&item);
} else {
}
else
{
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
}
if (FastTlb[count].ValidEntry) {
if (FastTlb[count].ValidEntry)
{
sprintf(Output,"%s",FastTlb[count].VALID?"Yes":"No");
} else {
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 1;
OldItem.iSubItem = 1;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
if (FastTlb[count].ValidEntry && FastTlb[count].VALID) {
if (FastTlb[count].ValidEntry && FastTlb[count].VALID)
{
sprintf(Output,"%s",FastTlb[count].DIRTY?"Yes":"No");
} else {
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 2;
OldItem.iSubItem = 2;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
if (FastTlb[count].ValidEntry && FastTlb[count].VALID) {
if (FastTlb[count].ValidEntry && FastTlb[count].VALID)
{
sprintf(Output,"%08X:%08X -> %08X:%08X",FastTlb[count].VSTART,FastTlb[count].VEND,
FastTlb[count].PHYSSTART,FastTlb[count].PHYSEND);
} else {
}
else
{
strcpy(Output,"................");
}
item.iSubItem = 3;
OldItem.iSubItem = 3;
ListView_GetItem(hList,&OldItem);
if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) {
if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
{
ListView_SetItem(hList,&item);
}
}

View File

@ -34,7 +34,8 @@ LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM
memset(m_CompareValid,0,sizeof(m_CompareValid));
HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR);
if (hScrlBar) {
if (hScrlBar)
{
SCROLLINFO si;
si.cbSize = sizeof(si);
@ -121,7 +122,7 @@ LRESULT CDebugMemoryView::OnDestroy ( void )
LRESULT CDebugMemoryView::OnClicked (WORD /*wNotifyCode*/, WORD wID, HWND , BOOL& /*bHandled*/)
{
switch(wID)
switch (wID)
{
case IDC_REFRSH_MEM:
RefreshMemory(true);
@ -162,7 +163,10 @@ LRESULT CDebugMemoryView::OnMemoryModified ( LPNMHDR lpNMHDR )
LPCSTR strValue = m_MemoryList->GetItemText(pListNotify->m_nItem,pListNotify->m_nSubItem);
int Finish = strlen(strValue);
if (Finish > 8) { Finish = 8; }
if (Finish > 8)
{
Finish = 8;
}
DWORD Value = 0;
for (int i = 0; i < Finish; i++)
{
@ -206,7 +210,9 @@ LRESULT CDebugMemoryView::OnMemoryModified ( LPNMHDR lpNMHDR )
{
WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos);
}
} else {
}
else
{
if (!g_MMU->SB_PAddr(m_DataStartLoc + Pos,(BYTE)Value))
{
WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos);
@ -249,7 +255,9 @@ void CDebugMemoryView::Insert_MemoryLineDump ( int LineNumber )
m_MemoryList->SetItemText(LineNumber,i,"-");
}
}
} else {
}
else
{
if ( strcmp( Output, m_MemoryList->GetItemText(LineNumber, 0) ) != 0 )
{
m_MemoryList->SetItemText(LineNumber,0,Output);
@ -286,11 +294,15 @@ void CDebugMemoryView::Insert_MemoryLineDump ( int LineNumber )
if (m_CurrentData[Pos] < 30)
{
strcat(Ascii,".");
} else {
}
else
{
sprintf(AsciiAddOn,"%c",m_CurrentData[Pos]);
strcat(Ascii,AsciiAddOn);
}
} else {
}
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 ) );
@ -393,7 +405,9 @@ void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
{
ValidData = false;
}
} else {
}
else
{
if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW))
{
ValidData = false;
@ -428,7 +442,9 @@ void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
{
ValidData = false;
}
} else {
}
else
{
if (!g_MMU->LW_PAddr(Pos, word.UW))
{
ValidData = false;
@ -449,7 +465,8 @@ void CDebugMemoryView::RefreshMemory ( bool ResetCompare )
}
}
for (int count = 0 ; count < 16;count ++ ){
for (int count = 0 ; count < 16;count ++
{
Insert_MemoryLineDump ( count );
}
}

View File

@ -44,5 +44,3 @@
#include "Debugger - View Memory.h"
#include "Debugger - Memory Dump.h"
#include "Debugger - TLB.h"