all repos — mgba @ 1768721e7e2669373f5472ab56690cc9b0904097

mGBA Game Boy Advance Emulator

SDL: Add back patch loading
Jeffrey Pfau jeffrey@endrift.com
Thu, 04 Feb 2016 22:25:04 -0800
commit

1768721e7e2669373f5472ab56690cc9b0904097

parent

a718a08e470457910f751448d6d76d26e3940cf2

2 files changed, 19 insertions(+), 5 deletions(-)

jump to
M src/gba/core.csrc/gba/core.c

@@ -12,6 +12,7 @@ #include "gba/context/overrides.h"

#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 @@ return GBALoadSave(core->board, 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) {
M src/platform/sdl/main.csrc/platform/sdl/main.c

@@ -210,6 +210,15 @@ }

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;