all repos — mgba @ 05e18ac25573cd3eaa443867ce5e9be06d54fcb7

mGBA Game Boy Advance Emulator

GBA: Change how GameShark ROM patches work
Jeffrey Pfau jeffrey@endrift.com
Sun, 08 Feb 2015 21:03:05 -0800
commit

05e18ac25573cd3eaa443867ce5e9be06d54fcb7

parent

2b92eab1b2a4c9b6bed60f36bd60ba7ddb200006

2 files changed, 13 insertions(+), 12 deletions(-)

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

@@ -227,13 +227,10 @@ cheat->address = op2;

cheats->incompleteCheat = cheat; break; case GSA_PATCH: - if (cheats->nRomPatches >= MAX_ROM_PATCHES) { - return false; - } - cheats->romPatches[cheats->nRomPatches].address = (op1 & 0xFFFFFF) << 1; - cheats->romPatches[cheats->nRomPatches].newValue = op2; - cheats->romPatches[cheats->nRomPatches].applied = false; - ++cheats->nRomPatches; + cheats->romPatches[0].address = (op1 & 0xFFFFFF) << 1; + cheats->romPatches[0].newValue = op2; + cheats->romPatches[0].applied = false; + cheats->romPatches[0].exists = true; return true; case GSA_BUTTON: // TODO: Implement button

@@ -298,8 +295,8 @@ if (!device->cheats || !device->p) {

return; } int i; - for (i = 0; i < device->cheats->nRomPatches; ++i) { - if (device->cheats->romPatches[i].applied) { + for (i = 0; i < MAX_ROM_PATCHES; ++i) { + if (!device->cheats->romPatches[i].exists || device->cheats->romPatches[i].applied) { continue; } GBAPatch16(device->p->cpu, device->cheats->romPatches[i].address, device->cheats->romPatches[i].newValue, &device->cheats->romPatches[i].oldValue);

@@ -312,8 +309,8 @@ if (!device->cheats || !device->p) {

return; } int i; - for (i = 0; i < device->cheats->nRomPatches; ++i) { - if (!device->cheats->romPatches[i].applied) { + for (i = 0; i < MAX_ROM_PATCHES; ++i) { + if (!device->cheats->romPatches[i].exists || !device->cheats->romPatches[i].applied) { continue; } GBAPatch16(device->p->cpu, device->cheats->romPatches[i].address, device->cheats->romPatches[i].oldValue, 0);

@@ -338,6 +335,10 @@ set->incompleteCheat = 0;

set->patchedOpcode = 0; set->gsaVersion = 0; set->remainingAddresses = 0; + int i; + for (i = 0; i < MAX_ROM_PATCHES; ++i) { + set->romPatches[i].exists = false; + } } void GBACheatSetDeinit(struct GBACheatSet* set) {
M src/gba/cheats.hsrc/gba/cheats.h

@@ -82,8 +82,8 @@ uint32_t address;

int16_t newValue; int16_t oldValue; bool applied; + bool exists; } romPatches[MAX_ROM_PATCHES]; - int nRomPatches; int gsaVersion; uint32_t gsaSeeds[4];