SDL: Add back patch loading

This commit is contained in:
Jeffrey Pfau 2016-02-04 22:25:04 -08:00
parent a718a08e47
commit 1768721e7e
2 changed files with 19 additions and 5 deletions

View File

@ -12,6 +12,7 @@
#include "gba/renderers/video-software.h"
#include "gba/serialize.h"
#include "util/memory.h"
#include "util/patch.h"
#include "util/vfs.h"
struct GBACore {
@ -123,11 +124,15 @@ static bool _GBACoreLoadSave(struct mCore* core, struct VFile* vf) {
}
static bool _GBACoreLoadPatch(struct mCore* core, struct VFile* vf) {
// TODO
UNUSED(core);
UNUSED(vf);
mLOG(GBA, STUB, "Patches are not yet supported");
return false;
if (!vf) {
return false;
}
struct Patch patch;
if (!loadPatch(vf, &patch)) {
return false;
}
GBAApplyPatch(core->board, &patch);
return true;
}
static void _GBACoreUnloadROM(struct mCore* core) {

View File

@ -210,6 +210,15 @@ int mSDLRun(struct mSDLRenderer* renderer, struct mArguments* args) {
mCoreAutoloadSave(renderer->core);
// TODO: Create debugger
if (args->patch) {
struct VFile* patch = VFileOpen(args->patch, O_RDONLY);
if (patch) {
renderer->core->loadPatch(renderer->core, patch);
}
} else {
mCoreAutoloadPatch(renderer->core);
}
renderer->audio.samples = renderer->core->opts.audioBuffers;
renderer->audio.sampleRate = 44100;