all repos — mgba @ 05ec732a83eca1a1291b163017d10f009905212b

mGBA Game Boy Advance Emulator

Add turbo
Jeffrey Pfau jeffrey@endrift.com
Sun, 19 Oct 2014 01:10:00 -0700
commit

05ec732a83eca1a1291b163017d10f009905212b

parent

24094ecdf04cdeda17711141a27bfa0bc30de467

3 files changed, 42 insertions(+), 4 deletions(-)

jump to
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -24,6 +24,8 @@ , m_audioThread(new QThread(this))

, m_audioProcessor(new AudioProcessor) , m_videoSync(VIDEO_SYNC) , m_audioSync(AUDIO_SYNC) + , m_turbo(false) + , m_turboForced(false) { m_renderer = new GBAVideoSoftwareRenderer; GBAVideoSoftwareRendererCreate(m_renderer);

@@ -238,15 +240,35 @@ }

void GameController::setVideoSync(bool set) { m_videoSync = set; - GBAThreadInterrupt(&m_threadContext); - m_threadContext.sync.videoFrameWait = set; - GBAThreadContinue(&m_threadContext); + if (!m_turbo) { + GBAThreadInterrupt(&m_threadContext); + m_threadContext.sync.videoFrameWait = set; + GBAThreadContinue(&m_threadContext); + } } void GameController::setAudioSync(bool set) { m_audioSync = set; + if (!m_turbo) { + GBAThreadInterrupt(&m_threadContext); + m_threadContext.sync.audioWait = set; + GBAThreadContinue(&m_threadContext); + } +} + +void GameController::setTurbo(bool set, bool forced) { + if (m_turboForced && !forced) { + return; + } + m_turbo = set; + if (set) { + m_turboForced = forced; + } else { + m_turboForced = false; + } GBAThreadInterrupt(&m_threadContext); - m_threadContext.sync.audioWait = set; + m_threadContext.sync.audioWait = set ? false : m_audioSync; + m_threadContext.sync.videoFrameWait = set ? false : m_videoSync; GBAThreadContinue(&m_threadContext); }
M src/platform/qt/GameController.hsrc/platform/qt/GameController.h

@@ -69,6 +69,7 @@ void loadState(int slot);

void saveState(int slot); void setVideoSync(bool); void setAudioSync(bool); + void setTurbo(bool, bool forced = true); #ifdef BUILD_SDL private slots:

@@ -98,6 +99,8 @@ bool m_pauseAfterFrame;

bool m_videoSync; bool m_audioSync; + bool m_turbo; + bool m_turboForced; }; }
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -154,6 +154,9 @@ if (event->isAutoRepeat()) {

QWidget::keyPressEvent(event); return; } + if (event->key() == Qt::Key_Tab) { + m_controller->setTurbo(true, false); + } GBAKey key = mapKey(event->key()); if (key == GBA_KEY_NONE) { QWidget::keyPressEvent(event);

@@ -167,6 +170,9 @@ void Window::keyReleaseEvent(QKeyEvent* event) {

if (event->isAutoRepeat()) { QWidget::keyReleaseEvent(event); return; + } + if (event->key() == Qt::Key_Tab) { + m_controller->setTurbo(false, false); } GBAKey key = mapKey(event->key()); if (key == GBA_KEY_NONE) {

@@ -358,6 +364,13 @@ connect(setTarget, &QAction::triggered, [this]() { emit fpsTargetChanged(240); });

target->addAction(setTarget); emulationMenu->addSeparator(); + + QAction* turbo = new QAction(tr("T&urbo"), emulationMenu); + turbo->setCheckable(true); + turbo->setChecked(false); + turbo->setShortcut(tr("Shift+Tab")); + connect(turbo, SIGNAL(triggered(bool)), m_controller, SLOT(setTurbo(bool))); + emulationMenu->addAction(turbo); QAction* videoSync = new QAction(tr("Sync to &video"), emulationMenu); videoSync->setCheckable(true);