Add fast forward option

This commit is contained in:
Cacodemon345
2026-01-08 18:46:23 +06:00
parent 06c3186858
commit 75cfe2bc7d
10 changed files with 48 additions and 9 deletions

View File

@@ -3002,3 +3002,6 @@ msgstr ""
msgid "&Allow recompilation"
msgstr ""
msgid "&Fast forward"
msgstr ""

View File

@@ -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 <locale.h>
@@ -452,7 +453,7 @@ main_thread_fn()
#endif
drawits += static_cast<int>(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. */

View File

@@ -65,6 +65,7 @@ extern int qt_nvr_save(void);
#endif
extern bool cpu_thread_running;
extern bool fast_forward;
};
#include <QGuiApplication>
@@ -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()
{

View File

@@ -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);

View File

@@ -78,6 +78,8 @@
<addaction name="actionAuto_pause"/>
<addaction name="actionPause"/>
<addaction name="separator"/>
<addaction name="action_Fast_forward"/>
<addaction name="separator"/>
<addaction name="actionForce_interpretation"/>
<addaction name="separator"/>
<addaction name="actionHard_Reset"/>
@@ -311,6 +313,8 @@
<addaction name="separator"/>
<addaction name="actionTake_screenshot"/>
<addaction name="actionCopy_screenshot"/>
<addaction name="separator"/>
<addaction name="action_Fast_forward"/>
</widget>
<action name="actionForce_interpretation">
<property name="icon">
@@ -1069,6 +1073,18 @@
<string>&amp;8x</string>
</property>
</action>
<action name="action_Fast_forward">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../qt_resources.qrc">
<normaloff>:/settings/qt/icons/fast_forward.ico</normaloff>:/settings/qt/icons/fast_forward.ico</iconset>
</property>
<property name="text">
<string>&amp;Fast forward</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <sys/audioio.h>
#include <sys/param.h>
@@ -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);

View File

@@ -18,6 +18,7 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#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);

View File

@@ -15,6 +15,7 @@
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
@@ -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);

View File

@@ -14,6 +14,7 @@
*/
#include <math.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -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),

View File

@@ -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. */