all repos — mgba @ 83dfbe61236b128bfdd09f29a34c486fe620e861

mGBA Game Boy Advance Emulator

Qt: ROM replacing
Jeffrey Pfau jeffrey@endrift.com
Fri, 19 Jun 2015 22:29:59 -0700
commit

83dfbe61236b128bfdd09f29a34c486fe620e861

parent

635fae7d0534853f2c9fbd46222ff179ed9ce9db

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

@@ -282,17 +282,7 @@ if (m_dirmode) {

m_threadContext.gameDir = VDirOpen(m_threadContext.fname); m_threadContext.stateDir = m_threadContext.gameDir; } else { - m_threadContext.rom = VFileOpen(m_threadContext.fname, O_RDONLY); -#if USE_LIBZIP - if (!m_threadContext.gameDir) { - m_threadContext.gameDir = VDirOpenZip(m_threadContext.fname, 0); - } -#endif -#if USE_LZMA - if (!m_threadContext.gameDir) { - m_threadContext.gameDir = VDirOpen7z(m_threadContext.fname, 0); - } -#endif + GBAThreadLoadROM(&m_threadContext, m_threadContext.fname); } }

@@ -331,6 +321,19 @@ return;

} threadInterrupt(); GBAYankROM(m_threadContext.gba); + threadContinue(); +} + + +void GameController::replaceGame(const QString& path) { + if (!m_gameOpen) { + return; + } + + m_fname = path; + threadInterrupt(); + m_threadContext.fname = strdup(m_fname.toLocal8Bit().constData()); + GBAThreadReplaceROM(&m_threadContext, m_threadContext.fname); threadContinue(); }
M src/platform/qt/GameController.hsrc/platform/qt/GameController.h

@@ -98,6 +98,7 @@ public slots:

void loadGame(const QString& path, bool dirmode = false); void loadBIOS(const QString& path); void yankPak(); + void replaceGame(const QString& path); void setSkipBIOS(bool); void setUseBIOS(bool); void loadPatch(const QString& path);
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -230,6 +230,24 @@ m_controller->loadGame(filename);

} } +void Window::replaceROM() { + QStringList formats{ + "*.gba", +#ifdef USE_LIBZIP + "*.zip", +#endif +#ifdef USE_LZMA + "*.7z", +#endif + "*.rom", + "*.bin"}; + QString filter = tr("Game Boy Advance ROMs (%1)").arg(formats.join(QChar(' '))); + QString filename = GBAApp::app()->getOpenFileName(this, tr("Select ROM"), filter); + if (!filename.isEmpty()) { + m_controller->replaceGame(filename); + } +} + void Window::selectBIOS() { QString filename = GBAApp::app()->getOpenFileName(this, tr("Select BIOS")); if (!filename.isEmpty()) {

@@ -614,6 +632,8 @@ addControlledAction(fileMenu, fileMenu->addAction(tr("Load &ROM..."), this, SLOT(selectROM()), QKeySequence::Open), "loadROM");

addControlledAction(fileMenu, fileMenu->addAction(tr("Load &BIOS..."), this, SLOT(selectBIOS())), "loadBIOS"); addControlledAction(fileMenu, fileMenu->addAction(tr("Load &patch..."), this, SLOT(selectPatch())), "loadPatch"); addControlledAction(fileMenu, fileMenu->addAction(tr("Boot BIOS"), m_controller, SLOT(bootBIOS())), "bootBIOS"); + + addControlledAction(fileMenu, fileMenu->addAction(tr("Replace ROM..."), this, SLOT(replaceROM())), "replaceROM"); m_mruMenu = fileMenu->addMenu(tr("Recent"));
M src/platform/qt/Window.hsrc/platform/qt/Window.h

@@ -65,6 +65,8 @@ void toggleFullScreen();

void loadConfig(); void saveConfig(); + void replaceROM(); + void importSharkport(); void exportSharkport();