(Untested) Implement cheats
This commit is contained in:
23
src/cheat.c
23
src/cheat.c
@@ -302,6 +302,29 @@ void FCEU_FlushGameCheats(FILE *override, int nosave) {
|
|||||||
RebuildSubCheats(); /* Remove memory handlers. */
|
RebuildSubCheats(); /* Remove memory handlers. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FCEU_ResetCheats(void)
|
||||||
|
{
|
||||||
|
if (CheatComp) {
|
||||||
|
free(CheatComp);
|
||||||
|
CheatComp = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cheats)
|
||||||
|
{
|
||||||
|
struct CHEATF *next = cheats;
|
||||||
|
for (;; ) {
|
||||||
|
struct CHEATF *last = next;
|
||||||
|
next = next->next;
|
||||||
|
free(last->name);
|
||||||
|
free(last);
|
||||||
|
if (!next) break;
|
||||||
|
}
|
||||||
|
cheats = cheatsl = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
RebuildSubCheats(); /* Remove memory handlers. */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int FCEUI_AddCheat(const char *name, uint32 addr, uint8 val, int compare, int type) {
|
int FCEUI_AddCheat(const char *name, uint32 addr, uint8 val, int compare, int type) {
|
||||||
char *t;
|
char *t;
|
||||||
|
|||||||
@@ -9,4 +9,6 @@ void FCEU_FlushGameCheats(FILE *override, int nosave);
|
|||||||
void FCEU_ApplyPeriodicCheats(void);
|
void FCEU_ApplyPeriodicCheats(void);
|
||||||
void FCEU_PowerCheats(void);
|
void FCEU_PowerCheats(void);
|
||||||
|
|
||||||
|
void FCEU_ResetCheats(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -797,10 +797,33 @@ bool retro_unserialize(const void * data, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void retro_cheat_reset(void)
|
void retro_cheat_reset(void)
|
||||||
{}
|
{
|
||||||
|
FCEU_ResetCheats();
|
||||||
|
}
|
||||||
|
|
||||||
void retro_cheat_set(unsigned a, bool b, const char* c)
|
void retro_cheat_set(unsigned index, bool enabled, const char *code)
|
||||||
{ }
|
{
|
||||||
|
char name[256];
|
||||||
|
sprintf(name, "N/A");
|
||||||
|
uint16 a;
|
||||||
|
uint8 v;
|
||||||
|
int c;
|
||||||
|
int type = 1;
|
||||||
|
|
||||||
|
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. */
|
||||||
|
|
||||||
|
return;
|
||||||
|
input_cheat:
|
||||||
|
FCEUI_AddCheat(name, a, v, c, type);
|
||||||
|
}
|
||||||
|
|
||||||
bool retro_load_game(const struct retro_game_info *game)
|
bool retro_load_game(const struct retro_game_info *game)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user