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 },
{ "dsub", R4300i_SPECIAL_DSUB, 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 }, //
{ "tlt", R4300i_SPECIAL_TLT, 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);
// attempt to assemble the line
// if a syntax error occurs, check if the command has alternative syntax forms and retry
// Attempt to assemble the line
// If a syntax error occurs, check if the command has alternative syntax forms and retry
for(int nFallback = 0;; nFallback++)
{
@ -327,7 +327,7 @@ bool CAssembler::AssembleLine(const char* line, uint32_t* opcode, uint32_t addre
if (nFallback > 0)
{
// prepare for re-tokenization
// Prepare for re-tokenization
strncpy(line_c, line, 128);
StrToLower(line_c);
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;
next_fallback:;
@ -436,11 +436,11 @@ uint32_t CAssembler::pop_val()
// return 0;
//}
int base = 0; // hex or dec
int base = 0; // Hexadecimal or decimal
if (*v == '$')
{
base = 16; // hex
base = 16; // Hexadecimal
v++;
}

View File

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

View File

@ -21,7 +21,7 @@ uint8_t* CDebugMMU::GetPhysicalPtr(uint32_t paddr, WORD* flags)
bool bCartRom = false;
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);
}
@ -55,7 +55,7 @@ uint8_t* CDebugMMU::GetPhysicalPtr(uint32_t paddr, WORD* flags)
}
else
{
// note: write-only registers are excluded
// Note: write-only registers are excluded
switch (paddr)
{
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;
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;
uint8_t data[4];
@ -186,7 +186,7 @@ bool CDebugMMU::GetPhysicalByte(uint32_t paddr, uint8_t* value)
*value = data[nByte ^ 3];
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();
uint32_t flashStatus = flashRam->ReadFromFlashStatus(0x08000000);

View File

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

View File

@ -91,7 +91,7 @@ LRESULT CDebugCommandsView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA
m_bIgnorePCChange = true;
m_PCEdit.SetValue(0x80000180, DisplayMode::ZeroExtend);
// Setup View PC button
// Setup view PC button
m_ViewPCButton.EnableWindow(FALSE);
m_StepButton.EnableWindow(FALSE);
m_StepOverButton.EnableWindow(FALSE);
@ -162,6 +162,7 @@ void CDebugCommandsView::RecompilerCheck(void)
!g_Settings->LoadBool(Setting_ForceInterpreterCPU) &&
(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"
L"For optimal experience, enable \"Always use interpreter core\" "
L"in advanced settings and restart the emulator.",
@ -259,7 +260,7 @@ void CDebugCommandsView::AddBranchArrow(int startPos, int endPos)
{
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) ||
(endPos >= arrow.startPos && endPos <= arrow.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;
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();
}
@ -693,35 +694,35 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR)
return CDRF_DODEFAULT;
}
if (nSubItem == CCommandList::COL_ADDRESS) // addr
if (nSubItem == CCommandList::COL_ADDRESS) // ADDR
{
CBreakpoints::BPSTATE bpState = m_Breakpoints->ExecutionBPExists(address);
if (bpState == CBreakpoints::BP_SET)
{
// breakpoint
// Breakpoint
pLVCD->clrTextBk = RGB(0x44, 0x00, 0x00);
pLVCD->clrText = (address == pc && isDebugging()) ?
RGB(0xFF, 0xFF, 0x00) : // breakpoint & current pc
RGB(0xFF, 0xFF, 0x00) : // Breakpoint & current PC
RGB(0xFF, 0xCC, 0xCC);
}
else if (bpState == CBreakpoints::BP_SET_TEMP)
{
// breakpoint
// Breakpoint
pLVCD->clrTextBk = RGB(0x66, 0x44, 0x00);
pLVCD->clrText = (address == pc && isDebugging()) ?
RGB(0xFF, 0xFF, 0x00) : // breakpoint & current pc
RGB(0xFF, 0xFF, 0x00) : // Breakpoint & current PC
RGB(0xFF, 0xEE, 0xCC);
}
else if (address == pc && isStepping())
{
// pc
// PC
pLVCD->clrTextBk = RGB(0x88, 0x88, 0x88);
pLVCD->clrText = RGB(0xFF, 0xFF, 0);
}
else
{
//default
// Default
pLVCD->clrTextBk = RGB(0xEE, 0xEE, 0xEE);
pLVCD->clrText = RGB(0x44, 0x44, 0x44);
}
@ -730,7 +731,7 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR)
// (nSubItem == 1 || nSubItem == 2)
// cmd & args
// Command and arguments
COpInfo OpInfo;
OPCODE& OpCode = OpInfo.m_OpCode;
bool bAddrOkay = m_Debugger->DebugLoad_VAddr(address, OpCode.Hex);
@ -794,10 +795,10 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR)
return CDRF_DODEFAULT;
}
// color register usage
// todo localise to temp register context (dont look before/after jumps and frame shifts)
COLORREF clrUsedRegister = RGB(0xF5, 0xF0, 0xFF); // light purple
COLORREF clrAffectedRegister = RGB(0xFF, 0xF0, 0xFF); // light pink
// Color register usage
// TODO: localize to temp register context (don't look before/after jumps and frame shifts)
COLORREF clrUsedRegister = RGB(0xF5, 0xF0, 0xFF); // Light purple
COLORREF clrAffectedRegister = RGB(0xFF, 0xF0, 0xFF); // Light pink
int pcUsedRegA = 0, pcUsedRegB = 0, pcChangedReg = 0;
int curUsedRegA = 0, curUsedRegB = 0, curChangedReg = 0;
@ -865,16 +866,16 @@ void CDebugCommandsView::DrawBranchArrows(HDC listDC)
{
COLORREF colors[] =
{
RGB(240, 240, 240), // white
RGB(30, 135, 255), // blue
RGB(255, 0, 200), // pink
RGB(215, 155, 0), // yellow
RGB(100, 180, 0), // green
RGB(200, 100, 255), // purple
RGB(120, 120, 120), // gray
RGB(0, 220, 160), // cyan
RGB(255, 100, 0), // orange
RGB(255, 255, 0), // yellow
RGB(240, 240, 240), // White
RGB(30, 135, 255), // Blue
RGB(255, 0, 200), // Pink
RGB(215, 155, 0), // Yellow
RGB(100, 180, 0), // Green
RGB(200, 100, 255), // Purple
RGB(120, 120, 120), // Gray
RGB(0, 220, 160), // Cyan
RGB(255, 100, 0), // Orange
RGB(255, 255, 0), // Yellow
};
int nColors = sizeof(colors) / sizeof(COLORREF);
@ -930,13 +931,13 @@ void CDebugCommandsView::DrawBranchArrows(HDC listDC)
int marginX = baseX - (4 + arrow.margin * 3);
// draw start pointer
// Draw start pointer
SetPixel(listDC, begX + 0, begY - 1, color);
SetPixel(listDC, begX + 1, begY - 2, color);
SetPixel(listDC, begX + 0, begY + 1, color);
SetPixel(listDC, begX + 1, begY + 2, color);
// draw outline
// Draw outline
CPen hPenOutline(CreatePen(PS_SOLID, 3, bgColor));
SelectObject(listDC, hPenOutline);
MoveToEx(listDC, begX - 1, begY, NULL);
@ -947,7 +948,7 @@ void CDebugCommandsView::DrawBranchArrows(HDC listDC)
LineTo(listDC, endX + 2, endY);
}
// draw fill line
// Draw fill line
CPen hPen(CreatePen(PS_SOLID, 1, color));
SelectObject(listDC, hPen);
MoveToEx(listDC, begX - 1, begY, NULL);
@ -958,7 +959,7 @@ void CDebugCommandsView::DrawBranchArrows(HDC listDC)
LineTo(listDC, endX + 2, endY);
}
// draw end pointer
// Draw end pointer
if (bEndVisible)
{
SetPixel(listDC, endX - 0, endY - 1, color);
@ -1061,13 +1062,13 @@ void CDebugCommandsView::CPUStepOver()
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);
CPUResume();
}
else
{
// normal step
// Normal step
if (WaitingForStep())
{
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*/)
{
// Add temp bp and resume
// Add temp BP and resume
m_Breakpoints->AddExecution(m_SelectedAddress, true);
return FALSE;
}
@ -1491,7 +1492,7 @@ void CDebugCommandsView::RedrawCommandsAndRegisters()
m_RegisterTabs.RedrawCurrentTab();
// Fix cmd list header
// Fix command list header
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*/)
{
// handle multiline input
// Handle multiline input
size_t length = m_OpEdit.GetWindowTextLength();
wchar_t* text = new wchar_t[length + 1];
m_OpEdit.GetWindowText(text, length + 1);

View File

@ -35,6 +35,7 @@ bool CDebugDMALogView::FilterEntry(int dmaLogIndex)
return true;
}
*/
void CDebugDMALogView::RefreshList()
{
if (g_Rom == NULL)
@ -105,7 +106,7 @@ void CDebugDMALogView::RefreshList()
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]))
{
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);
if (nItem >= 1) // continuation
if (nItem >= 1) // Continuation
{
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);

View File

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

View File

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

View File

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

View File

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

View File

@ -132,7 +132,7 @@ private:
"Virtual coherency (data)"
};
// for static dlgprocs, assumes single instance
// For static dlgprocs, assumes single instance
static bool m_bColorsEnabled;
static CDebuggerUI* m_Debugger;

View File

@ -439,7 +439,7 @@ void CDebugScripts::RunSelected()
}
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"");
int historySize = m_History.size();
// remove duplicate
// Remove duplicate
for (int i = 0; i < historySize; i++)
{
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)
{
m_History.erase(m_History.begin() + 0);

View File

@ -81,7 +81,7 @@ void CDebugStackTrace::Refresh()
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.DeleteAllItems();

View File

@ -119,7 +119,7 @@ LRESULT CDebugSymbols::OnListDblClicked(NMHDR* pNMHDR)
int nSelectedCol = -1;
// hit test for column
// Hit test for column
POINT mousePt;
RECT listRect;
@ -153,11 +153,11 @@ LRESULT CDebugSymbols::OnListDblClicked(NMHDR* pNMHDR)
{
case SymbolsListView_Col_Address:
// 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);
}
else // data/number
else // Data/number
{
m_Debugger->Debug_ShowMemoryLocation(symbol.m_Address, true);
}
@ -167,7 +167,7 @@ LRESULT CDebugSymbols::OnListDblClicked(NMHDR* pNMHDR)
{
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()->AddSymbol(t, symbol.m_Address, symbol.m_Name, symbol.m_Description);
}

View File

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

View File

@ -567,11 +567,11 @@ LRESULT CDebugMemoryView::OnHxCtrlKeyPressed(LPNMHDR lpNMHDR)
m_Breakpoints->ClearMemLocks();
break;
case 'F':
// todo put selection in the textbox
// TODO: put selection in the textbox
m_Debugger->OpenMemorySearch();
break;
case 'S':
// todo set start and end addrs to selection
// TODO: set start and end address to selection
m_Debugger->OpenMemoryDump();
break;
case 'T':
@ -786,8 +786,8 @@ LRESULT CDebugMemoryView::OnHxGetByteInfo(LPNMHDR lpNMHDR)
continue;
}
// always use virtual addresses for breakpoint & symbol info
// todo should be the other way around
// Always use virtual addresses for breakpoint and symbol info
// TODO: should be the other way around
uint32_t vaddress = m_bVirtualMemory ? address : address + 0x80000000;
CSymbol symbol;
@ -938,7 +938,7 @@ LRESULT CDebugMemoryView::OnHxHotAddrChanged(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();
m_bIgnoreAddressInput = true;
m_MemAddr.SetValue(address, DisplayMode::ZeroExtend);
@ -973,7 +973,7 @@ LRESULT CDebugMemoryView::OnHxPaste(LPNMHDR lpNMHDR)
if (nmp->column == HX_COL_HEXDATA)
{
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);
if (length != 0)
@ -1143,7 +1143,7 @@ void CDebugMemoryView::CloseTab(int nItem)
{
if (nItem == m_TabCtrl.GetItemCount() - 1)
{
// last tab
// Last tab
m_TabCtrl.SetCurSel(nItem - 1);
}
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)")
END_TOOLTIP_MAP()
};

View File

@ -457,7 +457,7 @@ void CDebuggerUI::TLBChanged()
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)
{
int exc = (g_Reg->CAUSE_REGISTER >> 2) & 0x1F;
@ -467,7 +467,7 @@ void CDebuggerUI::HandleCPUException(void)
if ((ExceptionBreakpoints() & (1 << exc)))
{
if (exc == 15) // floating-point exception
if (exc == 15) // Floating-point exception
{
if (fpExc & FpExceptionBreakpoints())
{
@ -475,7 +475,7 @@ void CDebuggerUI::HandleCPUException(void)
}
return;
}
else if (exc == 0) // interrupt exception
else if (exc == 0) // Interrupt exception
{
if (intr & IntrBreakpoints())
{
@ -487,14 +487,14 @@ void CDebuggerUI::HandleCPUException(void)
}
return;
}
else // other interrupts
else // Other interrupts
{
goto have_bp;
}
}
return;
}
else // other exceptions
else // Other exceptions
{
goto have_bp;
}
@ -522,7 +522,7 @@ void CDebuggerUI::HandleCartToRamDMA(void)
m_DMALog->AddEntry(dmaRomAddr, dmaRamAddr, dmaLen);
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))
{
g_Settings->SaveBool(Debugger_SteppingOps, true);
@ -586,7 +586,7 @@ void CDebuggerUI::CPUStepStarted()
if (pc == 0x80000000 || pc == 0x80000080 ||
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();
}
@ -657,7 +657,7 @@ void CDebuggerUI::CPUStepEnded()
{
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();
}

View File

@ -298,7 +298,7 @@ uint32_t CScanResult::GetVirtualAddress(void)
}
else
{
// convert physical to virtual kseg0
// Convert physical to virtual kseg0
return (m_Address | 0x80000000);
}
}
@ -470,9 +470,6 @@ bool CScanResult::SetStrLengthSafe(int length)
// m_bSelected = bSelected;
//}
/*********************/
CMemoryScanner::CMemoryScanner(void) :
m_DidFirstScan(false),
m_ValueType(ValueType_uint8),
@ -550,13 +547,13 @@ bool CMemoryScanner::SetAddressRange(uint32_t startAddress, uint32_t endAddress)
{
m_VAddrBits = startAddress & 0xE0000000;
// don't allow TLB
// Don't allow TLB
if (!RangeCheck(startAddress, endAddress, 0x80000000, 0xBFFFFFFF))
{
return false;
}
// use physical addresses internally
// Use physical addresses internally
startAddress = startAddress & 0x1FFFFFFF;
endAddress = endAddress & 0x1FFFFFFF;
}
@ -589,7 +586,7 @@ bool CMemoryScanner::SetAddressRange(uint32_t startAddress, uint32_t endAddress)
}
else
{
return false; // invalid range
return false; // Invalid range
}
m_Memory = GetMemoryPool(startAddress);
@ -711,7 +708,7 @@ void CMemoryScanner::RemoveResult(size_t 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)
{
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)
{
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)
{
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 _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) \
switch(m_ValueType) \
{ \
@ -937,7 +934,7 @@ bool CMemoryScanner::FirstScan(DisplayFormat resDisplayFormat)
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) \
switch(m_ValueType) \
{ \

View File

@ -15,7 +15,7 @@ enum ValueType
ValueType_int64,
ValueType_float,
ValueType_double,
// non-primitives:
// Non-primitives:
ValueType_string,
ValueType_istring,
ValueType_unkstring
@ -34,10 +34,10 @@ enum SearchType
SearchType_GreaterThanValue,
SearchType_LessThanOrEqualToValue,
SearchType_GreaterThanOrEqualToValue,
// first scan only:
// First scan only:
SearchType_UnknownValue,
SearchType_JalTo,
// next scan only:
// Next scan only:
SearchType_ChangedValue,
SearchType_UnchangedValue,
SearchType_IncreasedValue,
@ -250,7 +250,7 @@ private:
}
}
// for int64 and double
// For int64 and double
template <class T>
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>
void NextScanLoopPrimitive(bool(*CompareFunc)(T, T))
{
@ -301,7 +301,7 @@ private:
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>
void NextScanLoopPrimitive64(bool(*CompareFunc)(T, T))
{
@ -328,7 +328,7 @@ private:
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>
void NextScanLoopPrimitiveResults(bool(*CompareFunc)(T, T))
{
@ -354,7 +354,7 @@ private:
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>
void NextScanLoopPrimitiveResults64(bool(*CompareFunc)(T, T))
{

View File

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

View File

@ -32,9 +32,9 @@ public:
void InvokeAll();
void InvokeById(int callbackId);
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);
/* 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_GPRValue(uint32_t pc);
void RemoveById(int callbackId);

View File

@ -105,7 +105,7 @@ void CScriptInstance::SetState(INSTANCE_STATE state)
void CScriptInstance::StateChanged()
{
// todo mutex might be needed here
// TODO: mutex might be needed here
m_Debugger->Debug_RefreshScriptsWindow();
//m_ScriptSystem->DeleteStoppedInstances();
@ -179,7 +179,7 @@ void CScriptInstance::StartEventLoop()
{
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())
{
IOLISTENER* lpListener;
@ -300,7 +300,7 @@ void CScriptInstance::CloseAllAsyncFiles()
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++)
{
IOFD iofd = m_AsyncFiles[i];
@ -357,8 +357,9 @@ void CScriptInstance::RemoveListenerByIndex(UINT index)
}
else
{
// TODO: Remove/fix?
// 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);
}
@ -367,7 +368,7 @@ void CScriptInstance::RemoveListenerByIndex(UINT 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)
{
for (UINT i = 0; i < m_Listeners.size(); i++)
@ -415,19 +416,19 @@ void CScriptInstance::InvokeListenerCallback(IOLISTENER* lpListener)
}
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);
// pass null to callback
// Pass null to callback
duk_push_null(m_Ctx);
}
break;
case EVENT_WRITE:
nargs = 1;
duk_push_uint(m_Ctx, lpListener->dataLen); // num bytes written
duk_push_uint(m_Ctx, lpListener->dataLen); // Number of bytes written
break;
case EVENT_ACCEPT:
// pass client socket fd to callback
// Pass client socket FD to callback
nargs = 1;
duk_push_uint(m_Ctx, (UINT)lpListener->childFd);
break;
@ -585,8 +586,6 @@ void CScriptInstance::QueueAPC(PAPCFUNC userProc, ULONG_PTR param)
}
}
/****************************/
duk_ret_t CScriptInstance::js_ioSockConnect(duk_context* 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);
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);
@ -678,7 +677,7 @@ duk_ret_t CScriptInstance::js_ioSockAccept(duk_context* ctx)
int ok = AcceptEx(
(SOCKET)fd,
(SOCKET)lpListener->childFd,
lpListener->data, // local and remote SOCKADDR
lpListener->data, // Local and remote SOCKADDR
0,
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);
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);
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* 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);
data[dataLen] = '\0';
@ -991,7 +990,7 @@ duk_ret_t CScriptInstance::js_GetROMInt(duk_context* ctx)
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();
if (address > romSize)
@ -1060,7 +1059,7 @@ duk_ret_t CScriptInstance::js_GetROMFloat(duk_context* ctx)
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();
if (address > romSize)
@ -1351,7 +1350,7 @@ duk_ret_t CScriptInstance::js_MsgBox(duk_context* ctx)
return 1;
}
// Return zero-terminated string from ram
// Return zero-terminated string from RAM
duk_ret_t CScriptInstance::js_GetRDRAMString(duk_context* ctx)
{
CScriptInstance* _this = FetchInstance(ctx);
@ -1373,8 +1372,8 @@ duk_ret_t CScriptInstance::js_GetRDRAMString(duk_context* ctx)
uint8_t test = 0xFF;
int len = 0;
// determine length of string
while (len < maxLen && _this->m_Debugger->DebugLoad_VAddr(address + len, test) && test != 0) // todo protect from ram overrun
// Determine length of string
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())
{
@ -1394,11 +1393,11 @@ duk_ret_t CScriptInstance::js_GetRDRAMString(duk_context* ctx)
duk_pop_n(ctx, nargs);
duk_push_string(ctx, (char*)str);
free(str); // duk creates internal copy
free(str); // Duk creates internal copy
return 1;
}
// Return zero-terminated string from rom
// Return zero-terminated string from ROM
duk_ret_t CScriptInstance::js_GetROMString(duk_context* ctx)
{
// (address[, maxLen])
@ -1444,11 +1443,11 @@ duk_ret_t CScriptInstance::js_GetROMString(duk_context* ctx)
duk_pop(ctx);
duk_push_string(ctx, str);
free(str); // duk creates internal copy
free(str); // Duk creates internal copy
return 1;
}
// Return zero-terminated string from rom
// Return zero-terminated string from ROM
duk_ret_t CScriptInstance::js_GetROMBlock(duk_context* ctx)
{
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))
{
// string
// String
const char* str = duk_get_string(ctx, 1);
length = strlen(str);
@ -1627,7 +1626,7 @@ duk_ret_t CScriptInstance::js_FSWrite(duk_context* ctx)
}
else
{
// buffer
// Buffer
buffer = (const char*)duk_get_buffer_data(ctx, 1, &length);
if (buffer == NULL)
@ -1930,8 +1929,6 @@ duk_ret_t CScriptInstance::js_FSReadDir(duk_context* ctx)
return 1;
}
////////////
static BOOL ConnectEx(SOCKET s, const SOCKADDR* name, int namelen, PVOID lpSendBuffer,
DWORD dwSendDataLength, LPDWORD lpdwBytesSent, LPOVERLAPPED lpOverlapped)
{

View File

@ -13,9 +13,9 @@
class CScriptSystem;
typedef enum {
STATE_STARTED, // initial evaluation & execution
STATE_RUNNING, // event loop running with pending events
STATE_STOPPED, // no pending events
STATE_STARTED, // Initial evaluation and execution
STATE_RUNNING, // Event loop running with pending events
STATE_STOPPED, // No pending events
STATE_INVALID
} INSTANCE_STATE;
@ -32,11 +32,11 @@ class CScriptInstance
OVERLAPPED ovl;
IOEVENTTYPE eventType;
HANDLE fd;
HANDLE childFd; // accepted socket
HANDLE childFd; // Accepted socket
bool bSocket;
UINT id;
void* data;
DWORD dataLen; // changed to bytes transferred after event is fired
DWORD dataLen; // Changed to bytes transferred after event is fired
void* callback;
} IOLISTENER;
@ -122,14 +122,15 @@ private:
//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);
FILE* GetFilePointer(int fd);
void CloseAllFiles();
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;
Dynamic_CancelIoEx m_CancelIoEx;
@ -146,7 +147,7 @@ private:
static duk_ret_t js_ioSockConnect(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_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_AddCallback(duk_context*); // (hookId, callback, tag) ; external events
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_BreakHere(duk_context*);
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_Pause(duk_context*); // () ; Pauses emulation
static duk_ret_t js_ShowCommands(duk_context*); // ([address]) ; Shows commands window
static duk_ret_t js_ScreenPrint(duk_context*); // (x, y, text)

View File

@ -62,7 +62,7 @@ void CScriptSystem::RunScript(const char * path)
{
CGuard guard(m_CS);
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);
m_RunningInstances.push_back({ pathSaved, scriptInstance });

View File

@ -49,7 +49,7 @@ private:
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();
HDC m_ScreenDC;