* Lua: auto-clearing previous frame drawings (same behaviour as other emulators)

* Debugger: fixed mouseover when using Symbolic debugging
* Debugger: mouseover works for the disassembly window too
* updated docs

[[Split portion of a mixed commit.]]
This commit is contained in:
ansstuff 2012-09-23 12:45:28 +00:00
parent 48a55b2fa2
commit e30c685c5e
12 changed files with 254 additions and 194 deletions

View File

@ -1,3 +1,6 @@
23-Aug-2012 - AnS - Lua: clear previous frame drawings at the beginning of every frame
23-Aug-2012 - AnS - Debugger: fixed mouseover when using Symbolic debugging; mouseover works for the disassembly window too
22-Aug-2012 - AnS - Tracer: added "Symbolic tracing", "Log current Frame number", "Log emulator messages", "Log breakpoint hits" options
11-Aug-2012 - AnS - new Lua function: emu.setlagflag() 11-Aug-2012 - AnS - new Lua function: emu.setlagflag()
11-Aug-2012 - AnS - Debugger: deleting a breakpoint leaves selection in the Breakpoints list 11-Aug-2012 - AnS - Debugger: deleting a breakpoint leaves selection in the Breakpoints list
06-Aug-2012 - AnS - added "Use Custom Palette" checkbox to Palette config 06-Aug-2012 - AnS - added "Use Custom Palette" checkbox to Palette config
@ -31,7 +34,7 @@
08-Aug-2012 - AnS - Debugger: show the number of breakpoints (enabled and total) above the breakpoints list 08-Aug-2012 - AnS - Debugger: show the number of breakpoints (enabled and total) above the breakpoints list
06-Aug-2012 - CaH4e3 - fixed bug when loading UNF games (#525 ) 06-Aug-2012 - CaH4e3 - fixed bug when loading UNF games (#525 )
06-Aug-2012 - AnS - Tracer also updates its window when user pauses the game, not just when Debugger snaps 06-Aug-2012 - AnS - Tracer also updates its window when user pauses the game, not just when Debugger snaps
06-Aug-2012 - AnS - Tracer: added "Use Stack Pointer for lines tabbing" option and added "To the left from disassembly text" option 06-Aug-2012 - AnS - Tracer: added "Use Stack Pointer for code tabbing" option and added "To the left from disassembly text" option
05-Aug-2012 - AnS - Debugger: .DEB file now also stores the state of "Break on Bad Opcode" and "Break when exceed" checkboxes/editfields 05-Aug-2012 - AnS - Debugger: .DEB file now also stores the state of "Break on Bad Opcode" and "Break when exceed" checkboxes/editfields
05-Aug-2012 - AnS - Debugger: added "CPU cycles" and "Instructions" counters (request #527) and added "Break when exceed" breakpoints 05-Aug-2012 - AnS - Debugger: added "CPU cycles" and "Instructions" counters (request #527) and added "Break when exceed" breakpoints
05-Aug-2012 - AnS - Debugger: window layout cleanup 05-Aug-2012 - AnS - Debugger: window layout cleanup

View File

@ -85,6 +85,12 @@ bool debuggerAutoload = false;
bool debuggerSaveLoadDEBFiles = true; bool debuggerSaveLoadDEBFiles = true;
bool debuggerDisplayROMoffsets = false; bool debuggerDisplayROMoffsets = false;
char debug_str[35000] = {0};
char debug_str_decoration[NL_MAX_MULTILINE_COMMENT_LEN + NL_MAX_NAME_LEN + 10] = {0};
// this is used to keep track of addresses that lines of Disassembly window correspont to
std::vector<unsigned int> disassembly_addresses;
#define INVALID_START_OFFSET 1 #define INVALID_START_OFFSET 1
#define INVALID_END_OFFSET 2 #define INVALID_END_OFFSET 2
@ -337,10 +343,10 @@ BOOL CALLBACK AddbpCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
return FALSE; //TRUE; return FALSE; //TRUE;
} }
void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr) { void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr)
{
// ################################## Start of SP CODE ########################### // ################################## Start of SP CODE ###########################
// Changed 25 to 33 in this function for more disassembly lines
// Changed size of str (TODO: Better calculation of max size) // Changed size of str (TODO: Better calculation of max size)
// Changed the buffer size of str to 35000 // Changed the buffer size of str to 35000
@ -348,9 +354,11 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr) {
// ################################## End of SP CODE ########################### // ################################## End of SP CODE ###########################
char str[35000] = {0}, chr[40] = {0}; char chr[40] = {0};
int size; int size;
uint8 opcode[3]; uint8 opcode[3];
disassembly_addresses.resize(0);
// ################################## Start of SP CODE ########################### // ################################## Start of SP CODE ###########################
@ -364,9 +372,10 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr) {
//figure out how many lines we can draw //figure out how many lines we can draw
RECT rect; RECT rect;
GetClientRect(hWnd,&rect); GetClientRect(GetDlgItem(hWnd, id), &rect);
int lines = (rect.bottom-rect.top) / debugSystem->fixedFontHeight; int lines = (rect.bottom-rect.top) / debugSystem->fixedFontHeight;
debug_str[0] = 0;
for (int i = 0; i < lines; i++) for (int i = 0; i < lines; i++)
{ {
// PC pointer // PC pointer
@ -375,53 +384,77 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr) {
// ################################## Start of SP CODE ########################### // ################################## Start of SP CODE ###########################
if (symbDebugEnabled) if (symbDebugEnabled)
decorateAddress(addr, str); {
// Insert Name and Comment lines if needed
debug_str_decoration[0] = 0;
decorateAddress(addr, debug_str_decoration);
if (debug_str_decoration[0])
{
// divide the str_decoration into strings (Name, Comment1, Comment2, ...)
char* start_pos = debug_str_decoration;
char* end_pos = strstr(debug_str_decoration, "\r");
while (end_pos)
{
end_pos[0] = 0; // set \0 instead of \r
strcat(debug_str, start_pos);
strcat(debug_str, "\r\n");
end_pos += 2;
start_pos = end_pos;
end_pos = strstr(end_pos, "\r");
// we added one line to the disassembly window
disassembly_addresses.push_back(addr);
i++;
}
}
}
// ################################## End of SP CODE ########################### // ################################## End of SP CODE ###########################
if (addr == X.PC) if (addr == X.PC)
strcat(str, ">"); strcat(debug_str, ">");
else else
strcat(str, " "); strcat(debug_str, " ");
if (addr >= 0x8000) if (addr >= 0x8000)
{ {
if (debuggerDisplayROMoffsets && GetNesFileAddress(addr) != -1) if (debuggerDisplayROMoffsets && GetNesFileAddress(addr) != -1)
{ {
sprintf(chr, " %06X", GetNesFileAddress(addr)); sprintf(chr, " %06X:", GetNesFileAddress(addr));
} else } else
{ {
sprintf(chr, "%02X:%04X", getBank(addr), addr); sprintf(chr, "%02X:%04X:", getBank(addr), addr);
} }
} else } else
{ {
sprintf(chr, " :%04X", addr); sprintf(chr, " :%04X:", addr);
} }
// Add address // Add address
strcat(str, chr); strcat(debug_str, chr);
strcat(str, ":"); disassembly_addresses.push_back(addr);
if ((size = opsize[GetMem(addr)]) == 0) if ((size = opsize[GetMem(addr)]) == 0)
{ {
sprintf(chr, "%02X UNDEFINED", GetMem(addr++)); sprintf(chr, "%02X UNDEFINED", GetMem(addr++));
strcat(str,chr); strcat(debug_str, chr);
} else } else
{ {
char* a; char* a;
if ((addr+size) > 0x10000) { //should this be 0xFFFF? if ((addr+size) > 0x10000) { //should this be 0xFFFF?
while (addr < 0x10000) { while (addr < 0x10000) {
sprintf(chr, "%02X OVERFLOW\r\n", GetMem(addr++)); sprintf(chr, "%02X OVERFLOW\r\n", GetMem(addr++));
strcat(str,chr); strcat(debug_str, chr);
} }
break; break;
} }
for (int j = 0; j < size; j++) { for (int j = 0; j < size; j++)
{
sprintf(chr, "%02X ", opcode[j] = GetMem(addr++)); sprintf(chr, "%02X ", opcode[j] = GetMem(addr++));
strcat(str,chr); strcat(debug_str, chr);
} }
while (size < 3) { while (size < 3)
strcat(str," "); //pad output to align ASM {
strcat(debug_str, " "); //pad output to align ASM
size++; size++;
} }
@ -438,11 +471,11 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr) {
// ################################## End of SP CODE ########################### // ################################## End of SP CODE ###########################
strcat(strcat(str," "), a); strcat(strcat(debug_str, " "), a);
} }
strcat(str,"\r\n"); strcat(debug_str, "\r\n");
} }
SetDlgItemText(hWnd,id,str); SetDlgItemText(hWnd, id, debug_str);
} }
char *DisassembleLine(int addr) { char *DisassembleLine(int addr) {
@ -603,7 +636,7 @@ void FCEUD_DebugBreakpoint(int bp_num)
} }
} }
UpdateDebugger(); UpdateDebugger(true);
UpdateOtherDebuggingDialogs(); // Keeps the debugging windows updating smoothly when stepping UpdateOtherDebuggingDialogs(); // Keeps the debugging windows updating smoothly when stepping
if (bp_num >= 0) if (bp_num >= 0)
@ -644,7 +677,7 @@ void UpdateBreakpointsCaption()
SetDlgItemText(hDebug, IDC_DEBUGGER_BREAKPOINTS, str); SetDlgItemText(hDebug, IDC_DEBUGGER_BREAKPOINTS, str);
} }
void UpdateDebugger() void UpdateDebugger(bool jump_to_pc)
{ {
//don't do anything if the debugger is not visible //don't do anything if the debugger is not visible
if(!hDebug) if(!hDebug)
@ -655,11 +688,16 @@ void UpdateDebugger()
SetForegroundWindow(hDebug); SetForegroundWindow(hDebug);
char str[512] = {0}, str2[512] = {0}, chr[8]; char str[512] = {0}, str2[512] = {0}, chr[8];
int tmp,ret,i; int tmp, ret, i, starting_addres;
if (jump_to_pc || disassembly_addresses.size() == 0)
starting_addres = X.PC;
else
starting_addres = disassembly_addresses[0];
Disassemble(hDebug, IDC_DEBUGGER_DISASSEMBLY, IDC_DEBUGGER_DISASSEMBLY_VSCR, starting_addres);
Disassemble(hDebug, IDC_DEBUGGER_DISASSEMBLY, IDC_DEBUGGER_DISASSEMBLY_VSCR, X.PC);
// "Address Bookmark Add" follows the address // "Address Bookmark Add" follows the address
sprintf(str,"%04X", X.PC); sprintf(str,"%04X", starting_addres);
SetDlgItemText(hDebug, IDC_DEBUGGER_BOOKMARK, str); SetDlgItemText(hDebug, IDC_DEBUGGER_BOOKMARK, str);
sprintf(str, "%02X", X.A); sprintf(str, "%02X", X.A);
@ -1219,30 +1257,78 @@ BOOL CALLBACK IDC_DEBUGGER_DISASSEMBLY_WndProc(HWND hwndDlg, UINT uMsg, WPARAM w
{ {
case WM_LBUTTONDBLCLK: case WM_LBUTTONDBLCLK:
{ {
// select the text // set the selection cursor
CallWindowProc(IDC_DEBUGGER_DISASSEMBLY_oldWndProc, hwndDlg, uMsg, wParam, lParam); CallWindowProc(IDC_DEBUGGER_DISASSEMBLY_oldWndProc, hwndDlg, WM_LBUTTONDOWN, wParam, lParam);
int mouse_y = GET_Y_LPARAM(lParam); // debug_str contains the text in the disassembly window
int tmp = mouse_y / debugSystem->fixedFontHeight, tmp2; DWORD sel_start, sel_end;
int i = si.nPos; SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
while (tmp > 0) // find the ":" or "$" before sel_start
int i = sel_start - 1;
for (; i > sel_start - 5; i--)
if (i >= 0 && debug_str[i] == ':' || debug_str[i] == '$')
break;
if (i > sel_start - 5)
{ {
tmp2 = opsize[GetMem(i)]; char offsetBuffer[5];
if (tmp2 == 0) tmp2++; strncpy(offsetBuffer, debug_str + i + 1, 4);
if ((i += tmp2) > 0xFFFF) offsetBuffer[4] = 0;
// invalidate the string if a space or \r is found
char* firstspace = strstr(offsetBuffer, " ");
if (!firstspace)
firstspace = strstr(offsetBuffer, "\r");
if (!firstspace)
{ {
i = 0xFFFF; unsigned int offset;
return 0; if (sscanf(offsetBuffer, "%4X", &offset) != EOF)
{
// select the text
SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_SETSEL, (WPARAM)(i + 1), (LPARAM)(i + 5));
childwnd = 1;
if (DialogBoxParam(fceu_hInstance, "ADDBP", hwndDlg, AddbpCallB, offset))
AddBreakList();
childwnd = 0;
UpdateDebugger(false);
}
} }
tmp--;
} }
// prompt "Add PC breakpoint"
childwnd = 1;
if (DialogBoxParam(fceu_hInstance, "ADDBP", hwndDlg, AddbpCallB, i))
AddBreakList();
childwnd = 0;
UpdateDebugger();
return 0; return 0;
} }
case WM_MOUSEMOVE:
{
RECT wrect;
char str[256] = {0}, *ptr, dotdot[4];
int tmp, i;
int mouse_x, mouse_y;
mouse_x = GET_X_LPARAM(lParam);
mouse_y = GET_Y_LPARAM(lParam);
tmp = mouse_y / debugSystem->fixedFontHeight;
if (tmp < (int)disassembly_addresses.size())
{
i = disassembly_addresses[tmp];
if (i >= 0x8000)
{
dotdot[0] = 0;
if (!(ptr = iNesShortFName()))
ptr = "...";
if (strlen(ptr) > 60)
strcpy(dotdot, "...");
if (GetNesFileAddress(i) == -1)
sprintf(str,"CPU Address $%04X, Error retreiving ROM File Address!",i);
else
sprintf(str,"CPU Address %02X:%04X, Offset 0x%06X in file \"%.40s%s\" (NL file: %X)",getBank(i),i,GetNesFileAddress(i),ptr,dotdot,getBank(i));
SetDlgItemText(hDebug, IDC_DEBUGGER_ADDR_LINE,str);
} else
{
SetDlgItemText(hDebug, IDC_DEBUGGER_ADDR_LINE, "Double-click on any address to prompt Add Breakpoint.");
}
} else
{
SetDlgItemText(hDebug, IDC_DEBUGGER_ADDR_LINE, "Double-click on any address to prompt Add Breakpoint.");
}
break;
}
} }
return CallWindowProc(IDC_DEBUGGER_DISASSEMBLY_oldWndProc, hwndDlg, uMsg, wParam, lParam); return CallWindowProc(IDC_DEBUGGER_DISASSEMBLY_oldWndProc, hwndDlg, uMsg, wParam, lParam);
} }
@ -1252,9 +1338,8 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
RECT wrect; RECT wrect;
char str[256] = {0}, *ptr, dotdot[4]; char str[256] = {0}, *ptr, dotdot[4];
int tmp,tmp2; int tmp,tmp2;
int mouse_x,mouse_y; int mouse_x, mouse_y;
int ret,i; int i;
//FILE *fp;
//these messages get handled at any time //these messages get handled at any time
switch(uMsg) switch(uMsg)
@ -1333,7 +1418,8 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
inDebugger = true; inDebugger = true;
break; break;
} }
case WM_SIZE: { case WM_SIZE:
{
if(wParam == SIZE_RESTORED) //If dialog was resized if(wParam == SIZE_RESTORED) //If dialog was resized
{ {
GetWindowRect(hwndDlg,&newDebuggerRect); //Get new size GetWindowRect(hwndDlg,&newDebuggerRect); //Get new size
@ -1422,17 +1508,21 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
} }
//these messages only get handled when a game is loaded //these messages only get handled when a game is loaded
if (GameInfo) { if (GameInfo)
switch(uMsg) { {
case WM_ACTIVATE: { switch(uMsg)
{
case WM_ACTIVATE:
{
//Prevents numerous situations where the debugger is out of date with the data //Prevents numerous situations where the debugger is out of date with the data
if (wParam != WA_INACTIVE) if (LOWORD(wParam) != WA_INACTIVE)
UpdateDebugger(); {
else { UpdateDebugger(false);
if (FCEUI_EmulationPaused()) } else
UpdateRegs(hwndDlg); {
if (FCEUI_EmulationPaused())
UpdateRegs(hwndDlg);
} }
break; break;
} }
case WM_VSCROLL: case WM_VSCROLL:
@ -1516,44 +1606,24 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
mouse_y = GET_Y_LPARAM(lParam); mouse_y = GET_Y_LPARAM(lParam);
bool setString = false; bool setString = false;
if ((mouse_x > 8) && (mouse_x < 22) && (mouse_y > 12)) { if ((mouse_x > 8) && (mouse_x < 22) && (mouse_y > 10))
{
setString = true; setString = true;
RECT rectDisassembly; RECT rectDisassembly;
GetClientRect(GetDlgItem(hDebug,IDC_DEBUGGER_DISASSEMBLY),&rectDisassembly); GetClientRect(GetDlgItem(hDebug,IDC_DEBUGGER_DISASSEMBLY),&rectDisassembly);
int height = rectDisassembly.bottom-rectDisassembly.top; int height = rectDisassembly.bottom-rectDisassembly.top;
tmp = mouse_y - 12; tmp = mouse_y - 10;
if(tmp > height) setString = false; if(tmp > height)
setString = false;
tmp /= debugSystem->fixedFontHeight; tmp /= debugSystem->fixedFontHeight;
} }
if(setString) if (setString)
{ {
i = si.nPos; SetDlgItemText(hDebug, IDC_DEBUGGER_ADDR_LINE, "Leftclick = Inline Assembler. Midclick = Game Genie. Rightclick = Hexeditor.");
while (tmp > 0) {
if ((tmp2=opsize[GetMem(i)]) == 0) tmp2++;
if ((i+=tmp2) > 0xFFFF) {
i = 0xFFFF;
break;
}
tmp--;
}
if (i >= 0x8000)
{
dotdot[0] = 0;
if (!(ptr = iNesShortFName())) ptr = "...";
if (strlen(ptr) > 60) strcpy(dotdot,"...");
if (GetNesFileAddress(i) == -1) sprintf(str,"CPU Address $%04X, Error retreiving ROM File Address!",i);
// ################################## Start of SP CODE ###########################
else sprintf(str,"CPU Address %02X:%04X, Offset 0x%06X in file \"%.40s%s\" (NL file: %X)",getBank(i),i,GetNesFileAddress(i),ptr,dotdot,getBank(i));
// ################################## End of SP CODE ###########################
SetDlgItemText(hwndDlg,IDC_DEBUGGER_ADDR_LINE,str);
} else
{
SetDlgItemText(hwndDlg,IDC_DEBUGGER_ADDR_LINE,"...");
}
} else } else
{ {
SetDlgItemText(hwndDlg,IDC_DEBUGGER_ADDR_LINE,"Hover the mouse over the left pane to see the ROM address of the code. Also leftclick/midclick/rightclick."); SetDlgItemText(hDebug, IDC_DEBUGGER_ADDR_LINE, "");
} }
break; break;
} }
@ -1566,24 +1636,20 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
// mouse_y < 538 // mouse_y < 538
// > 33) tmp = 33 // > 33) tmp = 33
//mbg merge 7/18/06 changed pausing check //mbg merge 7/18/06 changed pausing check
if (FCEUI_EmulationPaused() && (mouse_x > 8) && (mouse_x < 22) && (mouse_y > 10) && (mouse_y < 538)) if (FCEUI_EmulationPaused() && (mouse_x > 8) && (mouse_x < 22) && (mouse_y > 10))
{ {
tmp = (mouse_y - 10) / debugSystem->fixedFontHeight; tmp = (mouse_y - 10) / debugSystem->fixedFontHeight;
// ################################## End of SP CODE ########################### // ################################## End of SP CODE ###########################
i = si.nPos; if (tmp < (int)disassembly_addresses.size())
while (tmp > 0) { {
if ((tmp2=opsize[GetMem(i)]) == 0) tmp2++; i = disassembly_addresses[tmp];
if ((i+=tmp2) > 0xFFFF) { //DoPatcher(GetNesFileAddress(i),hwndDlg);
i = 0xFFFF; iaPC=i;
break; if (iaPC >= 0x8000)
{
DialogBox(fceu_hInstance,"ASSEMBLER",hwndDlg,AssemblerCallB);
UpdateDebugger(false);
} }
tmp--;
}
//DoPatcher(GetNesFileAddress(i),hwndDlg);
iaPC=i;
if (iaPC >= 0x8000) {
DialogBox(fceu_hInstance,"ASSEMBLER",hwndDlg,AssemblerCallB);
UpdateDebugger();
} }
} }
break; break;
@ -1593,24 +1659,19 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
mouse_x = GET_X_LPARAM(lParam); mouse_x = GET_X_LPARAM(lParam);
mouse_y = GET_Y_LPARAM(lParam); mouse_y = GET_Y_LPARAM(lParam);
//mbg merge 7/18/06 changed pausing check //mbg merge 7/18/06 changed pausing check
if (FCEUI_EmulationPaused() && (mouse_x > 8) && (mouse_x < 22) && (mouse_y > 10) && (mouse_y < 538)) if (FCEUI_EmulationPaused() && (mouse_x > 8) && (mouse_x < 22) && (mouse_y > 10))
{ {
tmp = (mouse_y - 10) / debugSystem->fixedFontHeight; tmp = (mouse_y - 10) / debugSystem->fixedFontHeight;
i = si.nPos; if (tmp < (int)disassembly_addresses.size())
while (tmp > 0) { {
if ((tmp2=opsize[GetMem(i)]) == 0) tmp2++; i = disassembly_addresses[tmp];
if ((i+=tmp2) > 0xFFFF) { if (i >= 0x8000)
i = 0xFFFF; // show ROM data in Hexeditor
break; ChangeMemViewFocus(2, GetNesFileAddress(i), -1);
} else
tmp--; // show RAM data in Hexeditor
ChangeMemViewFocus(0, i, -1);
} }
if (i >= 0x8000)
// show ROM data in Hexeditor
ChangeMemViewFocus(2, GetNesFileAddress(i), -1);
else
// show RAM data in Hexeditor
ChangeMemViewFocus(0, i, -1);
} }
break; break;
} }
@ -1619,19 +1680,14 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
mouse_x = GET_X_LPARAM(lParam); mouse_x = GET_X_LPARAM(lParam);
mouse_y = GET_Y_LPARAM(lParam); mouse_y = GET_Y_LPARAM(lParam);
//mbg merge 7/18/06 changed pausing check //mbg merge 7/18/06 changed pausing check
if (FCEUI_EmulationPaused() && (mouse_x > 8) && (mouse_x < 22) && (mouse_y > 10) && (mouse_y < 538)) if (FCEUI_EmulationPaused() && (mouse_x > 8) && (mouse_x < 22) && (mouse_y > 10))
{ {
tmp = (mouse_y - 10) / debugSystem->fixedFontHeight; tmp = (mouse_y - 10) / debugSystem->fixedFontHeight;
i = si.nPos; if (tmp < (int)disassembly_addresses.size())
while (tmp > 0) { {
if ((tmp2=opsize[GetMem(i)]) == 0) tmp2++; i = disassembly_addresses[tmp];
if ((i+=tmp2) > 0xFFFF) { SetGGConvFocus(i,GetMem(i));
i = 0xFFFF;
break;
}
tmp--;
} }
SetGGConvFocus(i,GetMem(i));
} }
break; break;
} }
@ -1649,7 +1705,7 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
childwnd = 1; childwnd = 1;
if (DialogBoxParam(fceu_hInstance,"ADDBP",hwndDlg,AddbpCallB, 0)) AddBreakList(); if (DialogBoxParam(fceu_hInstance,"ADDBP",hwndDlg,AddbpCallB, 0)) AddBreakList();
childwnd = 0; childwnd = 0;
UpdateDebugger(); UpdateDebugger(false);
break; break;
case IDC_DEBUGGER_BP_DEL: case IDC_DEBUGGER_BP_DEL:
DeleteBreak(SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_BP_LIST,LB_GETCURSEL,0,0)); DeleteBreak(SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_BP_LIST,LB_GETCURSEL,0,0));
@ -1658,7 +1714,7 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
WP_edit = SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_BP_LIST,LB_GETCURSEL,0,0); WP_edit = SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_BP_LIST,LB_GETCURSEL,0,0);
if (DialogBoxParam(fceu_hInstance, "ADDBP", hwndDlg, AddbpCallB, 0)) EditBreakList(); if (DialogBoxParam(fceu_hInstance, "ADDBP", hwndDlg, AddbpCallB, 0)) EditBreakList();
WP_edit = -1; WP_edit = -1;
UpdateDebugger(); UpdateDebugger(false);
break; break;
case IDC_DEBUGGER_RUN: case IDC_DEBUGGER_RUN:
//mbg merge 7/18/06 changed pausing check and set //mbg merge 7/18/06 changed pausing check and set
@ -1719,7 +1775,6 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
else dbgstate.jsrcount = 0; else dbgstate.jsrcount = 0;
dbgstate.stepout = 1; dbgstate.stepout = 1;
FCEUI_SetEmulationPaused(0); FCEUI_SetEmulationPaused(0);
//UpdateDebugger();
} }
break; break;
case IDC_DEBUGGER_STEP_OVER: case IDC_DEBUGGER_STEP_OVER:
@ -1733,14 +1788,13 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
} }
else FCEUI_Debugger().step = true; else FCEUI_Debugger().step = true;
FCEUI_SetEmulationPaused(0); FCEUI_SetEmulationPaused(0);
//UpdateLogWindow();
} }
break; break;
case IDC_DEBUGGER_SEEK_PC: case IDC_DEBUGGER_SEEK_PC:
//mbg merge 7/18/06 changed pausing check //mbg merge 7/18/06 changed pausing check
if (FCEUI_EmulationPaused()) { if (FCEUI_EmulationPaused()) {
UpdateRegs(hwndDlg); UpdateRegs(hwndDlg);
UpdateDebugger(); UpdateDebugger(true);
} }
break; break;
case IDC_DEBUGGER_SEEK_TO: case IDC_DEBUGGER_SEEK_TO:
@ -1763,19 +1817,19 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
case IDC_DEBUGGER_BREAK_ON_BAD_OP: //Break on bad opcode case IDC_DEBUGGER_BREAK_ON_BAD_OP: //Break on bad opcode
FCEUI_Debugger().badopbreak ^= 1; FCEUI_Debugger().badopbreak ^= 1;
break; break;
case IDC_DEBUGGER_FLAG_N: X.P^=N_FLAG; UpdateDebugger(); break; case IDC_DEBUGGER_FLAG_N: X.P^=N_FLAG; UpdateDebugger(false); break;
case IDC_DEBUGGER_FLAG_V: X.P^=V_FLAG; UpdateDebugger(); break; case IDC_DEBUGGER_FLAG_V: X.P^=V_FLAG; UpdateDebugger(false); break;
case IDC_DEBUGGER_FLAG_U: X.P^=U_FLAG; UpdateDebugger(); break; case IDC_DEBUGGER_FLAG_U: X.P^=U_FLAG; UpdateDebugger(false); break;
case IDC_DEBUGGER_FLAG_B: X.P^=B_FLAG; UpdateDebugger(); break; case IDC_DEBUGGER_FLAG_B: X.P^=B_FLAG; UpdateDebugger(false); break;
case IDC_DEBUGGER_FLAG_D: X.P^=D_FLAG; UpdateDebugger(); break; case IDC_DEBUGGER_FLAG_D: X.P^=D_FLAG; UpdateDebugger(false); break;
case IDC_DEBUGGER_FLAG_I: X.P^=I_FLAG; UpdateDebugger(); break; case IDC_DEBUGGER_FLAG_I: X.P^=I_FLAG; UpdateDebugger(false); break;
case IDC_DEBUGGER_FLAG_Z: X.P^=Z_FLAG; UpdateDebugger(); break; case IDC_DEBUGGER_FLAG_Z: X.P^=Z_FLAG; UpdateDebugger(false); break;
case IDC_DEBUGGER_FLAG_C: X.P^=C_FLAG; UpdateDebugger(); break; case IDC_DEBUGGER_FLAG_C: X.P^=C_FLAG; UpdateDebugger(false); break;
case IDC_DEBUGGER_RESET_COUNTERS: case IDC_DEBUGGER_RESET_COUNTERS:
{ {
ResetDebugStatisticsCounters(); ResetDebugStatisticsCounters();
UpdateDebugger(); UpdateDebugger(false);
break; break;
} }
case IDC_DEBUGGER_BREAK_ON_CYCLES: case IDC_DEBUGGER_BREAK_ON_CYCLES:
@ -1791,23 +1845,28 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
// ################################## Start of SP CODE ########################### // ################################## Start of SP CODE ###########################
case IDC_DEBUGGER_RELOAD_SYMS: lastBank = loadedBank = -1; loadNameFiles(); UpdateDebugger(); break; case IDC_DEBUGGER_RELOAD_SYMS:
{
lastBank = loadedBank = -1;
loadNameFiles();
UpdateDebugger(false);
break;
}
case IDC_DEBUGGER_BOOKMARK_ADD: AddDebuggerBookmark(hwndDlg); break; case IDC_DEBUGGER_BOOKMARK_ADD: AddDebuggerBookmark(hwndDlg); break;
case IDC_DEBUGGER_BOOKMARK_DEL: DeleteDebuggerBookmark(hwndDlg); break; case IDC_DEBUGGER_BOOKMARK_DEL: DeleteDebuggerBookmark(hwndDlg); break;
case IDC_DEBUGGER_ENABLE_SYMBOLIC: UpdateDebugger(); break; case IDC_DEBUGGER_ENABLE_SYMBOLIC: UpdateDebugger(false); break;
// ################################## End of SP CODE ########################### // ################################## End of SP CODE ###########################
case IDC_DEBUGGER_ROM_OFFSETS: case IDC_DEBUGGER_ROM_OFFSETS:
{ {
debuggerDisplayROMoffsets ^= 1; debuggerDisplayROMoffsets ^= 1;
UpdateDebugger(); UpdateDebugger(false);
break; break;
} }
case IDC_DEBUGGER_ROM_PATCHER: DoPatcher(-1,hwndDlg); break; case IDC_DEBUGGER_ROM_PATCHER: DoPatcher(-1,hwndDlg); break;
case DEBUGGER_CONTEXT_TOGGLEBREAK: DebuggerCallB(hwndDlg, WM_COMMAND, (LBN_DBLCLK * 0x10000) | (IDC_DEBUGGER_BP_LIST), lParam); break; case DEBUGGER_CONTEXT_TOGGLEBREAK: DebuggerCallB(hwndDlg, WM_COMMAND, (LBN_DBLCLK * 0x10000) | (IDC_DEBUGGER_BP_LIST), lParam); break;
} }
//UpdateDebugger();
break; break;
case LBN_DBLCLK: case LBN_DBLCLK:
switch(LOWORD(wParam)) { switch(LOWORD(wParam)) {
@ -1858,11 +1917,12 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
extern void iNESGI(GI h); extern void iNESGI(GI h);
void DoPatcher(int address,HWND hParent){ void DoPatcher(int address,HWND hParent)
{
iapoffset=address; iapoffset=address;
if(GameInterface==iNESGI)DialogBox(fceu_hInstance,"ROMPATCHER",hParent,PatcherCallB); if(GameInterface==iNESGI)DialogBox(fceu_hInstance,"ROMPATCHER",hParent,PatcherCallB);
else MessageBox(hDebug, "Sorry, The Patcher only works on INES rom images", "Error", MB_OK); else MessageBox(hDebug, "Sorry, The Patcher only works on INES rom images", "Error", MB_OK);
UpdateDebugger(); UpdateDebugger(false);
} }
void UpdatePatcher(HWND hwndDlg){ void UpdatePatcher(HWND hwndDlg){
@ -1924,7 +1984,8 @@ void DoDebug(uint8 halt)
updateGameDependentMenusDebugger(GameInfo != 0); updateGameDependentMenusDebugger(GameInfo != 0);
if (GameInfo) UpdateDebugger(); if (GameInfo)
UpdateDebugger(true);
} }
} }

View File

@ -33,7 +33,7 @@ int GetEditHex(HWND hwndDlg, int id);
extern void AddBreakList(); extern void AddBreakList();
extern char* BreakToText(unsigned int num); extern char* BreakToText(unsigned int num);
void UpdateDebugger(); void UpdateDebugger(bool jump_to_pc = true);
void DoDebug(uint8 halt); void DoDebug(uint8 halt);
void DebuggerExit(); void DebuggerExit();

View File

@ -37,6 +37,7 @@ Name* ramBankNames = 0;
int lastBank = -1; int lastBank = -1;
int loadedBank = -1; int loadedBank = -1;
extern char LoadedRomFName[2048]; extern char LoadedRomFName[2048];
char NLfilename[2048];
char symbDebugEnabled = 0; char symbDebugEnabled = 0;
int debuggerWasActive = 0; int debuggerWasActive = 0;
@ -538,76 +539,60 @@ Name* searchNode(Name* node, const char* offs)
void loadNameFiles() void loadNameFiles()
{ {
int cb; int cb;
char* fn = (char*)malloc(strlen(LoadedRomFName) + 20);
if (ramBankNames) if (ramBankNames)
free(ramBankNames); free(ramBankNames);
// The NL file for the RAM addresses has the name nesrom.nes.ram.nl // The NL file for the RAM addresses has the name nesrom.nes.ram.nl
strcpy(fn, LoadedRomFName); strcpy(NLfilename, LoadedRomFName);
strcat(fn, ".ram.nl"); strcat(NLfilename, ".ram.nl");
// Load the address descriptions for the RAM addresses // Load the address descriptions for the RAM addresses
ramBankNames = parseNameFile(fn); ramBankNames = parseNameFile(NLfilename);
free(fn);
// Find out which bank is loaded at 0xC000 // Find out which bank is loaded at 0xC000
cb = getBank(0xC000); cb = getBank(0xC000);
if (cb == -1) // No bank was loaded at that offset if (cb == -1) // No bank was loaded at that offset
{ {
free(lastBankNames); free(lastBankNames);
lastBankNames = 0; lastBankNames = 0;
} } else if (cb != lastBank)
else if (cb != lastBank)
{ {
char* fn = (char*)malloc(strlen(LoadedRomFName) + 12);
// If the bank changed since loading the NL files the last time it's necessary // If the bank changed since loading the NL files the last time it's necessary
// to load the address descriptions of the new bank. // to load the address descriptions of the new bank.
lastBank = cb; lastBank = cb;
// Get the name of the NL file // Get the name of the NL file
sprintf(fn, "%s.%X.nl", LoadedRomFName, lastBank); sprintf(NLfilename, "%s.%X.nl", LoadedRomFName, lastBank);
if (lastBankNames) if (lastBankNames)
freeList(lastBankNames); freeList(lastBankNames);
// Load new address definitions // Load new address definitions
lastBankNames = parseNameFile(fn); lastBankNames = parseNameFile(NLfilename);
free(fn);
} }
// Find out which bank is loaded at 0x8000 // Find out which bank is loaded at 0x8000
cb = getBank(0x8000); cb = getBank(0x8000);
if (cb == -1) // No bank is loaded at that offset if (cb == -1) // No bank is loaded at that offset
{ {
free(loadedBankNames); free(loadedBankNames);
loadedBankNames = 0; loadedBankNames = 0;
} } else if (cb != loadedBank)
else if (cb != loadedBank)
{ {
char* fn = (char*)malloc(strlen(LoadedRomFName) + 12);
// If the bank changed since loading the NL files the last time it's necessary // If the bank changed since loading the NL files the last time it's necessary
// to load the address descriptions of the new bank. // to load the address descriptions of the new bank.
loadedBank = cb; loadedBank = cb;
// Get the name of the NL file // Get the name of the NL file
sprintf(fn, "%s.%X.nl", LoadedRomFName, loadedBank); sprintf(NLfilename, "%s.%X.nl", LoadedRomFName, loadedBank);
if (loadedBankNames) if (loadedBankNames)
freeList(loadedBankNames); freeList(loadedBankNames);
// Load new address definitions // Load new address definitions
loadedBankNames = parseNameFile(fn); loadedBankNames = parseNameFile(NLfilename);
free(fn);
} }
} }

View File

@ -20,8 +20,8 @@
#include <windows.h> #include <windows.h>
#define NL_MAX_NAME_LEN 50 #define NL_MAX_NAME_LEN 30
#define NL_MAX_MULTILINE_COMMENT_LEN 1024 #define NL_MAX_MULTILINE_COMMENT_LEN 1000
//mbg merge 7/17/06 made struct sane c++ //mbg merge 7/17/06 made struct sane c++
struct Name struct Name

Binary file not shown.

View File

@ -224,7 +224,7 @@ void AddLogText(const char *text, unsigned int add_newline)
// also log the text into Trace Logger log if needed // also log the text into Trace Logger log if needed
if (logging && (logging_options & LOG_MESSAGES)) if (logging && (logging_options & LOG_MESSAGES))
{ {
OutputLogLine(strdup(logtext[truncated_logcount()]), add_newline); OutputLogLine(strdup(logtext[truncated_logcount()]), add_newline != 0);
log_old_emu_paused = false; // force Trace Logger update log_old_emu_paused = false; // force Trace Logger update
} }

View File

@ -448,9 +448,7 @@ void FCEUD_TraceInstruction()
if (logging_options & LOG_SYMBOLIC) if (logging_options & LOG_SYMBOLIC)
{ {
loadNameFiles(); // Insert Name and Comment lines if needed
// Insert Name and Comment line if needed
str_decoration[0] = 0; str_decoration[0] = 0;
decorateAddress(X.PC, str_decoration); decorateAddress(X.PC, str_decoration);
if (str_decoration[0]) if (str_decoration[0])
@ -467,7 +465,6 @@ void FCEUD_TraceInstruction()
end_pos = strstr(end_pos, "\r"); end_pos = strstr(end_pos, "\r");
} }
} }
replaceNames(ramBankNames, a); replaceNames(ramBankNames, a);
replaceNames(loadedBankNames, a); replaceNames(loadedBankNames, a);
replaceNames(lastBankNames, a); replaceNames(lastBankNames, a);
@ -479,7 +476,7 @@ void FCEUD_TraceInstruction()
//stretch the disassembly string out if we have to output other stuff. //stretch the disassembly string out if we have to output other stuff.
if ((logging_options & (LOG_REGISTERS|LOG_PROCESSOR_STATUS)) && !(logging_options & LOG_TO_THE_LEFT)) if ((logging_options & (LOG_REGISTERS|LOG_PROCESSOR_STATUS)) && !(logging_options & LOG_TO_THE_LEFT))
{ {
for(j = strlen(str_disassembly);j < LOG_DISASSEMBLY_MAX_LEN - 1;j++) for (j = strlen(str_disassembly); j < (LOG_DISASSEMBLY_MAX_LEN - 1); ++j)
str_disassembly[j] = ' '; str_disassembly[j] = ' ';
str_disassembly[LOG_DISASSEMBLY_MAX_LEN - 1] = 0; str_disassembly[LOG_DISASSEMBLY_MAX_LEN - 1] = 0;
} }
@ -618,6 +615,10 @@ void UpdateLogWindow(void)
if (tracesi.nPos < tracesi.nMin) if (tracesi.nPos < tracesi.nMin)
tracesi.nPos = tracesi.nMin; tracesi.nPos = tracesi.nMin;
SetScrollInfo(GetDlgItem(hTracer,IDC_SCRL_TRACER_LOG),SB_CTL,&tracesi,TRUE); SetScrollInfo(GetDlgItem(hTracer,IDC_SCRL_TRACER_LOG),SB_CTL,&tracesi,TRUE);
if (logging_options & LOG_SYMBOLIC)
loadNameFiles();
UpdateLogText(); UpdateLogText();
return; return;

View File

@ -21,7 +21,7 @@
// Disassembly - 63 // Disassembly - 63
// EOL (/0) - 1 // EOL (/0) - 1
// ------------------------ // ------------------------
// 150 symbols total // 128 symbols total
#define LOG_AXYSTATE_MAX_LEN 21 #define LOG_AXYSTATE_MAX_LEN 21
#define LOG_PROCSTATUS_MAX_LEN 12 #define LOG_PROCSTATUS_MAX_LEN 12
#define LOG_TABS_MASK 31 #define LOG_TABS_MASK 31

View File

@ -230,7 +230,8 @@ static const char* toCString(lua_State* L, int idx=0);
/** /**
* Resets emulator speed / pause states after script exit. * Resets emulator speed / pause states after script exit.
*/ */
static void FCEU_LuaOnStop() { static void FCEU_LuaOnStop()
{
luaRunning = FALSE; luaRunning = FALSE;
for (int i = 0 ; i < 4 ; i++ ){ for (int i = 0 ; i < 4 ; i++ ){
luajoypads1[i]= 0xFF; // Set these back to pass-through luajoypads1[i]= 0xFF; // Set these back to pass-through
@ -5418,9 +5419,9 @@ void CallExitFunction() {
HandleCallbackError(L); HandleCallbackError(L);
} }
void FCEU_LuaFrameBoundary() { void FCEU_LuaFrameBoundary()
{
// printf("Lua Frame\n"); //printf("Lua Frame\n");
// HA! // HA!
if (!L || !luaRunning) if (!L || !luaRunning)
@ -5738,15 +5739,14 @@ int FCEU_LuaRerecordCountSkip() {
return L && luaRunning && skipRerecords; return L && luaRunning && skipRerecords;
} }
/** /**
* Given an 8-bit screen with the indicated resolution, * Given an 8-bit screen with the indicated resolution,
* draw the current GUI onto it. * draw the current GUI onto it.
* *
* Currently we only support 256x* resolutions. * Currently we only support 256x* resolutions.
*/ */
void FCEU_LuaGui(uint8 *XBuf) { void FCEU_LuaGui(uint8 *XBuf)
{
if (!L/* || !luaRunning*/) if (!L/* || !luaRunning*/)
return; return;
@ -5777,14 +5777,24 @@ void FCEU_LuaGui(uint8 *XBuf) {
if (gui_used == GUI_CLEAR) if (gui_used == GUI_CLEAR)
return; return;
if (gui_used == GUI_USED_SINCE_LAST_FRAME && !FCEUI_EmulationPaused())
{
memset(gui_data, 0, LUA_SCREEN_WIDTH*LUA_SCREEN_HEIGHT*4);
gui_used = GUI_CLEAR;
return;
}
gui_used = GUI_USED_SINCE_LAST_FRAME; gui_used = GUI_USED_SINCE_LAST_FRAME;
int x, y; int x, y;
for (y = 0; y < LUA_SCREEN_HEIGHT; y++) { for (y = 0; y < LUA_SCREEN_HEIGHT; y++)
for (x=0; x < LUA_SCREEN_WIDTH; x++) { {
for (x=0; x < LUA_SCREEN_WIDTH; x++)
{
const uint8 gui_alpha = gui_data[(y*LUA_SCREEN_WIDTH+x)*4+3]; const uint8 gui_alpha = gui_data[(y*LUA_SCREEN_WIDTH+x)*4+3];
if (gui_alpha == 0) { if (gui_alpha == 0)
{
// do nothing // do nothing
continue; continue;
} }

View File

@ -194,10 +194,10 @@ void FCEU_PutImage(void)
//Some messages need to be displayed before the avi is dumped //Some messages need to be displayed before the avi is dumped
DrawMessage(true); DrawMessage(true);
#ifdef _S9XLUA_H #ifdef _S9XLUA_H
//Lua gui should draw before the avi is dumped. // Lua gui should draw before the avi is dumped.
FCEU_LuaGui(XBuf); FCEU_LuaGui(XBuf);
#endif #endif
//Save snapshot //Save snapshot
if(dosnapsave==1) if(dosnapsave==1)

Binary file not shown.