all repos — mgba @ d6651050828fc93d73d0bbd0bc6d5b9a272f3402

mGBA Game Boy Advance Emulator

Qt: Support idle loop optimization
Jeffrey Pfau jeffrey@endrift.com
Thu, 29 Jan 2015 00:25:46 -0800
commit

d6651050828fc93d73d0bbd0bc6d5b9a272f3402

parent

9992282b1c35d8321dc44cd0ea4c11e27a42e8b0

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

@@ -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"

@@ -143,6 +144,18 @@

void GameController::setOverride(const GBACartridgeOverride& override) { m_threadContext.override = 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
M src/platform/qt/GameController.hsrc/platform/qt/GameController.h

@@ -21,6 +21,7 @@ #endif

} struct GBAAudio; +struct GBAOptions; struct GBAVideoSoftwareRenderer; struct Configuration;

@@ -58,6 +59,8 @@ void setOverrides(Configuration* overrides) { m_threadContext.overrides = overrides; }

void setOverride(const GBACartridgeOverride& override); void clearOverride() { m_threadContext.hasOverride = false; } + + void setOptions(const GBAOptions*); #ifdef USE_GDB_STUB ARMDebugger* debugger();
M src/platform/qt/GamePakView.cppsrc/platform/qt/GamePakView.cpp

@@ -81,7 +81,13 @@ m_override.hardware |= GPIO_RUMBLE;

} } - 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 @@ m_ui.hwLight->setChecked(thread->gba->memory.gpio.gpioDevices & GPIO_LIGHT_SENSOR);

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 @@ m_ui.hwLight->setChecked(false);

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); }
M src/platform/qt/GamePakView.uisrc/platform/qt/GamePakView.ui

@@ -7,7 +7,7 @@ <rect>

<x>0</x> <y>0</y> <width>409</width> - <height>198</height> + <height>228</height> </rect> </property> <property name="sizePolicy">

@@ -17,99 +17,47 @@ <verstretch>0</verstretch>

</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 @@ </item>

</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>
M src/platform/qt/SettingsView.cppsrc/platform/qt/SettingsView.cpp

@@ -30,6 +30,15 @@ loadSetting("rewindBufferInterval", m_ui.rewindInterval);

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 @@ saveSetting("rewindEnable", m_ui.rewind);

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 @@ saveSetting(key, field->lineEdit());

} 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 @@ loadSetting(key, field->lineEdit());

} 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); +}
M src/platform/qt/SettingsView.hsrc/platform/qt/SettingsView.h

@@ -36,11 +36,13 @@ void saveSetting(const char* key, const QAbstractButton*);

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); }; }
M src/platform/qt/SettingsView.uisrc/platform/qt/SettingsView.ui

@@ -6,7 +6,7 @@ <property name="geometry">

<rect> <x>0</x> <y>0</y> - <width>350</width> + <width>355</width> <height>501</height> </rect> </property>

@@ -325,6 +325,39 @@ </property>

</widget> </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>
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -146,11 +146,7 @@ const GBAOptions* opts = m_config->options();

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);