Test: Use refactored argument handling

This commit is contained in:
Vicki Pfau 2023-11-24 22:22:01 -08:00
parent 18a35b3928
commit 569bc92b90
2 changed files with 8 additions and 31 deletions

View File

@ -100,9 +100,6 @@ int main(int argc, char** argv) {
cleanExit = false;
goto loadError;
}
if (args.patch) {
core->loadPatch(core, VFileOpen(args.patch, O_RDONLY));
}
struct VFile* savestate = 0;
struct VFile* savestateOverlay = 0;
@ -137,15 +134,7 @@ int main(int argc, char** argv) {
hasDebugger = true;
}
struct mCheatDevice* device;
if (args.cheatsFile && (device = core->cheatDevice(core))) {
struct VFile* vf = VFileOpen(args.cheatsFile, O_RDONLY);
if (vf) {
mCheatDeviceClear(device);
mCheatParseFile(device, vf);
vf->close(vf);
}
}
mArgumentsApplyFileLoads(&args, core);
if (savestate) {
if (!savestateOverlay) {

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2013-2022 Jeffrey Pfau
/* Copyright (c) 2013-2023 Jeffrey Pfau
* Copyright (c) 2022 Felix Jones
*
* This Source Code Form is subject to the terms of the Mozilla Public
@ -10,6 +10,7 @@
#include <mgba/core/core.h>
#include <mgba/core/log.h>
#include <mgba/core/serialize.h>
#include <mgba/debugger/debugger.h>
#ifdef M_CORE_GBA
#include <mgba/internal/gba/gba.h>
#endif
@ -137,28 +138,15 @@ int main(int argc, char * argv[]) {
if (!mCoreLoadFile(core, args.fname)) {
goto loadError;
}
if (args.patch) {
core->loadPatch(core, VFileOpen(args.patch, O_RDONLY));
}
struct VFile* savestate = NULL;
if (args.savestate) {
savestate = VFileOpen(args.savestate, O_RDONLY);
}
core->reset(core);
struct mCheatDevice* device;
if (args.cheatsFile && (device = core->cheatDevice(core))) {
struct VFile* vf = VFileOpen(args.cheatsFile, O_RDONLY);
if (vf) {
mCheatDeviceClear(device);
mCheatParseFile(device, vf);
vf->close(vf);
}
}
mArgumentsApplyFileLoads(&args, core);
struct VFile* savestate = NULL;
if (args.savestate) {
savestate = VFileOpen(args.savestate, O_RDONLY);
}
if (savestate) {
mCoreLoadStateNamed(core, savestate, 0);
savestate->close(savestate);