mirror of https://github.com/mgba-emu/mgba.git
GBA Config: Add "override" layer for better one-time configuration
This commit is contained in:
parent
9f5bfeeebb
commit
3f36f3d88e
1
CHANGES
1
CHANGES
|
@ -38,6 +38,7 @@ Misc:
|
|||
- All: Reset next event to cycles instead of zero to interrupt
|
||||
- GBA Video: Remove lastHblank, as it is implied
|
||||
- GBA: Check for cycle count being too high
|
||||
- GBA Config: Add "override" layer for better one-time configuration`
|
||||
|
||||
0.3.0: (2015-08-16)
|
||||
Features:
|
||||
|
|
|
@ -30,6 +30,16 @@
|
|||
|
||||
static const char* _lookupValue(const struct GBAConfig* config, const char* key) {
|
||||
const char* value;
|
||||
if (config->port) {
|
||||
value = ConfigurationGetValue(&config->overridesTable, config->port, key);
|
||||
if (value) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
value = ConfigurationGetValue(&config->overridesTable, 0, key);
|
||||
if (value) {
|
||||
return value;
|
||||
}
|
||||
if (config->port) {
|
||||
value = ConfigurationGetValue(&config->configTable, config->port, key);
|
||||
if (value) {
|
||||
|
@ -106,6 +116,7 @@ static bool _lookupFloatValue(const struct GBAConfig* config, const char* key, f
|
|||
void GBAConfigInit(struct GBAConfig* config, const char* port) {
|
||||
ConfigurationInit(&config->configTable);
|
||||
ConfigurationInit(&config->defaultsTable);
|
||||
ConfigurationInit(&config->overridesTable);
|
||||
if (port) {
|
||||
config->port = malloc(strlen("ports.") + strlen(port) + 1);
|
||||
snprintf(config->port, strlen("ports.") + strlen(port) + 1, "ports.%s", port);
|
||||
|
@ -117,6 +128,7 @@ void GBAConfigInit(struct GBAConfig* config, const char* port) {
|
|||
void GBAConfigDeinit(struct GBAConfig* config) {
|
||||
ConfigurationDeinit(&config->configTable);
|
||||
ConfigurationDeinit(&config->defaultsTable);
|
||||
ConfigurationDeinit(&config->overridesTable);
|
||||
free(config->port);
|
||||
}
|
||||
|
||||
|
@ -268,6 +280,22 @@ void GBAConfigSetDefaultFloatValue(struct GBAConfig* config, const char* key, fl
|
|||
ConfigurationSetFloatValue(&config->defaultsTable, config->port, key, value);
|
||||
}
|
||||
|
||||
void GBAConfigSetOverrideValue(struct GBAConfig* config, const char* key, const char* value) {
|
||||
ConfigurationSetValue(&config->overridesTable, config->port, key, value);
|
||||
}
|
||||
|
||||
void GBAConfigSetOverrideIntValue(struct GBAConfig* config, const char* key, int value) {
|
||||
ConfigurationSetIntValue(&config->overridesTable, config->port, key, value);
|
||||
}
|
||||
|
||||
void GBAConfigSetOverrideUIntValue(struct GBAConfig* config, const char* key, unsigned value) {
|
||||
ConfigurationSetUIntValue(&config->overridesTable, config->port, key, value);
|
||||
}
|
||||
|
||||
void GBAConfigSetOverrideFloatValue(struct GBAConfig* config, const char* key, float value) {
|
||||
ConfigurationSetFloatValue(&config->overridesTable, config->port, key, value);
|
||||
}
|
||||
|
||||
void GBAConfigMap(const struct GBAConfig* config, struct GBAOptions* opts) {
|
||||
_lookupCharValue(config, "bios", &opts->bios);
|
||||
_lookupIntValue(config, "logLevel", &opts->logLevel);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
struct GBAConfig {
|
||||
struct Configuration configTable;
|
||||
struct Configuration defaultsTable;
|
||||
struct Configuration overridesTable;
|
||||
char* port;
|
||||
};
|
||||
|
||||
|
@ -73,6 +74,11 @@ 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);
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ bool parseArguments(struct GBAArguments* opts, struct GBAConfig* config, int arg
|
|||
while ((ch = getopt_long(argc, argv, options, _options, 0)) != -1) {
|
||||
switch (ch) {
|
||||
case 'b':
|
||||
GBAConfigSetDefaultValue(config, "bios", optarg);
|
||||
GBAConfigSetOverrideValue(config, "bios", optarg);
|
||||
break;
|
||||
case 'c':
|
||||
opts->cheatsFile = strdup(optarg);
|
||||
|
@ -99,13 +99,13 @@ bool parseArguments(struct GBAArguments* opts, struct GBAConfig* config, int arg
|
|||
opts->showHelp = true;
|
||||
break;
|
||||
case 'l':
|
||||
GBAConfigSetDefaultValue(config, "logLevel", optarg);
|
||||
GBAConfigSetOverrideValue(config, "logLevel", optarg);
|
||||
break;
|
||||
case 'p':
|
||||
opts->patch = strdup(optarg);
|
||||
break;
|
||||
case 's':
|
||||
GBAConfigSetDefaultValue(config, "frameskip", optarg);
|
||||
GBAConfigSetOverrideValue(config, "frameskip", optarg);
|
||||
break;
|
||||
case 'v':
|
||||
opts->movie = strdup(optarg);
|
||||
|
@ -154,7 +154,7 @@ bool _parseGraphicsArg(struct SubParser* parser, struct GBAConfig* config, int o
|
|||
switch (option) {
|
||||
case 'f':
|
||||
graphicsOpts->fullscreen = true;
|
||||
GBAConfigSetDefaultIntValue(config, "fullscreen", 1);
|
||||
GBAConfigSetOverrideIntValue(config, "fullscreen", 1);
|
||||
return true;
|
||||
case '1':
|
||||
case '2':
|
||||
|
@ -166,8 +166,8 @@ bool _parseGraphicsArg(struct SubParser* parser, struct GBAConfig* config, int o
|
|||
return false;
|
||||
}
|
||||
graphicsOpts->multiplier = option - '0';
|
||||
GBAConfigSetDefaultIntValue(config, "width", VIDEO_HORIZONTAL_PIXELS * graphicsOpts->multiplier);
|
||||
GBAConfigSetDefaultIntValue(config, "height", VIDEO_VERTICAL_PIXELS * graphicsOpts->multiplier);
|
||||
GBAConfigSetOverrideIntValue(config, "width", VIDEO_HORIZONTAL_PIXELS * graphicsOpts->multiplier);
|
||||
GBAConfigSetOverrideIntValue(config, "height", VIDEO_VERTICAL_PIXELS * graphicsOpts->multiplier);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue