Add frame advance
Jeffrey Pfau jeffrey@endrift.com
Wed, 29 Jan 2014 23:58:57 -0800
3 files changed,
28 insertions(+),
0 deletions(-)
M
src/platform/qt/GameController.cpp
→
src/platform/qt/GameController.cpp
@@ -32,6 +32,12 @@ controller->audioDeviceAvailable(&context->gba->audio);
}; m_threadContext.frameCallback = [] (GBAThread* context) { GameController* controller = static_cast<GameController*>(context->userData); + controller->m_pauseMutex.lock(); + if (controller->m_pauseAfterFrame) { + GBAThreadPause(context); + controller->m_pauseAfterFrame = false; + } + controller->m_pauseMutex.unlock(); controller->frameAvailable(controller->m_drawContext); }; }@@ -48,6 +54,9 @@ if (!m_rom->open(QIODevice::ReadOnly)) {
delete m_rom; m_rom = 0; } + + m_pauseAfterFrame = false; + m_threadContext.fd = m_rom->handle(); m_threadContext.fname = path.toLocal8Bit().constData(); GBAThreadStart(&m_threadContext);@@ -63,6 +72,13 @@ GBAThreadPause(&m_threadContext);
} else { GBAThreadUnpause(&m_threadContext); } +} + +void GameController::frameAdvance() { + m_pauseMutex.lock(); + m_pauseAfterFrame = true; + setPaused(false); + m_pauseMutex.unlock(); } void GameController::keyPressed(int key) {
M
src/platform/qt/GameController.h
→
src/platform/qt/GameController.h
@@ -4,6 +4,7 @@
#include <QFile> #include <QImage> #include <QObject> +#include <QMutex> #include <QString> #include "AudioDevice.h"@@ -32,6 +33,7 @@
public slots: void loadGame(const QString& path); void setPaused(bool paused); + void frameAdvance(); void keyPressed(int key); void keyReleased(int key);@@ -45,6 +47,9 @@ GBAVideoSoftwareRenderer* m_renderer;
QFile* m_rom; QFile* m_bios; + + QMutex m_pauseMutex; + bool m_pauseAfterFrame; }; }
M
src/platform/qt/Window.cpp
→
src/platform/qt/Window.cpp
@@ -119,4 +119,11 @@ pause->setDisabled(true);
connect(pause, SIGNAL(triggered(bool)), m_controller, SLOT(setPaused(bool))); m_gameActions.append(pause); emulationMenu->addAction(pause); + + QAction* frameAdvance = new QAction(tr("&Next frame"), 0); + frameAdvance->setShortcut(tr("Ctrl+N")); + frameAdvance->setDisabled(true); + connect(frameAdvance, SIGNAL(triggered()), m_controller, SLOT(frameAdvance())); + m_gameActions.append(frameAdvance); + emulationMenu->addAction(frameAdvance); }