X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=fceu.git;a=blobdiff_plain;f=drivers%2Fcommon%2Fcheat.c;h=30d549885b5f54b85bfe3b15983169ae27b74f43;hp=fe77510ab7d97e5022a6afda8b007eb418b4bd5d;hb=92764e6252a3691033d6044b466bf716c96b62d5;hpb=c62d28102c77e19c291c78bf6bf7f0a81abd54b9 diff --git a/drivers/common/cheat.c b/drivers/common/cheat.c index fe77510..30d5498 100644 --- a/drivers/common/cheat.c +++ b/drivers/common/cheat.c @@ -1,7 +1,7 @@ /* FCE Ultra - NES/Famicom Emulator * * Copyright notice for this file: - * Copyright (C) 2002 Ben Parnell + * Copyright (C) 2002 Xodnizel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,12 +22,12 @@ #include #include "../../driver.h" -static void GetString(char *s) +static void GetString(char *s, int max) { int x; - fgets(s,256,stdin); + fgets(s,max,stdin); - for(x=0;x<256;x++) + for(x=0;x=0) + sprintf(tmp,"%s $%04x:%03d:%03d - %s",s?"*":" ",(unsigned int)a,(unsigned int)v,compare,name); + else + sprintf(tmp,"%s $%04x:%03d - %s",s?"*":" ",(unsigned int)a,(unsigned int)v,name); + if(type==1) + tmp[2]='S'; ret=AddToList(tmp,lid); lid++; return(ret); @@ -270,7 +343,7 @@ static void ListCheats(void) lid=0; BeginListShow(); - FCEUI_ListCheats(clistcallb); + FCEUI_ListCheats(clistcallb,0); which=EndListShow(); if(which>=0) { @@ -283,7 +356,7 @@ static void ListCheats(void) break; case 'd':if(!FCEUI_DelCheat(which)) puts("Error deleting cheat!"); - else + else puts("Cheat has been deleted."); break; case 'm':ModifyCheat(which); @@ -298,7 +371,7 @@ static void ResetSearch(void) puts("Done."); } -static int srescallb(uint32 a, uint8 last, uint8 current) +static int srescallb(uint32 a, uint8 last, uint8 current, void *data) { char tmp[13]; sprintf(tmp, "$%04x:%03d:%03d",(unsigned int)a,(unsigned int)last,(unsigned int)current); @@ -313,7 +386,7 @@ static void ShowRes(void) { int which; BeginListShow(); - FCEUI_CheatSearchGet(srescallb); + FCEUI_CheatSearchGet(srescallb,0); which=EndListShow(); if(which>=0) AddCheatParam(which,0); @@ -354,10 +427,10 @@ static void DoSearch(void) { static int v1=0,v2=0; static int method=0; - char *m[4]={"O==V1 && C==V2","O==V1 && |O-C|==V2","|O-C|==V2","O!=C"}; + char *m[6]={"O==V1 && C==V2","O==V1 && |O-C|==V2","|O-C|==V2","O!=C","Value decreased","Value increased"}; printf("\nSearch Filter:\n"); - method=ShowShortList(m,4,method); + method=ShowShortList(m,6,method); if(method<=1) { printf("V1 [%03d]: ",v1); @@ -373,19 +446,21 @@ static void DoSearch(void) } -static MENU NewCheatsMenu[7]={ - {"Add Cheat",AddCheat,1}, - {"Reset Search",ResetSearch,1}, - {"Do Search",DoSearch,1}, - {"Set Original to Current",SetOC,1}, - {"Unhide Excluded",UnhideEx,1}, - {"Show Results",ShowRes,1}, +static MENU NewCheatsMenu[]={ + {"Add Cheat",(void *)AddCheat,1}, + {"Reset Search",(void *)ResetSearch,1}, + {"Do Search",(void *)DoSearch,1}, + {"Set Original to Current",(void *)SetOC,1}, + {"Unhide Excluded",(void *)UnhideEx,1}, + {"Show Results",(void *)ShowRes,1}, + {"Add Game Genie Cheat",(void *)AddCheatGG,1}, + {"Add PAR Cheat",(void *)AddCheatPAR,1}, {0} }; -static MENU MainMenu[3]={ - {"List Cheats",ListCheats,1}, - {"New Cheats...",NewCheatsMenu,0}, +static MENU MainMenu[]={ + {"List Cheats",(void *)ListCheats,1}, + {"New Cheats...",(void *)NewCheatsMenu,0}, {0} }; @@ -423,11 +498,11 @@ static void DoMenu(MENU *men) if(c>x) goto invalid; if(men[c-1].type) { - void (*func)(void)=men[c-1].action; + void (*func)(void)=(void(*)())men[c-1].action; func(); } else - DoMenu(men[c-1].action); /* Mmm...recursivey goodness. */ + DoMenu((MENU*)men[c-1].action); /* Mmm...recursivey goodness. */ goto redisplay; } else