all repos — mgba @ 37d65d181ccdfd7d18a20fb8031f873fb95c0d12

mGBA Game Boy Advance Emulator

GBA Cheats: Totally ignore ROM patch limits for GameShark too (closes #990)
Vicki Pfau vi@endrift.com
Sun, 11 Feb 2018 23:46:24 -0800
commit

37d65d181ccdfd7d18a20fb8031f873fb95c0d12

parent

080d02e8d73787cecc0e6c347d28b73eaac09659

1 files changed, 11 insertions(+), 4 deletions(-)

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

@@ -90,6 +90,7 @@

bool GBACheatAddGameSharkRaw(struct GBACheatSet* cheats, uint32_t op1, uint32_t op2) { enum GBAGameSharkType type = op1 >> 28; struct mCheat* cheat = 0; + int romPatch = 0; if (cheats->incompleteCheat != COMPLETE) { struct mCheat* incompleteCheat = mCheatListGetPointer(&cheats->d.list, cheats->incompleteCheat);

@@ -145,10 +146,16 @@ cheat->address = op2;

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