GBA Config: Add audio buffers and FPS target
Jeffrey Pfau jeffrey@endrift.com
Sun, 02 Nov 2014 02:34:16 -0800
3 files changed,
43 insertions(+),
0 deletions(-)
M
src/gba/gba-config.c
→
src/gba/gba-config.c
@@ -41,6 +41,34 @@ *out = value;
return true; } +static bool _lookupUIntValue(const struct Configuration* config, const char* key, const char* port, unsigned* out) { + const char* charValue = _lookupValue(config, key, port); + if (!charValue) { + return false; + } + char* end; + unsigned long value = strtoul(charValue, &end, 10); + if (*end) { + return false; + } + *out = value; + return true; +} + +static bool _lookupFloatValue(const struct Configuration* config, const char* key, const char* port, float* out) { + const char* charValue = _lookupValue(config, key, port); + if (!charValue) { + return false; + } + char* end; + float value = strtof(charValue, &end); + if (*end) { + return false; + } + *out = value; + return true; +} + bool GBAConfigLoad(struct Configuration* config) { return ConfigurationRead(config, BINARY_NAME ".ini"); }@@ -51,6 +79,11 @@ _lookupIntValue(config, "logLevel", port, &opts->logLevel);
_lookupIntValue(config, "frameskip", port, &opts->frameskip); _lookupIntValue(config, "rewindBufferCapacity", port, &opts->rewindBufferCapacity); _lookupIntValue(config, "rewindBufferInterval", port, &opts->rewindBufferInterval); + _lookupFloatValue(config, "fpsTarget", port, &opts->fpsTarget); + unsigned audioBuffers; + if (_lookupUIntValue(config, "audioBuffers", port, &audioBuffers)) { + opts->audioBuffers = audioBuffers; + } } void GBAConfigMapGraphicsOpts(const struct Configuration* config, const char* port, struct GBAOptions* opts) {
M
src/gba/gba-config.h
→
src/gba/gba-config.h
@@ -11,6 +11,8 @@ int logLevel;
int frameskip; int rewindBufferCapacity; int rewindBufferInterval; + float fpsTarget; + size_t audioBuffers; int fullscreen; int width;
M
src/gba/gba-thread.c
→
src/gba/gba-thread.c
@@ -226,6 +226,14 @@ threadContext->frameskip = opts->frameskip;
threadContext->logLevel = opts->logLevel; threadContext->rewindBufferCapacity = opts->rewindBufferCapacity; threadContext->rewindBufferInterval = opts->rewindBufferInterval; + + if (opts->fpsTarget) { + threadContext->fpsTarget = opts->fpsTarget; + } + + if (opts->audioBuffers) { + threadContext->audioBuffers = opts->audioBuffers; + } } void GBAMapArgumentsToContext(struct GBAArguments* args, struct GBAThread* threadContext) {