Gambatte: enabled cheat support
This commit is contained in:
@@ -406,4 +406,16 @@ static void writeSaveFile(const char* path, int type)
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)canCheat
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)setCheat:(NSString *)code setType:(NSString *)type setEnabled:(BOOL)enabled
|
||||
{
|
||||
const char *gsCode = [code UTF8String];
|
||||
const char *codeType = [type UTF8String];
|
||||
retro_cheat_set(nil, enabled, gsCode, codeType);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -139,7 +139,14 @@ bool retro_unserialize(const void *data, size_t size)
|
||||
}
|
||||
|
||||
void retro_cheat_reset() {}
|
||||
void retro_cheat_set(unsigned, bool, const char *) {}
|
||||
void retro_cheat_set(unsigned index, bool enabled, const char *code, const char *type)
|
||||
{
|
||||
if (!strcmp(type, "GameShark") || !strcmp(type, "Unknown"))
|
||||
gb.setGameShark(code);
|
||||
|
||||
if (!strcmp(type, "Game Genie"))
|
||||
gb.setGameGenie(code);
|
||||
}
|
||||
|
||||
static std::string basename(std::string filename)
|
||||
{
|
||||
|
||||
@@ -545,7 +545,7 @@ extern "C" {
|
||||
bool retro_unserialize(const void *data, size_t size);
|
||||
|
||||
void retro_cheat_reset(void);
|
||||
void retro_cheat_set(unsigned index, bool enabled, const char *code);
|
||||
void retro_cheat_set(unsigned index, bool enabled, const char *code, const char *type);
|
||||
|
||||
// Loads a game.
|
||||
bool retro_load_game(const struct retro_game_info *game);
|
||||
|
||||
@@ -50,7 +50,7 @@ void Interrupter::setGameShark(const std::string &codes) {
|
||||
std::string code;
|
||||
gsCodes.clear();
|
||||
|
||||
for (std::size_t pos = 0; pos < codes.length() && (code = codes.substr(pos, codes.find(';', pos) - pos), true); pos += code.length() + 1) {
|
||||
for (std::size_t pos = 0; pos < codes.length() && (code = codes.substr(pos, codes.find('+', pos) - pos), true); pos += code.length() + 1) {
|
||||
if (code.length() >= 8) {
|
||||
GsCode gs;
|
||||
gs.type = asHex(code[0]) << 4 | asHex(code[1]);
|
||||
|
||||
@@ -710,7 +710,7 @@ void Cartridge::setGameGenie(const std::string &codes) {
|
||||
|
||||
std::string code;
|
||||
for (std::size_t pos = 0; pos < codes.length()
|
||||
&& (code = codes.substr(pos, codes.find(';', pos) - pos), true); pos += code.length() + 1) {
|
||||
&& (code = codes.substr(pos, codes.find('+', pos) - pos), true); pos += code.length() + 1) {
|
||||
applyGameGenie(code);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user