mirror of https://github.com/mgba-emu/mgba.git
Test: Add rudimentary input playback
This commit is contained in:
parent
18ea9502cd
commit
57530a32b4
|
@ -427,7 +427,7 @@ static void _unloadConfigTree(const char* key, void* value, void* user) {
|
||||||
mCoreConfigDeinit(value);
|
mCoreConfigDeinit(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* _lookupValue(struct Table* configTree, const char* testName, const char* key) {
|
static const char* CInemaConfigGet(struct Table* configTree, const char* testName, const char* key) {
|
||||||
_loadConfigTree(configTree, testName);
|
_loadConfigTree(configTree, testName);
|
||||||
|
|
||||||
char testKey[MAX_TEST];
|
char testKey[MAX_TEST];
|
||||||
|
@ -456,7 +456,7 @@ static const char* _lookupValue(struct Table* configTree, const char* testName,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInemaConfigGetUInt(struct Table* configTree, const char* testName, const char* key, unsigned* out) {
|
bool CInemaConfigGetUInt(struct Table* configTree, const char* testName, const char* key, unsigned* out) {
|
||||||
const char* charValue = _lookupValue(configTree, testName, key);
|
const char* charValue = CInemaConfigGet(configTree, testName, key);
|
||||||
if (!charValue) {
|
if (!charValue) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -672,6 +672,29 @@ static void _writeBaseline(struct VDir* dir, const struct CInemaImage* image, si
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool _updateInput(struct mCore* core, size_t frame, const char** input) {
|
||||||
|
if (!*input || !*input[0]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
char* end;
|
||||||
|
uint32_t start = strtoul(*input, &end, 10);
|
||||||
|
if (end[0] != ':') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (start != frame) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
++end;
|
||||||
|
*input = end;
|
||||||
|
uint32_t keys = strtoul(*input, &end, 16);
|
||||||
|
if (end[0] == ',') {
|
||||||
|
++end;
|
||||||
|
}
|
||||||
|
*input = end;
|
||||||
|
core->setKeys(core, keys);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void CInemaTestRun(struct CInemaTest* test) {
|
void CInemaTestRun(struct CInemaTest* test) {
|
||||||
unsigned ignore = 0;
|
unsigned ignore = 0;
|
||||||
MutexLock(&configMutex);
|
MutexLock(&configMutex);
|
||||||
|
@ -724,12 +747,14 @@ void CInemaTestRun(struct CInemaTest* test) {
|
||||||
unsigned skip = 0;
|
unsigned skip = 0;
|
||||||
unsigned fail = 0;
|
unsigned fail = 0;
|
||||||
unsigned video = 0;
|
unsigned video = 0;
|
||||||
|
const char* input = NULL;
|
||||||
|
|
||||||
MutexLock(&configMutex);
|
MutexLock(&configMutex);
|
||||||
CInemaConfigGetUInt(&configTree, test->name, "frames", &limit);
|
CInemaConfigGetUInt(&configTree, test->name, "frames", &limit);
|
||||||
CInemaConfigGetUInt(&configTree, test->name, "skip", &skip);
|
CInemaConfigGetUInt(&configTree, test->name, "skip", &skip);
|
||||||
CInemaConfigGetUInt(&configTree, test->name, "fail", &fail);
|
CInemaConfigGetUInt(&configTree, test->name, "fail", &fail);
|
||||||
CInemaConfigGetUInt(&configTree, test->name, "video", &video);
|
CInemaConfigGetUInt(&configTree, test->name, "video", &video);
|
||||||
|
input = CInemaConfigGet(&configTree, test->name, "input");
|
||||||
CInemaConfigLoad(&configTree, test->name, core);
|
CInemaConfigLoad(&configTree, test->name, core);
|
||||||
MutexUnlock(&configMutex);
|
MutexUnlock(&configMutex);
|
||||||
|
|
||||||
|
@ -805,6 +830,7 @@ void CInemaTestRun(struct CInemaTest* test) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (frame = 0; limit; ++frame, --limit) {
|
for (frame = 0; limit; ++frame, --limit) {
|
||||||
|
_updateInput(core, frame, &input);
|
||||||
core->runFrame(core);
|
core->runFrame(core);
|
||||||
++test->totalFrames;
|
++test->totalFrames;
|
||||||
unsigned frameCounter = core->frameCounter(core);
|
unsigned frameCounter = core->frameCounter(core);
|
||||||
|
|
Loading…
Reference in New Issue