mirror of https://github.com/mgba-emu/mgba.git
GBA: Change how GameShark ROM patches work
This commit is contained in:
parent
2b92eab1b2
commit
05e18ac255
|
@ -227,13 +227,10 @@ static bool _addGSA1(struct GBACheatSet* cheats, uint32_t op1, uint32_t op2) {
|
||||||
cheats->incompleteCheat = cheat;
|
cheats->incompleteCheat = cheat;
|
||||||
break;
|
break;
|
||||||
case GSA_PATCH:
|
case GSA_PATCH:
|
||||||
if (cheats->nRomPatches >= MAX_ROM_PATCHES) {
|
cheats->romPatches[0].address = (op1 & 0xFFFFFF) << 1;
|
||||||
return false;
|
cheats->romPatches[0].newValue = op2;
|
||||||
}
|
cheats->romPatches[0].applied = false;
|
||||||
cheats->romPatches[cheats->nRomPatches].address = (op1 & 0xFFFFFF) << 1;
|
cheats->romPatches[0].exists = true;
|
||||||
cheats->romPatches[cheats->nRomPatches].newValue = op2;
|
|
||||||
cheats->romPatches[cheats->nRomPatches].applied = false;
|
|
||||||
++cheats->nRomPatches;
|
|
||||||
return true;
|
return true;
|
||||||
case GSA_BUTTON:
|
case GSA_BUTTON:
|
||||||
// TODO: Implement button
|
// TODO: Implement button
|
||||||
|
@ -298,8 +295,8 @@ static void _patchROM(struct GBACheatDevice* device) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < device->cheats->nRomPatches; ++i) {
|
for (i = 0; i < MAX_ROM_PATCHES; ++i) {
|
||||||
if (device->cheats->romPatches[i].applied) {
|
if (!device->cheats->romPatches[i].exists || device->cheats->romPatches[i].applied) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
GBAPatch16(device->p->cpu, device->cheats->romPatches[i].address, device->cheats->romPatches[i].newValue, &device->cheats->romPatches[i].oldValue);
|
GBAPatch16(device->p->cpu, device->cheats->romPatches[i].address, device->cheats->romPatches[i].newValue, &device->cheats->romPatches[i].oldValue);
|
||||||
|
@ -312,8 +309,8 @@ static void _unpatchROM(struct GBACheatDevice* device) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < device->cheats->nRomPatches; ++i) {
|
for (i = 0; i < MAX_ROM_PATCHES; ++i) {
|
||||||
if (!device->cheats->romPatches[i].applied) {
|
if (!device->cheats->romPatches[i].exists || !device->cheats->romPatches[i].applied) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
GBAPatch16(device->p->cpu, device->cheats->romPatches[i].address, device->cheats->romPatches[i].oldValue, 0);
|
GBAPatch16(device->p->cpu, device->cheats->romPatches[i].address, device->cheats->romPatches[i].oldValue, 0);
|
||||||
|
@ -338,6 +335,10 @@ void GBACheatSetInit(struct GBACheatSet* set) {
|
||||||
set->patchedOpcode = 0;
|
set->patchedOpcode = 0;
|
||||||
set->gsaVersion = 0;
|
set->gsaVersion = 0;
|
||||||
set->remainingAddresses = 0;
|
set->remainingAddresses = 0;
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < MAX_ROM_PATCHES; ++i) {
|
||||||
|
set->romPatches[i].exists = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBACheatSetDeinit(struct GBACheatSet* set) {
|
void GBACheatSetDeinit(struct GBACheatSet* set) {
|
||||||
|
|
|
@ -82,8 +82,8 @@ struct GBACheatSet {
|
||||||
int16_t newValue;
|
int16_t newValue;
|
||||||
int16_t oldValue;
|
int16_t oldValue;
|
||||||
bool applied;
|
bool applied;
|
||||||
|
bool exists;
|
||||||
} romPatches[MAX_ROM_PATCHES];
|
} romPatches[MAX_ROM_PATCHES];
|
||||||
int nRomPatches;
|
|
||||||
|
|
||||||
int gsaVersion;
|
int gsaVersion;
|
||||||
uint32_t gsaSeeds[4];
|
uint32_t gsaSeeds[4];
|
||||||
|
|
Loading…
Reference in New Issue