Core: Refactor GBAConfig into mCoreConfig

This commit is contained in:
Jeffrey Pfau 2016-01-29 00:33:56 -08:00
parent 234ecd9619
commit 811d8281c3
22 changed files with 249 additions and 249 deletions

View File

@ -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 * 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 * License, v. 2.0. If a copy of the MPL was not distributed with this
@ -28,7 +28,7 @@
#define SECTION_NAME_MAX 128 #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; const char* value;
if (config->port) { if (config->port) {
value = ConfigurationGetValue(&config->overridesTable, config->port, key); value = ConfigurationGetValue(&config->overridesTable, config->port, key);
@ -59,7 +59,7 @@ static const char* _lookupValue(const struct GBAConfig* config, const char* key)
return ConfigurationGetValue(&config->defaultsTable, 0, key); 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); const char* value = _lookupValue(config, key);
if (!value) { if (!value) {
return false; return false;
@ -71,7 +71,7 @@ static bool _lookupCharValue(const struct GBAConfig* config, const char* key, ch
return true; 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); const char* charValue = _lookupValue(config, key);
if (!charValue) { if (!charValue) {
return false; return false;
@ -85,7 +85,7 @@ static bool _lookupIntValue(const struct GBAConfig* config, const char* key, int
return true; 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); const char* charValue = _lookupValue(config, key);
if (!charValue) { if (!charValue) {
return false; return false;
@ -99,7 +99,7 @@ static bool _lookupUIntValue(const struct GBAConfig* config, const char* key, un
return true; 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); const char* charValue = _lookupValue(config, key);
if (!charValue) { if (!charValue) {
return false; return false;
@ -113,7 +113,7 @@ static bool _lookupFloatValue(const struct GBAConfig* config, const char* key, f
return true; return true;
} }
void GBAConfigInit(struct GBAConfig* config, const char* port) { void mCoreConfigInit(struct mCoreConfig* config, const char* port) {
ConfigurationInit(&config->configTable); ConfigurationInit(&config->configTable);
ConfigurationInit(&config->defaultsTable); ConfigurationInit(&config->defaultsTable);
ConfigurationInit(&config->overridesTable); ConfigurationInit(&config->overridesTable);
@ -125,7 +125,7 @@ void GBAConfigInit(struct GBAConfig* config, const char* port) {
} }
} }
void GBAConfigDeinit(struct GBAConfig* config) { void mCoreConfigDeinit(struct mCoreConfig* config) {
ConfigurationDeinit(&config->configTable); ConfigurationDeinit(&config->configTable);
ConfigurationDeinit(&config->defaultsTable); ConfigurationDeinit(&config->defaultsTable);
ConfigurationDeinit(&config->overridesTable); ConfigurationDeinit(&config->overridesTable);
@ -133,29 +133,29 @@ void GBAConfigDeinit(struct GBAConfig* config) {
} }
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
bool GBAConfigLoad(struct GBAConfig* config) { bool mCoreConfigLoad(struct mCoreConfig* config) {
char path[PATH_MAX]; char path[PATH_MAX];
GBAConfigDirectory(path, PATH_MAX); mCoreConfigDirectory(path, PATH_MAX);
strncat(path, PATH_SEP "config.ini", PATH_MAX - strlen(path)); 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]; char path[PATH_MAX];
GBAConfigDirectory(path, PATH_MAX); mCoreConfigDirectory(path, PATH_MAX);
strncat(path, PATH_SEP "config.ini", PATH_MAX - strlen(path)); 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); 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); return ConfigurationWrite(&config->configTable, path);
} }
void GBAConfigMakePortable(const struct GBAConfig* config) { void mCoreConfigMakePortable(const struct mCoreConfig* config) {
struct VFile* portable = 0; struct VFile* portable = 0;
#ifdef _WIN32 #ifdef _WIN32
char out[MAX_PATH]; char out[MAX_PATH];
@ -178,11 +178,11 @@ void GBAConfigMakePortable(const struct GBAConfig* config) {
#endif #endif
if (portable) { if (portable) {
portable->close(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; struct VFile* portable;
#ifdef _WIN32 #ifdef _WIN32
wchar_t wpath[MAX_PATH]; wchar_t wpath[MAX_PATH];
@ -235,71 +235,71 @@ void GBAConfigDirectory(char* out, size_t outLength) {
} }
#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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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, "bios", &opts->bios);
_lookupCharValue(config, "shader", &opts->shader); _lookupCharValue(config, "shader", &opts->shader);
_lookupIntValue(config, "logLevel", &opts->logLevel); _lookupIntValue(config, "logLevel", &opts->logLevel);
@ -365,7 +365,7 @@ void GBAConfigMap(const struct GBAConfig* config, struct GBAOptions* opts) {
} }
} }
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, "bios", opts->bios);
ConfigurationSetValue(&config->defaultsTable, 0, "shader", opts->shader); ConfigurationSetValue(&config->defaultsTable, 0, "shader", opts->shader);
ConfigurationSetIntValue(&config->defaultsTable, 0, "skipBios", opts->skipBios); ConfigurationSetIntValue(&config->defaultsTable, 0, "skipBios", opts->skipBios);
@ -403,15 +403,15 @@ void GBAConfigLoadDefaults(struct GBAConfig* config, const struct GBAOptions* op
} }
// These two are basically placeholders in case the internal layout changes, e.g. for loading separate files // 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; return &config->configTable;
} }
struct Configuration* GBAConfigGetOverrides(struct GBAConfig* config) { struct Configuration* mCoreConfigGetOverrides(struct mCoreConfig* config) {
return &config->configTable; return &config->configTable;
} }
void GBAConfigFreeOpts(struct GBAOptions* opts) { void mCoreConfigFreeOpts(struct GBAOptions* opts) {
free(opts->bios); free(opts->bios);
free(opts->shader); free(opts->shader);
free(opts->savegamePath); free(opts->savegamePath);

98
src/core/config.h Normal file
View File

@ -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

View File

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

View File

@ -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

View File

@ -39,19 +39,19 @@ bool GBAContextInit(struct GBAContext* context, const char* port) {
ARMSetComponents(context->cpu, &context->gba->d, GBA_COMPONENT_MAX, context->components); ARMSetComponents(context->cpu, &context->gba->d, GBA_COMPONENT_MAX, context->components);
ARMInit(context->cpu); ARMInit(context->cpu);
GBAConfigInit(&context->config, port); mCoreConfigInit(&context->config, port);
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
if (port) { if (port) {
if (!_logFile) { if (!_logFile) {
char logPath[PATH_MAX]; char logPath[PATH_MAX];
GBAConfigDirectory(logPath, PATH_MAX); mCoreConfigDirectory(logPath, PATH_MAX);
strncat(logPath, PATH_SEP "log", PATH_MAX - strlen(logPath)); strncat(logPath, PATH_SEP "log", PATH_MAX - strlen(logPath));
_logFile = VFileOpen(logPath, O_WRONLY | O_CREAT | O_TRUNC); _logFile = VFileOpen(logPath, O_WRONLY | O_CREAT | O_TRUNC);
} }
context->gba->logHandler = _GBAContextLog; context->gba->logHandler = _GBAContextLog;
char biosPath[PATH_MAX]; char biosPath[PATH_MAX];
GBAConfigDirectory(biosPath, PATH_MAX); mCoreConfigDirectory(biosPath, PATH_MAX);
strncat(biosPath, PATH_SEP "gba_bios.bin", PATH_MAX - strlen(biosPath)); strncat(biosPath, PATH_SEP "gba_bios.bin", PATH_MAX - strlen(biosPath));
struct GBAOptions opts = { struct GBAOptions opts = {
@ -60,8 +60,8 @@ bool GBAContextInit(struct GBAContext* context, const char* port) {
.idleOptimization = IDLE_LOOP_DETECT, .idleOptimization = IDLE_LOOP_DETECT,
.logLevel = GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL | GBA_LOG_STATUS .logLevel = GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL | GBA_LOG_STATUS
}; };
GBAConfigLoad(&context->config); mCoreConfigLoad(&context->config);
GBAConfigLoadDefaults(&context->config, &opts); mCoreConfigLoadDefaults(&context->config, &opts);
} }
#else #else
UNUSED(port); UNUSED(port);
@ -80,7 +80,7 @@ void GBAContextDeinit(struct GBAContext* context) {
} }
mappedMemoryFree(context->gba, 0); mappedMemoryFree(context->gba, 0);
mappedMemoryFree(context->cpu, 0); mappedMemoryFree(context->cpu, 0);
GBAConfigDeinit(&context->config); mCoreConfigDeinit(&context->config);
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
mDirectorySetDeinit(&context->dirs); mDirectorySetDeinit(&context->dirs);
#endif #endif
@ -171,7 +171,7 @@ bool GBAContextStart(struct GBAContext* context) {
return false; return false;
} }
GBAConfigMap(&context->config, &opts); mCoreConfigMap(&context->config, &opts);
if (!context->bios && opts.bios) { if (!context->bios && opts.bios) {
GBAContextLoadBIOS(context, opts.bios); GBAContextLoadBIOS(context, opts.bios);
@ -194,8 +194,8 @@ bool GBAContextStart(struct GBAContext* context) {
memcpy(override.id, &cart->id, sizeof(override.id)); memcpy(override.id, &cart->id, sizeof(override.id));
struct Configuration* overrides = 0; struct Configuration* overrides = 0;
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
overrides = GBAConfigGetOverrides(&context->config); overrides = mCoreConfigGetOverrides(&context->config);
GBAConfigFreeOpts(&opts); mCoreConfigFreeOpts(&opts);
#endif #endif
if (GBAOverrideFind(overrides, &override)) { if (GBAOverrideFind(overrides, &override)) {
GBAOverrideApply(context->gba, &override); GBAOverrideApply(context->gba, &override);

View File

@ -9,8 +9,8 @@
#include "util/common.h" #include "util/common.h"
#include "core/directories.h" #include "core/directories.h"
#include "core/config.h"
#include "core/sync.h" #include "core/sync.h"
#include "gba/context/config.h"
#include "gba/input.h" #include "gba/input.h"
struct GBAContext { struct GBAContext {
@ -25,7 +25,7 @@ struct GBAContext {
struct mDirectorySet dirs; struct mDirectorySet dirs;
#endif #endif
struct ARMComponent* components[GBA_COMPONENT_MAX]; struct ARMComponent* components[GBA_COMPONENT_MAX];
struct GBAConfig config; struct mCoreConfig config;
struct GBAOptions opts; struct GBAOptions opts;
struct GBAInputMap inputMap; struct GBAInputMap inputMap;
}; };

View File

@ -93,7 +93,7 @@ void GBAGUIShowConfig(struct GBAGUIRunner* runner, struct GUIMenuItem* extra, si
if (!item->validStates || !item->data) { if (!item->validStates || !item->data) {
continue; continue;
} }
GBAConfigGetUIntValue(&runner->context.config, item->data, &item->state); mCoreConfigGetUIntValue(&runner->context.config, item->data, &item->state);
} }
while (true) { while (true) {
@ -103,16 +103,16 @@ void GBAGUIShowConfig(struct GBAGUIRunner* runner, struct GUIMenuItem* extra, si
} }
if (!strcmp(item->data, "*SAVE")) { if (!strcmp(item->data, "*SAVE")) {
if (biosPath[0]) { if (biosPath[0]) {
GBAConfigSetValue(&runner->context.config, "bios", biosPath); mCoreConfigSetValue(&runner->context.config, "bios", biosPath);
} }
for (i = 0; i < GUIMenuItemListSize(&menu.items); ++i) { for (i = 0; i < GUIMenuItemListSize(&menu.items); ++i) {
item = GUIMenuItemListGetPointer(&menu.items, i); item = GUIMenuItemListGetPointer(&menu.items, i);
if (!item->validStates || !item->data) { if (!item->validStates || !item->data) {
continue; 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; break;
} }
if (!strcmp(item->data, "*REMAP")) { if (!strcmp(item->data, "*REMAP")) {

View File

@ -124,7 +124,7 @@ void GBAGUIInit(struct GBAGUIRunner* runner, const char* port) {
if (runner->context.config.port && runner->keySources) { if (runner->context.config.port && runner->keySources) {
size_t i; size_t i;
for (i = 0; runner->keySources[i].id; ++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 @@ void GBAGUIDeinit(struct GBAGUIRunner* runner) {
if (runner->keySources) { if (runner->keySources) {
size_t i; size_t i;
for (i = 0; runner->keySources[i].id; ++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); CircleBufferDeinit(&runner->fpsBuffer);
GBAContextDeinit(&runner->context); GBAContextDeinit(&runner->context);
@ -272,7 +272,7 @@ void GBAGUIRun(struct GBAGUIRunner* runner, const char* path) {
GBAContextFrame(&runner->context, keys); GBAContextFrame(&runner->context, keys);
if (runner->drawFrame) { if (runner->drawFrame) {
int drawFps = false; int drawFps = false;
GBAConfigGetIntValue(&runner->context.config, "fpsCounter", &drawFps); mCoreConfigGetIntValue(&runner->context.config, "fpsCounter", &drawFps);
runner->params.drawStart(); runner->params.drawStart();
runner->drawFrame(runner, false); runner->drawFrame(runner, false);
@ -347,7 +347,7 @@ void GBAGUIRun(struct GBAGUIRunner* runner, const char* path) {
break; break;
case RUNNER_CONFIG: case RUNNER_CONFIG:
GBAGUIShowConfig(runner, runner->configExtra, runner->nConfigExtra); 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; break;
case RUNNER_CONTINUE: case RUNNER_CONTINUE:
break; break;

View File

@ -6,10 +6,10 @@
#include "thread.h" #include "thread.h"
#include "arm.h" #include "arm.h"
#include "core/config.h"
#include "gba/gba.h" #include "gba/gba.h"
#include "gba/cheats.h" #include "gba/cheats.h"
#include "gba/serialize.h" #include "gba/serialize.h"
#include "gba/context/config.h"
#include "gba/rr/mgm.h" #include "gba/rr/mgm.h"
#include "gba/rr/vbm.h" #include "gba/rr/vbm.h"

View File

@ -271,7 +271,7 @@ static void _setup(struct GBAGUIRunner* runner) {
runner->context.renderer = &renderer.d; runner->context.renderer = &renderer.d;
unsigned mode; unsigned mode;
if (GBAConfigGetUIntValue(&runner->context.config, "screenMode", &mode) && mode < SM_MAX) { if (mCoreConfigGetUIntValue(&runner->context.config, "screenMode", &mode) && mode < SM_MAX) {
screenMode = mode; screenMode = mode;
} }
@ -304,7 +304,7 @@ static void _gameLoaded(struct GBAGUIRunner* runner) {
memset(audioLeft, 0, AUDIO_SAMPLE_BUFFER * 2 * sizeof(int16_t)); memset(audioLeft, 0, AUDIO_SAMPLE_BUFFER * 2 * sizeof(int16_t));
} }
unsigned mode; unsigned mode;
if (GBAConfigGetUIntValue(&runner->context.config, "screenMode", &mode) && mode != screenMode) { if (mCoreConfigGetUIntValue(&runner->context.config, "screenMode", &mode) && mode != screenMode) {
screenMode = mode; screenMode = mode;
screenCleanup |= SCREEN_CLEANUP_BOTTOM | SCREEN_CLEANUP_TOP; screenCleanup |= SCREEN_CLEANUP_BOTTOM | SCREEN_CLEANUP_TOP;
} }
@ -437,7 +437,7 @@ static void _incrementScreenMode(struct GBAGUIRunner* runner) {
UNUSED(runner); UNUSED(runner);
screenCleanup |= SCREEN_CLEANUP_TOP | SCREEN_CLEANUP_BOTTOM; screenCleanup |= SCREEN_CLEANUP_TOP | SCREEN_CLEANUP_BOTTOM;
screenMode = (screenMode + 1) % SM_MAX; screenMode = (screenMode + 1) % SM_MAX;
GBAConfigSetUIntValue(&runner->context.config, "screenMode", screenMode); mCoreConfigSetUIntValue(&runner->context.config, "screenMode", screenMode);
} }
static uint32_t _pollInput(void) { static uint32_t _pollInput(void) {

View File

@ -50,9 +50,9 @@ static const struct option _options[] = {
{ 0, 0, 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; int ch;
char options[64] = char options[64] =
"b:c:hl:p:s:v:" "b:c:hl:p:s:v:"
@ -80,7 +80,7 @@ bool parseArguments(struct GBAArguments* opts, struct GBAConfig* config, int arg
} }
break; break;
case 'b': case 'b':
GBAConfigSetOverrideValue(config, "bios", optarg); mCoreConfigSetOverrideValue(config, "bios", optarg);
break; break;
case 'c': case 'c':
opts->cheatsFile = strdup(optarg); opts->cheatsFile = strdup(optarg);
@ -105,13 +105,13 @@ bool parseArguments(struct GBAArguments* opts, struct GBAConfig* config, int arg
opts->showHelp = true; opts->showHelp = true;
break; break;
case 'l': case 'l':
GBAConfigSetOverrideValue(config, "logLevel", optarg); mCoreConfigSetOverrideValue(config, "logLevel", optarg);
break; break;
case 'p': case 'p':
opts->patch = strdup(optarg); opts->patch = strdup(optarg);
break; break;
case 's': case 's':
GBAConfigSetOverrideValue(config, "frameskip", optarg); mCoreConfigSetOverrideValue(config, "frameskip", optarg);
break; break;
case 'v': case 'v':
opts->movie = strdup(optarg); opts->movie = strdup(optarg);
@ -154,13 +154,13 @@ void initParserForGraphics(struct SubParser* parser, struct GraphicsOpts* opts)
opts->fullscreen = false; 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); UNUSED(arg);
struct GraphicsOpts* graphicsOpts = parser->opts; struct GraphicsOpts* graphicsOpts = parser->opts;
switch (option) { switch (option) {
case 'f': case 'f':
graphicsOpts->fullscreen = true; graphicsOpts->fullscreen = true;
GBAConfigSetOverrideIntValue(config, "fullscreen", 1); mCoreConfigSetOverrideIntValue(config, "fullscreen", 1);
return true; return true;
case '1': case '1':
case '2': case '2':
@ -172,8 +172,8 @@ bool _parseGraphicsArg(struct SubParser* parser, struct GBAConfig* config, int o
return false; return false;
} }
graphicsOpts->multiplier = option - '0'; graphicsOpts->multiplier = option - '0';
GBAConfigSetOverrideIntValue(config, "width", VIDEO_HORIZONTAL_PIXELS * graphicsOpts->multiplier); mCoreConfigSetOverrideIntValue(config, "width", VIDEO_HORIZONTAL_PIXELS * graphicsOpts->multiplier);
GBAConfigSetOverrideIntValue(config, "height", VIDEO_VERTICAL_PIXELS * graphicsOpts->multiplier); mCoreConfigSetOverrideIntValue(config, "height", VIDEO_VERTICAL_PIXELS * graphicsOpts->multiplier);
return true; return true;
default: default:
return false; return false;

View File

@ -8,7 +8,7 @@
#include "util/common.h" #include "util/common.h"
#include "gba/context/config.h" #include "core/config.h"
enum DebuggerType { enum DebuggerType {
DEBUGGER_NONE = 0, DEBUGGER_NONE = 0,
@ -35,7 +35,7 @@ struct GBAArguments {
struct SubParser { struct SubParser {
const char* usage; 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; const char* extraOptions;
void* opts; void* opts;
}; };
@ -47,7 +47,7 @@ struct GraphicsOpts {
struct GBAThread; 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); struct SubParser* subparser);
void freeArguments(struct GBAArguments* opts); void freeArguments(struct GBAArguments* opts);

View File

@ -79,7 +79,7 @@ static void _reloadSettings(void) {
} }
} }
GBAConfigLoadDefaults(&context.config, &opts); mCoreConfigLoadDefaults(&context.config, &opts);
} }
unsigned retro_api_version(void) { unsigned retro_api_version(void) {

View File

@ -63,7 +63,7 @@
.useBios = true, .useBios = true,
.idleOptimization = IDLE_LOOP_REMOVE .idleOptimization = IDLE_LOOP_REMOVE
}; };
GBAConfigLoadDefaults(&context.config, &opts); mCoreConfigLoadDefaults(&context.config, &opts);
GBAVideoSoftwareRendererCreate(&renderer); GBAVideoSoftwareRendererCreate(&renderer);
renderer.outputBuffer = malloc(256 * VIDEO_VERTICAL_PIXELS * BYTES_PER_PIXEL); renderer.outputBuffer = malloc(256 * VIDEO_VERTICAL_PIXELS * BYTES_PER_PIXEL);
renderer.outputBufferStride = 256; renderer.outputBufferStride = 256;

View File

@ -257,11 +257,11 @@ void GBAPSP2DrawScreenshot(struct GBAGUIRunner* runner, const uint32_t* pixels,
void GBAPSP2IncrementScreenMode(struct GBAGUIRunner* runner) { void GBAPSP2IncrementScreenMode(struct GBAGUIRunner* runner) {
unsigned mode; unsigned mode;
if (GBAConfigGetUIntValue(&runner->context.config, "screenMode", &mode) && mode != screenMode) { if (mCoreConfigGetUIntValue(&runner->context.config, "screenMode", &mode) && mode != screenMode) {
screenMode = mode; screenMode = mode;
} else { } else {
screenMode = (screenMode + 1) % SM_MAX; screenMode = (screenMode + 1) % SM_MAX;
GBAConfigSetUIntValue(&runner->context.config, "screenMode", screenMode); mCoreConfigSetUIntValue(&runner->context.config, "screenMode", screenMode);
} }
} }

View File

@ -96,13 +96,13 @@ ConfigController::ConfigController(QObject* parent)
, m_opts() , m_opts()
{ {
char path[PATH_MAX]; char path[PATH_MAX];
GBAConfigDirectory(path, sizeof(path)); mCoreConfigDirectory(path, sizeof(path));
QString fileName(path); QString fileName(path);
fileName.append(QDir::separator()); fileName.append(QDir::separator());
fileName.append("qt.ini"); fileName.append("qt.ini");
m_settings = new QSettings(fileName, QSettings::IniFormat, this); m_settings = new QSettings(fileName, QSettings::IniFormat, this);
GBAConfigInit(&m_config, PORT); mCoreConfigInit(&m_config, PORT);
m_opts.audioSync = GameController::AUDIO_SYNC; m_opts.audioSync = GameController::AUDIO_SYNC;
m_opts.videoSync = GameController::VIDEO_SYNC; m_opts.videoSync = GameController::VIDEO_SYNC;
@ -116,20 +116,20 @@ ConfigController::ConfigController(QObject* parent)
m_opts.rewindBufferCapacity = 0; m_opts.rewindBufferCapacity = 0;
m_opts.useBios = true; m_opts.useBios = true;
m_opts.suspendScreensaver = true; m_opts.suspendScreensaver = true;
GBAConfigLoad(&m_config); mCoreConfigLoad(&m_config);
GBAConfigLoadDefaults(&m_config, &m_opts); mCoreConfigLoadDefaults(&m_config, &m_opts);
GBAConfigMap(&m_config, &m_opts); mCoreConfigMap(&m_config, &m_opts);
} }
ConfigController::~ConfigController() { ConfigController::~ConfigController() {
GBAConfigDeinit(&m_config); mCoreConfigDeinit(&m_config);
GBAConfigFreeOpts(&m_opts); mCoreConfigFreeOpts(&m_opts);
} }
bool ConfigController::parseArguments(GBAArguments* args, int argc, char* argv[], SubParser* subparser) { bool ConfigController::parseArguments(GBAArguments* args, int argc, char* argv[], SubParser* subparser) {
if (::parseArguments(args, &m_config, argc, argv, subparser)) { if (::parseArguments(args, &m_config, argc, argv, subparser)) {
GBAConfigFreeOpts(&m_opts); mCoreConfigFreeOpts(&m_opts);
GBAConfigMap(&m_config, &m_opts); mCoreConfigMap(&m_config, &m_opts);
return true; return true;
} }
return false; return false;
@ -159,11 +159,11 @@ void ConfigController::updateOption(const char* key) {
if (!m_optionSet.contains(optionName)) { if (!m_optionSet.contains(optionName)) {
return; return;
} }
m_optionSet[optionName]->setValue(GBAConfigGetValue(&m_config, key)); m_optionSet[optionName]->setValue(mCoreConfigGetValue(&m_config, key));
} }
QString ConfigController::getOption(const char* key) const { 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 { QVariant ConfigController::getQtOption(const QString& key, const QString& group) const {
@ -183,7 +183,7 @@ void ConfigController::saveOverride(const GBACartridgeOverride& override) {
} }
void ConfigController::setOption(const char* key, bool value) { void ConfigController::setOption(const char* key, bool value) {
GBAConfigSetIntValue(&m_config, key, value); mCoreConfigSetIntValue(&m_config, key, value);
QString optionName(key); QString optionName(key);
if (m_optionSet.contains(optionName)) { if (m_optionSet.contains(optionName)) {
m_optionSet[optionName]->setValue(value); m_optionSet[optionName]->setValue(value);
@ -191,7 +191,7 @@ void ConfigController::setOption(const char* key, bool value) {
} }
void ConfigController::setOption(const char* key, int value) { void ConfigController::setOption(const char* key, int value) {
GBAConfigSetIntValue(&m_config, key, value); mCoreConfigSetIntValue(&m_config, key, value);
QString optionName(key); QString optionName(key);
if (m_optionSet.contains(optionName)) { if (m_optionSet.contains(optionName)) {
m_optionSet[optionName]->setValue(value); m_optionSet[optionName]->setValue(value);
@ -199,7 +199,7 @@ void ConfigController::setOption(const char* key, int value) {
} }
void ConfigController::setOption(const char* key, unsigned value) { void ConfigController::setOption(const char* key, unsigned value) {
GBAConfigSetUIntValue(&m_config, key, value); mCoreConfigSetUIntValue(&m_config, key, value);
QString optionName(key); QString optionName(key);
if (m_optionSet.contains(optionName)) { if (m_optionSet.contains(optionName)) {
m_optionSet[optionName]->setValue(value); m_optionSet[optionName]->setValue(value);
@ -207,7 +207,7 @@ void ConfigController::setOption(const char* key, unsigned value) {
} }
void ConfigController::setOption(const char* key, const char* value) { void ConfigController::setOption(const char* key, const char* value) {
GBAConfigSetValue(&m_config, key, value); mCoreConfigSetValue(&m_config, key, value);
QString optionName(key); QString optionName(key);
if (m_optionSet.contains(optionName)) { if (m_optionSet.contains(optionName)) {
m_optionSet[optionName]->setValue(value); m_optionSet[optionName]->setValue(value);
@ -261,18 +261,18 @@ void ConfigController::setMRU(const QList<QString>& mru) {
} }
void ConfigController::write() { void ConfigController::write() {
GBAConfigSave(&m_config); mCoreConfigSave(&m_config);
m_settings->sync(); m_settings->sync();
GBAConfigFreeOpts(&m_opts); mCoreConfigFreeOpts(&m_opts);
GBAConfigMap(&m_config, &m_opts); mCoreConfigMap(&m_config, &m_opts);
} }
void ConfigController::makePortable() { void ConfigController::makePortable() {
GBAConfigMakePortable(&m_config); mCoreConfigMakePortable(&m_config);
char path[PATH_MAX]; char path[PATH_MAX];
GBAConfigDirectory(path, sizeof(path)); mCoreConfigDirectory(path, sizeof(path));
QString fileName(path); QString fileName(path);
fileName.append(QDir::separator()); fileName.append(QDir::separator());
fileName.append("qt.ini"); fileName.append("qt.ini");

View File

@ -14,7 +14,7 @@
#include <functional> #include <functional>
extern "C" { extern "C" {
#include "gba/context/config.h" #include "core/config.h"
#include "util/configuration.h" #include "util/configuration.h"
#include "platform/commandline.h" #include "platform/commandline.h"
} }
@ -77,10 +77,10 @@ public:
QList<QString> getMRU() const; QList<QString> getMRU() const;
void setMRU(const QList<QString>& mru); void setMRU(const QList<QString>& mru);
Configuration* overrides() { return GBAConfigGetOverrides(&m_config); } Configuration* overrides() { return mCoreConfigGetOverrides(&m_config); }
void saveOverride(const GBACartridgeOverride&); void saveOverride(const GBACartridgeOverride&);
Configuration* input() { return GBAConfigGetInput(&m_config); } Configuration* input() { return mCoreConfigGetInput(&m_config); }
public slots: public slots:
void setOption(const char* key, bool value); void setOption(const char* key, bool value);
@ -96,7 +96,7 @@ public slots:
private: private:
Configuration* defaults() { return &m_config.defaultsTable; } Configuration* defaults() { return &m_config.defaultsTable; }
GBAConfig m_config; mCoreConfig m_config;
GBAOptions m_opts; GBAOptions m_opts;
QMap<QString, ConfigOption*> m_optionSet; QMap<QString, ConfigOption*> m_optionSet;

View File

@ -18,9 +18,9 @@
#include <ctime> #include <ctime>
extern "C" { extern "C" {
#include "core/config.h"
#include "core/directories.h" #include "core/directories.h"
#include "gba/audio.h" #include "gba/audio.h"
#include "gba/context/config.h"
#include "gba/gba.h" #include "gba/gba.h"
#include "gba/serialize.h" #include "gba/serialize.h"
#include "gba/sharkport.h" #include "gba/sharkport.h"

View File

@ -14,9 +14,9 @@
#endif #endif
#include "core/core.h" #include "core/core.h"
#include "core/config.h"
#ifdef M_CORE_GBA #ifdef M_CORE_GBA
#include "gba/gba.h" #include "gba/gba.h"
#include "gba/context/config.h"
#include "gba/supervisor/thread.h" #include "gba/supervisor/thread.h"
#include "gba/video.h" #include "gba/video.h"
#endif #endif
@ -49,7 +49,7 @@ static void mSDLDeinit(struct mSDLRenderer* renderer);
// TODO: Clean up signatures // TODO: Clean up signatures
#ifdef M_CORE_GBA #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 #endif
#ifdef M_CORE_GB #ifdef M_CORE_GB
static int mSDLRunGB(struct mSDLRenderer* renderer, struct GBAArguments* args); static int mSDLRunGB(struct mSDLRenderer* renderer, struct GBAArguments* args);
@ -62,9 +62,9 @@ int main(int argc, char** argv) {
struct GBAInputMap inputMap; struct GBAInputMap inputMap;
GBAInputMapInit(&inputMap); GBAInputMapInit(&inputMap);
struct GBAConfig config; struct mCoreConfig config;
GBAConfigInit(&config, PORT); mCoreConfigInit(&config, PORT);
GBAConfigLoad(&config); mCoreConfigLoad(&config);
struct GBAOptions opts = { struct GBAOptions opts = {
.width = 0, .width = 0,
@ -86,15 +86,15 @@ int main(int argc, char** argv) {
if (!parsed || args.showHelp) { if (!parsed || args.showHelp) {
usage(argv[0], subparser.usage); usage(argv[0], subparser.usage);
freeArguments(&args); freeArguments(&args);
GBAConfigFreeOpts(&opts); mCoreConfigFreeOpts(&opts);
GBAConfigDeinit(&config); mCoreConfigDeinit(&config);
return !parsed; return !parsed;
} }
if (args.showVersion) { if (args.showVersion) {
version(argv[0]); version(argv[0]);
freeArguments(&args); freeArguments(&args);
GBAConfigFreeOpts(&opts); mCoreConfigFreeOpts(&opts);
GBAConfigDeinit(&config); mCoreConfigDeinit(&config);
return 0; return 0;
} }
@ -105,8 +105,8 @@ int main(int argc, char** argv) {
if (!vf) { if (!vf) {
printf("Could not open game. Are you sure the file exists?\n"); printf("Could not open game. Are you sure the file exists?\n");
freeArguments(&args); freeArguments(&args);
GBAConfigFreeOpts(&opts); mCoreConfigFreeOpts(&opts);
GBAConfigDeinit(&config); mCoreConfigDeinit(&config);
return 1; return 1;
} }
#ifdef M_CORE_GBA #ifdef M_CORE_GBA
@ -150,14 +150,14 @@ int main(int argc, char** argv) {
else { else {
printf("Could not run game. Are you sure the file exists and is a Game Boy Advance game?\n"); printf("Could not run game. Are you sure the file exists and is a Game Boy Advance game?\n");
freeArguments(&args); freeArguments(&args);
GBAConfigFreeOpts(&opts); mCoreConfigFreeOpts(&opts);
GBAConfigDeinit(&config); mCoreConfigDeinit(&config);
return 1; return 1;
} }
} }
GBAConfigLoadDefaults(&config, &opts); mCoreConfigLoadDefaults(&config, &opts);
GBAConfigMap(&config, &opts); mCoreConfigMap(&config, &opts);
renderer.viewportWidth = opts.width; renderer.viewportWidth = opts.width;
renderer.viewportHeight = opts.height; renderer.viewportHeight = opts.height;
@ -177,8 +177,8 @@ int main(int argc, char** argv) {
if (!mSDLInit(&renderer)) { if (!mSDLInit(&renderer)) {
freeArguments(&args); freeArguments(&args);
GBAConfigFreeOpts(&opts); mCoreConfigFreeOpts(&opts);
GBAConfigDeinit(&config); mCoreConfigDeinit(&config);
return 1; return 1;
} }
@ -190,9 +190,9 @@ int main(int argc, char** argv) {
renderer.player.bindings = &inputMap; renderer.player.bindings = &inputMap;
GBASDLInitBindings(&inputMap); GBASDLInitBindings(&inputMap);
GBASDLInitEvents(&renderer.events); GBASDLInitEvents(&renderer.events);
GBASDLEventsLoadConfig(&renderer.events, GBAConfigGetInput(&config)); GBASDLEventsLoadConfig(&renderer.events, mCoreConfigGetInput(&config));
GBASDLAttachPlayer(&renderer.events, &renderer.player); GBASDLAttachPlayer(&renderer.events, &renderer.player);
GBASDLPlayerLoadConfig(&renderer.player, GBAConfigGetInput(&config)); GBASDLPlayerLoadConfig(&renderer.player, mCoreConfigGetInput(&config));
int ret; int ret;
@ -213,14 +213,14 @@ int main(int argc, char** argv) {
mSDLDeinit(&renderer); mSDLDeinit(&renderer);
freeArguments(&args); freeArguments(&args);
GBAConfigFreeOpts(&opts); mCoreConfigFreeOpts(&opts);
GBAConfigDeinit(&config); mCoreConfigDeinit(&config);
return ret; return ret;
} }
#ifdef M_CORE_GBA #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 = { struct GBAThread context = {
.renderer = &renderer->d.d, .renderer = &renderer->d.d,
.userData = renderer .userData = renderer
@ -230,7 +230,7 @@ int mSDLRunGBA(struct mSDLRenderer* renderer, struct GBAArguments* args, struct
GBAMapOptionsToContext(opts, &context); GBAMapOptionsToContext(opts, &context);
GBAMapArgumentsToContext(args, &context); GBAMapArgumentsToContext(args, &context);
context.overrides = GBAConfigGetOverrides(config); context.overrides = mCoreConfigGetOverrides(config);
bool didFail = false; bool didFail = false;

View File

@ -3,7 +3,7 @@
* This Source Code Form is subject to the terms of the Mozilla Public * 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 * 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/. */ * 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/context/context.h"
#include "gba/gba.h" #include "gba/gba.h"
#include "gba/renderers/video-software.h" #include "gba/renderers/video-software.h"
@ -36,7 +36,7 @@ struct FuzzOpts {
static void _GBAFuzzRunloop(struct GBAContext* context, int frames); static void _GBAFuzzRunloop(struct GBAContext* context, int frames);
static void _GBAFuzzShutdown(int signal); 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; static bool _dispatchExiting = false;
@ -56,8 +56,8 @@ int main(int argc, char** argv) {
struct GBAOptions opts = { struct GBAOptions opts = {
.idleOptimization = IDLE_LOOP_DETECT .idleOptimization = IDLE_LOOP_DETECT
}; };
GBAConfigLoadDefaults(&context.config, &opts); mCoreConfigLoadDefaults(&context.config, &opts);
GBAConfigFreeOpts(&opts); mCoreConfigFreeOpts(&opts);
struct GBAArguments args; struct GBAArguments args;
bool parsed = parseArguments(&args, &context.config, argc, argv, &subparser); bool parsed = parseArguments(&args, &context.config, argc, argv, &subparser);
@ -161,7 +161,7 @@ static void _GBAFuzzShutdown(int signal) {
_dispatchExiting = true; _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); UNUSED(config);
struct FuzzOpts* opts = parser->opts; struct FuzzOpts* opts = parser->opts;
errno = 0; errno = 0;

View File

@ -3,8 +3,8 @@
* This Source Code Form is subject to the terms of the Mozilla Public * 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 * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "core/config.h"
#include "gba/supervisor/thread.h" #include "gba/supervisor/thread.h"
#include "gba/context/config.h"
#include "gba/gba.h" #include "gba/gba.h"
#include "gba/renderers/video-software.h" #include "gba/renderers/video-software.h"
#include "gba/serialize.h" #include "gba/serialize.h"
@ -38,7 +38,7 @@ struct PerfOpts {
static void _GBAPerfRunloop(struct GBAThread* context, int* frames, bool quiet); static void _GBAPerfRunloop(struct GBAThread* context, int* frames, bool quiet);
static void _GBAPerfShutdown(int signal); 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 void _loadSavestate(struct GBAThread* context);
static struct GBAThread* _thread; static struct GBAThread* _thread;
@ -59,29 +59,29 @@ int main(int argc, char** argv) {
.opts = &perfOpts .opts = &perfOpts
}; };
struct GBAConfig config; struct mCoreConfig config;
GBAConfigInit(&config, "perf"); mCoreConfigInit(&config, "perf");
GBAConfigLoad(&config); mCoreConfigLoad(&config);
struct GBAOptions opts = { struct GBAOptions opts = {
.idleOptimization = IDLE_LOOP_DETECT .idleOptimization = IDLE_LOOP_DETECT
}; };
GBAConfigLoadDefaults(&config, &opts); mCoreConfigLoadDefaults(&config, &opts);
struct GBAArguments args; struct GBAArguments args;
bool parsed = parseArguments(&args, &config, argc, argv, &subparser); bool parsed = parseArguments(&args, &config, argc, argv, &subparser);
if (!parsed || args.showHelp) { if (!parsed || args.showHelp) {
usage(argv[0], PERF_USAGE); usage(argv[0], PERF_USAGE);
freeArguments(&args); freeArguments(&args);
GBAConfigFreeOpts(&opts); mCoreConfigFreeOpts(&opts);
GBAConfigDeinit(&config); mCoreConfigDeinit(&config);
return !parsed; return !parsed;
} }
if (args.showVersion) { if (args.showVersion) {
version(argv[0]); version(argv[0]);
freeArguments(&args); freeArguments(&args);
GBAConfigFreeOpts(&opts); mCoreConfigFreeOpts(&opts);
GBAConfigDeinit(&config); mCoreConfigDeinit(&config);
return 0; return 0;
} }
@ -103,10 +103,10 @@ int main(int argc, char** argv) {
} }
context.debugger = createDebugger(&args, &context); context.debugger = createDebugger(&args, &context);
context.overrides = GBAConfigGetOverrides(&config); context.overrides = mCoreConfigGetOverrides(&config);
char gameCode[5] = { 0 }; char gameCode[5] = { 0 };
GBAConfigMap(&config, &opts); mCoreConfigMap(&config, &opts);
opts.audioSync = false; opts.audioSync = false;
opts.videoSync = false; opts.videoSync = false;
GBAMapArgumentsToContext(&args, &context); GBAMapArgumentsToContext(&args, &context);
@ -158,9 +158,9 @@ cleanup:
if (_savestate) { if (_savestate) {
_savestate->close(_savestate); _savestate->close(_savestate);
} }
GBAConfigFreeOpts(&opts); mCoreConfigFreeOpts(&opts);
freeArguments(&args); freeArguments(&args);
GBAConfigDeinit(&config); mCoreConfigDeinit(&config);
free(context.debugger); free(context.debugger);
free(renderer.outputBuffer); free(renderer.outputBuffer);
@ -212,7 +212,7 @@ static void _GBAPerfShutdown(int signal) {
ConditionWake(&_thread->sync.videoFrameAvailableCond); 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); UNUSED(config);
struct PerfOpts* opts = parser->opts; struct PerfOpts* opts = parser->opts;
errno = 0; errno = 0;

View File

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