mirror of https://github.com/mgba-emu/mgba.git
Qt: Support idle loop optimization
This commit is contained in:
parent
9992282b1c
commit
d665105082
|
@ -16,6 +16,7 @@
|
|||
extern "C" {
|
||||
#include "gba.h"
|
||||
#include "gba-audio.h"
|
||||
#include "gba-config.h"
|
||||
#include "gba-serialize.h"
|
||||
#include "renderers/video-software.h"
|
||||
#include "util/vfs.h"
|
||||
|
@ -145,6 +146,18 @@ void GameController::setOverride(const GBACartridgeOverride& override) {
|
|||
m_threadContext.hasOverride = true;
|
||||
}
|
||||
|
||||
void GameController::setOptions(const GBAOptions* opts) {
|
||||
setFrameskip(opts->frameskip);
|
||||
setAudioSync(opts->audioSync);
|
||||
setVideoSync(opts->videoSync);
|
||||
setSkipBIOS(opts->skipBios);
|
||||
setRewind(opts->rewindEnable, opts->rewindBufferCapacity, opts->rewindBufferInterval);
|
||||
|
||||
threadInterrupt();
|
||||
m_threadContext.idleOptimization = opts->idleOptimization;
|
||||
threadContinue();
|
||||
}
|
||||
|
||||
#ifdef USE_GDB_STUB
|
||||
ARMDebugger* GameController::debugger() {
|
||||
return m_threadContext.debugger;
|
||||
|
|
|
@ -21,6 +21,7 @@ extern "C" {
|
|||
}
|
||||
|
||||
struct GBAAudio;
|
||||
struct GBAOptions;
|
||||
struct GBAVideoSoftwareRenderer;
|
||||
struct Configuration;
|
||||
|
||||
|
@ -59,6 +60,8 @@ public:
|
|||
void setOverride(const GBACartridgeOverride& override);
|
||||
void clearOverride() { m_threadContext.hasOverride = false; }
|
||||
|
||||
void setOptions(const GBAOptions*);
|
||||
|
||||
#ifdef USE_GDB_STUB
|
||||
ARMDebugger* debugger();
|
||||
void setDebugger(ARMDebugger*);
|
||||
|
|
|
@ -81,7 +81,13 @@ void GamePakView::updateOverrides() {
|
|||
}
|
||||
}
|
||||
|
||||
if (m_override.savetype != SAVEDATA_AUTODETECT || m_override.hardware != GPIO_NO_OVERRIDE) {
|
||||
bool ok;
|
||||
uint32_t parsedIdleLoop = m_ui.idleLoop->text().toInt(&ok, 16);
|
||||
if (ok) {
|
||||
m_override.idleLoop = parsedIdleLoop;
|
||||
}
|
||||
|
||||
if (m_override.savetype != SAVEDATA_AUTODETECT || m_override.hardware != GPIO_NO_OVERRIDE || m_override.idleLoop != IDLE_LOOP_NONE) {
|
||||
m_controller->setOverride(m_override);
|
||||
} else {
|
||||
m_controller->clearOverride();
|
||||
|
@ -109,9 +115,19 @@ void GamePakView::gameStarted(GBAThread* thread) {
|
|||
m_ui.hwTilt->setChecked(thread->gba->memory.gpio.gpioDevices & GPIO_TILT);
|
||||
m_ui.hwRumble->setChecked(thread->gba->memory.gpio.gpioDevices & GPIO_RUMBLE);
|
||||
|
||||
if (thread->gba->idleLoop != IDLE_LOOP_NONE) {
|
||||
m_ui.idleLoop->setText(QString::number(thread->gba->idleLoop, 16));
|
||||
} else {
|
||||
m_ui.idleLoop->clear();
|
||||
|
||||
}
|
||||
|
||||
GBAGetGameCode(thread->gba, m_override.id);
|
||||
m_override.hardware = thread->gba->memory.gpio.gpioDevices;
|
||||
m_override.savetype = thread->gba->memory.savedata.type;
|
||||
m_override.idleLoop = thread->gba->idleLoop;
|
||||
|
||||
m_ui.idleLoop->setEnabled(false);
|
||||
|
||||
m_ui.save->setEnabled(m_config);
|
||||
}
|
||||
|
@ -133,5 +149,8 @@ void GamePakView::gameStopped() {
|
|||
m_ui.hwTilt->setChecked(false);
|
||||
m_ui.hwRumble->setChecked(false);
|
||||
|
||||
m_ui.idleLoop->setEnabled(true);
|
||||
|
||||
m_ui.clear->setEnabled(false);
|
||||
m_ui.save->setEnabled(false);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>409</width>
|
||||
<height>198</height>
|
||||
<height>228</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -17,99 +17,47 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Game Pak Overrides</string>
|
||||
<string>Game Overrides</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_5">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Save type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="savetype">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Autodetect</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>SRAM</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Flash 512kb</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Flash 1Mb</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>EEPROM</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Idle loop</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="idleOptimization">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Run</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Optimize</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Detect</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="idleLoop"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="clear">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="save">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<item row="0" column="0" rowspan="3">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string/>
|
||||
|
@ -178,32 +126,88 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_5">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Save type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="savetype">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Autodetect</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>SRAM</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Flash 512kb</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Flash 1Mb</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>EEPROM</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Idle loop</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="idleLoop"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="save">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save overrides</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
|
@ -30,6 +30,15 @@ SettingsView::SettingsView(ConfigController* controller, QWidget* parent)
|
|||
loadSetting("rewindBufferCapacity", m_ui.rewindCapacity);
|
||||
loadSetting("resampleVideo", m_ui.resampleVideo);
|
||||
|
||||
QString idleOptimization = loadSetting("idleOptimization");
|
||||
if (idleOptimization == "ignore") {
|
||||
m_ui.idleOptimization->setCurrentIndex(0);
|
||||
} else if (idleOptimization == "remove") {
|
||||
m_ui.idleOptimization->setCurrentIndex(1);
|
||||
} else if (idleOptimization == "detect") {
|
||||
m_ui.idleOptimization->setCurrentIndex(2);
|
||||
}
|
||||
|
||||
connect(m_ui.biosBrowse, SIGNAL(clicked()), this, SLOT(selectBios()));
|
||||
connect(m_ui.buttonBox, SIGNAL(accepted()), this, SLOT(updateConfig()));
|
||||
}
|
||||
|
@ -54,6 +63,19 @@ void SettingsView::updateConfig() {
|
|||
saveSetting("rewindBufferInterval", m_ui.rewindInterval);
|
||||
saveSetting("rewindBufferCapacity", m_ui.rewindCapacity);
|
||||
saveSetting("resampleVideo", m_ui.resampleVideo);
|
||||
|
||||
switch (m_ui.idleOptimization->currentIndex() + IDLE_LOOP_IGNORE) {
|
||||
case IDLE_LOOP_IGNORE:
|
||||
saveSetting("idleOptimization", "ignore");
|
||||
break;
|
||||
case IDLE_LOOP_REMOVE:
|
||||
saveSetting("idleOptimization", "remove");
|
||||
break;
|
||||
case IDLE_LOOP_DETECT:
|
||||
saveSetting("idleOptimization", "detect");
|
||||
break;
|
||||
}
|
||||
|
||||
m_controller->write();
|
||||
|
||||
emit biosLoaded(m_ui.bios->text());
|
||||
|
@ -69,17 +91,20 @@ void SettingsView::saveSetting(const char* key, const QComboBox* field) {
|
|||
}
|
||||
|
||||
void SettingsView::saveSetting(const char* key, const QLineEdit* field) {
|
||||
m_controller->setOption(key, field->text());
|
||||
m_controller->updateOption(key);
|
||||
saveSetting(key, field->text());
|
||||
}
|
||||
|
||||
void SettingsView::saveSetting(const char* key, const QSpinBox* field) {
|
||||
m_controller->setOption(key, field->cleanText());
|
||||
saveSetting(key, field->cleanText());
|
||||
}
|
||||
|
||||
void SettingsView::saveSetting(const char* key, const QString& field) {
|
||||
m_controller->setOption(key, field);
|
||||
m_controller->updateOption(key);
|
||||
}
|
||||
|
||||
void SettingsView::loadSetting(const char* key, QAbstractButton* field) {
|
||||
QString option = m_controller->getOption(key);
|
||||
QString option = loadSetting(key);
|
||||
field->setChecked(option != "0");
|
||||
}
|
||||
|
||||
|
@ -88,11 +113,15 @@ void SettingsView::loadSetting(const char* key, QComboBox* field) {
|
|||
}
|
||||
|
||||
void SettingsView::loadSetting(const char* key, QLineEdit* field) {
|
||||
QString option = m_controller->getOption(key);
|
||||
QString option = loadSetting(key);
|
||||
field->setText(option);
|
||||
}
|
||||
|
||||
void SettingsView::loadSetting(const char* key, QSpinBox* field) {
|
||||
QString option = m_controller->getOption(key);
|
||||
QString option = loadSetting(key);
|
||||
field->setValue(option.toInt());
|
||||
}
|
||||
|
||||
QString SettingsView::loadSetting(const char* key) {
|
||||
return m_controller->getOption(key);
|
||||
}
|
||||
|
|
|
@ -36,11 +36,13 @@ private:
|
|||
void saveSetting(const char* key, const QComboBox*);
|
||||
void saveSetting(const char* key, const QLineEdit*);
|
||||
void saveSetting(const char* key, const QSpinBox*);
|
||||
void saveSetting(const char* key, const QString&);
|
||||
|
||||
void loadSetting(const char* key, QAbstractButton*);
|
||||
void loadSetting(const char* key, QComboBox*);
|
||||
void loadSetting(const char* key, QLineEdit*);
|
||||
void loadSetting(const char* key, QSpinBox*);
|
||||
QString loadSetting(const char* key);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>350</width>
|
||||
<width>355</width>
|
||||
<height>501</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -326,6 +326,39 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="17" column="1">
|
||||
<widget class="QComboBox" name="idleOptimization">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Run all</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Remove known</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Detect and remove</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="16" column="0" colspan="2">
|
||||
<widget class="Line" name="line_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="17" column="0">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Idle loops</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
@ -146,11 +146,7 @@ void Window::loadConfig() {
|
|||
|
||||
m_logView->setLevels(opts->logLevel);
|
||||
|
||||
m_controller->setFrameskip(opts->frameskip);
|
||||
m_controller->setAudioSync(opts->audioSync);
|
||||
m_controller->setVideoSync(opts->videoSync);
|
||||
m_controller->setSkipBIOS(opts->skipBios);
|
||||
m_controller->setRewind(opts->rewindEnable, opts->rewindBufferCapacity, opts->rewindBufferInterval);
|
||||
m_controller->setOptions(opts);
|
||||
m_display->lockAspectRatio(opts->lockAspectRatio);
|
||||
m_display->filter(opts->resampleVideo);
|
||||
|
||||
|
|
Loading…
Reference in New Issue