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

View File

@ -210,6 +210,15 @@ int mSDLRun(struct mSDLRenderer* renderer, struct mArguments* args) {
mCoreAutoloadSave(renderer->core); mCoreAutoloadSave(renderer->core);
// TODO: Create debugger // 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.samples = renderer->core->opts.audioBuffers;
renderer->audio.sampleRate = 44100; renderer->audio.sampleRate = 44100;