Skip to content

Commit

Permalink
libretro: enable_vfs
Browse files Browse the repository at this point in the history
  • Loading branch information
warmenhoven committed Jan 15, 2025
1 parent 2fe5f04 commit c9a0608
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion libretro-build/Makefile.common
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#plain 'make' doesn't include the file that sets this. force it set anyways.
RETRODEFS ?= -D__LIBRETRO__
RETRODEFS += -DMINIMAL_CORE=2 -DM_CORE_GBA -DM_CORE_GB
RETRODEFS += -DMINIMAL_CORE=2 -DM_CORE_GBA -DM_CORE_GB -DENABLE_VFS

INCLUDES += -I$(CORE_DIR)/src -I$(CORE_DIR)/src/arm -I$(CORE_DIR)/include -I$(CORE_DIR)/src/platform/libretro
RETRODEFS += -DHAVE_STDINT_H -DHAVE_INTTYPES_H -DINLINE=inline -DCOLOR_16_BIT -DRESAMPLE_LIBRARY=2 -DM_PI=3.14159265358979323846 -DMGBA_STANDALONE
Expand Down
2 changes: 1 addition & 1 deletion src/core/cheats.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ bool mCheatSaveFile(struct mCheatDevice* device, struct VFile* vf) {
return true;
}

#ifdef ENABLE_VFS
#if defined(ENABLE_VFS) && !defined(__LIBRETRO__)
void mCheatAutosave(struct mCheatDevice* device) {
if (!device->autosave) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/core/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void mCoreConfigDeinit(struct mCoreConfig* config) {
free(config->port);
}

#ifdef ENABLE_VFS
#if defined(ENABLE_VFS) && !defined(__LIBRETRO__)
bool mCoreConfigLoad(struct mCoreConfig* config) {
char path[PATH_MAX + 1];
mCoreConfigDirectory(path, PATH_MAX);
Expand Down
8 changes: 6 additions & 2 deletions src/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ struct mCore* mCoreFind(const char* path) {
return NULL;
}

#if !defined(__LIBRETRO__)
bool mCoreLoadFile(struct mCore* core, const char* path) {
core->unloadROM(core);
#ifdef FIXED_ROM_BUFFER
Expand All @@ -153,6 +154,7 @@ bool mCorePreloadVF(struct mCore* core, struct VFile* vf) {
bool mCorePreloadFile(struct mCore* core, const char* path) {
return mCorePreloadFileCB(core, path, NULL, NULL);
}
#endif

bool mCorePreloadVFCB(struct mCore* core, struct VFile* vf, void (cb)(size_t, size_t, void*), void* context) {
struct VFile* vfm;
Expand Down Expand Up @@ -209,6 +211,7 @@ bool mCorePreloadVFCB(struct mCore* core, struct VFile* vf, void (cb)(size_t, si
return ret;
}

#if !defined(__LIBRETRO__)
bool mCorePreloadFileCB(struct mCore* core, const char* path, void (cb)(size_t, size_t, void*), void* context) {
struct VFile* rom = mDirectorySetOpenPath(&core->dirs, path, core->isROM);
if (!rom) {
Expand Down Expand Up @@ -276,6 +279,7 @@ bool mCoreAutoloadCheats(struct mCore* core) {
}
return success;
}
#endif

bool mCoreLoadSaveFile(struct mCore* core, const char* path, bool temporary) {
struct VFile* vf = VFileOpen(path, O_CREAT | O_RDWR);
Expand Down Expand Up @@ -398,15 +402,15 @@ void mCoreInitConfig(struct mCore* core, const char* port) {
}

void mCoreLoadConfig(struct mCore* core) {
#ifdef ENABLE_VFS
#if defined(ENABLE_VFS) && !defined(__LIBRETRO__)
mCoreConfigLoad(&core->config);
#endif
mCoreLoadForeignConfig(core, &core->config);
}

void mCoreLoadForeignConfig(struct mCore* core, const struct mCoreConfig* config) {
mCoreConfigMap(config, &core->opts);
#ifdef ENABLE_VFS
#if defined(ENABLE_VFS) && !defined(__LIBRETRO__)
mDirectorySetMapOptions(&core->dirs, &core->opts);
#endif
if (core->opts.audioBuffers) {
Expand Down
6 changes: 4 additions & 2 deletions src/gb/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static bool _GBCoreInit(struct mCore* core) {
gbcore->keys = 0;
gb->keySource = &gbcore->keys;

#ifdef ENABLE_VFS
#if defined(ENABLE_VFS) && !defined(__LIBRETRO__)
mDirectorySetInit(&core->dirs);
#endif

Expand All @@ -162,7 +162,7 @@ static void _GBCoreDeinit(struct mCore* core) {
GBDestroy(core->board);
mappedMemoryFree(core->cpu, sizeof(struct SM83Core));
mappedMemoryFree(core->board, sizeof(struct GB));
#ifdef ENABLE_VFS
#if defined(ENABLE_VFS) && !defined(__LIBRETRO__)
mDirectorySetDeinit(&core->dirs);
#endif
#ifdef ENABLE_DEBUGGERS
Expand Down Expand Up @@ -651,6 +651,7 @@ static void _GBCoreReset(struct mCore* core) {
bios = NULL;
}
}
#ifndef __LIBRETRO__
if (!found) {
char path[PATH_MAX];
mCoreConfigDirectory(path, PATH_MAX);
Expand Down Expand Up @@ -679,6 +680,7 @@ static void _GBCoreReset(struct mCore* core) {
bios = NULL;
}
}
#endif
if (found && bios) {
GBLoadBIOS(gb, bios);
}
Expand Down
6 changes: 4 additions & 2 deletions src/gba/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ static bool _GBACoreInit(struct mCore* core) {
gbacore->proxyRenderer.logger = NULL;
#endif

#ifdef ENABLE_VFS
#if defined(ENABLE_VFS) && !defined(__LIBRETRO__)
mDirectorySetInit(&core->dirs);
#endif

Expand All @@ -308,7 +308,7 @@ static void _GBACoreDeinit(struct mCore* core) {
GBADestroy(core->board);
mappedMemoryFree(core->cpu, sizeof(struct ARMCore));
mappedMemoryFree(core->board, sizeof(struct GBA));
#ifdef ENABLE_VFS
#if defined(ENABLE_VFS) && !defined(__LIBRETRO__)
mDirectorySetDeinit(&core->dirs);
#endif
#ifdef ENABLE_DEBUGGERS
Expand Down Expand Up @@ -782,6 +782,7 @@ static void _GBACoreReset(struct mCore* core) {
bios = NULL;
}
}
#ifndef __LIBRETRO__
if (!found) {
char path[PATH_MAX];
mCoreConfigDirectory(path, PATH_MAX);
Expand All @@ -794,6 +795,7 @@ static void _GBACoreReset(struct mCore* core) {
bios = NULL;
}
}
#endif
if (found && bios) {
GBALoadBIOS(gba, bios);
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void separatePath(const char* path, char* dirname, char* basename, char* extensi
}
}

#ifdef ENABLE_VFS
#if defined(ENABLE_VFS) && !defined(__LIBRETRO__)
bool isAbsolute(const char* path) {
// XXX: Is this robust?
#ifdef _WIN32
Expand Down

0 comments on commit c9a0608

Please sign in to comment.