mirror of https://github.com/mgba-emu/mgba.git
Game resets when loading a patch or BIOS
This commit is contained in:
parent
422e2e2f62
commit
397ddafdd2
|
@ -119,8 +119,6 @@ void GameController::setDebugger(ARMDebugger* debugger) {
|
||||||
|
|
||||||
void GameController::loadGame(const QString& path, bool dirmode) {
|
void GameController::loadGame(const QString& path, bool dirmode) {
|
||||||
closeGame();
|
closeGame();
|
||||||
m_threadContext.sync.videoFrameWait = m_videoSync;
|
|
||||||
m_threadContext.sync.audioWait = m_audioSync;
|
|
||||||
if (!dirmode) {
|
if (!dirmode) {
|
||||||
QFile file(path);
|
QFile file(path);
|
||||||
if (!file.open(QIODevice::ReadOnly)) {
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
|
@ -128,12 +126,22 @@ void GameController::loadGame(const QString& path, bool dirmode) {
|
||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_fname = path;
|
||||||
|
m_dirmode = dirmode;
|
||||||
|
openGame();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameController::openGame() {
|
||||||
m_gameOpen = true;
|
m_gameOpen = true;
|
||||||
|
|
||||||
m_pauseAfterFrame = false;
|
m_pauseAfterFrame = false;
|
||||||
|
|
||||||
m_threadContext.fname = strdup(path.toLocal8Bit().constData());
|
m_threadContext.sync.videoFrameWait = m_videoSync;
|
||||||
if (dirmode) {
|
m_threadContext.sync.audioWait = m_audioSync;
|
||||||
|
|
||||||
|
m_threadContext.fname = m_fname.toLocal8Bit().constData();
|
||||||
|
if (m_dirmode) {
|
||||||
m_threadContext.gameDir = VDirOpen(m_threadContext.fname);
|
m_threadContext.gameDir = VDirOpen(m_threadContext.fname);
|
||||||
m_threadContext.stateDir = m_threadContext.gameDir;
|
m_threadContext.stateDir = m_threadContext.gameDir;
|
||||||
} else {
|
} else {
|
||||||
|
@ -151,15 +159,25 @@ void GameController::loadGame(const QString& path, bool dirmode) {
|
||||||
m_threadContext.patch = VFileOpen(m_patch.toLocal8Bit().constData(), O_RDONLY);
|
m_threadContext.patch = VFileOpen(m_patch.toLocal8Bit().constData(), O_RDONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
GBAThreadStart(&m_threadContext);
|
if (!GBAThreadStart(&m_threadContext)) {
|
||||||
|
m_gameOpen = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameController::loadBIOS(const QString& path) {
|
void GameController::loadBIOS(const QString& path) {
|
||||||
m_bios = path;
|
m_bios = path;
|
||||||
|
if (m_gameOpen) {
|
||||||
|
closeGame();
|
||||||
|
openGame();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameController::loadPatch(const QString& path) {
|
void GameController::loadPatch(const QString& path) {
|
||||||
m_patch = path;
|
m_patch = path;
|
||||||
|
if (m_gameOpen) {
|
||||||
|
closeGame();
|
||||||
|
openGame();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameController::closeGame() {
|
void GameController::closeGame() {
|
||||||
|
@ -168,10 +186,6 @@ void GameController::closeGame() {
|
||||||
}
|
}
|
||||||
GBAThreadEnd(&m_threadContext);
|
GBAThreadEnd(&m_threadContext);
|
||||||
GBAThreadJoin(&m_threadContext);
|
GBAThreadJoin(&m_threadContext);
|
||||||
if (m_threadContext.fname) {
|
|
||||||
free(const_cast<char*>(m_threadContext.fname));
|
|
||||||
m_threadContext.fname = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_gameOpen = false;
|
m_gameOpen = false;
|
||||||
emit gameStopped(&m_threadContext);
|
emit gameStopped(&m_threadContext);
|
||||||
|
|
|
@ -58,6 +58,7 @@ public slots:
|
||||||
void loadGame(const QString& path, bool dirmode = false);
|
void loadGame(const QString& path, bool dirmode = false);
|
||||||
void loadBIOS(const QString& path);
|
void loadBIOS(const QString& path);
|
||||||
void loadPatch(const QString& path);
|
void loadPatch(const QString& path);
|
||||||
|
void openGame();
|
||||||
void closeGame();
|
void closeGame();
|
||||||
void setPaused(bool paused);
|
void setPaused(bool paused);
|
||||||
void reset();
|
void reset();
|
||||||
|
@ -90,6 +91,9 @@ private:
|
||||||
int m_activeKeys;
|
int m_activeKeys;
|
||||||
|
|
||||||
bool m_gameOpen;
|
bool m_gameOpen;
|
||||||
|
bool m_dirmode;
|
||||||
|
|
||||||
|
QString m_fname;
|
||||||
QString m_bios;
|
QString m_bios;
|
||||||
QString m_patch;
|
QString m_patch;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue