mirror of https://github.com/mgba-emu/mgba.git
Qt: Make rewind speed adjustable (#2902)
This commit is contained in:
parent
a7ffcee399
commit
c9585b8abe
|
@ -33,6 +33,7 @@ struct mCoreOptions {
|
|||
int frameskip;
|
||||
bool rewindEnable;
|
||||
int rewindBufferCapacity;
|
||||
int rewindBufferInterval;
|
||||
float fpsTarget;
|
||||
size_t audioBuffers;
|
||||
unsigned sampleRate;
|
||||
|
|
|
@ -24,6 +24,7 @@ struct mCoreRewindContext {
|
|||
size_t size;
|
||||
struct VFile* previousState;
|
||||
struct VFile* currentState;
|
||||
int rewindFrameCounter;
|
||||
|
||||
#ifndef DISABLE_THREADING
|
||||
bool onThread;
|
||||
|
|
|
@ -406,6 +406,7 @@ void mCoreConfigMap(const struct mCoreConfig* config, struct mCoreOptions* opts)
|
|||
_lookupIntValue(config, "frameskip", &opts->frameskip);
|
||||
_lookupIntValue(config, "volume", &opts->volume);
|
||||
_lookupIntValue(config, "rewindBufferCapacity", &opts->rewindBufferCapacity);
|
||||
_lookupIntValue(config, "rewindBufferInterval", &opts->rewindBufferInterval);
|
||||
_lookupFloatValue(config, "fpsTarget", &opts->fpsTarget);
|
||||
unsigned audioBuffers;
|
||||
if (_lookupUIntValue(config, "audioBuffers", &audioBuffers)) {
|
||||
|
@ -448,6 +449,7 @@ void mCoreConfigLoadDefaults(struct mCoreConfig* config, const struct mCoreOptio
|
|||
ConfigurationSetIntValue(&config->defaultsTable, 0, "frameskip", opts->frameskip);
|
||||
ConfigurationSetIntValue(&config->defaultsTable, 0, "rewindEnable", opts->rewindEnable);
|
||||
ConfigurationSetIntValue(&config->defaultsTable, 0, "rewindBufferCapacity", opts->rewindBufferCapacity);
|
||||
ConfigurationSetIntValue(&config->defaultsTable, 0, "rewindBufferInterval", opts->rewindBufferInterval);
|
||||
ConfigurationSetFloatValue(&config->defaultsTable, 0, "fpsTarget", opts->fpsTarget);
|
||||
ConfigurationSetUIntValue(&config->defaultsTable, 0, "audioBuffers", opts->audioBuffers);
|
||||
ConfigurationSetUIntValue(&config->defaultsTable, 0, "sampleRate", opts->sampleRate);
|
||||
|
|
|
@ -30,6 +30,7 @@ void mCoreRewindContextInit(struct mCoreRewindContext* context, size_t entries,
|
|||
context->previousState = VFileMemChunk(0, 0);
|
||||
context->currentState = VFileMemChunk(0, 0);
|
||||
context->size = 0;
|
||||
context->rewindFrameCounter = 0;
|
||||
#ifndef DISABLE_THREADING
|
||||
context->onThread = onThread;
|
||||
context->ready = false;
|
||||
|
|
|
@ -157,7 +157,11 @@ void _frameStarted(void* context) {
|
|||
}
|
||||
if (thread->core->opts.rewindEnable && thread->core->opts.rewindBufferCapacity > 0) {
|
||||
if (!thread->impl->rewinding || !mCoreRewindRestore(&thread->impl->rewind, thread->core)) {
|
||||
if (thread->impl->rewind.rewindFrameCounter == 0) {
|
||||
mCoreRewindAppend(&thread->impl->rewind, thread->core);
|
||||
thread->impl->rewind.rewindFrameCounter = thread->core->opts.rewindBufferInterval;
|
||||
}
|
||||
thread->impl->rewind.rewindFrameCounter--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,6 +125,7 @@ ConfigController::ConfigController(QObject* parent)
|
|||
m_opts.logLevel = mLOG_WARN | mLOG_ERROR | mLOG_FATAL;
|
||||
m_opts.rewindEnable = false;
|
||||
m_opts.rewindBufferCapacity = 300;
|
||||
m_opts.rewindBufferInterval = 1;
|
||||
m_opts.useBios = true;
|
||||
m_opts.suspendScreensaver = true;
|
||||
m_opts.lockAspectRatio = true;
|
||||
|
|
|
@ -480,6 +480,7 @@ void SettingsView::updateConfig() {
|
|||
saveSetting("fastForwardMute", m_ui.muteFf);
|
||||
saveSetting("rewindEnable", m_ui.rewind);
|
||||
saveSetting("rewindBufferCapacity", m_ui.rewindCapacity);
|
||||
saveSetting("rewindBufferInterval", m_ui.rewindBufferInterval);
|
||||
saveSetting("resampleVideo", m_ui.resampleVideo);
|
||||
saveSetting("allowOpposingDirections", m_ui.allowOpposingDirections);
|
||||
saveSetting("suspendScreensaver", m_ui.suspendScreensaver);
|
||||
|
@ -708,6 +709,7 @@ void SettingsView::reloadConfig() {
|
|||
loadSetting("fastForwardMute", m_ui.muteFf, m_ui.mute->isChecked());
|
||||
loadSetting("rewindEnable", m_ui.rewind);
|
||||
loadSetting("rewindBufferCapacity", m_ui.rewindCapacity);
|
||||
loadSetting("rewindBufferInterval", m_ui.rewindBufferInterval);
|
||||
loadSetting("resampleVideo", m_ui.resampleVideo);
|
||||
loadSetting("allowOpposingDirections", m_ui.allowOpposingDirections);
|
||||
loadSetting("suspendScreensaver", m_ui.suspendScreensaver);
|
||||
|
|
|
@ -1195,21 +1195,51 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_54">
|
||||
<property name="text">
|
||||
<string>Rewind speed:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_23">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="rewindBufferInterval">
|
||||
<property name="suffix">
|
||||
<string notr="true">×</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="Line" name="line_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Idle loops:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="8" column="1">
|
||||
<widget class="QComboBox" name="idleOptimization">
|
||||
<item>
|
||||
<property name="text">
|
||||
|
@ -1228,21 +1258,21 @@
|
|||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<item row="9" column="1">
|
||||
<widget class="QCheckBox" name="preload">
|
||||
<property name="text">
|
||||
<string>Preload entire ROM into memory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<item row="10" column="1">
|
||||
<widget class="QCheckBox" name="forceGbp">
|
||||
<property name="text">
|
||||
<string>Enable Game Boy Player features by default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<item row="11" column="1">
|
||||
<widget class="QCheckBox" name="vbaBugCompat">
|
||||
<property name="text">
|
||||
<string>Enable VBA bug compatibility in ROM hacks</string>
|
||||
|
|
|
@ -1827,6 +1827,11 @@ void Window::setupOptions() {
|
|||
reloadConfig();
|
||||
}, this);
|
||||
|
||||
ConfigOption* rewindBufferInterval = m_config->addOption("rewindBufferInterval");
|
||||
rewindBufferInterval->connect([this](const QVariant&) {
|
||||
reloadConfig();
|
||||
}, this);
|
||||
|
||||
ConfigOption* allowOpposingDirections = m_config->addOption("allowOpposingDirections");
|
||||
allowOpposingDirections->connect([this](const QVariant&) {
|
||||
reloadConfig();
|
||||
|
|
|
@ -61,6 +61,7 @@ int main(int argc, char** argv) {
|
|||
.useBios = true,
|
||||
.rewindEnable = true,
|
||||
.rewindBufferCapacity = 600,
|
||||
.rewindBufferInterval = 1,
|
||||
.audioBuffers = 1024,
|
||||
.videoSync = false,
|
||||
.audioSync = true,
|
||||
|
|
Loading…
Reference in New Issue