all repos — mgba @ 811d8281c3f285e9e7421cf290ecefaefb46069d

mGBA Game Boy Advance Emulator

Core: Refactor GBAConfig into mCoreConfig
Jeffrey Pfau jeffrey@endrift.com
Fri, 29 Jan 2016 00:33:56 -0800
commit

811d8281c3f285e9e7421cf290ecefaefb46069d

parent

234ecd961976d7e24609beda22c9db9fafa6901b

A src/core/config.h

@@ -0,0 +1,98 @@

+/* Copyright (c) 2013-2016 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef M_CORE_CONFIG_H +#define M_CORE_CONFIG_H + +#include "util/common.h" + +#include "gba/gba.h" + +#include "util/configuration.h" + +struct mCoreConfig { + struct Configuration configTable; + struct Configuration defaultsTable; + struct Configuration overridesTable; + char* port; +}; + +struct GBAOptions { + char* bios; + bool skipBios; + bool useBios; + int logLevel; + int frameskip; + bool rewindEnable; + int rewindBufferCapacity; + int rewindBufferInterval; + float fpsTarget; + size_t audioBuffers; + unsigned sampleRate; + + int fullscreen; + int width; + int height; + bool lockAspectRatio; + bool resampleVideo; + bool suspendScreensaver; + char* shader; + + char* savegamePath; + char* savestatePath; + char* screenshotPath; + char* patchPath; + + int volume; + bool mute; + + bool videoSync; + bool audioSync; + + enum GBAIdleLoopOptimization idleOptimization; +}; + +void mCoreConfigInit(struct mCoreConfig*, const char* port); +void mCoreConfigDeinit(struct mCoreConfig*); + +#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 +bool mCoreConfigLoad(struct mCoreConfig*); +bool mCoreConfigSave(const struct mCoreConfig*); +bool mCoreConfigLoadPath(struct mCoreConfig*, const char* path); +bool mCoreConfigSavePath(const struct mCoreConfig*, const char* path); + +void mCoreConfigMakePortable(const struct mCoreConfig*); +void mCoreConfigDirectory(char* out, size_t outLength); +#endif + +const char* mCoreConfigGetValue(const struct mCoreConfig*, const char* key); +bool mCoreConfigGetIntValue(const struct mCoreConfig*, const char* key, int* value); +bool mCoreConfigGetUIntValue(const struct mCoreConfig*, const char* key, unsigned* value); +bool mCoreConfigGetFloatValue(const struct mCoreConfig*, const char* key, float* value); + +void mCoreConfigSetValue(struct mCoreConfig*, const char* key, const char* value); +void mCoreConfigSetIntValue(struct mCoreConfig*, const char* key, int value); +void mCoreConfigSetUIntValue(struct mCoreConfig*, const char* key, unsigned value); +void mCoreConfigSetFloatValue(struct mCoreConfig*, const char* key, float value); + +void mCoreConfigSetDefaultValue(struct mCoreConfig*, const char* key, const char* value); +void mCoreConfigSetDefaultIntValue(struct mCoreConfig*, const char* key, int value); +void mCoreConfigSetDefaultUIntValue(struct mCoreConfig*, const char* key, unsigned value); +void mCoreConfigSetDefaultFloatValue(struct mCoreConfig*, const char* key, float value); + +void mCoreConfigSetOverrideValue(struct mCoreConfig*, const char* key, const char* value); +void mCoreConfigSetOverrideIntValue(struct mCoreConfig*, const char* key, int value); +void mCoreConfigSetOverrideUIntValue(struct mCoreConfig*, const char* key, unsigned value); +void mCoreConfigSetOverrideFloatValue(struct mCoreConfig*, const char* key, float value); + +void mCoreConfigMap(const struct mCoreConfig* config, struct GBAOptions* opts); +void mCoreConfigLoadDefaults(struct mCoreConfig* config, const struct GBAOptions* opts); + +struct Configuration* mCoreConfigGetInput(struct mCoreConfig*); +struct Configuration* mCoreConfigGetOverrides(struct mCoreConfig*); + +void mCoreConfigFreeOpts(struct GBAOptions* opts); + +#endif
M src/core/directories.csrc/core/directories.c

@@ -5,7 +5,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this

* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "directories.h" -#include "gba/context/config.h" +#include "core/config.h" #include "util/vfs.h" #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
M src/gba/context/config.csrc/core/config.c

@@ -1,4 +1,4 @@

-/* Copyright (c) 2013-2015 Jeffrey Pfau +/* Copyright (c) 2013-2016 Jeffrey Pfau * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this

@@ -28,7 +28,7 @@ #endif

#define SECTION_NAME_MAX 128 -static const char* _lookupValue(const struct GBAConfig* config, const char* key) { +static const char* _lookupValue(const struct mCoreConfig* config, const char* key) { const char* value; if (config->port) { value = ConfigurationGetValue(&config->overridesTable, config->port, key);

@@ -59,7 +59,7 @@ }

return ConfigurationGetValue(&config->defaultsTable, 0, key); } -static bool _lookupCharValue(const struct GBAConfig* config, const char* key, char** out) { +static bool _lookupCharValue(const struct mCoreConfig* config, const char* key, char** out) { const char* value = _lookupValue(config, key); if (!value) { return false;

@@ -71,7 +71,7 @@ *out = strdup(value);

return true; } -static bool _lookupIntValue(const struct GBAConfig* config, const char* key, int* out) { +static bool _lookupIntValue(const struct mCoreConfig* config, const char* key, int* out) { const char* charValue = _lookupValue(config, key); if (!charValue) { return false;

@@ -85,7 +85,7 @@ *out = value;

return true; } -static bool _lookupUIntValue(const struct GBAConfig* config, const char* key, unsigned* out) { +static bool _lookupUIntValue(const struct mCoreConfig* config, const char* key, unsigned* out) { const char* charValue = _lookupValue(config, key); if (!charValue) { return false;

@@ -99,7 +99,7 @@ *out = value;

return true; } -static bool _lookupFloatValue(const struct GBAConfig* config, const char* key, float* out) { +static bool _lookupFloatValue(const struct mCoreConfig* config, const char* key, float* out) { const char* charValue = _lookupValue(config, key); if (!charValue) { return false;

@@ -113,7 +113,7 @@ *out = value;

return true; } -void GBAConfigInit(struct GBAConfig* config, const char* port) { +void mCoreConfigInit(struct mCoreConfig* config, const char* port) { ConfigurationInit(&config->configTable); ConfigurationInit(&config->defaultsTable); ConfigurationInit(&config->overridesTable);

@@ -125,7 +125,7 @@ config->port = 0;

} } -void GBAConfigDeinit(struct GBAConfig* config) { +void mCoreConfigDeinit(struct mCoreConfig* config) { ConfigurationDeinit(&config->configTable); ConfigurationDeinit(&config->defaultsTable); ConfigurationDeinit(&config->overridesTable);

@@ -133,29 +133,29 @@ free(config->port);

} #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 -bool GBAConfigLoad(struct GBAConfig* config) { +bool mCoreConfigLoad(struct mCoreConfig* config) { char path[PATH_MAX]; - GBAConfigDirectory(path, PATH_MAX); + mCoreConfigDirectory(path, PATH_MAX); strncat(path, PATH_SEP "config.ini", PATH_MAX - strlen(path)); - return GBAConfigLoadPath(config, path); + return mCoreConfigLoadPath(config, path); } -bool GBAConfigSave(const struct GBAConfig* config) { +bool mCoreConfigSave(const struct mCoreConfig* config) { char path[PATH_MAX]; - GBAConfigDirectory(path, PATH_MAX); + mCoreConfigDirectory(path, PATH_MAX); strncat(path, PATH_SEP "config.ini", PATH_MAX - strlen(path)); - return GBAConfigSavePath(config, path); + return mCoreConfigSavePath(config, path); } -bool GBAConfigLoadPath(struct GBAConfig* config, const char* path) { +bool mCoreConfigLoadPath(struct mCoreConfig* config, const char* path) { return ConfigurationRead(&config->configTable, path); } -bool GBAConfigSavePath(const struct GBAConfig* config, const char* path) { +bool mCoreConfigSavePath(const struct mCoreConfig* config, const char* path) { return ConfigurationWrite(&config->configTable, path); } -void GBAConfigMakePortable(const struct GBAConfig* config) { +void mCoreConfigMakePortable(const struct mCoreConfig* config) { struct VFile* portable = 0; #ifdef _WIN32 char out[MAX_PATH];

@@ -178,11 +178,11 @@ portable = VFileOpen(out, O_WRONLY | O_CREAT);

#endif if (portable) { portable->close(portable); - GBAConfigSave(config); + mCoreConfigSave(config); } } -void GBAConfigDirectory(char* out, size_t outLength) { +void mCoreConfigDirectory(char* out, size_t outLength) { struct VFile* portable; #ifdef _WIN32 wchar_t wpath[MAX_PATH];

@@ -235,71 +235,71 @@ #endif

} #endif -const char* GBAConfigGetValue(const struct GBAConfig* config, const char* key) { +const char* mCoreConfigGetValue(const struct mCoreConfig* config, const char* key) { return _lookupValue(config, key); } -bool GBAConfigGetIntValue(const struct GBAConfig* config, const char* key, int* value) { +bool mCoreConfigGetIntValue(const struct mCoreConfig* config, const char* key, int* value) { return _lookupIntValue(config, key, value); } -bool GBAConfigGetUIntValue(const struct GBAConfig* config, const char* key, unsigned* value) { +bool mCoreConfigGetUIntValue(const struct mCoreConfig* config, const char* key, unsigned* value) { return _lookupUIntValue(config, key, value); } -bool GBAConfigGetFloatValue(const struct GBAConfig* config, const char* key, float* value) { +bool mCoreConfigGetFloatValue(const struct mCoreConfig* config, const char* key, float* value) { return _lookupFloatValue(config, key, value); } -void GBAConfigSetValue(struct GBAConfig* config, const char* key, const char* value) { +void mCoreConfigSetValue(struct mCoreConfig* config, const char* key, const char* value) { ConfigurationSetValue(&config->configTable, config->port, key, value); } -void GBAConfigSetIntValue(struct GBAConfig* config, const char* key, int value) { +void mCoreConfigSetIntValue(struct mCoreConfig* config, const char* key, int value) { ConfigurationSetIntValue(&config->configTable, config->port, key, value); } -void GBAConfigSetUIntValue(struct GBAConfig* config, const char* key, unsigned value) { +void mCoreConfigSetUIntValue(struct mCoreConfig* config, const char* key, unsigned value) { ConfigurationSetUIntValue(&config->configTable, config->port, key, value); } -void GBAConfigSetFloatValue(struct GBAConfig* config, const char* key, float value) { +void mCoreConfigSetFloatValue(struct mCoreConfig* config, const char* key, float value) { ConfigurationSetFloatValue(&config->configTable, config->port, key, value); } -void GBAConfigSetDefaultValue(struct GBAConfig* config, const char* key, const char* value) { +void mCoreConfigSetDefaultValue(struct mCoreConfig* config, const char* key, const char* value) { ConfigurationSetValue(&config->defaultsTable, config->port, key, value); } -void GBAConfigSetDefaultIntValue(struct GBAConfig* config, const char* key, int value) { +void mCoreConfigSetDefaultIntValue(struct mCoreConfig* config, const char* key, int value) { ConfigurationSetIntValue(&config->defaultsTable, config->port, key, value); } -void GBAConfigSetDefaultUIntValue(struct GBAConfig* config, const char* key, unsigned value) { +void mCoreConfigSetDefaultUIntValue(struct mCoreConfig* config, const char* key, unsigned value) { ConfigurationSetUIntValue(&config->defaultsTable, config->port, key, value); } -void GBAConfigSetDefaultFloatValue(struct GBAConfig* config, const char* key, float value) { +void mCoreConfigSetDefaultFloatValue(struct mCoreConfig* config, const char* key, float value) { ConfigurationSetFloatValue(&config->defaultsTable, config->port, key, value); } -void GBAConfigSetOverrideValue(struct GBAConfig* config, const char* key, const char* value) { +void mCoreConfigSetOverrideValue(struct mCoreConfig* config, const char* key, const char* value) { ConfigurationSetValue(&config->overridesTable, config->port, key, value); } -void GBAConfigSetOverrideIntValue(struct GBAConfig* config, const char* key, int value) { +void mCoreConfigSetOverrideIntValue(struct mCoreConfig* config, const char* key, int value) { ConfigurationSetIntValue(&config->overridesTable, config->port, key, value); } -void GBAConfigSetOverrideUIntValue(struct GBAConfig* config, const char* key, unsigned value) { +void mCoreConfigSetOverrideUIntValue(struct mCoreConfig* config, const char* key, unsigned value) { ConfigurationSetUIntValue(&config->overridesTable, config->port, key, value); } -void GBAConfigSetOverrideFloatValue(struct GBAConfig* config, const char* key, float value) { +void mCoreConfigSetOverrideFloatValue(struct mCoreConfig* config, const char* key, float value) { ConfigurationSetFloatValue(&config->overridesTable, config->port, key, value); } -void GBAConfigMap(const struct GBAConfig* config, struct GBAOptions* opts) { +void mCoreConfigMap(const struct mCoreConfig* config, struct GBAOptions* opts) { _lookupCharValue(config, "bios", &opts->bios); _lookupCharValue(config, "shader", &opts->shader); _lookupIntValue(config, "logLevel", &opts->logLevel);

@@ -365,7 +365,7 @@ free(idleOptimization);

} } -void GBAConfigLoadDefaults(struct GBAConfig* config, const struct GBAOptions* opts) { +void mCoreConfigLoadDefaults(struct mCoreConfig* config, const struct GBAOptions* opts) { ConfigurationSetValue(&config->defaultsTable, 0, "bios", opts->bios); ConfigurationSetValue(&config->defaultsTable, 0, "shader", opts->shader); ConfigurationSetIntValue(&config->defaultsTable, 0, "skipBios", opts->skipBios);

@@ -403,15 +403,15 @@ }

} // These two are basically placeholders in case the internal layout changes, e.g. for loading separate files -struct Configuration* GBAConfigGetInput(struct GBAConfig* config) { +struct Configuration* mCoreConfigGetInput(struct mCoreConfig* config) { return &config->configTable; } -struct Configuration* GBAConfigGetOverrides(struct GBAConfig* config) { +struct Configuration* mCoreConfigGetOverrides(struct mCoreConfig* config) { return &config->configTable; } -void GBAConfigFreeOpts(struct GBAOptions* opts) { +void mCoreConfigFreeOpts(struct GBAOptions* opts) { free(opts->bios); free(opts->shader); free(opts->savegamePath);
D src/gba/context/config.h

@@ -1,98 +0,0 @@

-/* Copyright (c) 2013-2015 Jeffrey Pfau - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef GBA_CONFIG_H -#define GBA_CONFIG_H - -#include "util/common.h" - -#include "gba/gba.h" - -#include "util/configuration.h" - -struct GBAConfig { - struct Configuration configTable; - struct Configuration defaultsTable; - struct Configuration overridesTable; - char* port; -}; - -struct GBAOptions { - char* bios; - bool skipBios; - bool useBios; - int logLevel; - int frameskip; - bool rewindEnable; - int rewindBufferCapacity; - int rewindBufferInterval; - float fpsTarget; - size_t audioBuffers; - unsigned sampleRate; - - int fullscreen; - int width; - int height; - bool lockAspectRatio; - bool resampleVideo; - bool suspendScreensaver; - char* shader; - - char* savegamePath; - char* savestatePath; - char* screenshotPath; - char* patchPath; - - int volume; - bool mute; - - bool videoSync; - bool audioSync; - - enum GBAIdleLoopOptimization idleOptimization; -}; - -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); -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); -bool GBAConfigGetUIntValue(const struct GBAConfig*, const char* key, unsigned* value); -bool GBAConfigGetFloatValue(const struct GBAConfig*, const char* key, float* value); - -void GBAConfigSetValue(struct GBAConfig*, const char* key, const char* value); -void GBAConfigSetIntValue(struct GBAConfig*, const char* key, int value); -void GBAConfigSetUIntValue(struct GBAConfig*, const char* key, unsigned value); -void GBAConfigSetFloatValue(struct GBAConfig*, const char* key, float value); - -void GBAConfigSetDefaultValue(struct GBAConfig*, const char* key, const char* value); -void GBAConfigSetDefaultIntValue(struct GBAConfig*, const char* key, int value); -void GBAConfigSetDefaultUIntValue(struct GBAConfig*, const char* key, unsigned value); -void GBAConfigSetDefaultFloatValue(struct GBAConfig*, const char* key, float value); - -void GBAConfigSetOverrideValue(struct GBAConfig*, const char* key, const char* value); -void GBAConfigSetOverrideIntValue(struct GBAConfig*, const char* key, int value); -void GBAConfigSetOverrideUIntValue(struct GBAConfig*, const char* key, unsigned value); -void GBAConfigSetOverrideFloatValue(struct GBAConfig*, const char* key, float value); - -void GBAConfigMap(const struct GBAConfig* config, struct GBAOptions* opts); -void GBAConfigLoadDefaults(struct GBAConfig* config, const struct GBAOptions* opts); - -struct Configuration* GBAConfigGetInput(struct GBAConfig*); -struct Configuration* GBAConfigGetOverrides(struct GBAConfig*); - -void GBAConfigFreeOpts(struct GBAOptions* opts); - -#endif
M src/gba/context/context.csrc/gba/context/context.c

@@ -39,19 +39,19 @@ GBACreate(context->gba);

ARMSetComponents(context->cpu, &context->gba->d, GBA_COMPONENT_MAX, context->components); ARMInit(context->cpu); - GBAConfigInit(&context->config, port); + mCoreConfigInit(&context->config, port); #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 if (port) { if (!_logFile) { char logPath[PATH_MAX]; - GBAConfigDirectory(logPath, PATH_MAX); + mCoreConfigDirectory(logPath, PATH_MAX); strncat(logPath, PATH_SEP "log", PATH_MAX - strlen(logPath)); _logFile = VFileOpen(logPath, O_WRONLY | O_CREAT | O_TRUNC); } context->gba->logHandler = _GBAContextLog; char biosPath[PATH_MAX]; - GBAConfigDirectory(biosPath, PATH_MAX); + mCoreConfigDirectory(biosPath, PATH_MAX); strncat(biosPath, PATH_SEP "gba_bios.bin", PATH_MAX - strlen(biosPath)); struct GBAOptions opts = {

@@ -60,8 +60,8 @@ .useBios = true,

.idleOptimization = IDLE_LOOP_DETECT, .logLevel = GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL | GBA_LOG_STATUS }; - GBAConfigLoad(&context->config); - GBAConfigLoadDefaults(&context->config, &opts); + mCoreConfigLoad(&context->config); + mCoreConfigLoadDefaults(&context->config, &opts); } #else UNUSED(port);

@@ -80,7 +80,7 @@ context->bios = 0;

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

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

return false; } - GBAConfigMap(&context->config, &opts); + mCoreConfigMap(&context->config, &opts); if (!context->bios && opts.bios) { GBAContextLoadBIOS(context, opts.bios);

@@ -194,8 +194,8 @@ const struct GBACartridge* cart = (const struct GBACartridge*) context->gba->memory.rom;

memcpy(override.id, &cart->id, sizeof(override.id)); struct Configuration* overrides = 0; #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 - overrides = GBAConfigGetOverrides(&context->config); - GBAConfigFreeOpts(&opts); + overrides = mCoreConfigGetOverrides(&context->config); + mCoreConfigFreeOpts(&opts); #endif if (GBAOverrideFind(overrides, &override)) { GBAOverrideApply(context->gba, &override);
M src/gba/context/context.hsrc/gba/context/context.h

@@ -9,8 +9,8 @@

#include "util/common.h" #include "core/directories.h" +#include "core/config.h" #include "core/sync.h" -#include "gba/context/config.h" #include "gba/input.h" struct GBAContext {

@@ -25,7 +25,7 @@ #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2

struct mDirectorySet dirs; #endif struct ARMComponent* components[GBA_COMPONENT_MAX]; - struct GBAConfig config; + struct mCoreConfig config; struct GBAOptions opts; struct GBAInputMap inputMap; };
M src/gba/gui/gui-config.csrc/gba/gui/gui-config.c

@@ -93,7 +93,7 @@ item = GUIMenuItemListGetPointer(&menu.items, i);

if (!item->validStates || !item->data) { continue; } - GBAConfigGetUIntValue(&runner->context.config, item->data, &item->state); + mCoreConfigGetUIntValue(&runner->context.config, item->data, &item->state); } while (true) {

@@ -103,16 +103,16 @@ break;

} if (!strcmp(item->data, "*SAVE")) { if (biosPath[0]) { - GBAConfigSetValue(&runner->context.config, "bios", biosPath); + mCoreConfigSetValue(&runner->context.config, "bios", biosPath); } for (i = 0; i < GUIMenuItemListSize(&menu.items); ++i) { item = GUIMenuItemListGetPointer(&menu.items, i); if (!item->validStates || !item->data) { continue; } - GBAConfigSetUIntValue(&runner->context.config, item->data, item->state); + mCoreConfigSetUIntValue(&runner->context.config, item->data, item->state); } - GBAConfigSave(&runner->context.config); + mCoreConfigSave(&runner->context.config); break; } if (!strcmp(item->data, "*REMAP")) {
M src/gba/gui/gui-runner.csrc/gba/gui/gui-runner.c

@@ -124,7 +124,7 @@

if (runner->context.config.port && runner->keySources) { size_t i; for (i = 0; runner->keySources[i].id; ++i) { - GBAInputMapLoad(&runner->context.inputMap, runner->keySources[i].id, GBAConfigGetInput(&runner->context.config)); + GBAInputMapLoad(&runner->context.inputMap, runner->keySources[i].id, mCoreConfigGetInput(&runner->context.config)); } } }

@@ -137,10 +137,10 @@ if (runner->context.config.port) {

if (runner->keySources) { size_t i; for (i = 0; runner->keySources[i].id; ++i) { - GBAInputMapSave(&runner->context.inputMap, runner->keySources[i].id, GBAConfigGetInput(&runner->context.config)); + GBAInputMapSave(&runner->context.inputMap, runner->keySources[i].id, mCoreConfigGetInput(&runner->context.config)); } } - GBAConfigSave(&runner->context.config); + mCoreConfigSave(&runner->context.config); } CircleBufferDeinit(&runner->fpsBuffer); GBAContextDeinit(&runner->context);

@@ -272,7 +272,7 @@ }

GBAContextFrame(&runner->context, keys); if (runner->drawFrame) { int drawFps = false; - GBAConfigGetIntValue(&runner->context.config, "fpsCounter", &drawFps); + mCoreConfigGetIntValue(&runner->context.config, "fpsCounter", &drawFps); runner->params.drawStart(); runner->drawFrame(runner, false);

@@ -347,7 +347,7 @@ GBATakeScreenshot(runner->context.gba, runner->context.dirs.screenshot);

break; case RUNNER_CONFIG: GBAGUIShowConfig(runner, runner->configExtra, runner->nConfigExtra); - GBAConfigGetIntValue(&runner->context.config, "frameskip", &runner->context.gba->video.frameskip); + mCoreConfigGetIntValue(&runner->context.config, "frameskip", &runner->context.gba->video.frameskip); break; case RUNNER_CONTINUE: break;
M src/gba/supervisor/thread.csrc/gba/supervisor/thread.c

@@ -6,10 +6,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "thread.h" #include "arm.h" +#include "core/config.h" #include "gba/gba.h" #include "gba/cheats.h" #include "gba/serialize.h" -#include "gba/context/config.h" #include "gba/rr/mgm.h" #include "gba/rr/vbm.h"
M src/platform/3ds/main.csrc/platform/3ds/main.c

@@ -271,7 +271,7 @@ renderer.outputBufferStride = 256;

runner->context.renderer = &renderer.d; unsigned mode; - if (GBAConfigGetUIntValue(&runner->context.config, "screenMode", &mode) && mode < SM_MAX) { + if (mCoreConfigGetUIntValue(&runner->context.config, "screenMode", &mode) && mode < SM_MAX) { screenMode = mode; }

@@ -304,7 +304,7 @@ } else if (hasSound == DSP_SUPPORTED) {

memset(audioLeft, 0, AUDIO_SAMPLE_BUFFER * 2 * sizeof(int16_t)); } unsigned mode; - if (GBAConfigGetUIntValue(&runner->context.config, "screenMode", &mode) && mode != screenMode) { + if (mCoreConfigGetUIntValue(&runner->context.config, "screenMode", &mode) && mode != screenMode) { screenMode = mode; screenCleanup |= SCREEN_CLEANUP_BOTTOM | SCREEN_CLEANUP_TOP; }

@@ -437,7 +437,7 @@ static void _incrementScreenMode(struct GBAGUIRunner* runner) {

UNUSED(runner); screenCleanup |= SCREEN_CLEANUP_TOP | SCREEN_CLEANUP_BOTTOM; screenMode = (screenMode + 1) % SM_MAX; - GBAConfigSetUIntValue(&runner->context.config, "screenMode", screenMode); + mCoreConfigSetUIntValue(&runner->context.config, "screenMode", screenMode); } static uint32_t _pollInput(void) {
M src/platform/commandline.csrc/platform/commandline.c

@@ -50,9 +50,9 @@ { "version", no_argument, 0, '\0' },

{ 0, 0, 0, 0 } }; -static bool _parseGraphicsArg(struct SubParser* parser, struct GBAConfig* config, int option, const char* arg); +static bool _parseGraphicsArg(struct SubParser* parser, struct mCoreConfig* config, int option, const char* arg); -bool parseArguments(struct GBAArguments* opts, struct GBAConfig* config, int argc, char* const* argv, struct SubParser* subparser) { +bool parseArguments(struct GBAArguments* opts, struct mCoreConfig* config, int argc, char* const* argv, struct SubParser* subparser) { int ch; char options[64] = "b:c:hl:p:s:v:"

@@ -80,7 +80,7 @@ return false;

} break; case 'b': - GBAConfigSetOverrideValue(config, "bios", optarg); + mCoreConfigSetOverrideValue(config, "bios", optarg); break; case 'c': opts->cheatsFile = strdup(optarg);

@@ -105,13 +105,13 @@ case 'h':

opts->showHelp = true; break; case 'l': - GBAConfigSetOverrideValue(config, "logLevel", optarg); + mCoreConfigSetOverrideValue(config, "logLevel", optarg); break; case 'p': opts->patch = strdup(optarg); break; case 's': - GBAConfigSetOverrideValue(config, "frameskip", optarg); + mCoreConfigSetOverrideValue(config, "frameskip", optarg); break; case 'v': opts->movie = strdup(optarg);

@@ -154,13 +154,13 @@ opts->multiplier = 0;

opts->fullscreen = false; } -bool _parseGraphicsArg(struct SubParser* parser, struct GBAConfig* config, int option, const char* arg) { +bool _parseGraphicsArg(struct SubParser* parser, struct mCoreConfig* config, int option, const char* arg) { UNUSED(arg); struct GraphicsOpts* graphicsOpts = parser->opts; switch (option) { case 'f': graphicsOpts->fullscreen = true; - GBAConfigSetOverrideIntValue(config, "fullscreen", 1); + mCoreConfigSetOverrideIntValue(config, "fullscreen", 1); return true; case '1': case '2':

@@ -172,8 +172,8 @@ if (graphicsOpts->multiplier) {

return false; } graphicsOpts->multiplier = option - '0'; - GBAConfigSetOverrideIntValue(config, "width", VIDEO_HORIZONTAL_PIXELS * graphicsOpts->multiplier); - GBAConfigSetOverrideIntValue(config, "height", VIDEO_VERTICAL_PIXELS * graphicsOpts->multiplier); + mCoreConfigSetOverrideIntValue(config, "width", VIDEO_HORIZONTAL_PIXELS * graphicsOpts->multiplier); + mCoreConfigSetOverrideIntValue(config, "height", VIDEO_VERTICAL_PIXELS * graphicsOpts->multiplier); return true; default: return false;
M src/platform/commandline.hsrc/platform/commandline.h

@@ -8,7 +8,7 @@ #define COMMAND_LINE_H

#include "util/common.h" -#include "gba/context/config.h" +#include "core/config.h" enum DebuggerType { DEBUGGER_NONE = 0,

@@ -35,7 +35,7 @@ };

struct SubParser { const char* usage; - bool (*parse)(struct SubParser* parser, struct GBAConfig* config, int option, const char* arg); + bool (*parse)(struct SubParser* parser, struct mCoreConfig* config, int option, const char* arg); const char* extraOptions; void* opts; };

@@ -47,7 +47,7 @@ };

struct GBAThread; -bool parseArguments(struct GBAArguments* opts, struct GBAConfig* config, int argc, char* const* argv, +bool parseArguments(struct GBAArguments* opts, struct mCoreConfig* config, int argc, char* const* argv, struct SubParser* subparser); void freeArguments(struct GBAArguments* opts);
M src/platform/libretro/libretro.csrc/platform/libretro/libretro.c

@@ -79,7 +79,7 @@ opts.idleOptimization = IDLE_LOOP_DETECT;

} } - GBAConfigLoadDefaults(&context.config, &opts); + mCoreConfigLoadDefaults(&context.config, &opts); } unsigned retro_api_version(void) {
M src/platform/openemu/mGBAGameCore.msrc/platform/openemu/mGBAGameCore.m

@@ -63,7 +63,7 @@ struct GBAOptions opts = {

.useBios = true, .idleOptimization = IDLE_LOOP_REMOVE }; - GBAConfigLoadDefaults(&context.config, &opts); + mCoreConfigLoadDefaults(&context.config, &opts); GBAVideoSoftwareRendererCreate(&renderer); renderer.outputBuffer = malloc(256 * VIDEO_VERTICAL_PIXELS * BYTES_PER_PIXEL); renderer.outputBufferStride = 256;
M src/platform/psp2/psp2-context.csrc/platform/psp2/psp2-context.c

@@ -257,11 +257,11 @@ }

void GBAPSP2IncrementScreenMode(struct GBAGUIRunner* runner) { unsigned mode; - if (GBAConfigGetUIntValue(&runner->context.config, "screenMode", &mode) && mode != screenMode) { + if (mCoreConfigGetUIntValue(&runner->context.config, "screenMode", &mode) && mode != screenMode) { screenMode = mode; } else { screenMode = (screenMode + 1) % SM_MAX; - GBAConfigSetUIntValue(&runner->context.config, "screenMode", screenMode); + mCoreConfigSetUIntValue(&runner->context.config, "screenMode", screenMode); } }
M src/platform/qt/ConfigController.cppsrc/platform/qt/ConfigController.cpp

@@ -96,13 +96,13 @@ : QObject(parent)

, m_opts() { char path[PATH_MAX]; - GBAConfigDirectory(path, sizeof(path)); + mCoreConfigDirectory(path, sizeof(path)); QString fileName(path); fileName.append(QDir::separator()); fileName.append("qt.ini"); m_settings = new QSettings(fileName, QSettings::IniFormat, this); - GBAConfigInit(&m_config, PORT); + mCoreConfigInit(&m_config, PORT); m_opts.audioSync = GameController::AUDIO_SYNC; m_opts.videoSync = GameController::VIDEO_SYNC;

@@ -116,20 +116,20 @@ m_opts.rewindBufferInterval = 0;

m_opts.rewindBufferCapacity = 0; m_opts.useBios = true; m_opts.suspendScreensaver = true; - GBAConfigLoad(&m_config); - GBAConfigLoadDefaults(&m_config, &m_opts); - GBAConfigMap(&m_config, &m_opts); + mCoreConfigLoad(&m_config); + mCoreConfigLoadDefaults(&m_config, &m_opts); + mCoreConfigMap(&m_config, &m_opts); } ConfigController::~ConfigController() { - GBAConfigDeinit(&m_config); - GBAConfigFreeOpts(&m_opts); + mCoreConfigDeinit(&m_config); + mCoreConfigFreeOpts(&m_opts); } bool ConfigController::parseArguments(GBAArguments* args, int argc, char* argv[], SubParser* subparser) { if (::parseArguments(args, &m_config, argc, argv, subparser)) { - GBAConfigFreeOpts(&m_opts); - GBAConfigMap(&m_config, &m_opts); + mCoreConfigFreeOpts(&m_opts); + mCoreConfigMap(&m_config, &m_opts); return true; } return false;

@@ -159,11 +159,11 @@

if (!m_optionSet.contains(optionName)) { return; } - m_optionSet[optionName]->setValue(GBAConfigGetValue(&m_config, key)); + m_optionSet[optionName]->setValue(mCoreConfigGetValue(&m_config, key)); } QString ConfigController::getOption(const char* key) const { - return QString(GBAConfigGetValue(&m_config, key)); + return QString(mCoreConfigGetValue(&m_config, key)); } QVariant ConfigController::getQtOption(const QString& key, const QString& group) const {

@@ -183,7 +183,7 @@ write();

} void ConfigController::setOption(const char* key, bool value) { - GBAConfigSetIntValue(&m_config, key, value); + mCoreConfigSetIntValue(&m_config, key, value); QString optionName(key); if (m_optionSet.contains(optionName)) { m_optionSet[optionName]->setValue(value);

@@ -191,7 +191,7 @@ }

} void ConfigController::setOption(const char* key, int value) { - GBAConfigSetIntValue(&m_config, key, value); + mCoreConfigSetIntValue(&m_config, key, value); QString optionName(key); if (m_optionSet.contains(optionName)) { m_optionSet[optionName]->setValue(value);

@@ -199,7 +199,7 @@ }

} void ConfigController::setOption(const char* key, unsigned value) { - GBAConfigSetUIntValue(&m_config, key, value); + mCoreConfigSetUIntValue(&m_config, key, value); QString optionName(key); if (m_optionSet.contains(optionName)) { m_optionSet[optionName]->setValue(value);

@@ -207,7 +207,7 @@ }

} void ConfigController::setOption(const char* key, const char* value) { - GBAConfigSetValue(&m_config, key, value); + mCoreConfigSetValue(&m_config, key, value); QString optionName(key); if (m_optionSet.contains(optionName)) { m_optionSet[optionName]->setValue(value);

@@ -261,18 +261,18 @@ m_settings->endGroup();

} void ConfigController::write() { - GBAConfigSave(&m_config); + mCoreConfigSave(&m_config); m_settings->sync(); - GBAConfigFreeOpts(&m_opts); - GBAConfigMap(&m_config, &m_opts); + mCoreConfigFreeOpts(&m_opts); + mCoreConfigMap(&m_config, &m_opts); } void ConfigController::makePortable() { - GBAConfigMakePortable(&m_config); + mCoreConfigMakePortable(&m_config); char path[PATH_MAX]; - GBAConfigDirectory(path, sizeof(path)); + mCoreConfigDirectory(path, sizeof(path)); QString fileName(path); fileName.append(QDir::separator()); fileName.append("qt.ini");
M src/platform/qt/ConfigController.hsrc/platform/qt/ConfigController.h

@@ -14,7 +14,7 @@

#include <functional> extern "C" { -#include "gba/context/config.h" +#include "core/config.h" #include "util/configuration.h" #include "platform/commandline.h" }

@@ -77,10 +77,10 @@

QList<QString> getMRU() const; void setMRU(const QList<QString>& mru); - Configuration* overrides() { return GBAConfigGetOverrides(&m_config); } + Configuration* overrides() { return mCoreConfigGetOverrides(&m_config); } void saveOverride(const GBACartridgeOverride&); - Configuration* input() { return GBAConfigGetInput(&m_config); } + Configuration* input() { return mCoreConfigGetInput(&m_config); } public slots: void setOption(const char* key, bool value);

@@ -96,7 +96,7 @@

private: Configuration* defaults() { return &m_config.defaultsTable; } - GBAConfig m_config; + mCoreConfig m_config; GBAOptions m_opts; QMap<QString, ConfigOption*> m_optionSet;
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -18,9 +18,9 @@

#include <ctime> extern "C" { +#include "core/config.h" #include "core/directories.h" #include "gba/audio.h" -#include "gba/context/config.h" #include "gba/gba.h" #include "gba/serialize.h" #include "gba/sharkport.h"
M src/platform/sdl/main.csrc/platform/sdl/main.c

@@ -14,9 +14,9 @@ #include "debugger/gdb-stub.h"

#endif #include "core/core.h" +#include "core/config.h" #ifdef M_CORE_GBA #include "gba/gba.h" -#include "gba/context/config.h" #include "gba/supervisor/thread.h" #include "gba/video.h" #endif

@@ -49,7 +49,7 @@ static void mSDLDeinit(struct mSDLRenderer* renderer);

// TODO: Clean up signatures #ifdef M_CORE_GBA -static int mSDLRunGBA(struct mSDLRenderer* renderer, struct GBAArguments* args, struct GBAOptions* opts, struct GBAConfig* config); +static int mSDLRunGBA(struct mSDLRenderer* renderer, struct GBAArguments* args, struct GBAOptions* opts, struct mCoreConfig* config); #endif #ifdef M_CORE_GB static int mSDLRunGB(struct mSDLRenderer* renderer, struct GBAArguments* args);

@@ -62,9 +62,9 @@

struct GBAInputMap inputMap; GBAInputMapInit(&inputMap); - struct GBAConfig config; - GBAConfigInit(&config, PORT); - GBAConfigLoad(&config); + struct mCoreConfig config; + mCoreConfigInit(&config, PORT); + mCoreConfigLoad(&config); struct GBAOptions opts = { .width = 0,

@@ -86,15 +86,15 @@ bool parsed = parseArguments(&args, &config, argc, argv, &subparser);

if (!parsed || args.showHelp) { usage(argv[0], subparser.usage); freeArguments(&args); - GBAConfigFreeOpts(&opts); - GBAConfigDeinit(&config); + mCoreConfigFreeOpts(&opts); + mCoreConfigDeinit(&config); return !parsed; } if (args.showVersion) { version(argv[0]); freeArguments(&args); - GBAConfigFreeOpts(&opts); - GBAConfigDeinit(&config); + mCoreConfigFreeOpts(&opts); + mCoreConfigDeinit(&config); return 0; }

@@ -105,8 +105,8 @@ struct VFile* vf = VFileOpen(args.fname, O_RDONLY);

if (!vf) { printf("Could not open game. Are you sure the file exists?\n"); freeArguments(&args); - GBAConfigFreeOpts(&opts); - GBAConfigDeinit(&config); + mCoreConfigFreeOpts(&opts); + mCoreConfigDeinit(&config); return 1; } #ifdef M_CORE_GBA

@@ -150,14 +150,14 @@ #endif

else { printf("Could not run game. Are you sure the file exists and is a Game Boy Advance game?\n"); freeArguments(&args); - GBAConfigFreeOpts(&opts); - GBAConfigDeinit(&config); + mCoreConfigFreeOpts(&opts); + mCoreConfigDeinit(&config); return 1; } } - GBAConfigLoadDefaults(&config, &opts); - GBAConfigMap(&config, &opts); + mCoreConfigLoadDefaults(&config, &opts); + mCoreConfigMap(&config, &opts); renderer.viewportWidth = opts.width; renderer.viewportHeight = opts.height;

@@ -177,8 +177,8 @@ renderer.filter = opts.resampleVideo;

if (!mSDLInit(&renderer)) { freeArguments(&args); - GBAConfigFreeOpts(&opts); - GBAConfigDeinit(&config); + mCoreConfigFreeOpts(&opts); + mCoreConfigDeinit(&config); return 1; }

@@ -190,9 +190,9 @@

renderer.player.bindings = &inputMap; GBASDLInitBindings(&inputMap); GBASDLInitEvents(&renderer.events); - GBASDLEventsLoadConfig(&renderer.events, GBAConfigGetInput(&config)); + GBASDLEventsLoadConfig(&renderer.events, mCoreConfigGetInput(&config)); GBASDLAttachPlayer(&renderer.events, &renderer.player); - GBASDLPlayerLoadConfig(&renderer.player, GBAConfigGetInput(&config)); + GBASDLPlayerLoadConfig(&renderer.player, mCoreConfigGetInput(&config)); int ret;

@@ -213,14 +213,14 @@

mSDLDeinit(&renderer); freeArguments(&args); - GBAConfigFreeOpts(&opts); - GBAConfigDeinit(&config); + mCoreConfigFreeOpts(&opts); + mCoreConfigDeinit(&config); return ret; } #ifdef M_CORE_GBA -int mSDLRunGBA(struct mSDLRenderer* renderer, struct GBAArguments* args, struct GBAOptions* opts, struct GBAConfig* config) { +int mSDLRunGBA(struct mSDLRenderer* renderer, struct GBAArguments* args, struct GBAOptions* opts, struct mCoreConfig* config) { struct GBAThread context = { .renderer = &renderer->d.d, .userData = renderer

@@ -230,7 +230,7 @@ context.debugger = createDebugger(args, &context);

GBAMapOptionsToContext(opts, &context); GBAMapArgumentsToContext(args, &context); - context.overrides = GBAConfigGetOverrides(config); + context.overrides = mCoreConfigGetOverrides(config); bool didFail = false;
M src/platform/test/fuzz-main.csrc/platform/test/fuzz-main.c

@@ -3,7 +3,7 @@ *

* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "gba/context/config.h" +#include "core/config.h" #include "gba/context/context.h" #include "gba/gba.h" #include "gba/renderers/video-software.h"

@@ -36,7 +36,7 @@ };

static void _GBAFuzzRunloop(struct GBAContext* context, int frames); static void _GBAFuzzShutdown(int signal); -static bool _parseFuzzOpts(struct SubParser* parser, struct GBAConfig* config, int option, const char* arg); +static bool _parseFuzzOpts(struct SubParser* parser, struct mCoreConfig* config, int option, const char* arg); static bool _dispatchExiting = false;

@@ -56,8 +56,8 @@ GBAContextInit(&context, "fuzz");

struct GBAOptions opts = { .idleOptimization = IDLE_LOOP_DETECT }; - GBAConfigLoadDefaults(&context.config, &opts); - GBAConfigFreeOpts(&opts); + mCoreConfigLoadDefaults(&context.config, &opts); + mCoreConfigFreeOpts(&opts); struct GBAArguments args; bool parsed = parseArguments(&args, &context.config, argc, argv, &subparser);

@@ -161,7 +161,7 @@ UNUSED(signal);

_dispatchExiting = true; } -static bool _parseFuzzOpts(struct SubParser* parser, struct GBAConfig* config, int option, const char* arg) { +static bool _parseFuzzOpts(struct SubParser* parser, struct mCoreConfig* config, int option, const char* arg) { UNUSED(config); struct FuzzOpts* opts = parser->opts; errno = 0;
M src/platform/test/perf-main.csrc/platform/test/perf-main.c

@@ -3,8 +3,8 @@ *

* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "core/config.h" #include "gba/supervisor/thread.h" -#include "gba/context/config.h" #include "gba/gba.h" #include "gba/renderers/video-software.h" #include "gba/serialize.h"

@@ -38,7 +38,7 @@ };

static void _GBAPerfRunloop(struct GBAThread* context, int* frames, bool quiet); static void _GBAPerfShutdown(int signal); -static bool _parsePerfOpts(struct SubParser* parser, struct GBAConfig* config, int option, const char* arg); +static bool _parsePerfOpts(struct SubParser* parser, struct mCoreConfig* config, int option, const char* arg); static void _loadSavestate(struct GBAThread* context); static struct GBAThread* _thread;

@@ -59,29 +59,29 @@ .extraOptions = PERF_OPTIONS,

.opts = &perfOpts }; - struct GBAConfig config; - GBAConfigInit(&config, "perf"); - GBAConfigLoad(&config); + struct mCoreConfig config; + mCoreConfigInit(&config, "perf"); + mCoreConfigLoad(&config); struct GBAOptions opts = { .idleOptimization = IDLE_LOOP_DETECT }; - GBAConfigLoadDefaults(&config, &opts); + mCoreConfigLoadDefaults(&config, &opts); struct GBAArguments args; bool parsed = parseArguments(&args, &config, argc, argv, &subparser); if (!parsed || args.showHelp) { usage(argv[0], PERF_USAGE); freeArguments(&args); - GBAConfigFreeOpts(&opts); - GBAConfigDeinit(&config); + mCoreConfigFreeOpts(&opts); + mCoreConfigDeinit(&config); return !parsed; } if (args.showVersion) { version(argv[0]); freeArguments(&args); - GBAConfigFreeOpts(&opts); - GBAConfigDeinit(&config); + mCoreConfigFreeOpts(&opts); + mCoreConfigDeinit(&config); return 0; }

@@ -103,10 +103,10 @@ context.startCallback = _loadSavestate;

} context.debugger = createDebugger(&args, &context); - context.overrides = GBAConfigGetOverrides(&config); + context.overrides = mCoreConfigGetOverrides(&config); char gameCode[5] = { 0 }; - GBAConfigMap(&config, &opts); + mCoreConfigMap(&config, &opts); opts.audioSync = false; opts.videoSync = false; GBAMapArgumentsToContext(&args, &context);

@@ -158,9 +158,9 @@ cleanup:

if (_savestate) { _savestate->close(_savestate); } - GBAConfigFreeOpts(&opts); + mCoreConfigFreeOpts(&opts); freeArguments(&args); - GBAConfigDeinit(&config); + mCoreConfigDeinit(&config); free(context.debugger); free(renderer.outputBuffer);

@@ -212,7 +212,7 @@ _dispatchExiting = true;

ConditionWake(&_thread->sync.videoFrameAvailableCond); } -static bool _parsePerfOpts(struct SubParser* parser, struct GBAConfig* config, int option, const char* arg) { +static bool _parsePerfOpts(struct SubParser* parser, struct mCoreConfig* config, int option, const char* arg) { UNUSED(config); struct PerfOpts* opts = parser->opts; errno = 0;
M src/platform/wii/main.csrc/platform/wii/main.c

@@ -599,10 +599,10 @@ referenceRetraceCount = retraceCount;

_CPU_ISR_Restore(level); unsigned mode; - if (GBAConfigGetUIntValue(&runner->context.config, "screenMode", &mode) && mode < SM_MAX) { + if (mCoreConfigGetUIntValue(&runner->context.config, "screenMode", &mode) && mode < SM_MAX) { screenMode = mode; } - if (GBAConfigGetUIntValue(&runner->context.config, "filter", &mode) && mode < FM_MAX) { + if (mCoreConfigGetUIntValue(&runner->context.config, "filter", &mode) && mode < FM_MAX) { switch (mode) { case FM_NEAREST: default: