diff --git a/src/drivers/win/config.cpp b/src/drivers/win/config.cpp index 3ccb3da9..eb9b2fc4 100644 --- a/src/drivers/win/config.cpp +++ b/src/drivers/win/config.cpp @@ -88,6 +88,8 @@ extern int MainWindow_wndx, MainWindow_wndy; extern int MemWatch_wndx, MemWatch_wndy; extern int Monitor_wndx, Monitor_wndy; extern bool tracer_lines_tabbing; +extern bool tracer_statuses_to_the_left; +extern int logging_options; extern int Tracer_wndx, Tracer_wndy; extern int CDLogger_wndx, CDLogger_wndy; extern int GGConv_wndx, GGConv_wndy; @@ -281,6 +283,8 @@ static CFGSTRUCT fceuconfig[] = { AC(Monitor_wndx), AC(Monitor_wndy), AC(tracer_lines_tabbing), + AC(tracer_statuses_to_the_left), + AC(logging_options), AC(Tracer_wndx), AC(Tracer_wndy), AC(CDLogger_wndx), diff --git a/src/drivers/win/main.cpp b/src/drivers/win/main.cpp index 463ecaa0..3fabc008 100644 --- a/src/drivers/win/main.cpp +++ b/src/drivers/win/main.cpp @@ -866,7 +866,7 @@ void _updateWindow() PPUViewDoBlit(); UpdateMemoryView(0); UpdateCDLogger(); - //UpdateLogWindow(); //adelikat: Moved to FCEUI_Emulate + UpdateLogWindow(); //adelikat: Moved to FCEUI_Emulate; AnS: moved back UpdateMemWatch(); NTViewDoBlit(0); //UpdateTasEditor(); //AnS: moved to FCEUD_Update diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index 8e46c99b..23c38374 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -1149,7 +1149,7 @@ BEGIN EDITTEXT IDC_DEBUGGER_INSTRUCTIONS_EXCEED,483,216,50,12,ES_UPPERCASE | ES_NOHIDESEL | ES_WANTRETURN | ES_NUMBER END -TRACER DIALOGEX 65527, 65513, 383, 308 +TRACER DIALOGEX 65527, 65513, 383, 316 STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Trace Logger" FONT 8, "MS Sans Serif", 400, 0, 0x0 @@ -1161,22 +1161,24 @@ BEGIN LTEXT "instructions to this window",106,98,195,87,10 PUSHBUTTON "Start Logging",IDC_BTN_START_STOP_LOGGING,171,176,67,14,BS_CENTER | BS_VCENTER COMBOBOX IDC_TRACER_LOG_SIZE,47,193,48,127,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Extra Log Options",109,3,232,376,29 + GROUPBOX "Extra Log Options",109,3,232,376,39 CONTROL "Log state of A, X, Y and S registers",IDC_CHECK_LOG_REGISTERS, "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,9,243,126,10 CONTROL "Log Processor Status Flags",IDC_CHECK_LOG_PROCESSOR_STATUS, "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,138,243,102,10 PUSHBUTTON "Browse...",IDC_BTN_LOG_BROWSE,56,212,45,14,BS_CENTER | BS_VCENTER - LTEXT "",IDC_TRACER_STATS,123,213,159,14 + LTEXT "",IDC_TRACER_STATS,121,213,246,12 CONTROL "Only log newly mapped code",IDC_CHECK_LOG_NEW_INSTRUCTIONS, - "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,9,276,107,10 - GROUPBOX "Extra Log Options that work with the Code/Data Logger",113,3,264,376,40 + "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,9,284,107,10 + GROUPBOX "Extra Log Options that work with the Code/Data Logger",113,3,272,376,40 CONTROL "Only log code that accesses newly mapped data",IDC_CHECK_LOG_NEW_DATA, - "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,9,289,169,10 - CONTROL "Automatically update Window While logging",IDC_CHECK_LOG_UPDATE_WINDOW, + "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,9,297,169,10 + CONTROL "Automatically update Window while logging",IDC_CHECK_LOG_UPDATE_WINDOW, "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,192,195,156,10 - CONTROL "Use Stack Pointer for lines tabbing",IDC_CHECK_LINES_TABBING, - "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,247,243,126,10 + CONTROL "Use Stack Pointer for lines tabbing (nesting visualization)",IDC_CHECK_LINES_TABBING, + "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,9,256,197,10 + CONTROL "To the left from disassembly text",IDC_CHECK_LOG_STATUSES_TO_THE_LEFT, + "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,251,243,121,10 END ADDBP DIALOGEX 66, 83, 196, 130 diff --git a/src/drivers/win/resource.h b/src/drivers/win/resource.h index c1fc472b..7dfd9af6 100644 --- a/src/drivers/win/resource.h +++ b/src/drivers/win/resource.h @@ -139,10 +139,11 @@ #define CHEAT_CONTEXT_TOGGLECHEAT 117 #define IDC_DEBUGGER_RESET_ON_STEP 117 #define IDC_DEBUGGER_BREAK_ON_CYCLES 117 -#define IDC_CHECK_LOG_PROCESSOR_STATUS2 117 #define IDC_CHECK_LINES_TABBING 117 #define CHEAT_CONTEXT_POKECHEATVALUE 118 #define IDC_DEBUGGER_RESET_ON_BP0 118 +#define IDC_CHECK_LOG_STATUSES_TO_THE_RIGHT 118 +#define IDC_CHECK_LOG_STATUSES_TO_THE_LEFT 118 #define CHEAT_CONTEXT_GOTOINHEXEDITOR 119 #define IDC_DEBUGGER_BREAK_ON_INSTRUCTIONS 119 #define CHECK_SOUND_8BIT 122 diff --git a/src/drivers/win/tracer.cpp b/src/drivers/win/tracer.cpp index db708f6b..11df9a35 100644 --- a/src/drivers/win/tracer.cpp +++ b/src/drivers/win/tracer.cpp @@ -44,7 +44,7 @@ using namespace std; //#define LOG_ADD_PERIODS 8 //int logaxy = 1, logopdata = 1; //deleteme -int logging_options = -1; +int logging_options = LOG_REGISTERS | LOG_PROCESSOR_STATUS; int log_update_window = 0; //int tracer_open=0; volatile int logtofile = 0, logging = 0; @@ -61,6 +61,10 @@ int tracelogbufsize, tracelogbufpos; int tracelogbufusedsize; bool tracer_lines_tabbing = true; +bool tracer_statuses_to_the_left = false; + +bool old_emu_paused = false; // thus the window only updates once after the game is paused +extern bool JustFrameAdvanced; FILE *LOG_FP; @@ -127,21 +131,12 @@ BOOL CALLBACK TracerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) CheckDlgButton(hwndDlg, IDC_CHECK_LINES_TABBING, tracer_lines_tabbing ? BST_CHECKED : BST_UNCHECKED); - if(logging_options == -1) - { - logging_options = (LOG_REGISTERS | LOG_PROCESSOR_STATUS); - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_REGISTERS, BST_CHECKED); - CheckDlgButton(hwndDlg, IDC_CHECK_LOG_PROCESSOR_STATUS, BST_CHECKED); - } else - { - if(logging_options&LOG_REGISTERS)CheckDlgButton(hwndDlg, IDC_CHECK_LOG_REGISTERS, BST_CHECKED); - if(logging_options&LOG_PROCESSOR_STATUS)CheckDlgButton(hwndDlg, IDC_CHECK_LOG_PROCESSOR_STATUS, BST_CHECKED); - } + CheckDlgButton(hwndDlg, IDC_CHECK_LOG_STATUSES_TO_THE_LEFT, tracer_statuses_to_the_left ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_CHECK_LOG_REGISTERS, (logging_options & LOG_REGISTERS) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_CHECK_LOG_PROCESSOR_STATUS, (logging_options & LOG_PROCESSOR_STATUS) ? BST_CHECKED : BST_UNCHECKED); EnableWindow(GetDlgItem(hwndDlg,IDC_TRACER_LOG_SIZE),TRUE); EnableWindow(GetDlgItem(hwndDlg,IDC_BTN_LOG_BROWSE),FALSE); - - if(log_update_window)CheckDlgButton(hwndDlg, IDC_CHECK_LOG_UPDATE_WINDOW, BST_CHECKED); - + CheckDlgButton(hwndDlg, IDC_CHECK_LOG_UPDATE_WINDOW, log_update_window ? BST_CHECKED : BST_UNCHECKED); EnableTracerMenuItems(); break; case WM_CLOSE: @@ -175,6 +170,9 @@ BOOL CALLBACK TracerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) case IDC_CHECK_LOG_PROCESSOR_STATUS: logging_options ^= LOG_PROCESSOR_STATUS; break; + case IDC_CHECK_LOG_STATUSES_TO_THE_LEFT: + tracer_statuses_to_the_left ^= 1; + break; case IDC_CHECK_LINES_TABBING: tracer_lines_tabbing ^= 1; break; @@ -260,6 +258,7 @@ void BeginLoggingSequence(void){ if(logtofile){ if(logfilename == NULL) ShowLogDirDialog(); + if (!logfilename) return; LOG_FP = fopen(logfilename,"w"); if(LOG_FP == NULL){ sprintf(str,"Error Opening File %s",logfilename); @@ -329,7 +328,7 @@ done: void FCEUD_TraceInstruction(){ if(!logging) return; - char address[7], data[11], disassembly[LOG_DISASSEMBLY_MAX_LEN], axystate[21], procstatus[12]; + char str_tabs[LOG_TABS_MAX_LEN], address[7], data[11], disassembly[LOG_DISASSEMBLY_MAX_LEN], axystate[21], procstatus[12]; char str[LOG_LINE_MAX_LEN]; int addr=X.PC; int size, j; @@ -357,11 +356,14 @@ void FCEUD_TraceInstruction(){ axystate[0] = str[0] = 0; size = opsize[GetMem(addr)]; - if ((addr+size) > 0xFFFF){ + if ((addr+size) > 0xFFFF) + { sprintf(data, "%02X ", GetMem(addr&0xFFFF)); sprintf(disassembly,"OVERFLOW"); - } else { - switch(size){ + } else + { + switch(size) + { case 0: sprintf(data, "%02X ", GetMem(addr)); sprintf(disassembly,"UNDEFINED"); @@ -387,7 +389,8 @@ void FCEUD_TraceInstruction(){ } } //stretch the disassembly string out if we have to output other stuff. - if(logging_options & (LOG_REGISTERS|LOG_PROCESSOR_STATUS)){ + if((logging_options & (LOG_REGISTERS|LOG_PROCESSOR_STATUS)) && !tracer_statuses_to_the_left) + { for(j = strlen(disassembly);j < LOG_DISASSEMBLY_MAX_LEN - 1;j++)disassembly[j] = ' '; disassembly[LOG_DISASSEMBLY_MAX_LEN - 1] = 0; } @@ -410,23 +413,43 @@ void FCEUD_TraceInstruction(){ ); } + if (tracer_statuses_to_the_left) + { + if (logging_options & LOG_REGISTERS) + strcat(str, axystate); + if ((logging_options & LOG_REGISTERS) && (logging_options & LOG_PROCESSOR_STATUS)) + strcat(str, " "); + if (logging_options & LOG_PROCESSOR_STATUS) + strcat(str, procstatus); + if ((logging_options & LOG_REGISTERS) || (logging_options & LOG_PROCESSOR_STATUS)) + strcat(str, " "); + } + if (tracer_lines_tabbing) { // add spaces at the beginning of the line according to stack pointer int spaces = 0xFF - X.S; - if (spaces > LOG_TABS_MAX_LEN) - spaces = LOG_TABS_MAX_LEN; + if (spaces >= LOG_TABS_MAX_LEN) + spaces = LOG_TABS_MAX_LEN - 1; for (int i = 0; i < spaces; i++) - str[i] = ' '; - str[spaces] = 0; + str_tabs[i] = ' '; + str_tabs[spaces] = 0; + strcat(str, str_tabs); } - strcat(str,address); - strcat(str,data); - strcat(str,disassembly); - if(logging_options & LOG_REGISTERS)strcat(str,axystate); - if((logging_options & LOG_REGISTERS) && (logging_options & LOG_PROCESSOR_STATUS))strcat(str," "); - if(logging_options & LOG_PROCESSOR_STATUS)strcat(str,procstatus); + strcat(str, address); + strcat(str, data); + strcat(str, disassembly); + + if (!tracer_statuses_to_the_left) + { + if (logging_options & LOG_REGISTERS) + strcat(str,axystate); + if ((logging_options & LOG_REGISTERS) && (logging_options & LOG_PROCESSOR_STATUS)) + strcat(str," "); + if (logging_options & LOG_PROCESSOR_STATUS) + strcat(str,procstatus); + } OutputLogLine(str); @@ -481,12 +504,18 @@ void UpdateLogWindow(void){ // //we don't want to continue if the trace logger isn't logging, or if its logging to a file. - if((!logging) || logtofile)return; + if ((!logging) || logtofile) + return; - //if the game isn't paused, and the option to update the log window while running isn't checked, then halt here. - if(!FCEUI_EmulationPaused() && !log_update_window){ //mbg merge 7/19/06 changd to use EmulationPaused() + // only update the window when some emulation occured + // and only update the window when emulator is paused or log_update_window=true + bool emu_paused = (FCEUI_EmulationPaused() != 0); + if ((!emu_paused && !log_update_window) || (old_emu_paused && !JustFrameAdvanced)) //mbg merge 7/19/06 changd to use EmulationPaused() + { + old_emu_paused = emu_paused; return; } + old_emu_paused = emu_paused; tracesi.cbSize = sizeof(SCROLLINFO); tracesi.fMask = SIF_ALL; @@ -535,33 +564,29 @@ void EnableTracerMenuItems(void){ //EnableWindow(GetDlgItem(hTracer,IDC_CHECK_LOG_NEW_DATA),FALSE); //} - if(logging){ + if(logging) + { EnableWindow(GetDlgItem(hTracer,IDC_RADIO_LOG_LAST),FALSE); EnableWindow(GetDlgItem(hTracer,IDC_RADIO_LOG_TO_FILE),FALSE); EnableWindow(GetDlgItem(hTracer,IDC_TRACER_LOG_SIZE),FALSE); - //EnableWindow(GetDlgItem(hTracer,IDC_CHECK_LOG_REGISTERS),FALSE); - //EnableWindow(GetDlgItem(hTracer,IDC_CHECK_LOG_PROCESSOR_STATUS),FALSE); EnableWindow(GetDlgItem(hTracer,IDC_BTN_LOG_BROWSE),FALSE); - //EnableWindow(GetDlgItem(hTracer,IDC_CHECK_LOG_NEW_INSTRUCTIONS),FALSE); - //EnableWindow(GetDlgItem(hTracer,IDC_CHECK_LOG_NEW_DATA),FALSE); return; } EnableWindow(GetDlgItem(hTracer,IDC_RADIO_LOG_LAST),TRUE); EnableWindow(GetDlgItem(hTracer,IDC_RADIO_LOG_TO_FILE),TRUE); EnableWindow(GetDlgItem(hTracer,IDC_TRACER_LOG_SIZE),TRUE); - //EnableWindow(GetDlgItem(hTracer,IDC_CHECK_LOG_REGISTERS),TRUE); - //EnableWindow(GetDlgItem(hTracer,IDC_CHECK_LOG_PROCESSOR_STATUS),TRUE); //uncomment me EnableWindow(GetDlgItem(hTracer,IDC_BTN_LOG_BROWSE),TRUE); EnableWindow(GetDlgItem(hTracer,IDC_CHECK_LOG_NEW_INSTRUCTIONS),TRUE); - if(logtofile){ + if(logtofile) + { EnableWindow(GetDlgItem(hTracer,IDC_TRACER_LOG_SIZE),FALSE); EnableWindow(GetDlgItem(hTracer,IDC_BTN_LOG_BROWSE),TRUE); - CheckDlgButton(hTracer, IDC_CHECK_LOG_UPDATE_WINDOW, BST_UNCHECKED); log_update_window = 0; EnableWindow(GetDlgItem(hTracer,IDC_CHECK_LOG_UPDATE_WINDOW),FALSE); - } else{ + } else + { EnableWindow(GetDlgItem(hTracer,IDC_TRACER_LOG_SIZE),TRUE); EnableWindow(GetDlgItem(hTracer,IDC_BTN_LOG_BROWSE),FALSE); EnableWindow(GetDlgItem(hTracer,IDC_CHECK_LOG_UPDATE_WINDOW),TRUE); diff --git a/src/fceu.cpp b/src/fceu.cpp index 098bf889..850abcc2 100644 --- a/src/fceu.cpp +++ b/src/fceu.cpp @@ -217,7 +217,7 @@ bool frameAdvanceRequested=false; int frameAdvanceDelay; //indicates that the emulation core just frame advanced (consumed the frame advance state and paused) -bool JustFrameAdvanced=false; +bool JustFrameAdvanced = false; static int *AutosaveStatus; //is it safe to load Auto-savestate static int AutosaveIndex = 0; //which Auto-savestate we're on @@ -624,6 +624,11 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski //skip initiates frame skip if 1, or frame skip and sound skip if 2 int r,ssize; +#ifdef WIN32 + UpdateLogWindow(); +#endif + + JustFrameAdvanced = false; if (frameAdvanceRequested) @@ -676,7 +681,6 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski UpdateTextHooker(); Update_RAM_Search(); // Update_RAM_Watch() is also called. RamChange(); - UpdateLogWindow(); //FCEUI_AviVideoUpdate(XBuf); extern int KillFCEUXonFrame; if (KillFCEUXonFrame && (FCEUMOV_GetFrame() >= KillFCEUXonFrame))