GBA Config: Add audio buffers and FPS target

This commit is contained in:
Jeffrey Pfau 2014-11-02 02:34:16 -08:00
parent 6afa678a41
commit a7dc4e3285
3 changed files with 43 additions and 0 deletions

View File

@ -41,6 +41,34 @@ static bool _lookupIntValue(const struct Configuration* config, const char* key,
return true; 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) { bool GBAConfigLoad(struct Configuration* config) {
return ConfigurationRead(config, BINARY_NAME ".ini"); 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, "frameskip", port, &opts->frameskip);
_lookupIntValue(config, "rewindBufferCapacity", port, &opts->rewindBufferCapacity); _lookupIntValue(config, "rewindBufferCapacity", port, &opts->rewindBufferCapacity);
_lookupIntValue(config, "rewindBufferInterval", port, &opts->rewindBufferInterval); _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) { void GBAConfigMapGraphicsOpts(const struct Configuration* config, const char* port, struct GBAOptions* opts) {

View File

@ -11,6 +11,8 @@ struct GBAOptions {
int frameskip; int frameskip;
int rewindBufferCapacity; int rewindBufferCapacity;
int rewindBufferInterval; int rewindBufferInterval;
float fpsTarget;
size_t audioBuffers;
int fullscreen; int fullscreen;
int width; int width;

View File

@ -226,6 +226,14 @@ void GBAMapOptionsToContext(struct GBAOptions* opts, struct GBAThread* threadCon
threadContext->logLevel = opts->logLevel; threadContext->logLevel = opts->logLevel;
threadContext->rewindBufferCapacity = opts->rewindBufferCapacity; threadContext->rewindBufferCapacity = opts->rewindBufferCapacity;
threadContext->rewindBufferInterval = opts->rewindBufferInterval; 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) { void GBAMapArgumentsToContext(struct GBAArguments* args, struct GBAThread* threadContext) {