Add support for multiline cheats delimited with "+" signs.

This commit is contained in:
iLag 2017-03-23 11:19:23 -07:00
parent a8ac6adc59
commit 7093f1b7b2

View File

@ -1892,11 +1892,26 @@ void retro_cheat_reset(void)
void retro_cheat_set(unsigned index, bool enabled, const char *code)
{
char codeCopy[256];
char *buff;
bool multiline=0;
/* clear existing ROM patches */
clear_cheats();
/* Detect and split multiline cheats */
strcpy(codeCopy,code);
if (strstr(code,"+")){
multiline=1;
buff = strtok(codeCopy,"+");
} else {
buff=codeCopy;
}
while (buff != NULL)
{
/* interpret code and check if this is a valid cheat code */
if (decode_cheat((char *)code, maxcheats))
if (decode_cheat((char *)buff, maxcheats))
{
int i;
@ -1917,6 +1932,10 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code)
/* increment cheat count */
maxcheats++;
}
}
if (!multiline)
break;
buff = strtok(NULL,"+");
}
/* apply ROM patches */