mirror of https://github.com/mgba-emu/mgba.git
Add FPS target options
This commit is contained in:
parent
0717e4ab76
commit
d020bf4f0a
|
@ -20,7 +20,7 @@ void AudioDevice::setFormat(const QAudioFormat& format) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO: make this thread-safe
|
// TODO: make this thread-safe
|
||||||
m_ratio = GBAAudioCalculateRatio(&m_context->gba->audio, 60, format.sampleRate());
|
m_ratio = GBAAudioCalculateRatio(&m_context->gba->audio, m_context->fpsTarget, format.sampleRate());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioDevice::setInput(GBAThread* input) {
|
void AudioDevice::setInput(GBAThread* input) {
|
||||||
|
|
|
@ -61,3 +61,7 @@ void AudioProcessor::setBufferSamples(int samples) {
|
||||||
QAudioFormat format = m_audioOutput->format();
|
QAudioFormat format = m_audioOutput->format();
|
||||||
m_audioOutput->setBufferSize(samples * format.channelCount() * format.sampleSize() / 8);
|
m_audioOutput->setBufferSize(samples * format.channelCount() * format.sampleSize() / 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioProcessor::inputParametersChanged() {
|
||||||
|
m_device->setFormat(m_audioOutput->format());
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ public slots:
|
||||||
void pause();
|
void pause();
|
||||||
|
|
||||||
void setBufferSamples(int samples);
|
void setBufferSamples(int samples);
|
||||||
|
void inputParametersChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GBAThread* m_context;
|
GBAThread* m_context;
|
||||||
|
|
|
@ -181,6 +181,13 @@ void GameController::setAudioBufferSamples(int samples) {
|
||||||
QMetaObject::invokeMethod(m_audioProcessor, "setBufferSamples", Q_ARG(int, samples));
|
QMetaObject::invokeMethod(m_audioProcessor, "setBufferSamples", Q_ARG(int, samples));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameController::setFPSTarget(float fps) {
|
||||||
|
GBAThreadInterrupt(&m_threadContext);
|
||||||
|
m_threadContext.fpsTarget = fps;
|
||||||
|
GBAThreadContinue(&m_threadContext);
|
||||||
|
QMetaObject::invokeMethod(m_audioProcessor, "inputParametersChanged");
|
||||||
|
}
|
||||||
|
|
||||||
void GameController::updateKeys() {
|
void GameController::updateKeys() {
|
||||||
int activeKeys = m_activeKeys;
|
int activeKeys = m_activeKeys;
|
||||||
#ifdef BUILD_SDL
|
#ifdef BUILD_SDL
|
||||||
|
|
|
@ -55,6 +55,7 @@ public slots:
|
||||||
void keyPressed(int key);
|
void keyPressed(int key);
|
||||||
void keyReleased(int key);
|
void keyReleased(int key);
|
||||||
void setAudioBufferSamples(int samples);
|
void setAudioBufferSamples(int samples);
|
||||||
|
void setFPSTarget(float fps);
|
||||||
|
|
||||||
#ifdef BUILD_SDL
|
#ifdef BUILD_SDL
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
@ -29,6 +29,7 @@ Window::Window(QWidget* parent)
|
||||||
connect(this, SIGNAL(startDrawing(const uint32_t*, GBAThread*)), m_display, SLOT(startDrawing(const uint32_t*, GBAThread*)), Qt::QueuedConnection);
|
connect(this, SIGNAL(startDrawing(const uint32_t*, GBAThread*)), m_display, SLOT(startDrawing(const uint32_t*, GBAThread*)), Qt::QueuedConnection);
|
||||||
connect(this, SIGNAL(shutdown()), m_display, SLOT(stopDrawing()));
|
connect(this, SIGNAL(shutdown()), m_display, SLOT(stopDrawing()));
|
||||||
connect(this, SIGNAL(audioBufferSamplesChanged(int)), m_controller, SLOT(setAudioBufferSamples(int)));
|
connect(this, SIGNAL(audioBufferSamplesChanged(int)), m_controller, SLOT(setAudioBufferSamples(int)));
|
||||||
|
connect(this, SIGNAL(fpsTargetChanged(float)), m_controller, SLOT(setFPSTarget(float)));
|
||||||
|
|
||||||
setupMenu(menuBar());
|
setupMenu(menuBar());
|
||||||
}
|
}
|
||||||
|
@ -167,6 +168,29 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
m_gameActions.append(frameAdvance);
|
m_gameActions.append(frameAdvance);
|
||||||
emulationMenu->addAction(frameAdvance);
|
emulationMenu->addAction(frameAdvance);
|
||||||
|
|
||||||
|
QMenu* target = emulationMenu->addMenu("FPS target");
|
||||||
|
QAction* setTarget = new QAction(tr("15"), nullptr);
|
||||||
|
connect(setTarget, &QAction::triggered, [this]() { emit fpsTargetChanged(15); });
|
||||||
|
target->addAction(setTarget);
|
||||||
|
setTarget = new QAction(tr("30"), nullptr);
|
||||||
|
connect(setTarget, &QAction::triggered, [this]() { emit fpsTargetChanged(30); });
|
||||||
|
target->addAction(setTarget);
|
||||||
|
setTarget = new QAction(tr("45"), nullptr);
|
||||||
|
connect(setTarget, &QAction::triggered, [this]() { emit fpsTargetChanged(45); });
|
||||||
|
target->addAction(setTarget);
|
||||||
|
setTarget = new QAction(tr("60"), nullptr);
|
||||||
|
connect(setTarget, &QAction::triggered, [this]() { emit fpsTargetChanged(60); });
|
||||||
|
target->addAction(setTarget);
|
||||||
|
setTarget = new QAction(tr("90"), nullptr);
|
||||||
|
connect(setTarget, &QAction::triggered, [this]() { emit fpsTargetChanged(90); });
|
||||||
|
target->addAction(setTarget);
|
||||||
|
setTarget = new QAction(tr("120"), nullptr);
|
||||||
|
connect(setTarget, &QAction::triggered, [this]() { emit fpsTargetChanged(120); });
|
||||||
|
target->addAction(setTarget);
|
||||||
|
setTarget = new QAction(tr("240"), nullptr);
|
||||||
|
connect(setTarget, &QAction::triggered, [this]() { emit fpsTargetChanged(240); });
|
||||||
|
target->addAction(setTarget);
|
||||||
|
|
||||||
QMenu* soundMenu = menubar->addMenu(tr("&Sound"));
|
QMenu* soundMenu = menubar->addMenu(tr("&Sound"));
|
||||||
QMenu* buffersMenu = soundMenu->addMenu(tr("Buffer &size"));
|
QMenu* buffersMenu = soundMenu->addMenu(tr("Buffer &size"));
|
||||||
QAction* setBuffer = new QAction(tr("512"), nullptr);
|
QAction* setBuffer = new QAction(tr("512"), nullptr);
|
||||||
|
|
|
@ -40,6 +40,7 @@ protected:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void audioBufferSamplesChanged(int samples);
|
void audioBufferSamplesChanged(int samples);
|
||||||
|
void fpsTargetChanged(float target);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void gameStarted(GBAThread*);
|
void gameStarted(GBAThread*);
|
||||||
|
|
Loading…
Reference in New Issue