diff --git a/src/driver.h b/src/driver.h index fdb4191f..e82f7445 100644 --- a/src/driver.h +++ b/src/driver.h @@ -330,6 +330,9 @@ void FCEUD_DebugBreakpoint(int bp_num); ///the driver should log the current instruction, if it wants (we should move the code in the win driver that does this to the shared area) void FCEUD_TraceInstruction(uint8 *opcode, int size); +///the driver should flush its trace log +void FCEUD_FlushTrace(); + ///the driver might should update its NTView (only used if debugging support is compiled in) void FCEUD_UpdateNTView(int scanline, bool drawall); diff --git a/src/drivers/win/tracer.cpp b/src/drivers/win/tracer.cpp index 661dac2c..35f97eda 100644 --- a/src/drivers/win/tracer.cpp +++ b/src/drivers/win/tracer.cpp @@ -732,6 +732,12 @@ void BeginLoggingSequence(void) return; } +void FCEUD_FlushTrace() +{ + if(LOG_FP) + fflush(LOG_FP); +} + //todo: really speed this up void FCEUD_TraceInstruction(uint8 *opcode, int size) { @@ -975,7 +981,6 @@ void OutputLogLine(const char *str, std::vector* addressesLog, bool add_ fputs(str, LOG_FP); if (add_newline) fputs("\n", LOG_FP); - fflush(LOG_FP); } else { if (add_newline) diff --git a/src/fceu.cpp b/src/fceu.cpp index 4da0457b..83b8c223 100644 --- a/src/fceu.cpp +++ b/src/fceu.cpp @@ -808,6 +808,9 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski if (skip != 2) ssize = FlushEmulateSound(); //If skip = 2 we are skipping sound processing + //flush tracer once a frame, since we're likely to end up back at a user interaction loop after this with emulation paused + FCEUD_FlushTrace(); + #ifdef _S9XLUA_H CallRegisteredLuaFunctions(LUACALL_AFTEREMULATION); #endif @@ -1228,12 +1231,16 @@ void FCEUI_ClearEmulationFrameStepped() //ideally maybe we shouldnt be using this, but i need it for quick merging void FCEUI_SetEmulationPaused(int val) { EmulationPaused = val; + if(EmulationPaused) + FCEUD_FlushTrace(); } void FCEUI_ToggleEmulationPause(void) { EmulationPaused = (EmulationPaused & EMULATIONPAUSED_PAUSED) ^ EMULATIONPAUSED_PAUSED; DebuggerWasUpdated = false; + if(EmulationPaused) + FCEUD_FlushTrace(); } void FCEUI_FrameAdvanceEnd(void) {