From 9b4514550544ca3d0a451ba0a08eeb502961ec1c Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 3 Jun 2007 12:47:37 +0000 Subject: [PATCH] cheats, gg git-svn-id: file:///home/notaz/opt/svn/fceu@149 be3aeb3a-fb24-0410-a615-afba39da0efa --- drivers/gp2x/input.c | 5 ++- drivers/gp2x/main.c | 13 ++++-- drivers/gp2x/main.h | 1 + drivers/gp2x/menu.c | 95 ++++++++++++++++++++++++++++---------------- 4 files changed, 75 insertions(+), 39 deletions(-) diff --git a/drivers/gp2x/input.c b/drivers/gp2x/input.c index 43da4b3..6a51264 100644 --- a/drivers/gp2x/input.c +++ b/drivers/gp2x/input.c @@ -22,6 +22,8 @@ #include "../../video.h" #include "usbjoy.h" +extern int FSkip; + /* UsrInputType[] is user-specified. InputType[] is current (game loading can override user settings) */ @@ -184,7 +186,7 @@ static void do_fake_mouse(unsigned long keys) } -void FCEUD_UpdateInput(void) +static void FCEUD_UpdateInput(void) { static int volpushed_frames = 0; static int turbo_rate_cnt_a[2] = {0,0}, turbo_rate_cnt_b[2] = {0,0}; @@ -195,6 +197,7 @@ void FCEUD_UpdateInput(void) if ((down(VOL_DOWN) && down(VOL_UP)) || (keys & (GP2X_L|GP2X_L|GP2X_START)) == (GP2X_L|GP2X_L|GP2X_START)) { Exit = 1; + FSkip = 0; /* force rendering the last frame for menu */ return; } else if (down(VOL_UP)) diff --git a/drivers/gp2x/main.c b/drivers/gp2x/main.c index 05724c6..21cdea5 100644 --- a/drivers/gp2x/main.c +++ b/drivers/gp2x/main.c @@ -39,6 +39,7 @@ #include "../common/cheat.h" #include "../../fce.h" +#include "../../cart.h" #include "dface.h" @@ -249,7 +250,7 @@ static int DoArgs(int argc, char *argv[]) {"-input1",0,&inputa[0],0x4001},{"-input2",0,&inputa[1],0x4001}, {"-fcexp",0,&fcexp,0x4001}, - {"-gg",&docheckie[1],0,0}, + {"-gg",0,&eoptions,0x8000|EO_GG}, {"-no8lim",0,&eoptions,0x8000|EO_NO8LIM}, {"-snapname",0,&eoptions,0x8000|EO_SNAPNAME}, {"-nofs",0,&eoptions,0x8000|EO_NOFOURSCORE}, @@ -274,8 +275,7 @@ static int DoArgs(int argc, char *argv[]) } if(docheckie[0]) Settings.region_force=2; - if(docheckie[1]) - FCEUI_SetGameGenie(1); + FCEUI_SetGameGenie(eoptions&EO_GG); FCEUI_DisableSpriteLimitation(eoptions&EO_NO8LIM); FCEUI_SetSnapName(eoptions&EO_SNAPNAME); @@ -388,7 +388,12 @@ int CLImain(int argc, char *argv[]) ParseGI(fceugi); InitOtherInput(); - GameInterface(GI_INFOSTRING, infostring); + if ((eoptions&EO_GG) && geniestage == 0) { + strcpy(infostring, "gg.rom is missing, GG disabled"); + eoptions&=~EO_GG; + FCEUI_SetGameGenie(0); + } else + GameInterface(GI_INFOSTRING, infostring); FCEU_DispMessage("%s", infostring); } else diff --git a/drivers/gp2x/main.h b/drivers/gp2x/main.h index 1ea651a..be5ae19 100644 --- a/drivers/gp2x/main.h +++ b/drivers/gp2x/main.h @@ -26,6 +26,7 @@ extern int eoptions; #define EO_SNAPNAME 16 #define EO_NOFOURSCORE 32 #define EO_NOTHROTTLE 64 +#define EO_GG 128 extern int srendline,erendline,srendlinev[2],erendlinev[2]; extern int NoWaiting; diff --git a/drivers/gp2x/menu.c b/drivers/gp2x/menu.c index 86aff23..e4b3488 100644 --- a/drivers/gp2x/menu.c +++ b/drivers/gp2x/menu.c @@ -194,7 +194,7 @@ static void gp2x_smalltext16(int x, int y, const char *texto) } } -static void gp2x_smalltext8_lim(int x, int y, const char *texto, int max) +static void gp2x_smalltext16_lim(int x, int y, const char *texto, int max) { char buffer[320/6+1]; @@ -306,16 +306,16 @@ static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel) gp2x_fceu_darken_all(); if(start - 2 >= 0) - gp2x_smalltext8_lim(14, (start - 2)*10, curdir, 53-2); + gp2x_smalltext16_lim(14, (start - 2)*10, curdir, 53-2); for (i = 0; i < n; i++) { pos = start + i; if (pos < 0) continue; if (pos > 23) break; if (namelist[i+1]->d_type == DT_DIR) { - gp2x_smalltext8_lim(14, pos*10, "/", 1); - gp2x_smalltext8_lim(14+6, pos*10, namelist[i+1]->d_name, 53-3); + gp2x_smalltext16_lim(14, pos*10, "/", 1); + gp2x_smalltext16_lim(14+6, pos*10, namelist[i+1]->d_name, 53-3); } else { - gp2x_smalltext8_lim(14, pos*10, namelist[i+1]->d_name, 53-2); + gp2x_smalltext16_lim(14, pos*10, namelist[i+1]->d_name, 53-2); } } gp2x_text_out15(5, 120, ">"); @@ -468,47 +468,69 @@ static char *filesel_loop(char *curr_path, char *final_dest) // ------------ patch/gg menu ------------ -#if 0 // TODO? -static void draw_patchlist(int sel) +extern void *cheats; +static int cheat_count = 0, cheat_start, cheat_pos; + +static int countcallb(char *name, uint32 a, uint8 v, int compare, int s, int type, void *data) { - int start, i, pos; + cheat_count++; + return 1; +} - start = 12 - sel; +static int clistcallb(char *name, uint32 a, uint8 v, int compare, int s, int type, void *data) +{ + int pos; + + pos = cheat_start + cheat_pos; + cheat_pos++; + if (pos < 0) return 1; + if (pos > 23) return 0; + + gp2x_smalltext16_lim(14, pos*10, s ? "ON " : "OFF", 3); + gp2x_smalltext16_lim(14+6*4, pos*10, type ? "S" : "R", 1); + gp2x_smalltext16_lim(14+6*6, pos*10, name, 53-8); + + return 1; +} + +static void draw_patchlist(int sel) +{ + int pos; gp2x_fceu_copy_bg(); + gp2x_fceu_darken_all(); - for (i = 0; i < PicoPatchCount; i++) { - pos = start + i; - if (pos < 0) continue; - if (pos > 23) break; - gp2x_smalltext8_lim(14, pos*10, PicoPatches[i].active ? "ON " : "OFF", 3); - gp2x_smalltext8_lim(14+6*4, pos*10, PicoPatches[i].name, 53-6); - } - pos = start + i; - if (pos < 24) gp2x_smalltext8_lim(14, pos*10, "done", 4); + cheat_start = 12 - sel; + cheat_pos = 0; + FCEUI_ListCheats(clistcallb,0); + + pos = cheat_start + cheat_pos; + if (pos < 24) gp2x_smalltext16_lim(14, pos*10, "done", 4); gp2x_text_out15(5, 120, ">"); gp2x_video_flip(); } - void patches_menu_loop(void) { int menu_sel = 0; unsigned long inp = 0; + cheat_count = 0; + FCEUI_ListCheats(countcallb,0); + for(;;) { draw_patchlist(menu_sel); inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_L|GP2X_R|GP2X_B|GP2X_X); - if(inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; } - if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; } + if(inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = cheat_count; } + if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > cheat_count) menu_sel = 0; } if(inp &(GP2X_LEFT|GP2X_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; } - if(inp &(GP2X_RIGHT|GP2X_R)) { menu_sel+=10; if (menu_sel > PicoPatchCount) menu_sel = PicoPatchCount; } + if(inp &(GP2X_RIGHT|GP2X_R)) { menu_sel+=10; if (menu_sel > cheat_count) menu_sel = cheat_count; } if(inp & GP2X_B) { // action - if (menu_sel < PicoPatchCount) - PicoPatches[menu_sel].active = !PicoPatches[menu_sel].active; - else return; + if (menu_sel < cheat_count) + FCEUI_ToggleCheat(menu_sel); + else return; } if(inp & GP2X_X) return; } @@ -517,6 +539,7 @@ void patches_menu_loop(void) // ------------ savestate loader ------------ +#if 0 static void menu_prepare_bg(void); static int state_slot_flags = 0; @@ -942,7 +965,8 @@ static void draw_fcemenu_options(int menu_sel) gp2x_text_out15(tl_x, (y+=10), "Last visible line (PAL) %i", erendlinev[1]); gp2x_text_out15(tl_x, (y+=10), "Clip 8 left/right columns %s", (eoptions&EO_CLIPSIDES)?"ON":"OFF"); gp2x_text_out15(tl_x, (y+=10), "Disable 8 sprite limit %s", (eoptions&EO_NO8LIM)?"ON":"OFF"); - gp2x_text_out15(tl_x, (y+=10), "Done"); // 10 + gp2x_text_out15(tl_x, (y+=10), "Enable authentic GameGenie %s", (eoptions&EO_GG)?"ON":"OFF"); + gp2x_text_out15(tl_x, (y+=10), "Done"); // 11 // draw cursor gp2x_text_out15(tl_x - 16, tl_y + menu_sel*10, ">"); @@ -961,7 +985,7 @@ static void draw_fcemenu_options(int menu_sel) static void fcemenu_loop_options(void) { - int menu_sel = 0, menu_sel_max = 10, i; + int menu_sel = 0, menu_sel_max = 11, i; unsigned long inp = 0; FCEUI_GetNTSCTH(&ntsctint, &ntschue); @@ -977,7 +1001,8 @@ static void fcemenu_loop_options(void) case 1: ntsccol = !ntsccol; break; case 8: eoptions^=EO_CLIPSIDES; break; case 9: eoptions^=EO_NO8LIM; break; - case 10: return; + case 10: eoptions^=EO_GG; break; + case 11: return; } } if(inp & (GP2X_X|GP2X_A)) { @@ -989,6 +1014,7 @@ static void fcemenu_loop_options(void) FCEUI_SetNTSCTH(ntsccol, ntsctint, ntschue); FCEUI_SetRenderedLines(srendlinev[0],erendlinev[0],srendlinev[1],erendlinev[1]); FCEUI_DisableSpriteLimitation(eoptions&EO_NO8LIM); + FCEUI_SetGameGenie(eoptions&EO_GG); if (cpalette) LoadCPalette(); else FCEUI_SetPaletteArray(0); // set to default FCEU_ResetPalette(); @@ -1199,7 +1225,7 @@ static void draw_menu_credits(void) static void draw_menu_root(int menu_sel) { - int tl_x = 30, tl_y = 128, y; + int tl_x = 30, tl_y = 126, y; gp2x_fceu_copy_bg(); y = tl_y; @@ -1216,9 +1242,9 @@ static void draw_menu_root(int menu_sel) gp2x_text_out15(tl_x, (y+=10), "Controls"); gp2x_text_out15(tl_x, (y+=10), "Credits"); gp2x_text_out15(tl_x, (y+=10), "Exit"); -// TODO -// if (PicoPatches) -// gp2x_text_out15(tl_x, (y+=10), "Patches / GameGenie"); + + if (cheats) + gp2x_text_out15(tl_x, (y+=10), "Cheats"); // draw cursor gp2x_text_out15(tl_x - 16, tl_y + menu_sel*10, ">"); @@ -1231,7 +1257,7 @@ static void draw_menu_root(int menu_sel) else { char vstr[16]; sprintf(vstr, "v" GP2X_PORT_VERSION " r%i", GP2X_PORT_REV); - gp2x_text_out15(320-strlen(vstr)*8-1, 229, vstr); + gp2x_text_out15(320-strlen(vstr)*8-1, 228, vstr); } gp2x_fceu_darken_text_bg(); gp2x_video_flip(); @@ -1245,7 +1271,7 @@ static int menu_loop_root(void) unsigned long inp = 0; if (fceugi) menu_sel_min = 0; -// TODO if (PicoPatches) menu_sel_max = 9; + if (cheats) menu_sel_max = 9; if (menu_sel < menu_sel_min || menu_sel > menu_sel_max) menu_sel = menu_sel_min; @@ -1341,6 +1367,7 @@ static int menu_loop_root(void) case 8: // exit return 1; case 9: // patches/gg + patches_menu_loop(); break; } } -- 2.39.2