Libretro: Add Game Boy cheat support

This commit is contained in:
Vicki Pfau 2018-09-25 15:15:22 -07:00
parent ec4e2e80d9
commit 76366ae70a
2 changed files with 43 additions and 16 deletions

View File

@ -99,6 +99,8 @@ Misc:
- FFmpeg: Support lossless VP9 encoding - FFmpeg: Support lossless VP9 encoding
- mGUI: Add fast forward toggle - mGUI: Add fast forward toggle
Changes from beta 1: Changes from beta 1:
Features:
- Libretro: Add Game Boy cheat support
Bugfixes: Bugfixes:
- PSP2: Fix audio crackling after fast forward - PSP2: Fix audio crackling after fast forward
- PSP2: Fix audio crackling when buffer is full - PSP2: Fix audio crackling when buffer is full

View File

@ -605,24 +605,49 @@ void retro_cheat_set(unsigned index, bool enabled, const char* code) {
cheatSet = device->createSet(device, NULL); cheatSet = device->createSet(device, NULL);
mCheatAddSet(device, cheatSet); mCheatAddSet(device, cheatSet);
} }
// Convert the super wonky unportable libretro format to something normal // Convert the super wonky unportable libretro format to something normal
char realCode[] = "XXXXXXXX XXXXXXXX"; #ifdef M_CORE_GBA
size_t len = strlen(code) + 1; // Include null terminator if (core->platform(core) == PLATFORM_GBA) {
size_t i, pos; char realCode[] = "XXXXXXXX XXXXXXXX";
for (i = 0, pos = 0; i < len; ++i) { size_t len = strlen(code) + 1; // Include null terminator
if (isspace((int) code[i]) || code[i] == '+') { size_t i, pos;
realCode[pos] = ' '; for (i = 0, pos = 0; i < len; ++i) {
} else { if (isspace((int) code[i]) || code[i] == '+') {
realCode[pos] = code[i]; realCode[pos] = ' ';
} else {
realCode[pos] = code[i];
}
if ((pos == 13 && (realCode[pos] == ' ' || !realCode[pos])) || pos == 17) {
realCode[pos] = '\0';
mCheatAddLine(cheatSet, realCode, 0);
pos = 0;
continue;
}
++pos;
} }
if ((pos == 13 && (realCode[pos] == ' ' || !realCode[pos])) || pos == 17) {
realCode[pos] = '\0';
mCheatAddLine(cheatSet, realCode, 0);
pos = 0;
continue;
}
++pos;
} }
#endif
#ifdef M_CORE_GB
if (core->platform(core) == PLATFORM_GB) {
char realCode[] = "XXX-XXX-XXX";
size_t len = strlen(code) + 1; // Include null terminator
size_t i, pos;
for (i = 0, pos = 0; i < len; ++i) {
if (isspace((int) code[i]) || code[i] == '+') {
realCode[pos] = '\0';
} else {
realCode[pos] = code[i];
}
if (pos == 11 || !realCode[pos]) {
realCode[pos] = '\0';
mCheatAddLine(cheatSet, realCode, 0);
pos = 0;
continue;
}
++pos;
}
}
#endif
} }
unsigned retro_get_region(void) { unsigned retro_get_region(void) {