mirror of https://github.com/mgba-emu/mgba.git
Core: Refactor GBADirectorySet into mDirectorySet
This commit is contained in:
parent
2716a0f64f
commit
6ec99ce4e4
|
@ -9,7 +9,7 @@
|
|||
#include "util/vfs.h"
|
||||
|
||||
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
||||
void GBADirectorySetInit(struct GBADirectorySet* dirs) {
|
||||
void mDirectorySetInit(struct mDirectorySet* dirs) {
|
||||
dirs->base = 0;
|
||||
dirs->archive = 0;
|
||||
dirs->save = 0;
|
||||
|
@ -18,8 +18,8 @@ void GBADirectorySetInit(struct GBADirectorySet* dirs) {
|
|||
dirs->screenshot = 0;
|
||||
}
|
||||
|
||||
void GBADirectorySetDeinit(struct GBADirectorySet* dirs) {
|
||||
GBADirectorySetDetachBase(dirs);
|
||||
void mDirectorySetDeinit(struct mDirectorySet* dirs) {
|
||||
mDirectorySetDetachBase(dirs);
|
||||
|
||||
if (dirs->archive) {
|
||||
dirs->archive->close(dirs->archive);
|
||||
|
@ -47,7 +47,7 @@ void GBADirectorySetDeinit(struct GBADirectorySet* dirs) {
|
|||
}
|
||||
}
|
||||
|
||||
void GBADirectorySetAttachBase(struct GBADirectorySet* dirs, struct VDir* base) {
|
||||
void mDirectorySetAttachBase(struct mDirectorySet* dirs, struct VDir* base) {
|
||||
dirs->base = base;
|
||||
if (!dirs->save) {
|
||||
dirs->save = dirs->base;
|
||||
|
@ -63,7 +63,7 @@ void GBADirectorySetAttachBase(struct GBADirectorySet* dirs, struct VDir* base)
|
|||
}
|
||||
}
|
||||
|
||||
void GBADirectorySetDetachBase(struct GBADirectorySet* dirs) {
|
||||
void mDirectorySetDetachBase(struct mDirectorySet* dirs) {
|
||||
if (dirs->save == dirs->base) {
|
||||
dirs->save = 0;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ void GBADirectorySetDetachBase(struct GBADirectorySet* dirs) {
|
|||
}
|
||||
}
|
||||
|
||||
struct VFile* GBADirectorySetOpenPath(struct GBADirectorySet* dirs, const char* path, bool (*filter)(struct VFile*)) {
|
||||
struct VFile* mDirectorySetOpenPath(struct mDirectorySet* dirs, const char* path, bool (*filter)(struct VFile*)) {
|
||||
dirs->archive = VDirOpenArchive(path);
|
||||
struct VFile* file;
|
||||
if (dirs->archive) {
|
||||
|
@ -102,7 +102,7 @@ struct VFile* GBADirectorySetOpenPath(struct GBADirectorySet* dirs, const char*
|
|||
return file;
|
||||
}
|
||||
|
||||
void GBADirectorySetMapOptions(struct GBADirectorySet* dirs, const struct GBAOptions* opts) {
|
||||
void mDirectorySetMapOptions(struct mDirectorySet* dirs, const struct GBAOptions* opts) {
|
||||
if (opts->savegamePath) {
|
||||
struct VDir* dir = VDirOpen(opts->savegamePath);
|
||||
if (dir) {
|
|
@ -11,7 +11,7 @@
|
|||
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
||||
struct VDir;
|
||||
|
||||
struct GBADirectorySet {
|
||||
struct mDirectorySet {
|
||||
struct VDir* base;
|
||||
struct VDir* archive;
|
||||
struct VDir* save;
|
||||
|
@ -20,16 +20,16 @@ struct GBADirectorySet {
|
|||
struct VDir* screenshot;
|
||||
};
|
||||
|
||||
void GBADirectorySetInit(struct GBADirectorySet* dirs);
|
||||
void GBADirectorySetDeinit(struct GBADirectorySet* dirs);
|
||||
void mDirectorySetInit(struct mDirectorySet* dirs);
|
||||
void mDirectorySetDeinit(struct mDirectorySet* dirs);
|
||||
|
||||
void GBADirectorySetAttachBase(struct GBADirectorySet* dirs, struct VDir* base);
|
||||
void GBADirectorySetDetachBase(struct GBADirectorySet* dirs);
|
||||
void mDirectorySetAttachBase(struct mDirectorySet* dirs, struct VDir* base);
|
||||
void mDirectorySetDetachBase(struct mDirectorySet* dirs);
|
||||
|
||||
struct VFile* GBADirectorySetOpenPath(struct GBADirectorySet* dirs, const char* path, bool (*filter)(struct VFile*));
|
||||
struct VFile* mDirectorySetOpenPath(struct mDirectorySet* dirs, const char* path, bool (*filter)(struct VFile*));
|
||||
|
||||
struct GBAOptions;
|
||||
void GBADirectorySetMapOptions(struct GBADirectorySet* dirs, const struct GBAOptions* opts);
|
||||
void mDirectorySetMapOptions(struct mDirectorySet* dirs, const struct GBAOptions* opts);
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -22,7 +22,7 @@ bool GBAContextInit(struct GBAContext* context, const char* port) {
|
|||
context->save = 0;
|
||||
context->renderer = 0;
|
||||
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
||||
GBADirectorySetInit(&context->dirs);
|
||||
mDirectorySetInit(&context->dirs);
|
||||
#endif
|
||||
memset(context->components, 0, sizeof(context->components));
|
||||
|
||||
|
@ -82,13 +82,13 @@ void GBAContextDeinit(struct GBAContext* context) {
|
|||
mappedMemoryFree(context->cpu, 0);
|
||||
GBAConfigDeinit(&context->config);
|
||||
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
||||
GBADirectorySetDeinit(&context->dirs);
|
||||
mDirectorySetDeinit(&context->dirs);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool GBAContextLoadROM(struct GBAContext* context, const char* path, bool autoloadSave) {
|
||||
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
||||
context->rom = GBADirectorySetOpenPath(&context->dirs, path, GBAIsROM);
|
||||
context->rom = mDirectorySetOpenPath(&context->dirs, path, GBAIsROM);
|
||||
#else
|
||||
context->rom = VFileOpen(path, O_RDONLY);
|
||||
#endif
|
||||
|
@ -102,7 +102,7 @@ bool GBAContextLoadROM(struct GBAContext* context, const char* path, bool autolo
|
|||
char dirname[PATH_MAX];
|
||||
char basename[PATH_MAX];
|
||||
separatePath(context->fname, dirname, basename, 0);
|
||||
GBADirectorySetAttachBase(&context->dirs, VDirOpen(dirname));
|
||||
mDirectorySetAttachBase(&context->dirs, VDirOpen(dirname));
|
||||
strncat(basename, ".sav", PATH_MAX - strlen(basename) - 1);
|
||||
context->save = context->dirs.save->openFile(context->dirs.save, basename, O_RDWR | O_CREAT);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ bool GBAContextLoadROM(struct GBAContext* context, const char* path, bool autolo
|
|||
void GBAContextUnloadROM(struct GBAContext* context) {
|
||||
GBAUnloadROM(context->gba);
|
||||
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
||||
GBADirectorySetDetachBase(&context->dirs);
|
||||
mDirectorySetDetachBase(&context->dirs);
|
||||
#endif
|
||||
if (context->rom) {
|
||||
context->rom->close(context->rom);
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#include "util/common.h"
|
||||
|
||||
#include "core/directories.h"
|
||||
#include "gba/context/config.h"
|
||||
#include "gba/context/directories.h"
|
||||
#include "gba/context/sync.h"
|
||||
#include "gba/input.h"
|
||||
|
||||
|
@ -22,7 +22,7 @@ struct GBAContext {
|
|||
struct VFile* save;
|
||||
struct VFile* bios;
|
||||
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
||||
struct GBADirectorySet dirs;
|
||||
struct mDirectorySet dirs;
|
||||
#endif
|
||||
struct ARMComponent* components[GBA_COMPONENT_MAX];
|
||||
struct GBAConfig config;
|
||||
|
|
|
@ -27,13 +27,13 @@ static const float _defaultFPSTarget = 60.f;
|
|||
#ifndef DISABLE_THREADING
|
||||
|
||||
static bool _reloadDirectories(struct GBAThread* threadContext) {
|
||||
GBADirectorySetDetachBase(&threadContext->dirs);
|
||||
mDirectorySetDetachBase(&threadContext->dirs);
|
||||
|
||||
char basename[PATH_MAX];
|
||||
if (threadContext->fname) {
|
||||
char dirname[PATH_MAX];
|
||||
separatePath(threadContext->fname, dirname, basename, 0);
|
||||
GBADirectorySetAttachBase(&threadContext->dirs, VDirOpen(dirname));
|
||||
mDirectorySetAttachBase(&threadContext->dirs, VDirOpen(dirname));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ void GBAMapOptionsToContext(const struct GBAOptions* opts, struct GBAThread* thr
|
|||
|
||||
threadContext->idleOptimization = opts->idleOptimization;
|
||||
|
||||
GBADirectorySetMapOptions(&threadContext->dirs, opts);
|
||||
mDirectorySetMapOptions(&threadContext->dirs, opts);
|
||||
}
|
||||
|
||||
void GBAMapArgumentsToContext(const struct GBAArguments* args, struct GBAThread* threadContext) {
|
||||
|
@ -685,7 +685,7 @@ void GBAThreadPauseFromThread(struct GBAThread* threadContext) {
|
|||
}
|
||||
|
||||
void GBAThreadLoadROM(struct GBAThread* threadContext, const char* fname) {
|
||||
threadContext->rom = GBADirectorySetOpenPath(&threadContext->dirs, fname, GBAIsROM);
|
||||
threadContext->rom = mDirectorySetOpenPath(&threadContext->dirs, fname, GBAIsROM);
|
||||
}
|
||||
|
||||
void GBAThreadReplaceROM(struct GBAThread* threadContext, const char* fname) {
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
#include "util/common.h"
|
||||
|
||||
#include "core/directories.h"
|
||||
#include "gba/gba.h"
|
||||
#include "gba/input.h"
|
||||
#include "gba/context/directories.h"
|
||||
#include "gba/context/overrides.h"
|
||||
#include "gba/context/sync.h"
|
||||
|
||||
|
@ -49,7 +49,7 @@ struct GBAThread {
|
|||
struct GBASIODriverSet sioDrivers;
|
||||
struct ARMDebugger* debugger;
|
||||
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
||||
struct GBADirectorySet dirs;
|
||||
struct mDirectorySet dirs;
|
||||
#endif
|
||||
struct VFile* rom;
|
||||
struct VFile* save;
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
#include <ctime>
|
||||
|
||||
extern "C" {
|
||||
#include "core/directories.h"
|
||||
#include "gba/audio.h"
|
||||
#include "gba/context/config.h"
|
||||
#include "gba/context/directories.h"
|
||||
#include "gba/gba.h"
|
||||
#include "gba/serialize.h"
|
||||
#include "gba/sharkport.h"
|
||||
|
@ -78,7 +78,7 @@ GameController::GameController(QObject* parent)
|
|||
m_threadContext.rewindBufferCapacity = 0;
|
||||
m_threadContext.cheats = &m_cheatDevice;
|
||||
m_threadContext.logLevel = GBA_LOG_ALL;
|
||||
GBADirectorySetInit(&m_threadContext.dirs);
|
||||
mDirectorySetInit(&m_threadContext.dirs);
|
||||
|
||||
m_lux.p = this;
|
||||
m_lux.sample = [](GBALuminanceSource* context) {
|
||||
|
@ -216,7 +216,7 @@ GameController::~GameController() {
|
|||
clearMultiplayerController();
|
||||
closeGame();
|
||||
GBACheatDeviceDestroy(&m_cheatDevice);
|
||||
GBADirectorySetDeinit(&m_threadContext.dirs);
|
||||
mDirectorySetDeinit(&m_threadContext.dirs);
|
||||
delete m_renderer;
|
||||
delete[] m_drawContext;
|
||||
delete[] m_frontBuffer;
|
||||
|
@ -256,7 +256,7 @@ void GameController::setOptions(const GBAOptions* opts) {
|
|||
setMute(opts->mute);
|
||||
|
||||
threadInterrupt();
|
||||
GBADirectorySetMapOptions(&m_threadContext.dirs, opts);
|
||||
mDirectorySetMapOptions(&m_threadContext.dirs, opts);
|
||||
m_threadContext.idleOptimization = opts->idleOptimization;
|
||||
threadContinue();
|
||||
}
|
||||
|
|
|
@ -267,7 +267,7 @@ int mSDLRunGBA(struct mSDLRenderer* renderer, struct GBAArguments* args, struct
|
|||
}
|
||||
}
|
||||
free(context.debugger);
|
||||
GBADirectorySetDeinit(&context.dirs);
|
||||
mDirectorySetDeinit(&context.dirs);
|
||||
|
||||
return didFail;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue