mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2025-01-14 12:19:06 +01:00
Add support for multiline cheats delimited with "+" signs.
This commit is contained in:
parent
a8ac6adc59
commit
7093f1b7b2
@ -1892,32 +1892,51 @@ 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)
|
||||||
{
|
{
|
||||||
|
char codeCopy[256];
|
||||||
|
char *buff;
|
||||||
|
bool multiline=0;
|
||||||
|
|
||||||
/* clear existing ROM patches */
|
/* clear existing ROM patches */
|
||||||
clear_cheats();
|
clear_cheats();
|
||||||
|
|
||||||
/* interpret code and check if this is a valid cheat code */
|
/* Detect and split multiline cheats */
|
||||||
if (decode_cheat((char *)code, maxcheats))
|
strcpy(codeCopy,code);
|
||||||
{
|
if (strstr(code,"+")){
|
||||||
int i;
|
multiline=1;
|
||||||
|
buff = strtok(codeCopy,"+");
|
||||||
|
} else {
|
||||||
|
buff=codeCopy;
|
||||||
|
}
|
||||||
|
|
||||||
/* check if cheat code already exists */
|
while (buff != NULL)
|
||||||
for (i=0; i<maxcheats; i++)
|
{
|
||||||
|
/* interpret code and check if this is a valid cheat code */
|
||||||
|
if (decode_cheat((char *)buff, maxcheats))
|
||||||
{
|
{
|
||||||
if ((cheatlist[i].address == cheatlist[maxcheats].address)
|
int i;
|
||||||
&& (cheatlist[i].data == cheatlist[maxcheats].data))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* cheat can be enabled or disabled */
|
/* check if cheat code already exists */
|
||||||
cheatlist[i].enable = enabled;
|
for (i=0; i<maxcheats; i++)
|
||||||
|
{
|
||||||
|
if ((cheatlist[i].address == cheatlist[maxcheats].address)
|
||||||
|
&& (cheatlist[i].data == cheatlist[maxcheats].data))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* if new cheat code, check current cheat count */
|
/* cheat can be enabled or disabled */
|
||||||
if ((i == maxcheats) && (i < MAX_CHEATS))
|
cheatlist[i].enable = enabled;
|
||||||
{
|
|
||||||
/* increment cheat count */
|
/* if new cheat code, check current cheat count */
|
||||||
maxcheats++;
|
if ((i == maxcheats) && (i < MAX_CHEATS))
|
||||||
|
{
|
||||||
|
/* increment cheat count */
|
||||||
|
maxcheats++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (!multiline)
|
||||||
|
break;
|
||||||
|
buff = strtok(NULL,"+");
|
||||||
|
}
|
||||||
|
|
||||||
/* apply ROM patches */
|
/* apply ROM patches */
|
||||||
apply_cheats();
|
apply_cheats();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user