mirror of https://github.com/mgba-emu/mgba.git
Qt: Expose rewind (fixes #136)
This commit is contained in:
parent
d6e24b2051
commit
f97ba6517b
1
CHANGES
1
CHANGES
|
@ -13,6 +13,7 @@ Features:
|
||||||
- Game Pak overrides dialog for setting savetype and sensor values
|
- Game Pak overrides dialog for setting savetype and sensor values
|
||||||
- Support for games using the tilt sensor
|
- Support for games using the tilt sensor
|
||||||
- Remappable shortcuts for keyboard and gamepad
|
- Remappable shortcuts for keyboard and gamepad
|
||||||
|
- Rewinding of emulation
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
- Qt: Fix issue with set frame sizes being the wrong height
|
- Qt: Fix issue with set frame sizes being the wrong height
|
||||||
- Qt: Fix emulator crashing when full screen if a game is not running
|
- Qt: Fix emulator crashing when full screen if a game is not running
|
||||||
|
|
|
@ -23,6 +23,7 @@ Features
|
||||||
- Loading from ZIP files.
|
- Loading from ZIP files.
|
||||||
- IPS and UPS patch support.
|
- IPS and UPS patch support.
|
||||||
- Game debugging via a command-line interface (not available with Qt port) and GDB remote support.
|
- Game debugging via a command-line interface (not available with Qt port) and GDB remote support.
|
||||||
|
- Configurable emulation rewinding.
|
||||||
|
|
||||||
### Planned features
|
### Planned features
|
||||||
|
|
||||||
|
|
|
@ -298,6 +298,32 @@ void GameController::frameAdvance() {
|
||||||
m_pauseMutex.unlock();
|
m_pauseMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameController::setRewind(bool enable, int capacity, int interval) {
|
||||||
|
if (m_gameOpen) {
|
||||||
|
threadInterrupt();
|
||||||
|
GBARewindSettingsChanged(&m_threadContext, enable ? capacity : 0, enable ? interval : 0);
|
||||||
|
threadContinue();
|
||||||
|
} else {
|
||||||
|
if (enable) {
|
||||||
|
m_threadContext.rewindBufferInterval = interval;
|
||||||
|
m_threadContext.rewindBufferCapacity = capacity;
|
||||||
|
} else {
|
||||||
|
m_threadContext.rewindBufferInterval = 0;
|
||||||
|
m_threadContext.rewindBufferCapacity = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameController::rewind(int states) {
|
||||||
|
threadInterrupt();
|
||||||
|
if (!states) {
|
||||||
|
GBARewindAll(&m_threadContext);
|
||||||
|
} else {
|
||||||
|
GBARewind(&m_threadContext, states);
|
||||||
|
}
|
||||||
|
threadContinue();
|
||||||
|
}
|
||||||
|
|
||||||
void GameController::keyPressed(int key) {
|
void GameController::keyPressed(int key) {
|
||||||
int mappedKey = 1 << key;
|
int mappedKey = 1 << key;
|
||||||
m_activeKeys |= mappedKey;
|
m_activeKeys |= mappedKey;
|
||||||
|
|
|
@ -80,6 +80,8 @@ public slots:
|
||||||
void setPaused(bool paused);
|
void setPaused(bool paused);
|
||||||
void reset();
|
void reset();
|
||||||
void frameAdvance();
|
void frameAdvance();
|
||||||
|
void setRewind(bool enable, int capacity, int interval);
|
||||||
|
void rewind(int states = 0);
|
||||||
void keyPressed(int key);
|
void keyPressed(int key);
|
||||||
void keyReleased(int key);
|
void keyReleased(int key);
|
||||||
void clearKeys();
|
void clearKeys();
|
||||||
|
|
|
@ -25,6 +25,7 @@ SettingsView::SettingsView(ConfigController* controller, QWidget* parent)
|
||||||
loadSetting("frameskip", m_ui.frameskip);
|
loadSetting("frameskip", m_ui.frameskip);
|
||||||
loadSetting("fpsTarget", m_ui.fpsTarget);
|
loadSetting("fpsTarget", m_ui.fpsTarget);
|
||||||
loadSetting("lockAspectRatio", m_ui.lockAspectRatio);
|
loadSetting("lockAspectRatio", m_ui.lockAspectRatio);
|
||||||
|
loadSetting("rewindEnable", m_ui.rewind);
|
||||||
loadSetting("rewindBufferInterval", m_ui.rewindInterval);
|
loadSetting("rewindBufferInterval", m_ui.rewindInterval);
|
||||||
loadSetting("rewindBufferCapacity", m_ui.rewindCapacity);
|
loadSetting("rewindBufferCapacity", m_ui.rewindCapacity);
|
||||||
loadSetting("resampleVideo", m_ui.resampleVideo);
|
loadSetting("resampleVideo", m_ui.resampleVideo);
|
||||||
|
@ -49,6 +50,7 @@ void SettingsView::updateConfig() {
|
||||||
saveSetting("frameskip", m_ui.frameskip);
|
saveSetting("frameskip", m_ui.frameskip);
|
||||||
saveSetting("fpsTarget", m_ui.fpsTarget);
|
saveSetting("fpsTarget", m_ui.fpsTarget);
|
||||||
saveSetting("lockAspectRatio", m_ui.lockAspectRatio);
|
saveSetting("lockAspectRatio", m_ui.lockAspectRatio);
|
||||||
|
saveSetting("rewindEnable", m_ui.rewind);
|
||||||
saveSetting("rewindBufferInterval", m_ui.rewindInterval);
|
saveSetting("rewindBufferInterval", m_ui.rewindInterval);
|
||||||
saveSetting("rewindBufferCapacity", m_ui.rewindCapacity);
|
saveSetting("rewindBufferCapacity", m_ui.rewindCapacity);
|
||||||
saveSetting("resampleVideo", m_ui.resampleVideo);
|
saveSetting("resampleVideo", m_ui.resampleVideo);
|
||||||
|
|
|
@ -244,9 +244,6 @@
|
||||||
</item>
|
</item>
|
||||||
<item row="13" column="1">
|
<item row="13" column="1">
|
||||||
<widget class="QCheckBox" name="rewind">
|
<widget class="QCheckBox" name="rewind">
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Enable rewind</string>
|
<string>Enable rewind</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -144,6 +144,7 @@ void Window::loadConfig() {
|
||||||
m_controller->setAudioSync(opts->audioSync);
|
m_controller->setAudioSync(opts->audioSync);
|
||||||
m_controller->setVideoSync(opts->videoSync);
|
m_controller->setVideoSync(opts->videoSync);
|
||||||
m_controller->setSkipBIOS(opts->skipBios);
|
m_controller->setSkipBIOS(opts->skipBios);
|
||||||
|
m_controller->setRewind(opts->rewindEnable, opts->rewindBufferCapacity, opts->rewindBufferInterval);
|
||||||
m_display->lockAspectRatio(opts->lockAspectRatio);
|
m_display->lockAspectRatio(opts->lockAspectRatio);
|
||||||
m_display->filter(opts->resampleVideo);
|
m_display->filter(opts->resampleVideo);
|
||||||
|
|
||||||
|
@ -522,6 +523,12 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
connect(turbo, SIGNAL(triggered(bool)), m_controller, SLOT(setTurbo(bool)));
|
connect(turbo, SIGNAL(triggered(bool)), m_controller, SLOT(setTurbo(bool)));
|
||||||
addControlledAction(emulationMenu, turbo, "fastForward");
|
addControlledAction(emulationMenu, turbo, "fastForward");
|
||||||
|
|
||||||
|
QAction* rewind = new QAction(tr("Re&wind"), emulationMenu);
|
||||||
|
rewind->setShortcut(tr("`"));
|
||||||
|
connect(rewind, SIGNAL(triggered()), m_controller, SLOT(rewind()));
|
||||||
|
m_gameActions.append(rewind);
|
||||||
|
addControlledAction(emulationMenu, rewind, "rewind");
|
||||||
|
|
||||||
ConfigOption* videoSync = m_config->addOption("videoSync");
|
ConfigOption* videoSync = m_config->addOption("videoSync");
|
||||||
videoSync->addBoolean(tr("Sync to &video"), emulationMenu);
|
videoSync->addBoolean(tr("Sync to &video"), emulationMenu);
|
||||||
videoSync->connect([this](const QVariant& value) { m_controller->setVideoSync(value.toBool()); });
|
videoSync->connect([this](const QVariant& value) { m_controller->setVideoSync(value.toBool()); });
|
||||||
|
@ -649,6 +656,15 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
ConfigOption* skipBios = m_config->addOption("skipBios");
|
ConfigOption* skipBios = m_config->addOption("skipBios");
|
||||||
skipBios->connect([this](const QVariant& value) { m_controller->setSkipBIOS(value.toBool()); });
|
skipBios->connect([this](const QVariant& value) { m_controller->setSkipBIOS(value.toBool()); });
|
||||||
|
|
||||||
|
ConfigOption* rewindEnable = m_config->addOption("rewindEnable");
|
||||||
|
rewindEnable->connect([this](const QVariant& value) { m_controller->setRewind(value.toBool(), m_config->getOption("rewindBufferCapacity").toInt(), m_config->getOption("rewindBufferInterval").toInt()); });
|
||||||
|
|
||||||
|
ConfigOption* rewindBufferCapacity = m_config->addOption("rewindBufferCapacity");
|
||||||
|
rewindBufferCapacity->connect([this](const QVariant& value) { m_controller->setRewind(m_config->getOption("rewindEnable").toInt(), value.toInt(), m_config->getOption("rewindBufferInterval").toInt()); });
|
||||||
|
|
||||||
|
ConfigOption* rewindBufferInterval = m_config->addOption("rewindBufferInterval");
|
||||||
|
rewindBufferInterval->connect([this](const QVariant& value) { m_controller->setRewind(m_config->getOption("rewindEnable").toInt(), m_config->getOption("rewindBufferCapacity").toInt(), value.toInt()); });
|
||||||
|
|
||||||
QMenu* other = new QMenu(tr("Other"), this);
|
QMenu* other = new QMenu(tr("Other"), this);
|
||||||
m_shortcutController->addMenu(other);
|
m_shortcutController->addMenu(other);
|
||||||
m_shortcutController->addFunctions(other, [this]() {
|
m_shortcutController->addFunctions(other, [this]() {
|
||||||
|
|
Loading…
Reference in New Issue