mirror of https://github.com/mgba-emu/mgba.git
GBA: Split out autodetected version cheats from GameShark cheats
This commit is contained in:
parent
0bd9ae087e
commit
c8d3488804
|
@ -575,6 +575,37 @@ bool GBACheatAddCodeBreakerLine(struct GBACheatSet* cheats, const char* line) {
|
|||
}
|
||||
|
||||
bool GBACheatAddGameShark(struct GBACheatSet* set, uint32_t op1, uint32_t op2) {
|
||||
uint32_t o1 = op1;
|
||||
uint32_t o2 = op2;
|
||||
switch (set->gsaVersion) {
|
||||
case 0:
|
||||
_setGameSharkVersion(set, 1);
|
||||
// Fall through
|
||||
case 1:
|
||||
_decryptGameShark(&o1, &o2, set->gsaSeeds);
|
||||
return _addGSA1(set, o1, o2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GBACheatAddGameSharkLine(struct GBACheatSet* cheats, const char* line) {
|
||||
uint32_t op1;
|
||||
uint32_t op2;
|
||||
line = _hex32(line, &op1);
|
||||
if (!line) {
|
||||
return false;
|
||||
}
|
||||
while (*line == ' ') {
|
||||
++line;
|
||||
}
|
||||
line = _hex32(line, &op2);
|
||||
if (!line) {
|
||||
return false;
|
||||
}
|
||||
return GBACheatAddGameShark(cheats, op1, op2);
|
||||
}
|
||||
|
||||
bool GBACheatAddAutodetect(struct GBACheatSet* set, uint32_t op1, uint32_t op2) {
|
||||
uint32_t o1 = op1;
|
||||
uint32_t o2 = op2;
|
||||
switch (set->gsaVersion) {
|
||||
|
@ -603,7 +634,7 @@ bool GBACheatAddGameShark(struct GBACheatSet* set, uint32_t op1, uint32_t op2) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool GBACheatAddGameSharkLine(struct GBACheatSet* cheats, const char* line) {
|
||||
bool GBACheatAutodetectLine(struct GBACheatSet* cheats, const char* line) {
|
||||
uint32_t op1;
|
||||
uint32_t op2;
|
||||
line = _hex32(line, &op1);
|
||||
|
@ -617,7 +648,7 @@ bool GBACheatAddGameSharkLine(struct GBACheatSet* cheats, const char* line) {
|
|||
if (!line) {
|
||||
return false;
|
||||
}
|
||||
return GBACheatAddGameShark(cheats, op1, op2);
|
||||
return GBACheatAddAutodetect(cheats, op1, op2);
|
||||
}
|
||||
|
||||
bool GBACheatParseFile(struct GBACheatDevice* device, struct VFile* vf) {
|
||||
|
@ -707,7 +738,7 @@ bool GBACheatAddLine(struct GBACheatSet* cheats, const char* line) {
|
|||
uint32_t realOp2 = op2;
|
||||
realOp2 <<= 16;
|
||||
realOp2 |= op3;
|
||||
return GBACheatAddGameShark(cheats, op1, realOp2);
|
||||
return GBACheatAddAutodetect(cheats, op1, realOp2);
|
||||
}
|
||||
|
||||
void GBACheatRefresh(struct GBACheatDevice* device, struct GBACheatSet* cheats) {
|
||||
|
|
|
@ -192,6 +192,9 @@ bool GBACheatAddCodeBreakerLine(struct GBACheatSet*, const char* line);
|
|||
bool GBACheatAddGameShark(struct GBACheatSet*, uint32_t op1, uint32_t op2);
|
||||
bool GBACheatAddGameSharkLine(struct GBACheatSet*, const char* line);
|
||||
|
||||
bool GBACheatAddAutodetect(struct GBACheatSet*, uint32_t op1, uint32_t op2);
|
||||
bool GBACheatAddAutodetectLine(struct GBACheatSet*, const char* line);
|
||||
|
||||
bool GBACheatParseFile(struct GBACheatDevice*, struct VFile*);
|
||||
bool GBACheatAddLine(struct GBACheatSet*, const char* line);
|
||||
|
||||
|
|
Loading…
Reference in New Issue