all repos — mgba @ a7dc4e3285a6e617e2c16bec95dd922b551f4b98

mGBA Game Boy Advance Emulator

GBA Config: Add audio buffers and FPS target
Jeffrey Pfau jeffrey@endrift.com
Sun, 02 Nov 2014 02:34:16 -0800
commit

a7dc4e3285a6e617e2c16bec95dd922b551f4b98

parent

6afa678a41545ab0ab4255e10fe25cb56dbbcd37

3 files changed, 43 insertions(+), 0 deletions(-)

jump to
M src/gba/gba-config.csrc/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.hsrc/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.csrc/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) {