From f135fd288889155e8d1a753c34ef0133a7f1f4bc Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Sat, 8 Jan 2022 04:17:16 -0500 Subject: [PATCH] Added Qt TAS turbo seek functionality. --- src/drivers/Qt/TasEditor/TasEditorWindow.cpp | 8 ++++++++ src/drivers/Qt/TasEditor/playback.cpp | 10 ++++++++++ src/drivers/Qt/fceuWrapper.cpp | 8 ++++---- src/drivers/Qt/sdl-sound.cpp | 3 ++- src/drivers/Qt/sdl-throttle.cpp | 3 ++- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp index bb6aae78..97818590 100644 --- a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp +++ b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp @@ -3178,7 +3178,15 @@ void TasEditorWindow::playbackFollowCursorCb(bool val) // ---------------------------------------------------------------------------------------------- void TasEditorWindow::playbackTurboSeekCb(bool val) { + FCEU_CRITICAL_SECTION( emuLock ); + taseditorConfig.turboSeek = val; + + // if currently seeking, apply this option immediately + if (playback.getPauseFrame() >= 0) + { + turbo = taseditorConfig.turboSeek; + } } // ---------------------------------------------------------------------------------------------- void TasEditorWindow::playbackAutoRestoreCb(bool val) diff --git a/src/drivers/Qt/TasEditor/playback.cpp b/src/drivers/Qt/TasEditor/playback.cpp index f7875ace..805466c6 100644 --- a/src/drivers/Qt/TasEditor/playback.cpp +++ b/src/drivers/Qt/TasEditor/playback.cpp @@ -59,6 +59,7 @@ void PLAYBACK::reset() forwardFullButtonOldState = forwardFullButtonState = false; emuPausedOldState = emuPausedState = true; stopSeeking(); + turbo = false; } void PLAYBACK::update() { @@ -348,12 +349,19 @@ void PLAYBACK::startSeekingToFrame(int frame) pauseFrame = frame + 1; } if (taseditorConfig->turboSeek) + { + //printf("Turbo seek on\n"); turbo = true; + } unpauseEmulation(); } void PLAYBACK::stopSeeking() { pauseFrame = 0; + //if ( turbo ) + //{ + // printf("Turbo seek off\n"); + //} turbo = false; pauseEmulation(); setProgressbar(1, 1); @@ -381,7 +389,9 @@ void PLAYBACK::handleForwardFrame() if (pauseFrame && !emuPausedState) return; jump(currFrameCounter + 1); if (!pauseFrame) + { pauseEmulation(); + } turbo = false; } void PLAYBACK::handleRewindFull(int speed) diff --git a/src/drivers/Qt/fceuWrapper.cpp b/src/drivers/Qt/fceuWrapper.cpp index 04c25125..83953074 100644 --- a/src/drivers/Qt/fceuWrapper.cpp +++ b/src/drivers/Qt/fceuWrapper.cpp @@ -1202,7 +1202,7 @@ static void DoFun(int frameskip, int periodic_saves) fskipc = (fskipc + 1) % (frameskip + 1); #endif - if (NoWaiting) + if (NoWaiting || turbo) { gfx = 0; } @@ -1674,7 +1674,7 @@ bool FCEUD_ShouldDrawInputAids(void) return drawInputAidsEnable; } -void FCEUD_TurboOn (void) { /* TODO */ }; -void FCEUD_TurboOff (void) { /* TODO */ }; -void FCEUD_TurboToggle(void) { /* TODO */ }; +void FCEUD_TurboOn (void) { turbo = true; }; +void FCEUD_TurboOff (void) { turbo = false; }; +void FCEUD_TurboToggle(void) { turbo = !turbo; }; diff --git a/src/drivers/Qt/sdl-sound.cpp b/src/drivers/Qt/sdl-sound.cpp index 712dc82a..a73aaf6c 100644 --- a/src/drivers/Qt/sdl-sound.cpp +++ b/src/drivers/Qt/sdl-sound.cpp @@ -33,6 +33,7 @@ #include extern Config *g_config; +extern bool turbo; static volatile int *s_Buffer = 0; static unsigned int s_BufferSize; @@ -311,7 +312,7 @@ WriteSound(int32 *buf, int udrFlowDup = 1; static int skipCounter = 0; - if ( NoWaiting & 0x01 ) + if ( (NoWaiting & 0x01) || turbo ) { // During Turbo mode, don't bother with sound as // overflowing the audio buffer can cause delays. return; diff --git a/src/drivers/Qt/sdl-throttle.cpp b/src/drivers/Qt/sdl-throttle.cpp index 8e2417bf..f720e1ed 100644 --- a/src/drivers/Qt/sdl-throttle.cpp +++ b/src/drivers/Qt/sdl-throttle.cpp @@ -56,6 +56,7 @@ double g_fpsScale = Normal; // used by sdl.cpp bool MaxSpeed = false; bool useIntFrameRate = false; static double frmRateAdjRatio = 1.000000f; // Frame Rate Adjustment Ratio +extern bool turbo; double getHighPrecTimeStamp(void) { @@ -316,7 +317,7 @@ int highPrecSleep( double timeSeconds ) int SpeedThrottle(void) { - if ( (g_fpsScale >= 32) || (NoWaiting & 0x01) ) + if ( (g_fpsScale >= 32) || (NoWaiting & 0x01) || turbo ) { return 0; /* Done waiting */ }