From caac39d4d03579357441115fe5c83637fed7a813 Mon Sep 17 00:00:00 2001 From: ansstuff Date: Tue, 25 Sep 2012 20:28:14 +0000 Subject: [PATCH] * Fixed replay engine bug that doubles the last input of the movie * Tracer: RTS instructions output caller address/name * Debugger: RTS instructions are emphasized by "-----" --- changelog.txt | 16 +++++++++------- src/drivers/win/debugger.cpp | 29 ++++++++++++++++++++++------- src/drivers/win/res.rc | 10 +++++----- src/drivers/win/tracer.cpp | 33 ++++++++++++++++++++++++++++----- src/movie.cpp | 4 ++++ 5 files changed, 68 insertions(+), 24 deletions(-) diff --git a/changelog.txt b/changelog.txt index fc0c79fe..81bce4c7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,10 +1,12 @@ -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 - 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 - Debugger: special strings (NMI/IRQ/etc) can be also used in "Seek To" field and Bookmarks +26-Sep-2012 - AnS - Fixed replay engine bug that doubles the last input of the movie +26-Sep-2012 - AnS - Tracer: RTS instructions output caller address/name +23-Sep-2012 - AnS - Lua: clear previous frame drawings at the beginning of every frame +23-Sep-2012 - AnS - Debugger: fixed mouseover when using Symbolic debugging; mouseover works for the disassembly window too +22-Sep-2012 - AnS - Tracer: added "Symbolic tracing", "Log current Frame number", "Log emulator messages", "Log breakpoint hits" options +11-Sep-2012 - AnS - new Lua function: emu.setlagflag() +11-Sep-2012 - AnS - Debugger: deleting a breakpoint leaves selection in the Breakpoints list +06-Sep-2012 - AnS - added "Use Custom Palette" checkbox to Palette config +06-Sep-2012 - AnS - Debugger: special strings (NMI/IRQ/etc) can be also used in "Seek To" field and Bookmarks 01-Sep-2012 - AnS - fixed movie savestates logic, loading post-movie savestates is not allowed in read-only 31-Aug-2012 - zeromus - update mapper 156 from fceu-mm sources 30-Aug-2012 - AnS - fixed savestates filenaming bug when working with a movie diff --git a/src/drivers/win/debugger.cpp b/src/drivers/win/debugger.cpp index 3d74bd84..0e861cab 100644 --- a/src/drivers/win/debugger.cpp +++ b/src/drivers/win/debugger.cpp @@ -357,6 +357,7 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr) char chr[40] = {0}; int size; uint8 opcode[3]; + unsigned int instruction_addr; disassembly_addresses.resize(0); @@ -381,6 +382,8 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr) // PC pointer if (addr > 0xFFFF) break; + instruction_addr = addr; + // ################################## Start of SP CODE ########################### if (symbDebugEnabled) @@ -440,8 +443,10 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr) } else { char* a; - if ((addr+size) > 0x10000) { //should this be 0xFFFF? - while (addr < 0x10000) { + if ((addr + size) > 0xFFFF) + { + while (addr < 0xFFFF) + { sprintf(chr, "%02X OVERFLOW\r\n", GetMem(addr++)); strcat(debug_str, chr); } @@ -471,6 +476,17 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr) // ################################## End of SP CODE ########################### + // special case: an RTS opcode + if (GetMem(instruction_addr) == 0x60) + { + // add "----------" to emphasize the end of subroutine + strcat(a, " "); + for (int j = strlen(a); j < (LOG_DISASSEMBLY_MAX_LEN - 1); ++j) + a[j] = '-'; + a[LOG_DISASSEMBLY_MAX_LEN - 1] = 0; + } + + // append the disassembly to current line strcat(strcat(debug_str, " "), a); } strcat(debug_str, "\r\n"); @@ -786,7 +802,7 @@ void UpdateDebugger(bool jump_to_pc) tmp++; if (tmp > 0x1FF) break; - if ((i%4) == 0) + if ((i & 3) == 0) sprintf(chr, ",\r\n%02X", GetMem(tmp)); else sprintf(chr, ",%02X", GetMem(tmp)); @@ -1260,7 +1276,7 @@ BOOL CALLBACK IDC_DEBUGGER_DISASSEMBLY_WndProc(HWND hwndDlg, UINT uMsg, WPARAM w // set the selection cursor CallWindowProc(IDC_DEBUGGER_DISASSEMBLY_oldWndProc, hwndDlg, WM_LBUTTONDOWN, wParam, lParam); // debug_str contains the text in the disassembly window - DWORD sel_start, sel_end; + int sel_start, sel_end; SendDlgItemMessage(hDebug, IDC_DEBUGGER_DISASSEMBLY, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); // find the ":" or "$" before sel_start int i = sel_start - 1; @@ -1295,7 +1311,6 @@ BOOL CALLBACK IDC_DEBUGGER_DISASSEMBLY_WndProc(HWND hwndDlg, UINT uMsg, WPARAM w } case WM_MOUSEMOVE: { - RECT wrect; char str[256] = {0}, *ptr, dotdot[4]; int tmp, i; int mouse_x, mouse_y; @@ -1336,8 +1351,8 @@ BOOL CALLBACK IDC_DEBUGGER_DISASSEMBLY_WndProc(HWND hwndDlg, UINT uMsg, WPARAM w BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { RECT wrect; - char str[256] = {0}, *ptr, dotdot[4]; - int tmp,tmp2; + char str[256] = {0}; + int tmp; int mouse_x, mouse_y; int i; diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index 26337705..dc2797c2 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -12,7 +12,7 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// Neutral resources +// Нейтральный resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL @@ -279,8 +279,8 @@ BEGIN MENUITEM "Silent Autosave", ID_CONFIG_SILENTAUTOSAVE,MFT_STRING,MFS_ENABLED MENUITEM "Autofire Pattern skips Lag", ID_CONFIG_PATTERNSKIPSLAG,MFT_STRING,MFS_ENABLED MENUITEM "Auto-adjust Input according to Lag", ID_CONFIG_ADJUSTLAG,MFT_STRING,MFS_ENABLED - MENUITEM "Draw Input by dragging", ID_CONFIG_DRAWINPUTBYDRAGGING,MFT_STRING,MFS_ENABLED MENUITEM MFT_SEPARATOR + MENUITEM "Draw Input by dragging", ID_CONFIG_DRAWINPUTBYDRAGGING,MFT_STRING,MFS_ENABLED MENUITEM "Combine consecutive Recordings/Draws", ID_CONFIG_COMBINECONSECUTIVERECORDINGS,MFT_STRING,MFS_ENABLED MENUITEM "Use 1P keys for all single Recordings", ID_CONFIG_USE1PFORRECORDING,MFT_STRING,MFS_ENABLED MENUITEM "Use Input keys for Column Set", ID_CONFIG_USEINPUTKEYSFORCOLUMNSET,MFT_STRING,MFS_ENABLED @@ -2124,12 +2124,12 @@ BEGIN END #endif // APSTUDIO_INVOKED -#endif // Neutral resources +#endif // Нейтральный resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// English (United States) resources +// Английский (США) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US @@ -2363,7 +2363,7 @@ IDB_BITMAP_SELECTED17 BITMAP "res\\te_17_selected.bmp" IDB_BITMAP_SELECTED18 BITMAP "res\\te_18_selected.bmp" IDB_BITMAP_SELECTED19 BITMAP "res\\te_19_selected.bmp" IDB_BRANCH_SPRITESHEET BITMAP "res\\branch_spritesheet.bmp" -#endif // English (United States) resources +#endif // Английский (США) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/src/drivers/win/tracer.cpp b/src/drivers/win/tracer.cpp index 447eee6c..351fbc25 100644 --- a/src/drivers/win/tracer.cpp +++ b/src/drivers/win/tracer.cpp @@ -410,7 +410,6 @@ void FCEUD_TraceInstruction() return; } } - sprintf(str_address, "$%04X:", addr); size = opsize[GetMem(addr)]; if ((addr+size) > 0xFFFF) @@ -427,10 +426,21 @@ void FCEUD_TraceInstruction() sprintf(str_disassembly,"UNDEFINED"); break; case 1: + { opcode[0]=GetMem(addr++); sprintf(str_data, "%02X ", opcode[0]); a = Disassemble(addr, opcode); + // special case: an RTS opcode + if (opcode[0] == 0x60) + { + // add the beginning address of the subroutine that we exit from + unsigned int caller_addr = GetMem(((X.S) + 1)|0x0100) + (GetMem(((X.S) + 2)|0x0100) << 8) - 0x2; + unsigned int call_addr = GetMem(caller_addr + 1) + (GetMem(caller_addr + 2) << 8); + sprintf(str_decoration, " (from $%04X)", call_addr); + strcat(a, str_decoration); + } break; + } case 2: opcode[0]=GetMem(addr++); opcode[1]=GetMem(addr++); @@ -473,12 +483,24 @@ void FCEUD_TraceInstruction() strcpy(str_disassembly, a); } - //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)) + + // special case: an RTS opcode + if (size == 1 && GetMem(addr - 1) == 0x60) { - for (j = strlen(str_disassembly); j < (LOG_DISASSEMBLY_MAX_LEN - 1); ++j) - str_disassembly[j] = ' '; + // add "----------" to emphasize the end of subroutine + strcat(str_disassembly, " "); + for (int j = strlen(str_disassembly); j < (LOG_DISASSEMBLY_MAX_LEN - 1); ++j) + str_disassembly[j] = '-'; str_disassembly[LOG_DISASSEMBLY_MAX_LEN - 1] = 0; + } else + { + // 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)) + { + for (j = strlen(str_disassembly); j < (LOG_DISASSEMBLY_MAX_LEN - 1); ++j) + str_disassembly[j] = ' '; + str_disassembly[LOG_DISASSEMBLY_MAX_LEN - 1] = 0; + } } // Start filling the str_temp line: Frame number, AXYS state, Processor status, Tabs, Address, Data, Disassembly @@ -530,6 +552,7 @@ void FCEUD_TraceInstruction() strcat(str_temp, str_tabs); } + sprintf(str_address, "$%04X:", X.PC); strcat(str_temp, str_address); strcat(str_temp, str_data); strcat(str_temp, str_disassembly); diff --git a/src/movie.cpp b/src/movie.cpp index 36ce7fa5..5c9a6dae 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -1001,6 +1001,10 @@ void FCEUMOV_AddInputState() if(currFrameCounter >= (int)currMovieData.records.size()) { FinishPlayback(); + //tell all drivers to poll input and set up their logical states + for(int port=0;port<2;port++) + joyports[port].driver->Update(port,joyports[port].ptr,joyports[port].attrib); + portFC.driver->Update(portFC.ptr,portFC.attrib); } else {