Merge pull request #2024 from vgturtle127/beautification-9

Beautification 9 - Source\Project64\UserInterface\Debugger directory
This commit is contained in:
zilmar 2021-03-23 12:48:32 +10:30 committed by GitHub
commit f2afda0e5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 212 additions and 227 deletions

View File

@ -132,7 +132,7 @@ const ASM_INSTRUCTION CAssembler::m_Instructions[] =
{ "daddu", R4300i_SPECIAL_DADDU, base_spec, syn_arith }, { "daddu", R4300i_SPECIAL_DADDU, base_spec, syn_arith },
{ "dsub", R4300i_SPECIAL_DSUB, base_spec, syn_arith }, { "dsub", R4300i_SPECIAL_DSUB, base_spec, syn_arith },
{ "dsubu", R4300i_SPECIAL_DSUBU, base_spec, syn_arith }, { "dsubu", R4300i_SPECIAL_DSUBU, base_spec, syn_arith },
{ "tge", R4300i_SPECIAL_TGE, base_spec, syn_arith2 }, // note: no code field { "tge", R4300i_SPECIAL_TGE, base_spec, syn_arith2 }, // Note: no code field
{ "tgeu", R4300i_SPECIAL_TGEU, base_spec, syn_arith2 }, // { "tgeu", R4300i_SPECIAL_TGEU, base_spec, syn_arith2 }, //
{ "tlt", R4300i_SPECIAL_TLT, base_spec, syn_arith2 }, // { "tlt", R4300i_SPECIAL_TLT, base_spec, syn_arith2 }, //
{ "tltu", R4300i_SPECIAL_TLTU, base_spec, syn_arith2 }, // { "tltu", R4300i_SPECIAL_TLTU, base_spec, syn_arith2 }, //
@ -310,8 +310,8 @@ bool CAssembler::AssembleLine(const char* line, uint32_t* opcode, uint32_t addre
char* name = strtok_s(line_c, " \t", &m_TokContext); char* name = strtok_s(line_c, " \t", &m_TokContext);
// attempt to assemble the line // Attempt to assemble the line
// if a syntax error occurs, check if the command has alternative syntax forms and retry // If a syntax error occurs, check if the command has alternative syntax forms and retry
for(int nFallback = 0;; nFallback++) for(int nFallback = 0;; nFallback++)
{ {
@ -327,7 +327,7 @@ bool CAssembler::AssembleLine(const char* line, uint32_t* opcode, uint32_t addre
if (nFallback > 0) if (nFallback > 0)
{ {
// prepare for re-tokenization // Prepare for re-tokenization
strncpy(line_c, line, 128); strncpy(line_c, line, 128);
StrToLower(line_c); StrToLower(line_c);
name = strtok_s(line_c, " \t", &m_TokContext); name = strtok_s(line_c, " \t", &m_TokContext);
@ -351,7 +351,7 @@ bool CAssembler::AssembleLine(const char* line, uint32_t* opcode, uint32_t addre
} }
} }
// assembled without errors // Assembled without errors
return true; return true;
next_fallback:; next_fallback:;
@ -436,11 +436,11 @@ uint32_t CAssembler::pop_val()
// return 0; // return 0;
//} //}
int base = 0; // hex or dec int base = 0; // Hexadecimal or decimal
if (*v == '$') if (*v == '$')
{ {
base = 16; // hex base = 16; // Hexadecimal
v++; v++;
} }

View File

@ -7,8 +7,8 @@ typedef void(*ASM_SYNTAX_FN)(uint32_t* opcode);
typedef struct { typedef struct {
const char* name; const char* name;
uint32_t val; uint32_t val;
uint32_t(*base)(uint32_t val); // value shift uint32_t(*base)(uint32_t val); // Value shift
const ASM_SYNTAX_FN* syntax; // arguments const ASM_SYNTAX_FN* syntax; // Arguments
} ASM_INSTRUCTION; } ASM_INSTRUCTION;
typedef struct { typedef struct {

View File

@ -90,4 +90,4 @@ private:
bool m_bHaveRegBP; bool m_bHaveRegBP;
uint32_t m_GPRWriteBP, m_GPRReadBP; uint32_t m_GPRWriteBP, m_GPRReadBP;
bool m_HIWriteBP, m_HIReadBP, m_LOWriteBP, m_LOReadBP; bool m_HIWriteBP, m_HIReadBP, m_LOWriteBP, m_LOReadBP;
}; };

View File

@ -182,4 +182,4 @@ void CCPULog::DumpToFile(const char* path)
} }
fclose(fp); fclose(fp);
} }

View File

@ -98,4 +98,4 @@ DMALOGENTRY* CDMALog::GetEntryByRomAddress(uint32_t romAddr, uint32_t* lpRamAddr
*lpRamAddr = lpEntry->ramAddr + *lpOffset; *lpRamAddr = lpEntry->ramAddr + *lpOffset;
return lpEntry; return lpEntry;
} }

View File

@ -23,4 +23,4 @@ public:
DMALOGENTRY* GetEntryByRamAddress(uint32_t ramAddr, uint32_t* lpRomAddr, uint32_t* lpOffset); DMALOGENTRY* GetEntryByRamAddress(uint32_t ramAddr, uint32_t* lpRomAddr, uint32_t* lpOffset);
DMALOGENTRY* GetEntryByRomAddress(uint32_t romAddr); DMALOGENTRY* GetEntryByRomAddress(uint32_t romAddr);
DMALOGENTRY* GetEntryByRomAddress(uint32_t romAddr, uint32_t* lpRamAddr, uint32_t* lpOffset); DMALOGENTRY* GetEntryByRomAddress(uint32_t romAddr, uint32_t* lpRamAddr, uint32_t* lpOffset);
}; };

View File

@ -132,4 +132,4 @@ private:
bool m_SaveWnd; bool m_SaveWnd;
LONG m_SaveWndTop; LONG m_SaveWndTop;
LONG m_SaveWndLeft; LONG m_SaveWndLeft;
}; };

View File

@ -21,7 +21,7 @@ uint8_t* CDebugMMU::GetPhysicalPtr(uint32_t paddr, WORD* flags)
bool bCartRom = false; bool bCartRom = false;
if ((paddr < g_MMU->RdramSize()) || if ((paddr < g_MMU->RdramSize()) ||
(paddr >= 0x04000000 && paddr <= 0x04001FFF)) // RDRAM & DMEM/IMEM (paddr >= 0x04000000 && paddr <= 0x04001FFF)) // RDRAM and DMEM/IMEM
{ {
ptr = (uint8_t*)(g_MMU->Rdram() + paddr); ptr = (uint8_t*)(g_MMU->Rdram() + paddr);
} }
@ -55,7 +55,7 @@ uint8_t* CDebugMMU::GetPhysicalPtr(uint32_t paddr, WORD* flags)
} }
else else
{ {
// note: write-only registers are excluded // Note: write-only registers are excluded
switch (paddr) switch (paddr)
{ {
case 0x03F00000: ptr = (uint8_t*)&g_Reg->RDRAM_CONFIG_REG; break; case 0x03F00000: ptr = (uint8_t*)&g_Reg->RDRAM_CONFIG_REG; break;
@ -176,7 +176,7 @@ bool CDebugMMU::GetPhysicalByte(uint32_t paddr, uint8_t* value)
{ {
uint32_t saveOffset = paddr & 0x000FFFFF; uint32_t saveOffset = paddr & 0x000FFFFF;
if (g_System->m_SaveUsing == SaveChip_Sram && saveOffset <= 0x7FFF) // sram if (g_System->m_SaveUsing == SaveChip_Sram && saveOffset <= 0x7FFF) // SRAM
{ {
uint32_t wordpaddr = paddr & ~3; uint32_t wordpaddr = paddr & ~3;
uint8_t data[4]; uint8_t data[4];
@ -186,7 +186,7 @@ bool CDebugMMU::GetPhysicalByte(uint32_t paddr, uint8_t* value)
*value = data[nByte ^ 3]; *value = data[nByte ^ 3];
return true; return true;
} }
else if (g_System->m_SaveUsing == SaveChip_FlashRam && saveOffset <= 3) // flash ram status else if (g_System->m_SaveUsing == SaveChip_FlashRam && saveOffset <= 3) // Flash RAM status
{ {
CFlashram* flashRam = g_MMU->GetFlashram(); CFlashram* flashRam = g_MMU->GetFlashram();
uint32_t flashStatus = flashRam->ReadFromFlashStatus(0x08000000); uint32_t flashStatus = flashRam->ReadFromFlashStatus(0x08000000);

View File

@ -44,4 +44,4 @@ LRESULT CAddBreakpointDlg::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL&
break; break;
} }
return FALSE; return FALSE;
} }

View File

@ -31,4 +31,4 @@ private:
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked) COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
MSG_WM_DESTROY(OnDestroy) MSG_WM_DESTROY(OnDestroy)
END_MSG_MAP() END_MSG_MAP()
}; };

View File

@ -115,4 +115,4 @@ INT_PTR CAddSymbolDlg::DoModal(CDebuggerUI* debugger, uint32_t initAddress, int
m_InitAddress = initAddress; m_InitAddress = initAddress;
m_InitType = initType; m_InitType = initType;
return CDialogImpl<CAddSymbolDlg>::DoModal(); return CDialogImpl<CAddSymbolDlg>::DoModal();
} }

View File

@ -412,7 +412,7 @@ void CDebugCPULogView::Export(void)
} }
} }
// util // Utility
int CDebugCPULogView::GetNumVisibleRows(CListViewCtrl& list) int CDebugCPULogView::GetNumVisibleRows(CListViewCtrl& list)
{ {

View File

@ -91,7 +91,7 @@ LRESULT CDebugCommandsView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA
m_bIgnorePCChange = true; m_bIgnorePCChange = true;
m_PCEdit.SetValue(0x80000180, DisplayMode::ZeroExtend); m_PCEdit.SetValue(0x80000180, DisplayMode::ZeroExtend);
// Setup View PC button // Setup view PC button
m_ViewPCButton.EnableWindow(FALSE); m_ViewPCButton.EnableWindow(FALSE);
m_StepButton.EnableWindow(FALSE); m_StepButton.EnableWindow(FALSE);
m_StepOverButton.EnableWindow(FALSE); m_StepOverButton.EnableWindow(FALSE);
@ -162,6 +162,7 @@ void CDebugCommandsView::RecompilerCheck(void)
!g_Settings->LoadBool(Setting_ForceInterpreterCPU) && !g_Settings->LoadBool(Setting_ForceInterpreterCPU) &&
(CPU_TYPE)g_Settings->LoadDword(Game_CpuType) != CPU_Interpreter) (CPU_TYPE)g_Settings->LoadDword(Game_CpuType) != CPU_Interpreter)
{ {
// TODO: Remove this or fix?
MessageBox(L"Debugger support for the recompiler core is experimental.\n\n" MessageBox(L"Debugger support for the recompiler core is experimental.\n\n"
L"For optimal experience, enable \"Always use interpreter core\" " L"For optimal experience, enable \"Always use interpreter core\" "
L"in advanced settings and restart the emulator.", L"in advanced settings and restart the emulator.",
@ -259,7 +260,7 @@ void CDebugCommandsView::AddBranchArrow(int startPos, int endPos)
{ {
BRANCHARROW arrow = m_BranchArrows[j]; BRANCHARROW arrow = m_BranchArrows[j];
// Arrow's start or end pos within another arrow's stride // Arrow's start or end position within another arrow's stride
if ((startPos >= arrow.startPos && startPos <= arrow.endPos) || if ((startPos >= arrow.startPos && startPos <= arrow.endPos) ||
(endPos >= arrow.startPos && endPos <= arrow.endPos) || (endPos >= arrow.startPos && endPos <= arrow.endPos) ||
(arrow.startPos <= startPos && arrow.startPos >= endPos)) (arrow.startPos <= startPos && arrow.startPos >= endPos))
@ -554,7 +555,7 @@ void CDebugCommandsView::ShowAddress(uint32_t address, bool top, bool bUserInput
} }
} }
// Detect reads and writes to mapped registers, cart header data, etc // Detect reads and writes to mapped registers, cart header data, etc.
const char* annotation = NULL; const char* annotation = NULL;
bool bLoadStoreAnnotation = false; bool bLoadStoreAnnotation = false;
@ -648,7 +649,7 @@ void CDebugCommandsView::ShowAddress(uint32_t address, bool top, bool bUserInput
} }
} }
if (!top) // update registers when called via breakpoint/stepping if (!top) // Update registers when called via breakpoint/stepping
{ {
m_RegisterTabs.RefreshEdits(); m_RegisterTabs.RefreshEdits();
} }
@ -693,35 +694,35 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR)
return CDRF_DODEFAULT; return CDRF_DODEFAULT;
} }
if (nSubItem == CCommandList::COL_ADDRESS) // addr if (nSubItem == CCommandList::COL_ADDRESS) // ADDR
{ {
CBreakpoints::BPSTATE bpState = m_Breakpoints->ExecutionBPExists(address); CBreakpoints::BPSTATE bpState = m_Breakpoints->ExecutionBPExists(address);
if (bpState == CBreakpoints::BP_SET) if (bpState == CBreakpoints::BP_SET)
{ {
// breakpoint // Breakpoint
pLVCD->clrTextBk = RGB(0x44, 0x00, 0x00); pLVCD->clrTextBk = RGB(0x44, 0x00, 0x00);
pLVCD->clrText = (address == pc && isDebugging()) ? pLVCD->clrText = (address == pc && isDebugging()) ?
RGB(0xFF, 0xFF, 0x00) : // breakpoint & current pc RGB(0xFF, 0xFF, 0x00) : // Breakpoint & current PC
RGB(0xFF, 0xCC, 0xCC); RGB(0xFF, 0xCC, 0xCC);
} }
else if (bpState == CBreakpoints::BP_SET_TEMP) else if (bpState == CBreakpoints::BP_SET_TEMP)
{ {
// breakpoint // Breakpoint
pLVCD->clrTextBk = RGB(0x66, 0x44, 0x00); pLVCD->clrTextBk = RGB(0x66, 0x44, 0x00);
pLVCD->clrText = (address == pc && isDebugging()) ? pLVCD->clrText = (address == pc && isDebugging()) ?
RGB(0xFF, 0xFF, 0x00) : // breakpoint & current pc RGB(0xFF, 0xFF, 0x00) : // Breakpoint & current PC
RGB(0xFF, 0xEE, 0xCC); RGB(0xFF, 0xEE, 0xCC);
} }
else if (address == pc && isStepping()) else if (address == pc && isStepping())
{ {
// pc // PC
pLVCD->clrTextBk = RGB(0x88, 0x88, 0x88); pLVCD->clrTextBk = RGB(0x88, 0x88, 0x88);
pLVCD->clrText = RGB(0xFF, 0xFF, 0); pLVCD->clrText = RGB(0xFF, 0xFF, 0);
} }
else else
{ {
//default // Default
pLVCD->clrTextBk = RGB(0xEE, 0xEE, 0xEE); pLVCD->clrTextBk = RGB(0xEE, 0xEE, 0xEE);
pLVCD->clrText = RGB(0x44, 0x44, 0x44); pLVCD->clrText = RGB(0x44, 0x44, 0x44);
} }
@ -730,7 +731,7 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR)
// (nSubItem == 1 || nSubItem == 2) // (nSubItem == 1 || nSubItem == 2)
// cmd & args // Command and arguments
COpInfo OpInfo; COpInfo OpInfo;
OPCODE& OpCode = OpInfo.m_OpCode; OPCODE& OpCode = OpInfo.m_OpCode;
bool bAddrOkay = m_Debugger->DebugLoad_VAddr(address, OpCode.Hex); bool bAddrOkay = m_Debugger->DebugLoad_VAddr(address, OpCode.Hex);
@ -794,10 +795,10 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR)
return CDRF_DODEFAULT; return CDRF_DODEFAULT;
} }
// color register usage // Color register usage
// todo localise to temp register context (dont look before/after jumps and frame shifts) // TODO: localize to temp register context (don't look before/after jumps and frame shifts)
COLORREF clrUsedRegister = RGB(0xF5, 0xF0, 0xFF); // light purple COLORREF clrUsedRegister = RGB(0xF5, 0xF0, 0xFF); // Light purple
COLORREF clrAffectedRegister = RGB(0xFF, 0xF0, 0xFF); // light pink COLORREF clrAffectedRegister = RGB(0xFF, 0xF0, 0xFF); // Light pink
int pcUsedRegA = 0, pcUsedRegB = 0, pcChangedReg = 0; int pcUsedRegA = 0, pcUsedRegB = 0, pcChangedReg = 0;
int curUsedRegA = 0, curUsedRegB = 0, curChangedReg = 0; int curUsedRegA = 0, curUsedRegB = 0, curChangedReg = 0;
@ -865,16 +866,16 @@ void CDebugCommandsView::DrawBranchArrows(HDC listDC)
{ {
COLORREF colors[] = COLORREF colors[] =
{ {
RGB(240, 240, 240), // white RGB(240, 240, 240), // White
RGB(30, 135, 255), // blue RGB(30, 135, 255), // Blue
RGB(255, 0, 200), // pink RGB(255, 0, 200), // Pink
RGB(215, 155, 0), // yellow RGB(215, 155, 0), // Yellow
RGB(100, 180, 0), // green RGB(100, 180, 0), // Green
RGB(200, 100, 255), // purple RGB(200, 100, 255), // Purple
RGB(120, 120, 120), // gray RGB(120, 120, 120), // Gray
RGB(0, 220, 160), // cyan RGB(0, 220, 160), // Cyan
RGB(255, 100, 0), // orange RGB(255, 100, 0), // Orange
RGB(255, 255, 0), // yellow RGB(255, 255, 0), // Yellow
}; };
int nColors = sizeof(colors) / sizeof(COLORREF); int nColors = sizeof(colors) / sizeof(COLORREF);
@ -930,13 +931,13 @@ void CDebugCommandsView::DrawBranchArrows(HDC listDC)
int marginX = baseX - (4 + arrow.margin * 3); int marginX = baseX - (4 + arrow.margin * 3);
// draw start pointer // Draw start pointer
SetPixel(listDC, begX + 0, begY - 1, color); SetPixel(listDC, begX + 0, begY - 1, color);
SetPixel(listDC, begX + 1, begY - 2, color); SetPixel(listDC, begX + 1, begY - 2, color);
SetPixel(listDC, begX + 0, begY + 1, color); SetPixel(listDC, begX + 0, begY + 1, color);
SetPixel(listDC, begX + 1, begY + 2, color); SetPixel(listDC, begX + 1, begY + 2, color);
// draw outline // Draw outline
CPen hPenOutline(CreatePen(PS_SOLID, 3, bgColor)); CPen hPenOutline(CreatePen(PS_SOLID, 3, bgColor));
SelectObject(listDC, hPenOutline); SelectObject(listDC, hPenOutline);
MoveToEx(listDC, begX - 1, begY, NULL); MoveToEx(listDC, begX - 1, begY, NULL);
@ -947,7 +948,7 @@ void CDebugCommandsView::DrawBranchArrows(HDC listDC)
LineTo(listDC, endX + 2, endY); LineTo(listDC, endX + 2, endY);
} }
// draw fill line // Draw fill line
CPen hPen(CreatePen(PS_SOLID, 1, color)); CPen hPen(CreatePen(PS_SOLID, 1, color));
SelectObject(listDC, hPen); SelectObject(listDC, hPen);
MoveToEx(listDC, begX - 1, begY, NULL); MoveToEx(listDC, begX - 1, begY, NULL);
@ -958,7 +959,7 @@ void CDebugCommandsView::DrawBranchArrows(HDC listDC)
LineTo(listDC, endX + 2, endY); LineTo(listDC, endX + 2, endY);
} }
// draw end pointer // Draw end pointer
if (bEndVisible) if (bEndVisible)
{ {
SetPixel(listDC, endX - 0, endY - 1, color); SetPixel(listDC, endX - 0, endY - 1, color);
@ -1061,13 +1062,13 @@ void CDebugCommandsView::CPUStepOver()
if (opInfo.IsJAL()) if (opInfo.IsJAL())
{ {
// put temp BP on return address and resume // Put temp BP on return address and resume
m_Breakpoints->AddExecution(g_Reg->m_PROGRAM_COUNTER + 8, true); m_Breakpoints->AddExecution(g_Reg->m_PROGRAM_COUNTER + 8, true);
CPUResume(); CPUResume();
} }
else else
{ {
// normal step // Normal step
if (WaitingForStep()) if (WaitingForStep())
{ {
m_StepEvent.Trigger(); m_StepEvent.Trigger();
@ -1114,7 +1115,7 @@ LRESULT CDebugCommandsView::OnSymbolsButton(WORD /*wNotifyCode*/, WORD /*wID*/,
LRESULT CDebugCommandsView::OnPopupmenuRunTo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) LRESULT CDebugCommandsView::OnPopupmenuRunTo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/)
{ {
// Add temp bp and resume // Add temp BP and resume
m_Breakpoints->AddExecution(m_SelectedAddress, true); m_Breakpoints->AddExecution(m_SelectedAddress, true);
return FALSE; return FALSE;
} }
@ -1491,7 +1492,7 @@ void CDebugCommandsView::RedrawCommandsAndRegisters()
m_RegisterTabs.RedrawCurrentTab(); m_RegisterTabs.RedrawCurrentTab();
// Fix cmd list header // Fix command list header
listHead.ResizeClient(listRect.Width(), headRect.Height()); listHead.ResizeClient(listRect.Width(), headRect.Height());
} }
@ -1698,7 +1699,7 @@ LRESULT CDebugCommandsView::OnOpEditKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM
LRESULT CDebugCommandsView::OnOpEditChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) LRESULT CDebugCommandsView::OnOpEditChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/)
{ {
// handle multiline input // Handle multiline input
size_t length = m_OpEdit.GetWindowTextLength(); size_t length = m_OpEdit.GetWindowTextLength();
wchar_t* text = new wchar_t[length + 1]; wchar_t* text = new wchar_t[length + 1];
m_OpEdit.GetWindowText(text, length + 1); m_OpEdit.GetWindowText(text, length + 1);
@ -1770,4 +1771,4 @@ void CEditOp::SetCommandsWindow(CDebugCommandsView* commandsWindow)
BOOL CEditOp::Attach(HWND hWndNew) BOOL CEditOp::Attach(HWND hWndNew)
{ {
return SubclassWindow(hWndNew); return SubclassWindow(hWndNew);
} }

View File

@ -35,6 +35,7 @@ bool CDebugDMALogView::FilterEntry(int dmaLogIndex)
return true; return true;
} }
*/ */
void CDebugDMALogView::RefreshList() void CDebugDMALogView::RefreshList()
{ {
if (g_Rom == NULL) if (g_Rom == NULL)
@ -105,7 +106,7 @@ void CDebugDMALogView::RefreshList()
sig.u32 = _byteswap_ulong(*(uint32_t*)&rom[lpEntry->romAddr]); sig.u32 = _byteswap_ulong(*(uint32_t*)&rom[lpEntry->romAddr]);
} }
// Todo checkbox to display all in hex // TODO: checkbox to display all in hex
if (isalnum(sig.sz[0]) && isalnum(sig.sz[1]) && isalnum(sig.sz[2]) && isalnum(sig.sz[3])) if (isalnum(sig.sz[0]) && isalnum(sig.sz[1]) && isalnum(sig.sz[2]) && isalnum(sig.sz[3]))
{ {
m_DMAList.AddItem(itemIndex, 4, stdstr((char*)sig.sz).ToUTF16().c_str()); m_DMAList.AddItem(itemIndex, 4, stdstr((char*)sig.sz).ToUTF16().c_str());
@ -392,7 +393,7 @@ LRESULT CDebugDMALogView::OnCustomDrawList(NMHDR* pNMHDR)
DMALOGENTRY* lpEntry = m_DMALog->GetEntryByIndex(nItem); DMALOGENTRY* lpEntry = m_DMALog->GetEntryByIndex(nItem);
if (nItem >= 1) // continuation if (nItem >= 1) // Continuation
{ {
DMALOGENTRY* lpPrevEntry = m_DMALog->GetEntryByIndex(nItem - 1); DMALOGENTRY* lpPrevEntry = m_DMALog->GetEntryByIndex(nItem - 1);
@ -403,7 +404,7 @@ LRESULT CDebugDMALogView::OnCustomDrawList(NMHDR* pNMHDR)
} }
} }
if (nEntries >= 2 && nItem <= nEntries - 2) // head if (nEntries >= 2 && nItem <= nEntries - 2) // Head
{ {
DMALOGENTRY* lpNextEntry = m_DMALog->GetEntryByIndex(nItem + 1); DMALOGENTRY* lpNextEntry = m_DMALog->GetEntryByIndex(nItem + 1);
@ -415,4 +416,4 @@ LRESULT CDebugDMALogView::OnCustomDrawList(NMHDR* pNMHDR)
} }
return CDRF_DODEFAULT; return CDRF_DODEFAULT;
} }

View File

@ -181,4 +181,4 @@ void CDebugExcBreakpoints::EnableCheckboxes(ExcCheckboxMeta* checkboxMap, bool b
{ {
::EnableWindow(GetDlgItem(checkboxMap[i].ctrlId), bEnable); ::EnableWindow(GetDlgItem(checkboxMap[i].ctrlId), bEnable);
} }
} }

View File

@ -102,7 +102,7 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl
GetDlgItemText(IDC_FILENAME, FileName, sizeof(FileName)); GetDlgItemText(IDC_FILENAME, FileName, sizeof(FileName));
if (wcslen(FileName) == 0) if (wcslen(FileName) == 0)
{ {
g_Notify->DisplayWarning("Please Choose target file"); g_Notify->DisplayWarning("Please choose target file");
::SetFocus(GetDlgItem(IDC_FILENAME)); ::SetFocus(GetDlgItem(IDC_FILENAME));
return false; return false;
} }
@ -110,7 +110,7 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl
{ {
DumpPC = StartPC; DumpPC = StartPC;
} }
//disable buttons // Disable buttons
::EnableWindow(GetDlgItem(IDC_E_START_ADDR), FALSE); ::EnableWindow(GetDlgItem(IDC_E_START_ADDR), FALSE);
::EnableWindow(GetDlgItem(IDC_E_END_ADDR), FALSE); ::EnableWindow(GetDlgItem(IDC_E_END_ADDR), FALSE);
::EnableWindow(GetDlgItem(IDC_E_ALT_PC), FALSE); ::EnableWindow(GetDlgItem(IDC_E_ALT_PC), FALSE);
@ -123,7 +123,7 @@ LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory); g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory);
if (!DumpMemory(FileName, Format, StartPC, EndPC, DumpPC)) if (!DumpMemory(FileName, Format, StartPC, EndPC, DumpPC))
{ {
//enable buttons // Enable buttons
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory);
return false; return false;
} }
@ -204,4 +204,4 @@ bool CDumpMemory::DumpMemory(LPCTSTR FileName, DumpFormat Format, DWORD StartPC,
} }
return false; return false;
} }

View File

@ -53,7 +53,7 @@ LRESULT CDebugMemorySearch::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA
m_AddrEnd.SetDisplayType(CEditNumber32::DisplayHex); m_AddrEnd.SetDisplayType(CEditNumber32::DisplayHex);
m_AddrStart.SetDisplayType(CEditNumber32::DisplayHex); m_AddrStart.SetDisplayType(CEditNumber32::DisplayHex);
UpdateOptions(); // setup search type combobox UpdateOptions(); // Setup search type combo box
CComboBox & vtcb = m_ValueTypeOptions; CComboBox & vtcb = m_ValueTypeOptions;
vtcb.SetItemData(vtcb.AddString(L"int8"), ValueType_int8); vtcb.SetItemData(vtcb.AddString(L"int8"), ValueType_int8);
@ -236,8 +236,8 @@ LRESULT CDebugMemorySearch::OnSearchButton(WORD /*wNotifyCode*/, WORD /*wID*/, H
{ {
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory); g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory);
Search(); Search();
// emulator won't resume sometimes unless there's a sleep() here // Emulator won't resume sometimes unless there's a sleep() here
Sleep(50); // todo fix? Sleep(50); // TODO: fix?
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory); g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory);
return FALSE; return FALSE;
} }
@ -262,7 +262,7 @@ LRESULT CDebugMemorySearch::OnScanTypeChanged(WORD /*wNotifyCode*/, WORD /*wID*/
SetComboBoxSelByData(m_ValueTypeOptions, ValueType_int32); SetComboBoxSelByData(m_ValueTypeOptions, ValueType_int32);
m_ValueTypeOptions.EnableWindow(FALSE); m_ValueTypeOptions.EnableWindow(FALSE);
// remember checkbox states // Remember checkbox states
m_bJalHexWasChecked = (m_HexCheckbox.GetCheck() == BST_CHECKED); m_bJalHexWasChecked = (m_HexCheckbox.GetCheck() == BST_CHECKED);
m_bJalUnsignedWasChecked = (m_UnsignedCheckbox.GetCheck() == BST_CHECKED); m_bJalUnsignedWasChecked = (m_UnsignedCheckbox.GetCheck() == BST_CHECKED);
@ -383,7 +383,7 @@ LRESULT CDebugMemorySearch::OnResultsCustomDraw(LPNMHDR lpnmh)
case ResultsListCtrl_Col_Address: case ResultsListCtrl_Col_Address:
if (presult->m_AddressType == AddressType_Physical) if (presult->m_AddressType == AddressType_Physical)
{ {
// green if address is physical // Green if address is physical
pLVCD->clrText = RGB(0x44, 0x88, 0x44); pLVCD->clrText = RGB(0x44, 0x88, 0x44);
} }
break; break;
@ -399,13 +399,13 @@ LRESULT CDebugMemorySearch::OnResultsCustomDraw(LPNMHDR lpnmh)
pLVCD->clrText = RGB(0, 0, 0); pLVCD->clrText = RGB(0, 0, 0);
if (presult->m_DisplayFormat == DisplayHex) if (presult->m_DisplayFormat == DisplayHex)
{ {
// blue if hex string // Blue if hex string
pLVCD->clrText = RGB(0, 0, 255); pLVCD->clrText = RGB(0, 0, 255);
} }
} }
else if (strcmp(szCurrentValue, szOldValue) != 0) else if (strcmp(szCurrentValue, szOldValue) != 0)
{ {
// red if value has changed // Red if value has changed
pLVCD->clrText = RGB(255, 0, 0); pLVCD->clrText = RGB(255, 0, 0);
} }
} }
@ -442,15 +442,15 @@ LRESULT CDebugMemorySearch::OnResultsRClick(LPNMHDR /*lpnmh*/)
return true; return true;
} }
//Load the menu // Load the menu
HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MEM_SEARCH)); HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MEM_SEARCH));
HMENU hPopupMenu = GetSubMenu(hMenu, 0); HMENU hPopupMenu = GetSubMenu(hMenu, 0);
//Get the current Mouse location // Get the current mouse location
POINT Mouse; POINT Mouse;
GetCursorPos(&Mouse); GetCursorPos(&Mouse);
//Show the menu // Show the menu
TrackPopupMenu(hPopupMenu, 0, Mouse.x, Mouse.y, 0, m_hWnd, NULL); TrackPopupMenu(hPopupMenu, 0, Mouse.x, Mouse.y, 0, m_hWnd, NULL);
DestroyMenu(hMenu); DestroyMenu(hMenu);
return true; return true;
@ -597,7 +597,7 @@ LRESULT CDebugMemorySearch::OnWatchListCustomDraw(LPNMHDR lpnmh)
case WatchListCtrl_Col_Address: case WatchListCtrl_Col_Address:
if (presult->m_AddressType == AddressType_Physical) if (presult->m_AddressType == AddressType_Physical)
{ {
// green if address is physical // Green if address is physical
pLVCD->clrText = RGB(0x44, 0x88, 0x44); pLVCD->clrText = RGB(0x44, 0x88, 0x44);
} }
break; break;
@ -607,7 +607,7 @@ LRESULT CDebugMemorySearch::OnWatchListCustomDraw(LPNMHDR lpnmh)
pLVCD->clrText = RGB(0, 0, 0); pLVCD->clrText = RGB(0, 0, 0);
if (presult->m_DisplayFormat == DisplayHex) if (presult->m_DisplayFormat == DisplayHex)
{ {
// blue if hex string // Blue if hex string
pLVCD->clrText = RGB(0, 0, 255); pLVCD->clrText = RGB(0, 0, 255);
} }
} }
@ -633,7 +633,7 @@ LRESULT CDebugMemorySearch::OnWatchListDblClick(LPNMHDR /*lpnmh*/)
int nSelectedCol = -1; int nSelectedCol = -1;
// hit test for column // Hit test for column
POINT mousePt; POINT mousePt;
RECT listRect; RECT listRect;
@ -732,11 +732,11 @@ LRESULT CDebugMemorySearch::OnWatchListRClick(LPNMHDR /*lpnmh*/)
int index = m_WatchListCtrl.GetItemData(iItem); int index = m_WatchListCtrl.GetItemData(iItem);
CScanResult *presult = &m_WatchList[index]; CScanResult *presult = &m_WatchList[index];
//Load the menu // Load the menu
HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MEM_WATCHLIST)); HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MEM_WATCHLIST));
HMENU hPopupMenu = GetSubMenu(hMenu, 0); HMENU hPopupMenu = GetSubMenu(hMenu, 0);
//Get the current Mouse location // Get the current mouse location
POINT Mouse; POINT Mouse;
GetCursorPos(&Mouse); GetCursorPos(&Mouse);
@ -752,7 +752,7 @@ LRESULT CDebugMemorySearch::OnWatchListRClick(LPNMHDR /*lpnmh*/)
CheckMenuItem(hPopupMenu, ID_WATCHLIST_WRITEBP, bHaveWriteBP ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hPopupMenu, ID_WATCHLIST_WRITEBP, bHaveWriteBP ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(hPopupMenu, ID_WATCHLIST_HEXADECIMAL, bHex ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hPopupMenu, ID_WATCHLIST_HEXADECIMAL, bHex ? MF_CHECKED : MF_UNCHECKED);
//Show the menu // Show the menu
TrackPopupMenu(hPopupMenu, 0, Mouse.x, Mouse.y, 0, m_hWnd, NULL); TrackPopupMenu(hPopupMenu, 0, Mouse.x, Mouse.y, 0, m_hWnd, NULL);
DestroyMenu(hMenu); DestroyMenu(hMenu);
return true; return true;
@ -825,7 +825,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupAddSymbol(WORD /*wNotifyCode*/, WORD
return FALSE; return FALSE;
} }
// todo fix magic numbers // TODO: fix magic numbers
int nSymType = 1; int nSymType = 1;
switch (presult->GetType()) switch (presult->GetType())
@ -897,7 +897,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupChangeValue(WORD /*wNotifyCode*/, WO
int index = m_WatchListCtrl.GetItemData(iItem); int index = m_WatchListCtrl.GetItemData(iItem);
CScanResult* presult = &m_WatchList[index]; CScanResult* presult = &m_WatchList[index];
stdstr enteredString = stdstr().FromUTF16(m_SetValueDlg.GetEnteredString()); stdstr enteredString = stdstr().FromUTF16(m_SetValueDlg.GetEnteredString());
// todo prompt for size change if string is too long // TODO: prompt for size change if string is too long
presult->SetMemoryValueFromString(enteredString.c_str()); presult->SetMemoryValueFromString(enteredString.c_str());
m_WatchListCtrl.SetItemText(iItem, WatchListCtrl_Col_Value, stdstr(enteredString).ToUTF16().c_str()); m_WatchListCtrl.SetItemText(iItem, WatchListCtrl_Col_Value, stdstr(enteredString).ToUTF16().c_str());
} }
@ -1206,7 +1206,7 @@ LRESULT CDebugMemorySearch::OnWatchListPopupCopyAddressAndDescription(WORD /*wNo
LRESULT CDebugMemorySearch::OnSetFont(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) LRESULT CDebugMemorySearch::OnSetFont(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{ {
// set row height for the results list and watch list // Set row height for the results list and watch list
CClientDC dc(m_hWnd); CClientDC dc(m_hWnd);
dc.SelectFont((HFONT)wParam); dc.SelectFont((HFONT)wParam);
TEXTMETRIC tm; TEXTMETRIC tm;
@ -1306,7 +1306,7 @@ void CDebugMemorySearch::OnInterceptMouseMove(WPARAM /*wParam*/, LPARAM /*lParam
CRect sepRect, windowRect; CRect sepRect, windowRect;
int yChange = cursorPos.y - m_LastSeparatorRect.top; int yChange = cursorPos.y - m_LastSeparatorRect.top;
// move separator // Move separator
HWND hSeparator = GetDlgItem(IDC_SEPARATOR); HWND hSeparator = GetDlgItem(IDC_SEPARATOR);
::GetWindowRect(hSeparator, &sepRect); ::GetWindowRect(hSeparator, &sepRect);
ScreenToClient(&sepRect); ScreenToClient(&sepRect);
@ -1314,19 +1314,19 @@ void CDebugMemorySearch::OnInterceptMouseMove(WPARAM /*wParam*/, LPARAM /*lParam
SWP_NOSIZE | SWP_NOZORDER); SWP_NOSIZE | SWP_NOZORDER);
::InvalidateRect(hSeparator, NULL, true); ::InvalidateRect(hSeparator, NULL, true);
// move and resize controls // Move and resize controls
SeparatorMoveCtrl(IDC_LST_WATCHLIST, yChange, false); SeparatorMoveCtrl(IDC_LST_WATCHLIST, yChange, false);
SeparatorMoveCtrl(IDC_SCRL_WATCHLIST, yChange, false); SeparatorMoveCtrl(IDC_SCRL_WATCHLIST, yChange, false);
SeparatorMoveCtrl(IDC_NUM_RESULTS, yChange, true); SeparatorMoveCtrl(IDC_NUM_RESULTS, yChange, true);
SeparatorMoveCtrl(IDC_LST_RESULTS, yChange, true); SeparatorMoveCtrl(IDC_LST_RESULTS, yChange, true);
SeparatorMoveCtrl(IDC_SCRL_RESULTS, yChange, true); SeparatorMoveCtrl(IDC_SCRL_RESULTS, yChange, true);
// adjust window height // Adjust window height
GetWindowRect(&windowRect); GetWindowRect(&windowRect);
windowRect.bottom += yChange; windowRect.bottom += yChange;
SetWindowPos(HWND_TOP, &windowRect, SWP_NOMOVE); SetWindowPos(HWND_TOP, &windowRect, SWP_NOMOVE);
// save separator pos // Save separator position
::GetWindowRect(hSeparator, &m_LastSeparatorRect); ::GetWindowRect(hSeparator, &m_LastSeparatorRect);
ScreenToClient(&m_LastSeparatorRect); ScreenToClient(&m_LastSeparatorRect);
} }
@ -1338,21 +1338,21 @@ void CDebugMemorySearch::OnInterceptMouseWheel(WPARAM wParam, LPARAM /*lParam*/)
if (MouseHovering(IDC_LST_RESULTS) || MouseHovering(IDC_SCRL_RESULTS)) if (MouseHovering(IDC_LST_RESULTS) || MouseHovering(IDC_SCRL_RESULTS))
{ {
// scroll results list // Scroll results list
int scrollPos = m_ResultsScrollbar.GetScrollPos(); int scrollPos = m_ResultsScrollbar.GetScrollPos();
m_ResultsScrollbar.SetScrollPos(scrollPos + nScroll); m_ResultsScrollbar.SetScrollPos(scrollPos + nScroll);
UpdateResultsList(); UpdateResultsList();
} }
else if (MouseHovering(IDC_LST_WATCHLIST) || MouseHovering(IDC_SCRL_WATCHLIST)) else if (MouseHovering(IDC_LST_WATCHLIST) || MouseHovering(IDC_SCRL_WATCHLIST))
{ {
// scroll watch list // Scroll watch list
int scrollPos = m_WatchListScrollbar.GetScrollPos(); int scrollPos = m_WatchListScrollbar.GetScrollPos();
m_WatchListScrollbar.SetScrollPos(scrollPos + nScroll); m_WatchListScrollbar.SetScrollPos(scrollPos + nScroll);
UpdateWatchList(); UpdateWatchList();
} }
} }
// util // Utility
void CDebugMemorySearch::ClearWatchList(void) void CDebugMemorySearch::ClearWatchList(void)
{ {
@ -1466,12 +1466,12 @@ void CDebugMemorySearch::SeparatorMoveCtrl(WORD ctrlId, int yChange, bool bResiz
::GetWindowRect(hControl, &rect); ::GetWindowRect(hControl, &rect);
ScreenToClient(&rect); ScreenToClient(&rect);
if (bResize) // resize control if (bResize) // Resize control
{ {
::SetWindowPos(hControl, NULL, 0, 0, rect.Width(), rect.Height() + yChange, ::SetWindowPos(hControl, NULL, 0, 0, rect.Width(), rect.Height() + yChange,
SWP_NOMOVE | SWP_NOZORDER); SWP_NOMOVE | SWP_NOZORDER);
} }
else // move control else // Move control
{ {
::SetWindowPos(hControl, NULL, rect.left, rect.top + yChange, 0, 0, ::SetWindowPos(hControl, NULL, rect.left, rect.top + yChange, 0, 0,
SWP_NOSIZE | SWP_NOZORDER); SWP_NOSIZE | SWP_NOZORDER);
@ -1768,7 +1768,7 @@ void CDebugMemorySearch::UpdateOptions(void)
valueType == ValueType_istring || valueType == ValueType_istring ||
valueType == ValueType_unkstring) valueType == ValueType_unkstring)
{ {
// complex search types, disable next search // Complex search types, disable next search
::EnableWindow(GetDlgItem(IDC_BTN_SEARCH), false); ::EnableWindow(GetDlgItem(IDC_BTN_SEARCH), false);
m_SearchTypeOptions.EnableWindow(FALSE); m_SearchTypeOptions.EnableWindow(FALSE);
} }
@ -2100,7 +2100,7 @@ void CDebugMemorySearch::LoadWatchList(void)
if (result.IsStringType()) if (result.IsStringType())
{ {
// g_MMU is null here, can't use SetStrLengthSafe // g_MMU is null here, can't use SetStrLengthSafe
// todo fix // TODO: fix
result.SetStrLength(charArrayLength); result.SetStrLength(charArrayLength);
} }
@ -2167,8 +2167,6 @@ CPath CDebugMemorySearch::GetWatchListPath(void)
return wlFilePath; return wlFilePath;
} }
////////////////////////
INT_PTR CSetValueDlg::DoModal(const char* caption, const char* label, const char* initialText) INT_PTR CSetValueDlg::DoModal(const char* caption, const char* label, const char* initialText)
{ {
m_Mode = Mode_TextBox; m_Mode = Mode_TextBox;
@ -2292,8 +2290,6 @@ CSetValueDlg::~CSetValueDlg(void)
} }
} }
////////////////////////
CEditMixed::CEditMixed(void) : CEditMixed::CEditMixed(void) :
m_String(NULL) m_String(NULL)
{ {
@ -2442,7 +2438,7 @@ bool CEditMixed::GetValue(uint64_t& value)
if (*end != '\0') if (*end != '\0')
{ {
return false; // parse failure return false; // Parse failure
} }
value = res; value = res;
@ -2463,7 +2459,7 @@ bool CEditMixed::GetValue(int64_t& value)
if (*end != '\0') if (*end != '\0')
{ {
return false; // parse failure return false; // Parse failure
} }
value = res; value = res;

View File

@ -43,8 +43,6 @@ public:
END_MSG_MAP() END_MSG_MAP()
}; };
//////////////
class CSetValueDlg : public CDialogImpl<CSetValueDlg> class CSetValueDlg : public CDialogImpl<CSetValueDlg>
{ {
public: public:
@ -100,10 +98,6 @@ private:
END_MSG_MAP() END_MSG_MAP()
}; };
//////////////
class CDebugMemorySearch : class CDebugMemorySearch :
public CDebugDialog<CDebugMemorySearch>, public CDebugDialog<CDebugMemorySearch>,
public CDialogResize<CDebugMemorySearch> public CDialogResize<CDebugMemorySearch>
@ -230,13 +224,12 @@ private:
CPath GetWatchListPath(void); CPath GetWatchListPath(void);
/* generic ui util */ // Generic UI utility
void FixListHeader(CListViewCtrl& listCtrl); void FixListHeader(CListViewCtrl& listCtrl);
void SetComboBoxSelByData(CComboBox& cb, DWORD_PTR data); void SetComboBoxSelByData(CComboBox& cb, DWORD_PTR data);
bool MouseHovering(WORD ctrlId, int hMargin = 0, int vMargin = 0); bool MouseHovering(WORD ctrlId, int hMargin = 0, int vMargin = 0);
int GetNumVisibleRows(CListViewCtrl& list); int GetNumVisibleRows(CListViewCtrl& list);
/*******************/
bool m_bJalSelected; bool m_bJalSelected;
bool m_bJalHexWasChecked; bool m_bJalHexWasChecked;
bool m_bJalUnsignedWasChecked; bool m_bJalUnsignedWasChecked;

View File

@ -330,4 +330,4 @@ public:
}; };
static constexpr TabRecord DD = TabRecord{sizeof(DDFields), DDFields}; static constexpr TabRecord DD = TabRecord{sizeof(DDFields), DDFields};
}; };

View File

@ -297,7 +297,7 @@ void CRegisterTabs::RegisterChanged(HWND hDlg, TAB_ID srcTabId, WPARAM wParam)
uint32_t value = wcstoul(text, NULL, 16); uint32_t value = wcstoul(text, NULL, 16);
wsprintf(text, L"%08X", value); wsprintf(text, L"%08X", value);
editCtrl.SetWindowText(text); // reformat text editCtrl.SetWindowText(text); // Reformat text
if (srcTabId == TabFPR) if (srcTabId == TabFPR)
{ {
@ -468,7 +468,7 @@ INT_PTR CALLBACK CRegisterTabs::TabProcGPR(HWND hDlg, UINT msg, WPARAM wParam, L
return TRUE; return TRUE;
} }
// color textboxes // Color textboxes
if (msg == WM_CTLCOLOREDIT) if (msg == WM_CTLCOLOREDIT)
{ {
HDC hdc = (HDC)wParam; HDC hdc = (HDC)wParam;
@ -549,7 +549,7 @@ INT_PTR CALLBACK CRegisterTabs::TabProcGPR(HWND hDlg, UINT msg, WPARAM wParam, L
return FALSE; return FALSE;
} }
// right click labels // Right click labels
if (msg == WM_CONTEXTMENU) if (msg == WM_CONTEXTMENU)
{ {
if (m_Debugger == NULL) if (m_Debugger == NULL)
@ -574,7 +574,7 @@ INT_PTR CALLBACK CRegisterTabs::TabProcGPR(HWND hDlg, UINT msg, WPARAM wParam, L
{ {
int nReg = TabData::GPR.GetLabelIndex(ctrlId); int nReg = TabData::GPR.GetLabelIndex(ctrlId);
if (nReg <= 0) // ignore R0 if (nReg <= 0) // Ignore R0
{ {
return FALSE; return FALSE;
} }
@ -586,7 +586,7 @@ INT_PTR CALLBACK CRegisterTabs::TabProcGPR(HWND hDlg, UINT msg, WPARAM wParam, L
return FALSE; return FALSE;
} }
// click labels // Click labels
if (msg == WM_COMMAND && HIWORD(wParam) == STN_CLICKED || HIWORD(wParam) == STN_DBLCLK) if (msg == WM_COMMAND && HIWORD(wParam) == STN_CLICKED || HIWORD(wParam) == STN_DBLCLK)
{ {
if (m_Debugger == NULL) if (m_Debugger == NULL)
@ -611,7 +611,7 @@ INT_PTR CALLBACK CRegisterTabs::TabProcGPR(HWND hDlg, UINT msg, WPARAM wParam, L
{ {
int nReg = TabData::GPR.GetLabelIndex(ctrlId); int nReg = TabData::GPR.GetLabelIndex(ctrlId);
if (nReg <= 0) // ignore R0 if (nReg <= 0) // Ignore R0
{ {
return FALSE; return FALSE;
} }
@ -623,7 +623,7 @@ INT_PTR CALLBACK CRegisterTabs::TabProcGPR(HWND hDlg, UINT msg, WPARAM wParam, L
return FALSE; return FALSE;
} }
// color labels // Color labels
if (msg == WM_CTLCOLORSTATIC) if (msg == WM_CTLCOLORSTATIC)
{ {
if (m_Debugger == NULL) if (m_Debugger == NULL)
@ -1036,7 +1036,7 @@ stdstr CEditReg64::GetValueText()
LRESULT CEditReg64::OnLostFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) LRESULT CEditReg64::OnLostFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{ {
SetValue(GetValue()); // clean up SetValue(GetValue()); // Clean up
bHandled = FALSE; bHandled = FALSE;
return 0; return 0;
} }
@ -1053,4 +1053,4 @@ void CEditReg64::SetValue(uint64_t value)
uint32_t h = (value & 0xFFFFFFFF00000000LL) >> 32; uint32_t h = (value & 0xFFFFFFFF00000000LL) >> 32;
uint32_t l = (value & 0x00000000FFFFFFFFLL); uint32_t l = (value & 0x00000000FFFFFFFFLL);
SetValue(h, l); SetValue(h, l);
} }

View File

@ -132,7 +132,7 @@ private:
"Virtual coherency (data)" "Virtual coherency (data)"
}; };
// for static dlgprocs, assumes single instance // For static dlgprocs, assumes single instance
static bool m_bColorsEnabled; static bool m_bColorsEnabled;
static CDebuggerUI* m_Debugger; static CDebuggerUI* m_Debugger;
@ -182,4 +182,4 @@ private:
CWindow m_DDTab; CWindow m_DDTab;
CEditNumber32 m_DDEdits[TabData::DD.FieldCount]; CEditNumber32 m_DDEdits[TabData::DD.FieldCount];
}; };

View File

@ -439,7 +439,7 @@ void CDebugScripts::RunSelected()
} }
else else
{ {
m_Debugger->Debug_LogScriptsWindow("[Error: Script is already running]\n"); m_Debugger->Debug_LogScriptsWindow("[Error: script is already running]\n");
} }
} }
@ -513,7 +513,7 @@ LRESULT CEditEval::OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BO
SetWindowText(L""); SetWindowText(L"");
int historySize = m_History.size(); int historySize = m_History.size();
// remove duplicate // Remove duplicate
for (int i = 0; i < historySize; i++) for (int i = 0; i < historySize; i++)
{ {
if (wcscmp(code, m_History[i]) == 0) if (wcscmp(code, m_History[i]) == 0)
@ -525,7 +525,7 @@ LRESULT CEditEval::OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BO
} }
} }
// remove oldest if maxed // Remove oldest if maxed
if (historySize >= HISTORY_MAX_ENTRIES) if (historySize >= HISTORY_MAX_ENTRIES)
{ {
m_History.erase(m_History.begin() + 0); m_History.erase(m_History.begin() + 0);

View File

@ -81,7 +81,7 @@ void CDebugStackTrace::Refresh()
return; return;
} }
SetWindowText(stdstr_f("Stack Trace (%d)", m_EntriesIndex).ToUTF16().c_str()); SetWindowText(stdstr_f("Stack trace (%d)", m_EntriesIndex).ToUTF16().c_str());
m_List.SetRedraw(FALSE); m_List.SetRedraw(FALSE);
m_List.DeleteAllItems(); m_List.DeleteAllItems();
@ -108,4 +108,4 @@ void CDebugStackTrace::Refresh()
} }
m_List.SetRedraw(TRUE); m_List.SetRedraw(TRUE);
} }

View File

@ -70,4 +70,4 @@ private:
BEGIN_DLGRESIZE_MAP(CDebugStackTrace) BEGIN_DLGRESIZE_MAP(CDebugStackTrace)
DLGRESIZE_CONTROL(IDC_STACKTRACE_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y) DLGRESIZE_CONTROL(IDC_STACKTRACE_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
END_DLGRESIZE_MAP() END_DLGRESIZE_MAP()
}; };

View File

@ -104,4 +104,4 @@ void CDebugStackView::Refresh()
} }
m_StackList.SetRedraw(TRUE); m_StackList.SetRedraw(TRUE);
} }

View File

@ -32,4 +32,4 @@ private:
BEGIN_DLGRESIZE_MAP(CDebugStackView) BEGIN_DLGRESIZE_MAP(CDebugStackView)
DLGRESIZE_CONTROL(IDC_STACK_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y) DLGRESIZE_CONTROL(IDC_STACK_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
END_DLGRESIZE_MAP() END_DLGRESIZE_MAP()
}; };

View File

@ -119,7 +119,7 @@ LRESULT CDebugSymbols::OnListDblClicked(NMHDR* pNMHDR)
int nSelectedCol = -1; int nSelectedCol = -1;
// hit test for column // Hit test for column
POINT mousePt; POINT mousePt;
RECT listRect; RECT listRect;
@ -153,11 +153,11 @@ LRESULT CDebugSymbols::OnListDblClicked(NMHDR* pNMHDR)
{ {
case SymbolsListView_Col_Address: case SymbolsListView_Col_Address:
// Open it in memory viewer/commands viewer // Open it in memory viewer/commands viewer
if (symbol.m_Type == SYM_CODE) // code if (symbol.m_Type == SYM_CODE) // Code
{ {
m_Debugger->Debug_ShowCommandsLocation(symbol.m_Address, true); m_Debugger->Debug_ShowCommandsLocation(symbol.m_Address, true);
} }
else // data/number else // Data/number
{ {
m_Debugger->Debug_ShowMemoryLocation(symbol.m_Address, true); m_Debugger->Debug_ShowMemoryLocation(symbol.m_Address, true);
} }
@ -167,7 +167,7 @@ LRESULT CDebugSymbols::OnListDblClicked(NMHDR* pNMHDR)
{ {
ValueType t = (ValueType)m_SetValueDlg.GetEnteredData(); ValueType t = (ValueType)m_SetValueDlg.GetEnteredData();
//Is there a better way? // TODO: Is there a better way?
m_Debugger->SymbolTable()->RemoveSymbolById(id); m_Debugger->SymbolTable()->RemoveSymbolById(id);
m_Debugger->SymbolTable()->AddSymbol(t, symbol.m_Address, symbol.m_Name, symbol.m_Description); m_Debugger->SymbolTable()->AddSymbol(t, symbol.m_Address, symbol.m_Name, symbol.m_Description);
} }

View File

@ -2,7 +2,7 @@
#include "DebuggerUI.h" #include "DebuggerUI.h"
// todo maybe add char* ownerName and use a TreeView // TODO: Maybe add char* ownerName and use a TreeView
class CDebugSymbols : class CDebugSymbols :
public CDebugDialog<CDebugSymbols>, public CDebugDialog<CDebugSymbols>,

View File

@ -567,11 +567,11 @@ LRESULT CDebugMemoryView::OnHxCtrlKeyPressed(LPNMHDR lpNMHDR)
m_Breakpoints->ClearMemLocks(); m_Breakpoints->ClearMemLocks();
break; break;
case 'F': case 'F':
// todo put selection in the textbox // TODO: put selection in the textbox
m_Debugger->OpenMemorySearch(); m_Debugger->OpenMemorySearch();
break; break;
case 'S': case 'S':
// todo set start and end addrs to selection // TODO: set start and end address to selection
m_Debugger->OpenMemoryDump(); m_Debugger->OpenMemoryDump();
break; break;
case 'T': case 'T':
@ -786,8 +786,8 @@ LRESULT CDebugMemoryView::OnHxGetByteInfo(LPNMHDR lpNMHDR)
continue; continue;
} }
// always use virtual addresses for breakpoint & symbol info // Always use virtual addresses for breakpoint and symbol info
// todo should be the other way around // TODO: should be the other way around
uint32_t vaddress = m_bVirtualMemory ? address : address + 0x80000000; uint32_t vaddress = m_bVirtualMemory ? address : address + 0x80000000;
CSymbol symbol; CSymbol symbol;
@ -938,7 +938,7 @@ LRESULT CDebugMemoryView::OnHxHotAddrChanged(LPNMHDR /*lpNMHDR*/)
LRESULT CDebugMemoryView::OnHxBaseAddrChanged(LPNMHDR /*lpNMHDR*/) LRESULT CDebugMemoryView::OnHxBaseAddrChanged(LPNMHDR /*lpNMHDR*/)
{ {
// address was updated from the control // Address was updated from the control
uint32_t address = m_HexEditCtrl.GetBaseAddress(); uint32_t address = m_HexEditCtrl.GetBaseAddress();
m_bIgnoreAddressInput = true; m_bIgnoreAddressInput = true;
m_MemAddr.SetValue(address, DisplayMode::ZeroExtend); m_MemAddr.SetValue(address, DisplayMode::ZeroExtend);
@ -973,7 +973,7 @@ LRESULT CDebugMemoryView::OnHxPaste(LPNMHDR lpNMHDR)
if (nmp->column == HX_COL_HEXDATA) if (nmp->column == HX_COL_HEXDATA)
{ {
char* data = NULL; char* data = NULL;
// todo move this function to some utility class // TODO: move this function to some utility class
int length = CMemoryScanner::ParseHexString(NULL, text); int length = CMemoryScanner::ParseHexString(NULL, text);
if (length != 0) if (length != 0)
@ -1143,7 +1143,7 @@ void CDebugMemoryView::CloseTab(int nItem)
{ {
if (nItem == m_TabCtrl.GetItemCount() - 1) if (nItem == m_TabCtrl.GetItemCount() - 1)
{ {
// last tab // Last tab
m_TabCtrl.SetCurSel(nItem - 1); m_TabCtrl.SetCurSel(nItem - 1);
} }
else if (nItem == nSelItem) else if (nItem == nSelItem)

View File

@ -277,4 +277,3 @@ private:
TOOLTIP(IDC_CHK_VADDR, "Checked = Use virtual address space (CPU), Unchecked = Use physical address space (RCP)") TOOLTIP(IDC_CHK_VADDR, "Checked = Use virtual address space (CPU), Unchecked = Use physical address space (RCP)")
END_TOOLTIP_MAP() END_TOOLTIP_MAP()
}; };

View File

@ -457,7 +457,7 @@ void CDebuggerUI::TLBChanged()
Debug_RefreshTLBWindow(); Debug_RefreshTLBWindow();
} }
// Exception handling - break on exception vector if exception bp is set // Exception handling - break on exception vector if exception BP is set
void CDebuggerUI::HandleCPUException(void) void CDebuggerUI::HandleCPUException(void)
{ {
int exc = (g_Reg->CAUSE_REGISTER >> 2) & 0x1F; int exc = (g_Reg->CAUSE_REGISTER >> 2) & 0x1F;
@ -467,7 +467,7 @@ void CDebuggerUI::HandleCPUException(void)
if ((ExceptionBreakpoints() & (1 << exc))) if ((ExceptionBreakpoints() & (1 << exc)))
{ {
if (exc == 15) // floating-point exception if (exc == 15) // Floating-point exception
{ {
if (fpExc & FpExceptionBreakpoints()) if (fpExc & FpExceptionBreakpoints())
{ {
@ -475,7 +475,7 @@ void CDebuggerUI::HandleCPUException(void)
} }
return; return;
} }
else if (exc == 0) // interrupt exception else if (exc == 0) // Interrupt exception
{ {
if (intr & IntrBreakpoints()) if (intr & IntrBreakpoints())
{ {
@ -487,14 +487,14 @@ void CDebuggerUI::HandleCPUException(void)
} }
return; return;
} }
else // other interrupts else // Other interrupts
{ {
goto have_bp; goto have_bp;
} }
} }
return; return;
} }
else // other exceptions else // Other exceptions
{ {
goto have_bp; goto have_bp;
} }
@ -522,7 +522,7 @@ void CDebuggerUI::HandleCartToRamDMA(void)
m_DMALog->AddEntry(dmaRomAddr, dmaRamAddr, dmaLen); m_DMALog->AddEntry(dmaRomAddr, dmaRamAddr, dmaLen);
Debug_RefreshDMALogWindow(); Debug_RefreshDMALogWindow();
// break if write breakpoint exists anywhere in target buffer // Break if write breakpoint exists anywhere in target buffer
if (m_Breakpoints->WriteBPExistsInChunk(dmaRamAddr, dmaLen)) if (m_Breakpoints->WriteBPExistsInChunk(dmaRamAddr, dmaLen))
{ {
g_Settings->SaveBool(Debugger_SteppingOps, true); g_Settings->SaveBool(Debugger_SteppingOps, true);
@ -586,7 +586,7 @@ void CDebuggerUI::CPUStepStarted()
if (pc == 0x80000000 || pc == 0x80000080 || if (pc == 0x80000000 || pc == 0x80000080 ||
pc == 0xA0000100 || pc == 0x80000180) pc == 0xA0000100 || pc == 0x80000180)
{ {
if ((g_Reg->STATUS_REGISTER >> 1) & 3) // if exl/erl bits are set if ((g_Reg->STATUS_REGISTER >> 1) & 3) // If EXL/ERL bits are set
{ {
HandleCPUException(); HandleCPUException();
} }
@ -657,7 +657,7 @@ void CDebuggerUI::CPUStepEnded()
{ {
m_StackTrace->PopEntry(); m_StackTrace->PopEntry();
} }
else if (op == R4300i_CP0 && funct == R4300i_COP0_CO_ERET) // TODO may need more work else if (op == R4300i_CP0 && funct == R4300i_COP0_CO_ERET) // TODO: may need more work
{ {
m_StackTrace->ClearEntries(); m_StackTrace->ClearEntries();
} }

View File

@ -16,4 +16,4 @@
#include "Debugger-CPULogView.h" #include "Debugger-CPULogView.h"
#include "Debugger-StackView.h" #include "Debugger-StackView.h"
#include "Debugger-StackTrace.h" #include "Debugger-StackTrace.h"
#include "Debugger-ExceptionBreakpoints.h" #include "Debugger-ExceptionBreakpoints.h"

View File

@ -298,7 +298,7 @@ uint32_t CScanResult::GetVirtualAddress(void)
} }
else else
{ {
// convert physical to virtual kseg0 // Convert physical to virtual kseg0
return (m_Address | 0x80000000); return (m_Address | 0x80000000);
} }
} }
@ -470,9 +470,6 @@ bool CScanResult::SetStrLengthSafe(int length)
// m_bSelected = bSelected; // m_bSelected = bSelected;
//} //}
/*********************/
CMemoryScanner::CMemoryScanner(void) : CMemoryScanner::CMemoryScanner(void) :
m_DidFirstScan(false), m_DidFirstScan(false),
m_ValueType(ValueType_uint8), m_ValueType(ValueType_uint8),
@ -550,13 +547,13 @@ bool CMemoryScanner::SetAddressRange(uint32_t startAddress, uint32_t endAddress)
{ {
m_VAddrBits = startAddress & 0xE0000000; m_VAddrBits = startAddress & 0xE0000000;
// don't allow TLB // Don't allow TLB
if (!RangeCheck(startAddress, endAddress, 0x80000000, 0xBFFFFFFF)) if (!RangeCheck(startAddress, endAddress, 0x80000000, 0xBFFFFFFF))
{ {
return false; return false;
} }
// use physical addresses internally // Use physical addresses internally
startAddress = startAddress & 0x1FFFFFFF; startAddress = startAddress & 0x1FFFFFFF;
endAddress = endAddress & 0x1FFFFFFF; endAddress = endAddress & 0x1FFFFFFF;
} }
@ -589,7 +586,7 @@ bool CMemoryScanner::SetAddressRange(uint32_t startAddress, uint32_t endAddress)
} }
else else
{ {
return false; // invalid range return false; // Invalid range
} }
m_Memory = GetMemoryPool(startAddress); m_Memory = GetMemoryPool(startAddress);
@ -711,7 +708,7 @@ void CMemoryScanner::RemoveResult(size_t index)
m_Results.erase(m_Results.begin() + index); m_Results.erase(m_Results.begin() + index);
} }
// scan for text or hex array // Scan for text or hexadecimal array
void CMemoryScanner::FirstScanLoopString(DisplayFormat resultDisplayFormat) void CMemoryScanner::FirstScanLoopString(DisplayFormat resultDisplayFormat)
{ {
int length = m_StringValueLength; int length = m_StringValueLength;
@ -740,7 +737,7 @@ void CMemoryScanner::FirstScanLoopString(DisplayFormat resultDisplayFormat)
} }
} }
// scan for text (case-insensitive) // Scan for text (case-insensitive)
void CMemoryScanner::FirstScanLoopIString(DisplayFormat resultDisplayFormat) void CMemoryScanner::FirstScanLoopIString(DisplayFormat resultDisplayFormat)
{ {
int length = m_StringValueLength; int length = m_StringValueLength;
@ -769,7 +766,7 @@ void CMemoryScanner::FirstScanLoopIString(DisplayFormat resultDisplayFormat)
} }
} }
// scan for text of unknown single-byte encoding // Scan for text of unknown single-byte encoding
void CMemoryScanner::FirstScanLoopUnkString(void) void CMemoryScanner::FirstScanLoopUnkString(void)
{ {
const char* str = stdstr().FromUTF16(m_Value._string).c_str(); const char* str = stdstr().FromUTF16(m_Value._string).c_str();
@ -921,7 +918,7 @@ bool CMemoryScanner::FirstScan(DisplayFormat resDisplayFormat)
#define _NextScanLoopPrimitive64(T, Compare) NextScanLoopPrimitive64<T>(Compare<T>) #define _NextScanLoopPrimitive64(T, Compare) NextScanLoopPrimitive64<T>(Compare<T>)
#define _NextScanLoopPrimitiveResults64(T, Compare) NextScanLoopPrimitiveResults64<T>(Compare<T>) #define _NextScanLoopPrimitiveResults64(T, Compare) NextScanLoopPrimitiveResults64<T>(Compare<T>)
// compare result's current value in memory against m_Value // Compare result's current value in memory against m_Value
#define NEXT_SCAN_PRIMITIVES_AGAINST_VALUE(CompareFunc) \ #define NEXT_SCAN_PRIMITIVES_AGAINST_VALUE(CompareFunc) \
switch(m_ValueType) \ switch(m_ValueType) \
{ \ { \
@ -937,7 +934,7 @@ bool CMemoryScanner::FirstScan(DisplayFormat resDisplayFormat)
case ValueType_double: _NextScanLoopPrimitive64(double, CompareFunc); break; \ case ValueType_double: _NextScanLoopPrimitive64(double, CompareFunc); break; \
} }
// compare result's current value in memory against result's old value // Compare result's current value in memory against result's old value
#define NEXT_SCAN_PRIMITIVES_AGAINST_RESULTS(CompareFunc) \ #define NEXT_SCAN_PRIMITIVES_AGAINST_RESULTS(CompareFunc) \
switch(m_ValueType) \ switch(m_ValueType) \
{ \ { \

View File

@ -15,7 +15,7 @@ enum ValueType
ValueType_int64, ValueType_int64,
ValueType_float, ValueType_float,
ValueType_double, ValueType_double,
// non-primitives: // Non-primitives:
ValueType_string, ValueType_string,
ValueType_istring, ValueType_istring,
ValueType_unkstring ValueType_unkstring
@ -34,10 +34,10 @@ enum SearchType
SearchType_GreaterThanValue, SearchType_GreaterThanValue,
SearchType_LessThanOrEqualToValue, SearchType_LessThanOrEqualToValue,
SearchType_GreaterThanOrEqualToValue, SearchType_GreaterThanOrEqualToValue,
// first scan only: // First scan only:
SearchType_UnknownValue, SearchType_UnknownValue,
SearchType_JalTo, SearchType_JalTo,
// next scan only: // Next scan only:
SearchType_ChangedValue, SearchType_ChangedValue,
SearchType_UnchangedValue, SearchType_UnchangedValue,
SearchType_IncreasedValue, SearchType_IncreasedValue,
@ -250,7 +250,7 @@ private:
} }
} }
// for int64 and double // For int64 and double
template <class T> template <class T>
void FirstScanLoopPrimitive64(bool(*CompareFunc)(T, T), DisplayFormat resultDisplayFormat) void FirstScanLoopPrimitive64(bool(*CompareFunc)(T, T), DisplayFormat resultDisplayFormat)
{ {
@ -276,7 +276,7 @@ private:
} }
} }
// compare result's current value in memory against m_Value // Compare result's current value in memory against m_Value
template <class T> template <class T>
void NextScanLoopPrimitive(bool(*CompareFunc)(T, T)) void NextScanLoopPrimitive(bool(*CompareFunc)(T, T))
{ {
@ -301,7 +301,7 @@ private:
m_Results.swap(m_NewResults); m_Results.swap(m_NewResults);
} }
// compare result's current value in memory against m_Value (for 64 bit types) // Compare result's current value in memory against m_Value (for 64-bit types)
template <class T> template <class T>
void NextScanLoopPrimitive64(bool(*CompareFunc)(T, T)) void NextScanLoopPrimitive64(bool(*CompareFunc)(T, T))
{ {
@ -328,7 +328,7 @@ private:
m_Results.swap(m_NewResults); m_Results.swap(m_NewResults);
} }
// compare result's current value in memory against result's old value // Compare result's current value in memory against result's old value
template <class T> template <class T>
void NextScanLoopPrimitiveResults(bool(*CompareFunc)(T, T)) void NextScanLoopPrimitiveResults(bool(*CompareFunc)(T, T))
{ {
@ -354,7 +354,7 @@ private:
m_Results.swap(m_NewResults); m_Results.swap(m_NewResults);
} }
// compare result's current value in memory against result's old value (for 64 bit types) // Compare result's current value in memory against result's old value (for 64-bit types)
template <class T> template <class T>
void NextScanLoopPrimitiveResults64(bool(*CompareFunc)(T, T)) void NextScanLoopPrimitiveResults64(bool(*CompareFunc)(T, T))
{ {

View File

@ -21,7 +21,7 @@ public:
bool IsStaticJump() bool IsStaticJump()
{ {
// j, jal // J, JAL
uint32_t op = m_OpCode.op; uint32_t op = m_OpCode.op;
@ -35,7 +35,7 @@ public:
bool IsJump() bool IsJump()
{ {
// j, jal, jr, jalr, exception // J, JAL, JR, JALR, exception
uint32_t op = m_OpCode.op; uint32_t op = m_OpCode.op;
@ -147,13 +147,13 @@ public:
m_OpCode.op >= R4300i_SC && m_OpCode.op <= R4300i_SD); m_OpCode.op >= R4300i_SC && m_OpCode.op <= R4300i_SD);
} }
// addiu sp, sp, x // ADDIU SP, SP, X
bool IsStackShift() bool IsStackShift()
{ {
return (m_OpCode.op == R4300i_ADDIU || m_OpCode.op == R4300i_ADDI) && m_OpCode.rt == 29; return (m_OpCode.op == R4300i_ADDIU || m_OpCode.op == R4300i_ADDI) && m_OpCode.rt == 29;
} }
// addiu sp, sp, <negative value> // ADDIU SP, SP, <negative value>
bool IsStackAlloc() bool IsStackAlloc()
{ {
if (!IsStackShift()) if (!IsStackShift())
@ -164,7 +164,7 @@ public:
return (short)m_OpCode.immediate < 0; return (short)m_OpCode.immediate < 0;
} }
// addiu sp, sp, <positive value> // ADDIU SP, SP, <positive value>
bool IsStackFree() bool IsStackFree()
{ {
if (!IsStackShift()) if (!IsStackShift())
@ -384,4 +384,4 @@ public:
return 4; return 4;
} }
} }
}; };

View File

@ -176,4 +176,4 @@ CScriptHook::CScriptHook(CScriptSystem* scriptSystem)
CScriptHook::~CScriptHook() CScriptHook::~CScriptHook()
{ {
m_Callbacks.clear(); m_Callbacks.clear();
} }

View File

@ -32,9 +32,9 @@ public:
void InvokeAll(); void InvokeAll();
void InvokeById(int callbackId); void InvokeById(int callbackId);
void InvokeByParam(uint32_t param); void InvokeByParam(uint32_t param);
/* invoke if param >= cb.param && param < cb.param2*/ // invoke if param >= cb.param && param < cb.param2
void InvokeByAddressInRange(uint32_t address); void InvokeByAddressInRange(uint32_t address);
/* invoke if param >= cb.param && param < cb.param2 && (value & cb.param4) == cb.param3 */ // invoke if param >= cb.param && param < cb.param2 && (value & cb.param4) == cb.param3
void InvokeByAddressInRange_MaskedOpcode(uint32_t pc, uint32_t value); void InvokeByAddressInRange_MaskedOpcode(uint32_t pc, uint32_t value);
void InvokeByAddressInRange_GPRValue(uint32_t pc); void InvokeByAddressInRange_GPRValue(uint32_t pc);
void RemoveById(int callbackId); void RemoveById(int callbackId);

View File

@ -105,7 +105,7 @@ void CScriptInstance::SetState(INSTANCE_STATE state)
void CScriptInstance::StateChanged() void CScriptInstance::StateChanged()
{ {
// todo mutex might be needed here // TODO: mutex might be needed here
m_Debugger->Debug_RefreshScriptsWindow(); m_Debugger->Debug_RefreshScriptsWindow();
//m_ScriptSystem->DeleteStoppedInstances(); //m_ScriptSystem->DeleteStoppedInstances();
@ -179,7 +179,7 @@ void CScriptInstance::StartEventLoop()
{ {
SetState(STATE_RUNNING); SetState(STATE_RUNNING);
// Todo interrupt with an apc when an event is removed and event count is 0 // TODO: interrupt with an APC when an event is removed and event count is 0
while (HaveEvents()) while (HaveEvents())
{ {
IOLISTENER* lpListener; IOLISTENER* lpListener;
@ -300,7 +300,7 @@ void CScriptInstance::CloseAllAsyncFiles()
void CScriptInstance::RemoveAsyncFile(HANDLE fd) void CScriptInstance::RemoveAsyncFile(HANDLE fd)
{ {
// Stop tracking an fd and remove all of its listeners // Stop tracking an FD and remove all of its listeners
for (uint32_t i = 0; i < m_AsyncFiles.size(); i++) for (uint32_t i = 0; i < m_AsyncFiles.size(); i++)
{ {
IOFD iofd = m_AsyncFiles[i]; IOFD iofd = m_AsyncFiles[i];
@ -357,8 +357,9 @@ void CScriptInstance::RemoveListenerByIndex(UINT index)
} }
else else
{ {
// TODO: Remove/fix?
// This isn't a good replacement and the script aspects of the debugger shouldn't // This isn't a good replacement and the script aspects of the debugger shouldn't
// be used in WindowsXP // be used in Windows XP
CancelIo(lpListener->fd); CancelIo(lpListener->fd);
} }
@ -367,7 +368,7 @@ void CScriptInstance::RemoveListenerByIndex(UINT index)
m_Listeners.erase(m_Listeners.begin() + index); m_Listeners.erase(m_Listeners.begin() + index);
} }
// Free listener & its buffer, remove from list // Free listener & it's buffer, remove from list
void CScriptInstance::RemoveListener(IOLISTENER* lpListener) void CScriptInstance::RemoveListener(IOLISTENER* lpListener)
{ {
for (UINT i = 0; i < m_Listeners.size(); i++) for (UINT i = 0; i < m_Listeners.size(); i++)
@ -415,19 +416,19 @@ void CScriptInstance::InvokeListenerCallback(IOLISTENER* lpListener)
} }
else else
{ {
// handle must have closed, safe to untrack fd and remove all associated listeners // Handle must have closed, safe to untrack FD and remove all associated listeners
RemoveAsyncFile(lpListener->fd); RemoveAsyncFile(lpListener->fd);
// pass null to callback // Pass null to callback
duk_push_null(m_Ctx); duk_push_null(m_Ctx);
} }
break; break;
case EVENT_WRITE: case EVENT_WRITE:
nargs = 1; nargs = 1;
duk_push_uint(m_Ctx, lpListener->dataLen); // num bytes written duk_push_uint(m_Ctx, lpListener->dataLen); // Number of bytes written
break; break;
case EVENT_ACCEPT: case EVENT_ACCEPT:
// pass client socket fd to callback // Pass client socket FD to callback
nargs = 1; nargs = 1;
duk_push_uint(m_Ctx, (UINT)lpListener->childFd); duk_push_uint(m_Ctx, (UINT)lpListener->childFd);
break; break;
@ -585,8 +586,6 @@ void CScriptInstance::QueueAPC(PAPCFUNC userProc, ULONG_PTR param)
} }
} }
/****************************/
duk_ret_t CScriptInstance::js_ioSockConnect(duk_context* ctx) duk_ret_t CScriptInstance::js_ioSockConnect(duk_context* ctx)
{ {
CScriptInstance* _this = FetchInstance(ctx); CScriptInstance* _this = FetchInstance(ctx);
@ -668,7 +667,7 @@ duk_ret_t CScriptInstance::js_ioSockAccept(duk_context* ctx)
HANDLE fd = (HANDLE)duk_get_uint(ctx, 0); HANDLE fd = (HANDLE)duk_get_uint(ctx, 0);
void* jsCallback = duk_get_heapptr(ctx, 1); void* jsCallback = duk_get_heapptr(ctx, 1);
void* data = malloc(sizeof(SOCKADDR) * 4); // issue? void* data = malloc(sizeof(SOCKADDR) * 4); // Issue?
IOLISTENER* lpListener = _this->AddListener(fd, EVENT_ACCEPT, jsCallback, data, 0); IOLISTENER* lpListener = _this->AddListener(fd, EVENT_ACCEPT, jsCallback, data, 0);
@ -678,7 +677,7 @@ duk_ret_t CScriptInstance::js_ioSockAccept(duk_context* ctx)
int ok = AcceptEx( int ok = AcceptEx(
(SOCKET)fd, (SOCKET)fd,
(SOCKET)lpListener->childFd, (SOCKET)lpListener->childFd,
lpListener->data, // local and remote SOCKADDR lpListener->data, // Local and remote SOCKADDR
0, 0,
sizeof(SOCKADDR_IN) + 16, sizeof(SOCKADDR_IN) + 16,
sizeof(SOCKADDR_IN) + 16, sizeof(SOCKADDR_IN) + 16,
@ -706,7 +705,7 @@ duk_ret_t CScriptInstance::js_ioRead(duk_context* ctx)
size_t bufferSize = duk_get_uint(ctx, 1); size_t bufferSize = duk_get_uint(ctx, 1);
void* jsCallback = duk_get_heapptr(ctx, 2); void* jsCallback = duk_get_heapptr(ctx, 2);
void* data = malloc(bufferSize); // freed after event is fired void* data = malloc(bufferSize); // Freed after event is fired
IOLISTENER* lpListener = _this->AddListener(fd, EVENT_READ, jsCallback, data, bufferSize); IOLISTENER* lpListener = _this->AddListener(fd, EVENT_READ, jsCallback, data, bufferSize);
BOOL status = ReadFile(fd, lpListener->data, lpListener->dataLen, NULL, (LPOVERLAPPED)lpListener); BOOL status = ReadFile(fd, lpListener->data, lpListener->dataLen, NULL, (LPOVERLAPPED)lpListener);
@ -729,7 +728,7 @@ duk_ret_t CScriptInstance::js_ioWrite(duk_context* ctx)
void* jsData = duk_to_buffer(ctx, 1, &dataLen); void* jsData = duk_to_buffer(ctx, 1, &dataLen);
void* jsCallback = duk_get_heapptr(ctx, 2); void* jsCallback = duk_get_heapptr(ctx, 2);
char* data = (char*)malloc(dataLen + 1); // freed after event is fired char* data = (char*)malloc(dataLen + 1); // Freed after event is fired
memcpy(data, jsData, dataLen); memcpy(data, jsData, dataLen);
data[dataLen] = '\0'; data[dataLen] = '\0';
@ -991,7 +990,7 @@ duk_ret_t CScriptInstance::js_GetROMInt(duk_context* ctx)
goto return_err; goto return_err;
} }
uint8_t* rom = g_Rom->GetRomAddress(); // little endian uint8_t* rom = g_Rom->GetRomAddress(); // Little endian
uint32_t romSize = g_Rom->GetRomSize(); uint32_t romSize = g_Rom->GetRomSize();
if (address > romSize) if (address > romSize)
@ -1060,7 +1059,7 @@ duk_ret_t CScriptInstance::js_GetROMFloat(duk_context* ctx)
goto return_err; goto return_err;
} }
uint8_t* rom = g_Rom->GetRomAddress(); // little endian uint8_t* rom = g_Rom->GetRomAddress(); // Little endian
uint32_t romSize = g_Rom->GetRomSize(); uint32_t romSize = g_Rom->GetRomSize();
if (address > romSize) if (address > romSize)
@ -1351,7 +1350,7 @@ duk_ret_t CScriptInstance::js_MsgBox(duk_context* ctx)
return 1; return 1;
} }
// Return zero-terminated string from ram // Return zero-terminated string from RAM
duk_ret_t CScriptInstance::js_GetRDRAMString(duk_context* ctx) duk_ret_t CScriptInstance::js_GetRDRAMString(duk_context* ctx)
{ {
CScriptInstance* _this = FetchInstance(ctx); CScriptInstance* _this = FetchInstance(ctx);
@ -1373,8 +1372,8 @@ duk_ret_t CScriptInstance::js_GetRDRAMString(duk_context* ctx)
uint8_t test = 0xFF; uint8_t test = 0xFF;
int len = 0; int len = 0;
// determine length of string // Determine length of string
while (len < maxLen && _this->m_Debugger->DebugLoad_VAddr(address + len, test) && test != 0) // todo protect from ram overrun while (len < maxLen && _this->m_Debugger->DebugLoad_VAddr(address + len, test) && test != 0) // TODO: protect from RAM overrun
{ {
if ((address & 0xFFFFFF) + len >= g_MMU->RdramSize()) if ((address & 0xFFFFFF) + len >= g_MMU->RdramSize())
{ {
@ -1394,11 +1393,11 @@ duk_ret_t CScriptInstance::js_GetRDRAMString(duk_context* ctx)
duk_pop_n(ctx, nargs); duk_pop_n(ctx, nargs);
duk_push_string(ctx, (char*)str); duk_push_string(ctx, (char*)str);
free(str); // duk creates internal copy free(str); // Duk creates internal copy
return 1; return 1;
} }
// Return zero-terminated string from rom // Return zero-terminated string from ROM
duk_ret_t CScriptInstance::js_GetROMString(duk_context* ctx) duk_ret_t CScriptInstance::js_GetROMString(duk_context* ctx)
{ {
// (address[, maxLen]) // (address[, maxLen])
@ -1444,11 +1443,11 @@ duk_ret_t CScriptInstance::js_GetROMString(duk_context* ctx)
duk_pop(ctx); duk_pop(ctx);
duk_push_string(ctx, str); duk_push_string(ctx, str);
free(str); // duk creates internal copy free(str); // Duk creates internal copy
return 1; return 1;
} }
// Return zero-terminated string from rom // Return zero-terminated string from ROM
duk_ret_t CScriptInstance::js_GetROMBlock(duk_context* ctx) duk_ret_t CScriptInstance::js_GetROMBlock(duk_context* ctx)
{ {
uint32_t address = duk_get_uint(ctx, 0); uint32_t address = duk_get_uint(ctx, 0);
@ -1619,7 +1618,7 @@ duk_ret_t CScriptInstance::js_FSWrite(duk_context* ctx)
if (duk_is_string(ctx, 1)) if (duk_is_string(ctx, 1))
{ {
// string // String
const char* str = duk_get_string(ctx, 1); const char* str = duk_get_string(ctx, 1);
length = strlen(str); length = strlen(str);
@ -1627,7 +1626,7 @@ duk_ret_t CScriptInstance::js_FSWrite(duk_context* ctx)
} }
else else
{ {
// buffer // Buffer
buffer = (const char*)duk_get_buffer_data(ctx, 1, &length); buffer = (const char*)duk_get_buffer_data(ctx, 1, &length);
if (buffer == NULL) if (buffer == NULL)
@ -1930,8 +1929,6 @@ duk_ret_t CScriptInstance::js_FSReadDir(duk_context* ctx)
return 1; return 1;
} }
////////////
static BOOL ConnectEx(SOCKET s, const SOCKADDR* name, int namelen, PVOID lpSendBuffer, static BOOL ConnectEx(SOCKET s, const SOCKADDR* name, int namelen, PVOID lpSendBuffer,
DWORD dwSendDataLength, LPDWORD lpdwBytesSent, LPOVERLAPPED lpOverlapped) DWORD dwSendDataLength, LPDWORD lpdwBytesSent, LPOVERLAPPED lpOverlapped)
{ {
@ -1956,4 +1953,4 @@ static BOOL ConnectEx(SOCKET s, const SOCKADDR* name, int namelen, PVOID lpSendB
} }
return false; return false;
} }

View File

@ -13,9 +13,9 @@
class CScriptSystem; class CScriptSystem;
typedef enum { typedef enum {
STATE_STARTED, // initial evaluation & execution STATE_STARTED, // Initial evaluation and execution
STATE_RUNNING, // event loop running with pending events STATE_RUNNING, // Event loop running with pending events
STATE_STOPPED, // no pending events STATE_STOPPED, // No pending events
STATE_INVALID STATE_INVALID
} INSTANCE_STATE; } INSTANCE_STATE;
@ -32,11 +32,11 @@ class CScriptInstance
OVERLAPPED ovl; OVERLAPPED ovl;
IOEVENTTYPE eventType; IOEVENTTYPE eventType;
HANDLE fd; HANDLE fd;
HANDLE childFd; // accepted socket HANDLE childFd; // Accepted socket
bool bSocket; bool bSocket;
UINT id; UINT id;
void* data; void* data;
DWORD dataLen; // changed to bytes transferred after event is fired DWORD dataLen; // Changed to bytes transferred after event is fired
void* callback; void* callback;
} IOLISTENER; } IOLISTENER;
@ -122,14 +122,15 @@ private:
//static void CALLBACK EvalAsyncCallback(ULONG_PTR evalWait); //static void CALLBACK EvalAsyncCallback(ULONG_PTR evalWait);
bool AddFile(const char* path, const char* mode, int* fd); // return fd bool AddFile(const char* path, const char* mode, int* fd); // Return FD
void CloseFile(int fd); void CloseFile(int fd);
FILE* GetFilePointer(int fd); FILE* GetFilePointer(int fd);
void CloseAllFiles(); void CloseAllFiles();
const char* EvalFile(const char* jsPath); const char* EvalFile(const char* jsPath);
// Handle to to dynamically load CancelIoEx for Windows XP compatibility // TODO: fix/remove?
// Handle dynamically loading CancelIoEx for Windows XP compatibility
HMODULE m_hKernel; HMODULE m_hKernel;
Dynamic_CancelIoEx m_CancelIoEx; Dynamic_CancelIoEx m_CancelIoEx;
@ -146,7 +147,7 @@ private:
static duk_ret_t js_ioSockConnect(duk_context*); // async static duk_ret_t js_ioSockConnect(duk_context*); // async
static duk_ret_t js_ioRead(duk_context*); // async static duk_ret_t js_ioRead(duk_context*); // async
static duk_ret_t js_ioWrite(duk_context*); // async static duk_ret_t js_ioWrite(duk_context*); // async
static duk_ret_t js_ioClose(duk_context*); // (fd) ; file or socket static duk_ret_t js_ioClose(duk_context*); // (FD) ; file or socket
static duk_ret_t js_MsgBox(duk_context*); // (message, caption) static duk_ret_t js_MsgBox(duk_context*); // (message, caption)
static duk_ret_t js_AddCallback(duk_context*); // (hookId, callback, tag) ; external events static duk_ret_t js_AddCallback(duk_context*); // (hookId, callback, tag) ; external events
static duk_ret_t js_RemoveCallback(duk_context*); // (callbackId) static duk_ret_t js_RemoveCallback(duk_context*); // (callbackId)
@ -177,8 +178,8 @@ private:
static duk_ret_t js_ConsoleClear(duk_context*); static duk_ret_t js_ConsoleClear(duk_context*);
static duk_ret_t js_BreakHere(duk_context*); static duk_ret_t js_BreakHere(duk_context*);
static duk_ret_t js_Pause(duk_context*); // () ; pauses emulation static duk_ret_t js_Pause(duk_context*); // () ; Pauses emulation
static duk_ret_t js_ShowCommands(duk_context*); // ([address]) ; shows commands window static duk_ret_t js_ShowCommands(duk_context*); // ([address]) ; Shows commands window
static duk_ret_t js_ScreenPrint(duk_context*); // (x, y, text) static duk_ret_t js_ScreenPrint(duk_context*); // (x, y, text)
@ -252,4 +253,4 @@ private:
{ "fsReadDir", js_FSReadDir, DUK_VARARGS }, { "fsReadDir", js_FSReadDir, DUK_VARARGS },
{ NULL, NULL, 0 } { NULL, NULL, 0 }
}; };
}; };

View File

@ -62,7 +62,7 @@ void CScriptSystem::RunScript(const char * path)
{ {
CGuard guard(m_CS); CGuard guard(m_CS);
CScriptInstance* scriptInstance = new CScriptInstance(m_Debugger); CScriptInstance* scriptInstance = new CScriptInstance(m_Debugger);
char* pathSaved = (char*)malloc(strlen(path)+1); // freed via DeleteStoppedInstances char* pathSaved = (char*)malloc(strlen(path)+1); // Freed via DeleteStoppedInstances
strcpy(pathSaved, path); strcpy(pathSaved, path);
m_RunningInstances.push_back({ pathSaved, scriptInstance }); m_RunningInstances.push_back({ pathSaved, scriptInstance });

View File

@ -49,7 +49,7 @@ private:
CriticalSection m_CS; CriticalSection m_CS;
void RegisterHook(const char* hookId, CScriptHook* cbList); // associate string id with callback list void RegisterHook(const char* hookId, CScriptHook* cbList); // Associate string ID with callback list
void UnregisterHooks(); void UnregisterHooks();
HDC m_ScreenDC; HDC m_ScreenDC;
@ -133,4 +133,4 @@ public:
{ {
return m_HookFrameDrawn; return m_HookFrameDrawn;
} }
}; };

View File

@ -176,4 +176,4 @@ public:
{ {
return CSymbolTable::GetTypeSize(m_Type); return CSymbolTable::GetTypeSize(m_Type);
} }
}; };