GB, GBA: Unload cheats when unloading ROM
Jeffrey Pfau jeffrey@endrift.com
Mon, 19 Sep 2016 07:26:06 -0700
2 files changed,
19 insertions(+),
1 deletions(-)
M
src/gb/core.c
→
src/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.c
→
src/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); }