mirror of https://github.com/mgba-emu/mgba.git
Add turbo
This commit is contained in:
parent
24094ecdf0
commit
05ec732a83
|
@ -24,6 +24,8 @@ GameController::GameController(QObject* parent)
|
||||||
, m_audioProcessor(new AudioProcessor)
|
, m_audioProcessor(new AudioProcessor)
|
||||||
, m_videoSync(VIDEO_SYNC)
|
, m_videoSync(VIDEO_SYNC)
|
||||||
, m_audioSync(AUDIO_SYNC)
|
, m_audioSync(AUDIO_SYNC)
|
||||||
|
, m_turbo(false)
|
||||||
|
, m_turboForced(false)
|
||||||
{
|
{
|
||||||
m_renderer = new GBAVideoSoftwareRenderer;
|
m_renderer = new GBAVideoSoftwareRenderer;
|
||||||
GBAVideoSoftwareRendererCreate(m_renderer);
|
GBAVideoSoftwareRendererCreate(m_renderer);
|
||||||
|
@ -238,15 +240,35 @@ void GameController::saveState(int slot) {
|
||||||
|
|
||||||
void GameController::setVideoSync(bool set) {
|
void GameController::setVideoSync(bool set) {
|
||||||
m_videoSync = set;
|
m_videoSync = set;
|
||||||
GBAThreadInterrupt(&m_threadContext);
|
if (!m_turbo) {
|
||||||
m_threadContext.sync.videoFrameWait = set;
|
GBAThreadInterrupt(&m_threadContext);
|
||||||
GBAThreadContinue(&m_threadContext);
|
m_threadContext.sync.videoFrameWait = set;
|
||||||
|
GBAThreadContinue(&m_threadContext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameController::setAudioSync(bool set) {
|
void GameController::setAudioSync(bool set) {
|
||||||
m_audioSync = 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);
|
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);
|
GBAThreadContinue(&m_threadContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ public slots:
|
||||||
void saveState(int slot);
|
void saveState(int slot);
|
||||||
void setVideoSync(bool);
|
void setVideoSync(bool);
|
||||||
void setAudioSync(bool);
|
void setAudioSync(bool);
|
||||||
|
void setTurbo(bool, bool forced = true);
|
||||||
|
|
||||||
#ifdef BUILD_SDL
|
#ifdef BUILD_SDL
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -98,6 +99,8 @@ private:
|
||||||
|
|
||||||
bool m_videoSync;
|
bool m_videoSync;
|
||||||
bool m_audioSync;
|
bool m_audioSync;
|
||||||
|
bool m_turbo;
|
||||||
|
bool m_turboForced;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,6 +154,9 @@ void Window::keyPressEvent(QKeyEvent* event) {
|
||||||
QWidget::keyPressEvent(event);
|
QWidget::keyPressEvent(event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (event->key() == Qt::Key_Tab) {
|
||||||
|
m_controller->setTurbo(true, false);
|
||||||
|
}
|
||||||
GBAKey key = mapKey(event->key());
|
GBAKey key = mapKey(event->key());
|
||||||
if (key == GBA_KEY_NONE) {
|
if (key == GBA_KEY_NONE) {
|
||||||
QWidget::keyPressEvent(event);
|
QWidget::keyPressEvent(event);
|
||||||
|
@ -168,6 +171,9 @@ void Window::keyReleaseEvent(QKeyEvent* event) {
|
||||||
QWidget::keyReleaseEvent(event);
|
QWidget::keyReleaseEvent(event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (event->key() == Qt::Key_Tab) {
|
||||||
|
m_controller->setTurbo(false, false);
|
||||||
|
}
|
||||||
GBAKey key = mapKey(event->key());
|
GBAKey key = mapKey(event->key());
|
||||||
if (key == GBA_KEY_NONE) {
|
if (key == GBA_KEY_NONE) {
|
||||||
QWidget::keyPressEvent(event);
|
QWidget::keyPressEvent(event);
|
||||||
|
@ -359,6 +365,13 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
|
|
||||||
emulationMenu->addSeparator();
|
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);
|
QAction* videoSync = new QAction(tr("Sync to &video"), emulationMenu);
|
||||||
videoSync->setCheckable(true);
|
videoSync->setCheckable(true);
|
||||||
videoSync->setChecked(GameController::VIDEO_SYNC);
|
videoSync->setChecked(GameController::VIDEO_SYNC);
|
||||||
|
|
Loading…
Reference in New Issue