From a7dc4e3285a6e617e2c16bec95dd922b551f4b98 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 2 Nov 2014 02:34:16 -0800 Subject: [PATCH] GBA Config: Add audio buffers and FPS target --- src/gba/gba-config.c | 33 +++++++++++++++++++++++++++++++++ src/gba/gba-config.h | 2 ++ src/gba/gba-thread.c | 8 ++++++++ 3 files changed, 43 insertions(+) diff --git a/src/gba/gba-config.c b/src/gba/gba-config.c index be8338c31..0c7bd8dfd 100644 --- a/src/gba/gba-config.c +++ b/src/gba/gba-config.c @@ -41,6 +41,34 @@ static bool _lookupIntValue(const struct Configuration* config, const char* key, 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 @@ void GBAConfigMapGeneralOpts(const struct Configuration* config, const char* por _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) { diff --git a/src/gba/gba-config.h b/src/gba/gba-config.h index 8f89e6b87..99b7d4af5 100644 --- a/src/gba/gba-config.h +++ b/src/gba/gba-config.h @@ -11,6 +11,8 @@ struct GBAOptions { int frameskip; int rewindBufferCapacity; int rewindBufferInterval; + float fpsTarget; + size_t audioBuffers; int fullscreen; int width; diff --git a/src/gba/gba-thread.c b/src/gba/gba-thread.c index 4eb8676b6..746b2b571 100644 --- a/src/gba/gba-thread.c +++ b/src/gba/gba-thread.c @@ -226,6 +226,14 @@ void GBAMapOptionsToContext(struct GBAOptions* opts, struct GBAThread* threadCon 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) {