all repos — mgba @ 469f2d99409718196858759c8691771055c5f725

mGBA Game Boy Advance Emulator

Test: Actually add CInema core config loading
Vicki Pfau vi@endrift.com
Thu, 25 Jun 2020 02:12:27 -0700
commit

469f2d99409718196858759c8691771055c5f725

parent

e1bd52a3d08b99168c586fc8d4d002be44965899

1 files changed, 30 insertions(+), 1 deletions(-)

jump to
M src/platform/test/cinema-main.csrc/platform/test/cinema-main.c

@@ -303,7 +303,36 @@ }

void CInemaConfigLoad(struct Table* configTree, const char* testName, struct mCore* core) { _loadConfigTree(configTree, testName); - // TODO: Write + + char testKey[MAX_TEST] = {0}; + char* keyEnd = testKey; + const char* pos; + while (true) { + pos = strchr(testName, '.'); + size_t maxlen = sizeof(testKey) - (keyEnd - testKey) - 1; + size_t len; + if (pos) { + len = pos - testName; + } else { + len = strlen(testName); + } + if (len > maxlen) { + len = maxlen; + } + strncpy(keyEnd, testName, len); + keyEnd += len; + + struct mCoreConfig* config = HashTableLookup(configTree, testKey); + if (config) { + core->loadConfig(core, config); + } + if (!pos) { + break; + } + testName = pos + 1; + keyEnd[0] = '.'; + ++keyEnd; + } } bool CInemaTestInit(struct CInemaTest* test, const char* directory, const char* filename) {