diff --git a/src/qt/languages/86box.pot b/src/qt/languages/86box.pot index e04c73f2a..cbf086210 100644 --- a/src/qt/languages/86box.pot +++ b/src/qt/languages/86box.pot @@ -3002,3 +3002,6 @@ msgstr "" msgid "&Allow recompilation" msgstr "" + +msgid "&Fast forward" +msgstr "" diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index 1d362dd62..9d55ba7ca 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -100,6 +100,7 @@ extern int qt_nvr_save(void); extern void exit_pause(void); bool cpu_thread_running = false; +bool fast_forward = false; } #include @@ -452,7 +453,7 @@ main_thread_fn() #endif drawits += static_cast(new_time - old_time); old_time = new_time; - if (drawits > 0 && !dopause) { + if ((drawits > 0 || fast_forward) && !dopause) { /* Yes, so run frames now. */ do { #ifdef USE_INSTRUMENT @@ -478,8 +479,9 @@ main_thread_fn() } drawits -= force_10ms ? 10 : 1; - if (drawits > 50) + if (drawits > 50 || fast_forward) drawits = 0; + } while (drawits > 0); } else { /* Just so we dont overload the host OS. */ diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 35fd05491..79380ecb4 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -65,6 +65,7 @@ extern int qt_nvr_save(void); #endif extern bool cpu_thread_running; +extern bool fast_forward; }; #include @@ -2135,6 +2136,12 @@ MainWindow::on_actionUpdate_mouse_every_CPU_frame_triggered() config_save(); } +void +MainWindow::on_action_Fast_forward_triggered() +{ + fast_forward ^= 1; +} + void MainWindow::on_actionRemember_size_and_position_triggered() { diff --git a/src/qt/qt_mainwindow.hpp b/src/qt/qt_mainwindow.hpp index e1c0c7409..98096a54a 100644 --- a/src/qt/qt_mainwindow.hpp +++ b/src/qt/qt_mainwindow.hpp @@ -141,6 +141,7 @@ private slots: void on_actionPreferences_triggered(); void on_actionEnable_Discord_integration_triggered(bool checked); void on_actionRenderer_options_triggered(); + void on_action_Fast_forward_triggered(); void refreshMediaMenu(); void showMessage_(int flags, const QString &header, const QString &message, bool richText, std::atomic_bool *done = nullptr); diff --git a/src/qt/qt_mainwindow.ui b/src/qt/qt_mainwindow.ui index 47744b38f..4592f1ed6 100644 --- a/src/qt/qt_mainwindow.ui +++ b/src/qt/qt_mainwindow.ui @@ -78,6 +78,8 @@ + + @@ -311,6 +313,8 @@ + + @@ -1069,6 +1073,18 @@ &8x + + + true + + + + :/settings/qt/icons/fast_forward.ico:/settings/qt/icons/fast_forward.ico + + + &Fast forward + + diff --git a/src/sound/audio4.c b/src/sound/audio4.c index dcff2068d..48b0a6ce1 100644 --- a/src/sound/audio4.c +++ b/src/sound/audio4.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -41,6 +42,7 @@ #define I_MIDI 6 static int audio[7] = {-1, -1, -1, -1, -1, -1, -1}; +extern bool fast_forward; #ifdef USE_NEW_API static struct audio_swpar info[7]; @@ -104,7 +106,7 @@ givealbuffer_common(const void *buf, const uint8_t src, const int size) double gain; int target_rate; - if(audio[src] == -1) + if(audio[src] == -1 || fast_forward) return; gain = sound_muted ? 0.0 : pow(10.0, (double) sound_gain / 20.0); diff --git a/src/sound/openal.c b/src/sound/openal.c index 598709de9..399e4ac8e 100644 --- a/src/sound/openal.c +++ b/src/sound/openal.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #undef AL_API #undef ALC_API @@ -313,6 +314,7 @@ inital(void) initialized = 1; } +extern bool fast_forward; void givealbuffer_common(const void *buf, const uint8_t src, const int size, const int freq) { @@ -320,7 +322,7 @@ givealbuffer_common(const void *buf, const uint8_t src, const int size, const in int state; ALuint buffer; - if (!initialized) + if (!initialized || fast_forward) return; alGetSourcei(source[src], AL_SOURCE_STATE, &state); @@ -331,7 +333,7 @@ givealbuffer_common(const void *buf, const uint8_t src, const int size, const in alGetSourcei(source[src], AL_BUFFERS_PROCESSED, &processed); if (processed >= 1) { - const double gain = sound_muted ? 0.0 : pow(10.0, (double) sound_gain / 20.0); + const double gain = (sound_muted) ? 0.0 : pow(10.0, (double) sound_gain / 20.0); alListenerf(AL_GAIN, (float) gain); alSourceUnqueueBuffers(source[src], 1, &buffer); diff --git a/src/sound/sndio.c b/src/sound/sndio.c index d572652ae..3f8c90b89 100644 --- a/src/sound/sndio.c +++ b/src/sound/sndio.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -32,6 +33,7 @@ #define I_FDD 5 #define I_HDD 6 +extern bool fast_forward; static struct sio_hdl* audio[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; static struct sio_par info[7]; static int freqs[7] = { SOUND_FREQ, MUSIC_FREQ, WT_FREQ, CD_FREQ, SOUND_FREQ, SOUND_FREQ, 0 }; @@ -83,7 +85,7 @@ givealbuffer_common(const void *buf, const uint8_t src, const int size) int conv_size; double gain; int target_rate; - if (audio[src] == NULL) + if (audio[src] == NULL || fast_forward) return; gain = sound_muted ? 0.0 : pow(10.0, (double) sound_gain / 20.0); diff --git a/src/sound/xaudio2.c b/src/sound/xaudio2.c index 7833af435..4d109bce9 100644 --- a/src/sound/xaudio2.c +++ b/src/sound/xaudio2.c @@ -14,6 +14,7 @@ */ #include #include +#include #include #include #include @@ -56,6 +57,8 @@ static IXAudio2SourceVoice *srcvoicecd = NULL; static IXAudio2SourceVoice *srcvoicefdd = NULL; static IXAudio2SourceVoice *srcvoicehdd = NULL; +extern bool fast_forward; + #define FREQ SOUND_FREQ #define BUFLEN SOUNDBUFLEN @@ -258,7 +261,7 @@ closeal(void) void givealbuffer_common(const void *buf, IXAudio2SourceVoice *sourcevoice, const size_t buflen) { - if (!initialized) + if (!initialized || fast_forward) return; (void) IXAudio2MasteringVoice_SetVolume(mastervoice, sound_muted ? 0.0 : pow(10.0, (double) sound_gain / 20.0), diff --git a/src/unix/unix.c b/src/unix/unix.c index b417d38bd..ed16c20c6 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -63,6 +63,7 @@ int update_icons; int kbd_req_capture; int hide_status_bar; int hide_tool_bar; +bool fast_forward = false; // Technically unused. int fixed_size_x = 640; int fixed_size_y = 480; extern int title_set; @@ -596,10 +597,10 @@ main_thread(UNUSED(void *param)) #endif old_time = new_time; - if (drawits > 0 && !dopause) { + if ((drawits > 0 || fast_forward) && !dopause) { /* Yes, so do one frame now. */ drawits -= force_10ms ? 10 : 1; - if (drawits > 50) + if (drawits > 50 || fast_forward) drawits = 0; /* Run a block of code. */