all repos — mgba @ 891a607507b3093985e1db427514820cbf926d2c

mGBA Game Boy Advance Emulator

GB, GBA: Unload cheats when unloading ROM
Jeffrey Pfau jeffrey@endrift.com
Mon, 19 Sep 2016 07:26:06 -0700
commit

891a607507b3093985e1db427514820cbf926d2c

parent

836051ee32a58a7190331bf4da0767459d00cc75

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

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

@@ -194,6 +194,14 @@ return true;

} static void _GBCoreUnloadROM(struct mCore* core) { + struct GBCore* gbcore = (struct GBCore*) core; + struct LR35902Core* cpu = core->cpu; + if (gbcore->cheatDevice) { + LR35902HotplugDetach(cpu, CPU_COMPONENT_CHEAT_DEVICE); + cpu->components[CPU_COMPONENT_CHEAT_DEVICE] = NULL; + mCheatDeviceDestroy(gbcore->cheatDevice); + gbcore->cheatDevice = NULL; + } return GBUnloadROM(core->board); }

@@ -455,7 +463,9 @@ }

static void _GBCoreDetachDebugger(struct mCore* core) { struct LR35902Core* cpu = core->cpu; - LR35902HotplugDetach(cpu, CPU_COMPONENT_DEBUGGER); + if (core->debugger) { + LR35902HotplugDetach(cpu, CPU_COMPONENT_DEBUGGER); + } cpu->components[CPU_COMPONENT_DEBUGGER] = NULL; core->debugger = NULL; }
M src/gba/core.csrc/gba/core.c

@@ -228,6 +228,14 @@ return true;

} static void _GBACoreUnloadROM(struct mCore* core) { + struct GBACore* gbacore = (struct GBACore*) core; + struct ARMCore* cpu = core->cpu; + if (gbacore->cheatDevice) { + ARMHotplugDetach(cpu, CPU_COMPONENT_CHEAT_DEVICE); + cpu->components[CPU_COMPONENT_CHEAT_DEVICE] = NULL; + mCheatDeviceDestroy(gbacore->cheatDevice); + gbacore->cheatDevice = NULL; + } return GBAUnloadROM(core->board); }