Merge pull request #379 from negativeExponent/fix_cheat_support
Cheat: Add raw format and multiline cheat support
This commit is contained in:
@@ -1966,25 +1966,45 @@ 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 name[256];
|
char name[256];
|
||||||
|
char temp[256];
|
||||||
|
char *codepart;
|
||||||
uint16 a;
|
uint16 a;
|
||||||
uint8 v;
|
uint8 v;
|
||||||
int c;
|
int c;
|
||||||
int type = 1;
|
int type = 1;
|
||||||
sprintf(name, "N/A");
|
int ret = 0;
|
||||||
|
|
||||||
if (FCEUI_DecodeGG(code, &a, &v, &c))
|
|
||||||
goto input_cheat;
|
|
||||||
|
|
||||||
/* Not a Game Genie code. */
|
|
||||||
|
|
||||||
if (FCEUI_DecodePAR(code, &a, &v, &c, &type))
|
|
||||||
goto input_cheat;
|
|
||||||
|
|
||||||
/* Not a Pro Action Replay code. */
|
|
||||||
|
|
||||||
|
if (code == NULL)
|
||||||
return;
|
return;
|
||||||
input_cheat:
|
|
||||||
|
sprintf(name, "N/A");
|
||||||
|
strcpy(temp, code);
|
||||||
|
codepart = strtok(temp, "+,;._ ");
|
||||||
|
|
||||||
|
while (codepart)
|
||||||
|
{
|
||||||
|
if ((strlen(codepart) == 7) && (codepart[4]==':'))
|
||||||
|
{
|
||||||
|
/* raw code format */
|
||||||
|
c = -1;
|
||||||
|
codepart[4] = '\0';
|
||||||
|
a = strtoul(codepart, NULL, 16);
|
||||||
|
v = strtoul(codepart + 5, NULL, 16);
|
||||||
FCEUI_AddCheat(name, a, v, c, type);
|
FCEUI_AddCheat(name, a, v, c, type);
|
||||||
|
log_cb.log(RETRO_LOG_DEBUG, "Cheat code added: '%s' (Raw)\n", codepart);
|
||||||
|
}
|
||||||
|
else if (FCEUI_DecodeGG(codepart, &a, &v, &c))
|
||||||
|
{
|
||||||
|
FCEUI_AddCheat(name, a, v, c, type);
|
||||||
|
log_cb.log(RETRO_LOG_DEBUG, "Cheat code added: '%s' (GG)\n", codepart);
|
||||||
|
}
|
||||||
|
else if (FCEUI_DecodePAR(codepart, &a, &v, &c, &type))
|
||||||
|
{
|
||||||
|
FCEUI_AddCheat(name, a, v, c, type);
|
||||||
|
log_cb.log(RETRO_LOG_DEBUG, "Cheat code added: '%s' (PAR)\n", codepart);
|
||||||
|
}
|
||||||
|
codepart = strtok(NULL,"+,;._ ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct cartridge_db
|
typedef struct cartridge_db
|
||||||
|
|||||||
Reference in New Issue
Block a user