From 56f08ab6bab895ad4fb76976b538dba144fdce9f Mon Sep 17 00:00:00 2001 From: Dana Yatsuta Date: Fri, 11 Nov 2022 23:33:16 +0300 Subject: [PATCH] Load shader from command line --- include/mgba/feature/commandline.h | 1 + src/feature/commandline.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/mgba/feature/commandline.h b/include/mgba/feature/commandline.h index 0f9c543d1..472fb2d83 100644 --- a/include/mgba/feature/commandline.h +++ b/include/mgba/feature/commandline.h @@ -20,6 +20,7 @@ struct mArguments { char* cheatsFile; char* savestate; char* bios; + char* shader; int logLevel; int frameskip; diff --git a/src/feature/commandline.c b/src/feature/commandline.c index 72e5f6c26..d9cc15ea3 100644 --- a/src/feature/commandline.c +++ b/src/feature/commandline.c @@ -37,6 +37,7 @@ static const struct option _options[] = { { "log-level", required_argument, 0, 'l' }, { "savestate", required_argument, 0, 't' }, { "patch", required_argument, 0, 'p' }, + { "shader", required_argument, 0, 'a'}, { "version", no_argument, 0, '\0' }, { 0, 0, 0, 0 } }; @@ -71,7 +72,7 @@ static void _tableApply(const char* key, void* value, void* user) { bool mArgumentsParse(struct mArguments* args, int argc, char* const* argv, struct mSubParser* subparsers, int nSubparsers) { int ch; char options[128] = - "b:c:C:hl:p:s:t:" + "b:c:C:hl:p:s:t:a:" #ifdef USE_EDITLINE "d" #endif @@ -166,6 +167,9 @@ bool mArgumentsParse(struct mArguments* args, int argc, char* const* argv, struc case 't': args->savestate = strdup(optarg); break; + case 'a': + args->shader = strdup(optarg); + break; default: for (i = 0; i < nSubparsers; ++i) { if (subparsers[i].parse) { @@ -201,6 +205,9 @@ void mArgumentsApply(const struct mArguments* args, struct mSubParser* subparser mCoreConfigSetOverrideValue(config, "bios", args->bios); mCoreConfigSetOverrideIntValue(config, "useBios", true); } + if (args->shader) { + mCoreConfigSetOverrideValue(config, "shader", args->shader); + } HashTableEnumerate(&args->configOverrides, _tableApply, config); int i; for (i = 0; i < nSubparsers; ++i) { @@ -226,6 +233,9 @@ void mArgumentsDeinit(struct mArguments* args) { free(args->bios); args->bios = 0; + free(args->shader); + args->shader = 0; + HashTableDeinit(&args->configOverrides); }