all repos — mgba @ 29556f45a4a1753c5cab239c26b5b8c1cd4e1d78

mGBA Game Boy Advance Emulator

GBA: Add "super-minimal" core configuration, useful for cores-as-plugins, e.g. for libretro
Jeffrey Pfau jeffrey@endrift.com
Fri, 01 Jan 2016 17:54:37 -0800
commit

29556f45a4a1753c5cab239c26b5b8c1cd4e1d78

parent

3a7350c8d2d7332713630b7b4cf47f6f11a74b8e

4 files changed, 24 insertions(+), 5 deletions(-)

jump to
M CMakeLists.txtCMakeLists.txt

@@ -37,7 +37,7 @@ file(GLOB GUI_SRC ${CMAKE_SOURCE_DIR}/src/util/gui/*.c ${CMAKE_SOURCE_DIR}/src/gba/gui/*.c)

file(GLOB RENDERER_SRC ${CMAKE_SOURCE_DIR}/src/gba/renderers/*.c) file(GLOB SIO_SRC ${CMAKE_SOURCE_DIR}/src/gba/sio/lockstep.c) file(GLOB THIRD_PARTY_SRC ${CMAKE_SOURCE_DIR}/src/third-party/inih/*.c) -list(APPEND UTIL_SRC ${CMAKE_SOURCE_DIR}/src/platform/commandline.c) +list(APPEND GBA_SV_SRC ${CMAKE_SOURCE_DIR}/src/platform/commandline.c) set(CORE_VFS_SRC ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-mem.c) set(VFS_SRC) source_group("ARM core" FILES ${ARM_SRC})

@@ -553,7 +553,7 @@

if(BUILD_LIBRETRO) file(GLOB RETRO_SRC ${CMAKE_SOURCE_DIR}/src/platform/libretro/*.c) add_library(${BINARY_NAME}_libretro SHARED ${CORE_SRC} ${RETRO_SRC}) - set_target_properties(${BINARY_NAME}_libretro PROPERTIES PREFIX "" COMPILE_DEFINITIONS "COLOR_16_BIT;COLOR_5_6_5;DISABLE_THREADING;${OS_DEFINES};${FUNCTION_DEFINES}") + set_target_properties(${BINARY_NAME}_libretro PROPERTIES PREFIX "" COMPILE_DEFINITIONS "COLOR_16_BIT;COLOR_5_6_5;DISABLE_THREADING;${OS_DEFINES};${FUNCTION_DEFINES};MINIMAL_CORE=2") target_link_libraries(${BINARY_NAME}_libretro ${OS_LIB}) install(TARGETS ${BINARY_NAME}_libretro LIBRARY DESTINATION ${LIBDIR} COMPONENT ${BINARY_NAME}_libretro NAMELINK_SKIP) endif()
M src/gba/context/config.csrc/gba/context/config.c

@@ -132,6 +132,7 @@ ConfigurationDeinit(&config->overridesTable);

free(config->port); } +#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 bool GBAConfigLoad(struct GBAConfig* config) { char path[PATH_MAX]; GBAConfigDirectory(path, PATH_MAX);

@@ -231,6 +232,7 @@ snprintf(out, outLength, "%s/.config/%s", home, binaryName);

mkdir(out, 0755); #endif } +#endif const char* GBAConfigGetValue(const struct GBAConfig* config, const char* key) { return _lookupValue(config, key);
M src/gba/context/config.hsrc/gba/context/config.h

@@ -52,6 +52,7 @@

void GBAConfigInit(struct GBAConfig*, const char* port); void GBAConfigDeinit(struct GBAConfig*); +#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 bool GBAConfigLoad(struct GBAConfig*); bool GBAConfigSave(const struct GBAConfig*); bool GBAConfigLoadPath(struct GBAConfig*, const char* path);

@@ -59,6 +60,7 @@ bool GBAConfigSavePath(const struct GBAConfig*, const char* path);

void GBAConfigMakePortable(const struct GBAConfig*); void GBAConfigDirectory(char* out, size_t outLength); +#endif const char* GBAConfigGetValue(const struct GBAConfig*, const char* key); bool GBAConfigGetIntValue(const struct GBAConfig*, const char* key, int* value);
M src/gba/context/context.csrc/gba/context/context.c

@@ -38,6 +38,7 @@ ARMSetComponents(context->cpu, &context->gba->d, GBA_COMPONENT_MAX, context->components);

ARMInit(context->cpu); GBAConfigInit(&context->config, port); +#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 if (port) { if (!_logFile) { char logPath[PATH_MAX];

@@ -60,6 +61,9 @@ };

GBAConfigLoad(&context->config); GBAConfigLoadDefaults(&context->config, &opts); } +#else + UNUSED(port); +#endif context->gba->sync = 0; return true;

@@ -70,7 +74,9 @@ ARMDeinit(context->cpu);

GBADestroy(context->gba); mappedMemoryFree(context->gba, 0); mappedMemoryFree(context->cpu, 0); +#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 GBAConfigDeinit(&context->config); +#endif GBADirectorySetDeinit(&context->dirs); }

@@ -81,15 +87,18 @@ return false;

} context->fname = path; +#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 if (autoloadSave) { char dirname[PATH_MAX]; char basename[PATH_MAX]; separatePath(context->fname, dirname, basename, 0); - // TODO: Remove autoloadSave GBADirectorySetAttachBase(&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); } +#else + UNUSED(autoloadSave); +#endif return true; }

@@ -154,7 +163,9 @@ if (!GBALoadROM(context->gba, context->rom, context->save, context->fname)) {

return false; } +#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 GBAConfigMap(&context->config, &opts); +#endif if (!context->bios && opts.bios) { GBAContextLoadBIOS(context, opts.bios);

@@ -175,10 +186,14 @@

struct GBACartridgeOverride override; const struct GBACartridge* cart = (const struct GBACartridge*) context->gba->memory.rom; memcpy(override.id, &cart->id, sizeof(override.id)); - if (GBAOverrideFind(GBAConfigGetOverrides(&context->config), &override)) { + struct Configuration* overrides = 0; +#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 + overrides = GBAConfigGetOverrides(&context->config); + GBAConfigFreeOpts(&opts); +#endif + if (GBAOverrideFind(overrides, &override)) { GBAOverrideApply(context->gba, &override); } - GBAConfigFreeOpts(&opts); return true; }