debugger: rework to display disasm bg in white and current PC bg in blue

This commit is contained in:
feos-tas 2016-09-17 19:57:51 +00:00
parent 7b1609e75e
commit 2bf748a94c
2 changed files with 67 additions and 23 deletions

View File

@ -69,6 +69,8 @@ WNDPROC IDC_DEBUGGER_DISASSEMBLY_oldWndProc = 0;
static HFONT hFont;
static SCROLLINFO si;
static HBRUSH WhiteBrush = CreateSolidBrush(RGB(255,255,255));
static HBRUSH BlueBrush = CreateSolidBrush(RGB(208,255,255));
bool debuggerAutoload = false;
bool debuggerSaveLoadDEBFiles = true;
@ -86,6 +88,7 @@ std::vector<uint16> disassembly_addresses;
std::vector<std::vector<uint16>> disassembly_operands;
// this is used to autoscroll the Disassembly window while keeping relative position of the ">" pointer inside this window
unsigned int PC_pointerOffset = 0;
int PCLine = -1;
// this is used for dirty, but unavoidable hack, which is necessary to ensure the ">" pointer is visible when stepping/seeking to PC
bool PCPointerWasDrawn = false;
// and another hack...
@ -410,6 +413,7 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr)
int lines = (rect.bottom-rect.top) / debugSystem->fixedFontHeight;
debug_str[0] = 0;
PCLine = -1;
unsigned int instructions_count = 0;
for (int i = 0; i < lines; i++)
{
@ -466,6 +470,7 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr)
PCPointerWasDrawn = true;
beginningOfPCPointerLine = strlen(debug_str);
strcat(debug_str, ">");
PCLine = instructions_count;
} else
{
strcat(debug_str, " ");
@ -475,14 +480,14 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr)
{
if (debuggerDisplayROMoffsets && GetNesFileAddress(addr) != -1)
{
sprintf(chr, " %06X:", GetNesFileAddress(addr));
sprintf(chr, " %06X: ", GetNesFileAddress(addr));
} else
{
sprintf(chr, "%02X:%04X:", getBank(addr), addr);
sprintf(chr, "%02X:%04X: ", getBank(addr), addr);
}
} else
{
sprintf(chr, " %04X:", addr);
sprintf(chr, " %04X: ", addr);
}
// Add address
@ -562,7 +567,7 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr)
if (cdl_data == 3)
strcat(debug_cdl_str, "cd\r\n"); // both Code and Data
else if (cdl_data == 2)
strcat(debug_cdl_str, " d\r\n"); // Data
strcat(debug_cdl_str, " d\r\n"); // Data
else if (cdl_data == 1)
strcat(debug_cdl_str, "c\r\n"); // Code
else
@ -1482,8 +1487,31 @@ int Debugger_CheckClickingOnAnAddressOrSymbolicName(unsigned int lineNumber, boo
BOOL CALLBACK IDC_DEBUGGER_DISASSEMBLY_WndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
switch(uMsg)
{
case WM_PAINT:
{
BeginPaint(hwndDlg, &ps);
HDC hdcStatic = GetDC(hwndDlg);
SetBkMode(hdcStatic, TRANSPARENT);
SetTextColor(hdcStatic, RGB(0, 0, 0));
RECT rect;
GetClientRect(hwndDlg, &rect);
SelectObject(hdcStatic, (HGDIOBJ)debugSystem->hFixedFont);
FillRect(hdcStatic, &rect, WhiteBrush);
if (PCLine != -1)
{
RECT PC = {
rect.left, debugSystem->fixedFontHeight * PCLine + 1,
rect.right, debugSystem->fixedFontHeight * PCLine + debugSystem->fixedFontHeight + 1 };
FillRect(hdcStatic, &PC, BlueBrush);
}
OffsetRect(&rect, 1, 1);
DrawText(hdcStatic, debug_str, strlen(debug_str), &rect, NULL);
EndPaint(hwndDlg, &ps);
return 0;
}
case WM_LBUTTONDBLCLK:
{
int offset = Debugger_CheckClickingOnAnAddressOrSymbolicName(GET_Y_LPARAM(lParam) / debugSystem->fixedFontHeight, false);
@ -1498,6 +1526,13 @@ BOOL CALLBACK IDC_DEBUGGER_DISASSEMBLY_WndProc(HWND hwndDlg, UINT uMsg, WPARAM w
}
return 0;
}
case WM_LBUTTONDOWN:
{
RECT rect;
GetClientRect(hwndDlg, &rect);
InvalidateRect(hwndDlg, &rect, 0);
break;
}
case WM_LBUTTONUP:
{
Debugger_CheckClickingOnAnAddressOrSymbolicName(GET_Y_LPARAM(lParam) / debugSystem->fixedFontHeight, true);
@ -1701,7 +1736,7 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
newDebuggerRect.top = currDebuggerRect.top;
newDebuggerRect.bottom = currDebuggerRect.bottom;
}
SetWindowPos(hwndDlg,HWND_TOPMOST,newDebuggerRect.left,newDebuggerRect.top,(newDebuggerRect.right-newDebuggerRect.left),(newDebuggerRect.bottom-newDebuggerRect.top),SWP_SHOWWINDOW);
SetWindowPos(hwndDlg,HWND_TOPMOST,newDebuggerRect.left,newDebuggerRect.top,(newDebuggerRect.right-newDebuggerRect.left),(newDebuggerRect.bottom-newDebuggerRect.top),SWP_SHOWWINDOW);
}
//Else run normal resizing procedure-------------------------
else
@ -1737,6 +1772,14 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
}
break;
case WM_CTLCOLORSTATIC:
if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_DEBUGGER_DISASSEMBLY))
{
SetBkColor((HDC)wParam, RGB(255, 255, 255));
return (LRESULT) GetStockObject(DC_BRUSH);
}
break;
//adelikat: Buttons that don't need a rom loaded to do something, such as autoload
case WM_COMMAND:
{
@ -1944,8 +1987,8 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
mouse_y = GET_Y_LPARAM(lParam);
// ################################## Start of SP CODE ###########################
// mouse_y < 538
// > 33) tmp = 33
// mouse_y < 538
// > 33) tmp = 33
//mbg merge 7/18/06 changed pausing check
if (FCEUI_EmulationPaused() && (mouse_x > 6) && (mouse_x < 30) && (mouse_y > 10))
{

View File

@ -869,21 +869,21 @@ BEGIN
LTEXT "Display on scanline:",-1,173,269,65,9
EDITTEXT IDC_NTVIEW_SCANLINE,235,267,27,12
CONTROL "Show Scroll Lines",IDC_NTVIEW_SHOW_SCROLL_LINES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,254,69,10
CONTROL "Show Attributes", IDC_NTVIEW_SHOW_ATTRIBUTES, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,265,69,10
CONTROL "Ignore Palettes", IDC_NTVIEW_HIDE_PALETTES, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,276,69,10
CONTROL "Show Attributes",IDC_NTVIEW_SHOW_ATTRIBUTES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,265,69,10
CONTROL "Ignore Palettes",IDC_NTVIEW_HIDE_PALETTES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,276,69,10
GROUPBOX "Current Mirroring",-1,2,289,130,59
CONTROL "Horizontal", IDC_NTVIEW_MIRROR_HORIZONTAL, "Button",BS_AUTORADIOBUTTON,6,300,47,10
CONTROL "Vertical", IDC_NTVIEW_MIRROR_VERTICAL, "Button",BS_AUTORADIOBUTTON,6,311,39,10
CONTROL "Horizontal",IDC_NTVIEW_MIRROR_HORIZONTAL,"Button",BS_AUTORADIOBUTTON,6,300,47,10
CONTROL "Vertical",IDC_NTVIEW_MIRROR_VERTICAL,"Button",BS_AUTORADIOBUTTON,6,311,39,10
CONTROL "Four Screen",IDC_NTVIEW_MIRROR_FOUR_SCREEN,"Button",BS_AUTORADIOBUTTON,6,322,55,10
CONTROL "Single Screen 0",IDC_NTVIEW_MIRROR_SS_TABLE_0,"Button",BS_AUTORADIOBUTTON,65,300,60,10
CONTROL "Single Screen 1",IDC_NTVIEW_MIRROR_SS_TABLE_1,"Button",BS_AUTORADIOBUTTON,65,311,60,10
CONTROL "Single Screen 2",IDC_NTVIEW_MIRROR_SS_TABLE_2,"Button",BS_AUTORADIOBUTTON,65,322,60,10
CONTROL "Single Screen 3",IDC_NTVIEW_MIRROR_SS_TABLE_3,"Button",BS_AUTORADIOBUTTON,65,333,60,10
GROUPBOX "Properties",-1,134,289,130,59
LTEXT "Tile ID:", IDC_NTVIEW_PROPERTIES_LINE_1,144,300,110,10
LTEXT "X / Y:", IDC_NTVIEW_PROPERTIES_LINE_2,144,311,110,10
LTEXT "Tile ID:",IDC_NTVIEW_PROPERTIES_LINE_1,144,300,110,10
LTEXT "X / Y:",IDC_NTVIEW_PROPERTIES_LINE_2,144,311,110,10
LTEXT "PPU Address:",IDC_NTVIEW_PROPERTIES_LINE_3,144,322,110,10
LTEXT "Attribute:", IDC_NTVIEW_PROPERTIES_LINE_4,144,333,110,10
LTEXT "Attribute:",IDC_NTVIEW_PROPERTIES_LINE_4,144,333,110,10
END
ROMPATCHER DIALOGEX 84, 67, 304, 135
@ -1251,16 +1251,18 @@ CAPTION "PPU Viewer"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
GROUPBOX "Pattern Tables",GRP_PPUVIEW_TABLES,2,-1,263,185,WS_TABSTOP
LTEXT "Tile:",LBL_PPUVIEW_TILE1, 6,138,50,9
LTEXT "Tile:",LBL_PPUVIEW_TILE1,6,138,50,9
LTEXT "Tile:",LBL_PPUVIEW_TILE2,134,138,50,9
LTEXT "Refresh: More",-1,145,151,50,9
CONTROL "",CTL_PPUVIEW_TRACKBAR,"msctls_trackbar32",WS_TABSTOP,195,151,50,11
LTEXT "Less",-1,245,151,18,10
LTEXT "Display on scanline:",-1,173,166,65,9
EDITTEXT IDC_PPUVIEW_SCANLINE,235,164,27,12
CONTROL "Sprites 8x16 mode", IDC_SPRITE16_MODE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,151, 75,10
CONTROL "Mask unused graphics (Code/Data Logger)",IDC_MASK_UNUSED_GRAPHICS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,162,140,10
CONTROL "Invert the mask (Code/Data Logger)", IDC_INVERT_THE_MASK, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,173,140,10
CONTROL "Sprites 8x16 mode",IDC_SPRITE16_MODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,151,75,10
CONTROL "Mask unused graphics (Code/Data Logger)",IDC_MASK_UNUSED_GRAPHICS,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,162,140,10
CONTROL "Invert the mask (Code/Data Logger)",IDC_INVERT_THE_MASK,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,173,140,10
GROUPBOX "Palettes",LBL_PPUVIEW_PALETTES,2,185,263,46,WS_TABSTOP
END
@ -1697,7 +1699,6 @@ BEGIN
"PPUVIEW", DIALOG
BEGIN
BOTTOMMARGIN, 258
END
"ARCHIVECHOOSERDIALOG", DIALOG
@ -1871,10 +1872,10 @@ BEGIN
END
POPUP "RAM Init"
BEGIN
MENUITEM "&Default", MENU_RAMINIT_DEFAULT
MENUITEM "Fill $&FF", MENU_RAMINIT_FF
MENUITEM "Fill $&00", MENU_RAMINIT_00
MENUITEM "&Random", MENU_RAMINIT_RANDOM
MENUITEM "&Default", MENU_RAMINIT_DEFAULT
MENUITEM "Fill $&FF", MENU_RAMINIT_FF
MENUITEM "Fill $&00", MENU_RAMINIT_00
MENUITEM "&Random", MENU_RAMINIT_RANDOM
END
MENUITEM SEPARATOR
MENUITEM "&Directories...", MENU_DIRECTORIES