all repos — mgba @ c207675dfb0ae3e39f9cb0745fe0cca79a697ae2

mGBA Game Boy Advance Emulator

Qt: Ability to temporarily load a savegame
Jeffrey Pfau jeffrey@endrift.com
Mon, 22 Aug 2016 10:33:59 -0700
commit

c207675dfb0ae3e39f9cb0745fe0cca79a697ae2

parent

a088ad781a815f66c227b42a64dbb660880fdb52

M CHANGESCHANGES

@@ -10,6 +10,7 @@ - GUI: Add UI control remapping

- GUI: Add fast-forward - Wii: 240p support - 3DS: Adjustable screen darkening + - Ability to temporarily load a savegame Bugfixes: - SDL: Fix axes being mapped wrong - GBA Memory: Fix mirror on non-overdumped Classic NES games
M src/gba/core.csrc/gba/core.c

@@ -209,7 +209,8 @@ return GBALoadSave(core->board, vf);

} static bool _GBACoreLoadTemporarySave(struct mCore* core, struct VFile* vf) { - GBASavedataMask(core->board, vf); + struct GBA* gba = core->board; + GBASavedataMask(&gba->memory.savedata, vf); return true; // TODO: Return a real value }
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -138,6 +138,11 @@ };

m_threadContext.resetCallback = [](mCoreThread* context) { GameController* controller = static_cast<GameController*>(context->userData); + for (auto action : controller->m_resetActions) { + action(); + } + controller->m_resetActions.clear(); + unsigned width, height; controller->m_threadContext.core->desiredVideoDimensions(controller->m_threadContext.core, &width, &height); memset(controller->m_frontBuffer, 0xF8, width * height * BYTES_PER_PIXEL);

@@ -415,17 +420,20 @@ void GameController::loadSave(const QString& path, bool temporary) {

if (!isLoaded()) { return; } - VFile* vf = VFileDevice::open(path, temporary ? O_RDONLY : O_RDWR); - if (!vf) { - LOG(QT, ERROR) << tr("Failed to open save file: %1").arg(path); - return; - } + m_resetActions.append([this, path, temporary]() { + VFile* vf = VFileDevice::open(path, temporary ? O_RDONLY : O_RDWR); + if (!vf) { + LOG(QT, ERROR) << tr("Failed to open save file: %1").arg(path); + return; + } - if (temporary) { - m_threadContext.core->loadTemporarySave(m_threadContext.core, vf); - } else { - m_threadContext.core->loadSave(m_threadContext.core, vf); - } + if (temporary) { + m_threadContext.core->loadTemporarySave(m_threadContext.core, vf); + } else { + m_threadContext.core->loadSave(m_threadContext.core, vf); + } + }); + reset(); } void GameController::yankPak() {
M src/platform/qt/GameController.hsrc/platform/qt/GameController.h

@@ -192,6 +192,7 @@ QThread* m_audioThread;

AudioProcessor* m_audioProcessor; QAtomicInt m_pauseAfterFrame; + QList<std::function<void ()>> m_resetActions; bool m_videoSync; bool m_audioSync;
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -850,7 +850,7 @@ m_shortcutController->addMenu(fileMenu);

installEventFilter(m_shortcutController); addControlledAction(fileMenu, fileMenu->addAction(tr("Load &ROM..."), this, SLOT(selectROM()), QKeySequence::Open), "loadROM"); - QAction* loadTemporarySave = new QAction(tr("Load temporary save"), fileMenu); + QAction* loadTemporarySave = new QAction(tr("Load temporary save..."), fileMenu); connect(loadTemporarySave, &QAction::triggered, [this]() { this->selectSave(true); }); m_gameActions.append(loadTemporarySave); m_gbaActions.append(loadTemporarySave);