bool GBACheatAddLine(struct GBACheatSet* cheats, const char* line) { uint32_t op1; uint16_t op2; uint16_t op3; line = hex32(line, &op1); if (!line) { return false; } while (isspace((int) line[0])) { ++line; } line = hex16(line, &op2); if (!line) { return false; } if (!line[0] || isspace((int) line[0])) { return GBACheatAddCodeBreaker(cheats, op1, op2); } line = hex16(line, &op3); if (!line) { return false; } uint32_t realOp2 = op2; realOp2 <<= 16; realOp2 |= op3; return GBACheatAddAutodetect(cheats, op1, realOp2); }
bool GBACheatAddCodeBreakerLine(struct GBACheatSet* cheats, const char* line) { uint32_t op1; uint16_t op2; line = hex32(line, &op1); if (!line) { return false; } while (*line == ' ') { ++line; } line = hex16(line, &op2); if (!line) { return false; } return GBACheatAddCodeBreaker(cheats, op1, op2); }
bool GBACheatAddLine(struct mCheatSet* set, const char* line, int type) { struct GBACheatSet* cheats = (struct GBACheatSet*) set; switch (type) { case GBA_CHEAT_AUTODETECT: break; case GBA_CHEAT_CODEBREAKER: return GBACheatAddCodeBreakerLine(cheats, line); case GBA_CHEAT_GAMESHARK: return GBACheatAddGameSharkLine(cheats, line); case GBA_CHEAT_PRO_ACTION_REPLAY: return GBACheatAddProActionReplayLine(cheats, line); case GBA_CHEAT_VBA: return GBACheatAddVBALine(cheats, line); default: return false; } uint32_t op1; uint16_t op2; uint16_t op3; const char* lineNext = hex32(line, &op1); if (!lineNext) { return false; } if (lineNext[0] == ':') { return GBACheatAddVBALine(cheats, line); } while (isspace((int) lineNext[0])) { ++lineNext; } lineNext = hex16(lineNext, &op2); if (!lineNext) { return false; } if (!lineNext[0] || isspace((int) lineNext[0])) { return GBACheatAddCodeBreaker(cheats, op1, op2); } lineNext = hex16(lineNext, &op3); if (!lineNext) { return false; } uint32_t realOp2 = op2; realOp2 <<= 16; realOp2 |= op3; return GBACheatAddAutodetect(cheats, op1, realOp2); }