Permalink
Browse files

GBA Cheats: Totally ignore ROM patch limits for GameShark too (closes #…

  • Loading branch information...
endrift committed Feb 12, 2018
1 parent 0e738e8 commit 1b601d005e3e1b5454f33c3022c76d055d188828
Showing with 11 additions and 4 deletions.
  1. +11 −4 src/gba/cheats/gameshark.c
View
@@ -93,6 +93,7 @@ void GBACheatSetGameSharkVersion(struct GBACheatSet* cheats, enum GBACheatGameSh
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);
@@ -148,10 +149,16 @@ bool GBACheatAddGameSharkRaw(struct GBACheatSet* cheats, uint32_t op1, uint32_t
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:
switch (op1 & 0x00F00000) {

0 comments on commit 1b601d0

Please sign in to comment.