X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=fceu.git;a=blobdiff_plain;f=drivers%2Fgp2x%2Fmenu.c;h=ee599b44a008e5f66dc991df44dfc7f9acff0a56;hp=b23837adbf10e585c61667e04f38d7fcea639f62;hb=642070a99a18726024c5b214263221a0340e6987;hpb=6f6bc6fa47b2888c4420eeb323d96be0982150de diff --git a/drivers/gp2x/menu.c b/drivers/gp2x/menu.c index b23837a..ee599b4 100644 --- a/drivers/gp2x/menu.c +++ b/drivers/gp2x/menu.c @@ -1,7 +1,5 @@ +// menu system for gpfce - FCE Ultra port // (c) Copyright 2006,2007 notaz, All rights reserved. -// Free for non-commercial use. - -// For commercial use, separate licencing terms must be obtained. #include #include @@ -21,6 +19,7 @@ #include "../../input.h" #include "../../state.h" #include "../../palette.h" +#include "readpng.h" #ifndef _DIRENT_HAVE_D_TYPE #error "need d_type for file browser @@ -44,13 +43,73 @@ static char *gp2xKeyNames[] = { static char path_buffer[PATH_MAX]; +static unsigned short *menu_bg = 0; +static int txt_xmin, txt_xmax, txt_ymin, txt_ymax; char menuErrorMsg[40] = {0, }; -// TODO -void gp2x_fceu_copy_bg(void) +static void menu_flip(void) +{ + gp2x_video_flush_cache(); + gp2x_video_flip(); +} + +static void menu_darken_reset(void) +{ + txt_xmin = 320; txt_xmax = 0; + txt_ymin = 240; txt_ymax = 0; +} + +static void gp2x_fceu_copy_bg(void) +{ + if (menu_bg) + memcpy(gp2x_screen, menu_bg, 320*240*2); + else memset(gp2x_screen, 0, 320*240*2); + menu_darken_reset(); +} + +static void menu_darken_text_bg(void) { - memset(gp2x_screen, 0, 320*240*2); + int x, y, xmin, xmax, ymax; + unsigned short *screen = gp2x_screen; + + xmin = txt_xmin - 3; + if (xmin < 0) xmin = 0; + xmax = txt_xmax + 2; + if (xmax > 319) xmax = 319; + + y = txt_ymin - 3; + if (y < 0) y = 0; + ymax = txt_ymax + 2; + if (ymax > 239) ymax = 239; + + for (x = xmin; x <= xmax; x++) + screen[y*320+x] = 0xa514; + for (y++; y < ymax; y++) + { + screen[y*320+xmin] = 0xffff; + for (x = xmin+1; x < xmax; x++) + { + unsigned int p = screen[y*320+x]; + if (p != 0xffff) + screen[y*320+x] = ((p&0xf79e)>>1) - ((p&0xc618)>>3); + } + screen[y*320+xmax] = 0xffff; + } + for (x = xmin; x <= xmax; x++) + screen[y*320+x] = 0xffff; +} + +static void gp2x_fceu_darken_all(void) +{ + unsigned int *screen = gp2x_screen; + int count = 320*240/2; + + while (count--) + { + unsigned int p = screen[count]; + screen[count] = ((p&0xf79ef79e)>>1) - ((p&0xc618c618)>>3); + } } // draws white text to current bbp15 screen @@ -76,6 +135,10 @@ static void gp2x_text_out15_(int x, int y, const char *text) } screen += 8; } + if (x < txt_xmin) txt_xmin = x; + if (x+i*8 > txt_xmax) txt_xmax = x+i*8; + if (y < txt_ymin) txt_ymin = y; + if (y+8 > txt_ymax) txt_ymax = y+8; } void gp2x_text_out15(int x, int y, const char *texto, ...) @@ -103,7 +166,7 @@ void gp2x_text_out15_lim(int x, int y, const char *texto, int max) gp2x_text_out15(x,y,buffer); } -static void gp2x_smalltext16(int x, int y, const char *texto) +static void gp2x_smalltext16(int x, int y, const char *texto, unsigned short color) { int i; unsigned char *src; @@ -124,7 +187,7 @@ static void gp2x_smalltext16(int x, int y, const char *texto) int w = 0x20; while (w) { - if( *src & w ) *dst = 0xffff; + if( *src & w ) *dst = color; dst++; w>>=1; } @@ -135,7 +198,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, unsigned short color, int max) { char buffer[320/6+1]; @@ -144,7 +207,7 @@ static void gp2x_smalltext8_lim(int x, int y, const char *texto, int max) if (max < 0) max = 0; buffer[max] = 0; - gp2x_smalltext16(x, y, buffer); + gp2x_smalltext16(x, y, buffer, color); } @@ -236,6 +299,22 @@ static unsigned long wait_for_input_usbjoy(unsigned long interesting, int *joy) // -------------- ROM selector -------------- +// rrrr rggg gggb bbbb +static unsigned short file2color(const char *fname) +{ + const char *ext = fname + strlen(fname) - 3; + static const char *rom_exts[] = { "zip", "nes", "fds", "unf", "nez", "nif" }; // nif is for unif + static const char *other_exts[] = { "nsf", "ips", "fcm" }; + int i; + + if (ext < fname) ext = fname; + for (i = 0; i < sizeof(rom_exts)/sizeof(rom_exts[0]); i++) + if (strcasecmp(ext, rom_exts[i]) == 0) return 0xbdff; + for (i = 0; i < sizeof(other_exts)/sizeof(other_exts[0]); i++) + if (strcasecmp(ext, other_exts[i]) == 0) return 0xaff5; + return 0xffff; +} + static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel) { int start, i, pos; @@ -243,24 +322,25 @@ static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel) start = 12 - sel; n--; // exclude current dir (".") - //memset(gp2x_screen, 0, 320*240); gp2x_fceu_copy_bg(); + 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, 0xffff, 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, "/", 0xfff6, 1); + gp2x_smalltext16_lim(14+6, pos*10, namelist[i+1]->d_name, 0xfff6, 53-3); } else { - gp2x_smalltext8_lim(14, pos*10, namelist[i+1]->d_name, 53-2); + unsigned short color = file2color(namelist[i+1]->d_name); + gp2x_smalltext16_lim(14, pos*10, namelist[i+1]->d_name, color, 53-2); } } gp2x_text_out15(5, 120, ">"); - gp2x_video_flip(); + menu_flip(); } static int scandir_cmp(const void *p1, const void *p2) @@ -369,7 +449,7 @@ static char *filesel_loop(char *curr_path, char *final_dest) } else { strcpy(newdir, curr_path); p = newdir + strlen(newdir) - 1; - while (*p == '/' && p >= newdir) *p-- = 0; + while (p >= newdir && *p == '/') *p-- = 0; strcat(newdir, "/"); strcat(newdir, namelist[sel+1]->d_name); } @@ -409,47 +489,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", 0xffff, 3); + gp2x_smalltext16_lim(14+6*4, pos*10, type ? "S" : "R", 0xffff, 1); + gp2x_smalltext16_lim(14+6*6, pos*10, name, 0xffff, 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", 0xffff, 4); gp2x_text_out15(5, 120, ">"); - gp2x_video_flip(); + menu_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; } @@ -458,6 +560,7 @@ void patches_menu_loop(void) // ------------ savestate loader ------------ +#if 0 static void menu_prepare_bg(void); static int state_slot_flags = 0; @@ -551,7 +654,7 @@ static void draw_savestate_menu(int menu_sel, int is_loading) // draw cursor gp2x_text_out15(tl_x - 16, tl_y + menu_sel*10, ">"); - gp2x_video_flip(); + menu_flip(); } static int savestate_menu_loop(int is_loading) @@ -651,15 +754,14 @@ static void unbind_action(int action) Settings.JoyBinds[u][i] &= ~action; } -static int count_bound_keys(int action, int is_joy) +static int count_bound_keys(int action, int joy) { - int i, u, keys = 0; + int i, keys = 0; - if (is_joy) + if (joy) { - for (u = 0; u < 4; u++) - for (i = 0; i < 32; i++) - if (Settings.JoyBinds[u][i] & action) keys++; + for (i = 0; i < 32; i++) + if (Settings.JoyBinds[joy-1][i] & action) keys++; } else { @@ -689,6 +791,9 @@ static void draw_key_config(const bind_action_t *opts, int opt_cnt, int player_i // draw cursor gp2x_text_out15(x - 16, tl_y + sel*10, ">"); + menu_darken_text_bg(); + menu_darken_reset(); + if (sel < opt_cnt) { gp2x_text_out15(30, 190, "Press a button to bind/unbind"); gp2x_text_out15(30, 200, "Use VOL+ to clear"); @@ -699,7 +804,8 @@ static void draw_key_config(const bind_action_t *opts, int opt_cnt, int player_i gp2x_text_out15(30, 210, "to save controls"); gp2x_text_out15(30, 220, "Press B or X to exit"); } - gp2x_video_flip(); + menu_darken_text_bg(); + menu_flip(); } static void key_config_loop(const bind_action_t *opts, int opt_cnt, int player_idx) @@ -740,7 +846,7 @@ static void key_config_loop(const bind_action_t *opts, int opt_cnt, int player_i { for (i = 0; i < 32; i++) if (inp & (1 << i)) { - if (count_bound_keys(opts[sel].mask, 1) >= 1) // disallow combos for usbjoy + if (count_bound_keys(opts[sel].mask, joy) >= 1) // disallow combos for usbjoy Settings.JoyBinds[joy-1][i] &= ~opts[sel].mask; else Settings.JoyBinds[joy-1][i] ^= opts[sel].mask; if (player_idx >= 0) { @@ -778,7 +884,8 @@ static void draw_kc_sel(int menu_sel) gp2x_text_out15(tl_x, (y+=10), "none"); } - gp2x_video_flip(); + menu_darken_text_bg(); + menu_flip(); } // b_turbo,a_turbo RLDU SEBA @@ -821,7 +928,7 @@ static void kc_sel_loop(void) if(inp & GP2X_B) { switch (menu_sel) { case 0: key_config_loop(ctrl_actions, 10, 0); return; - case 1: key_config_loop(ctrl_actions, 8, 1); return; + case 1: key_config_loop(ctrl_actions, 10, 1); return; case 2: key_config_loop(emuctrl_actions, sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]), -1); return; case 3: if (!fceugi) SaveConfig(NULL); return; @@ -878,22 +985,27 @@ 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, ">"); if (menu_sel == 0) { + menu_darken_text_bg(); + menu_darken_reset(); + gp2x_text_out15(30, 210, "Press B to browse,"); gp2x_text_out15(30, 220, "START to use default"); } - // draw cursor - gp2x_text_out15(tl_x - 16, tl_y + menu_sel*10, ">"); - - gp2x_video_flip(); + menu_darken_text_bg(); + menu_flip(); } 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); @@ -909,7 +1021,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)) { @@ -921,6 +1034,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(); @@ -961,7 +1075,7 @@ static void fcemenu_loop_options(void) static void draw_menu_options(int menu_sel) { - int tl_x = 25, tl_y = 32, y; + int tl_x = 25, tl_y = 20, y; char strframeskip[8], *strscaling, *strssconfirm; char *mms = mmuhack_status ? "active) " : "inactive)"; @@ -987,26 +1101,37 @@ static void draw_menu_options(int menu_sel) gp2x_text_out15(tl_x, y, "Scaling: %s", strscaling); // 0 gp2x_text_out15(tl_x, (y+=10), "Show FPS %s", Settings.showfps?"ON":"OFF"); // 1 gp2x_text_out15(tl_x, (y+=10), "Frameskip %s", strframeskip); // 2 + gp2x_text_out15(tl_x, (y+=10), "Accurate renderer (slow) %s", Settings.accurate_mode?"ON":"OFF"); gp2x_text_out15(tl_x, (y+=10), "Enable sound %s", soundvol?"ON":"OFF"); - gp2x_text_out15(tl_x, (y+=10), "Sound Rate: %5iHz", Settings.sound_rate); // 4 + gp2x_text_out15(tl_x, (y+=10), "Sound Rate: %5iHz", Settings.sound_rate); // 5 gp2x_text_out15(tl_x, (y+=10), "Force Region: %s", - Settings.region_force == 2 ? "PAL" : Settings.region_force == 1 ? "NTSC" : "OFF"); // 5 + Settings.region_force == 2 ? "PAL" : Settings.region_force == 1 ? "NTSC" : "OFF"); // 6 gp2x_text_out15(tl_x, (y+=10), "Turbo rate %iHz", (Settings.turbo_rate_add*60/2) >> 24); - gp2x_text_out15(tl_x, (y+=10), "Confirm savestate %s", strssconfirm); // 7 + gp2x_text_out15(tl_x, (y+=10), "Confirm savestate %s", strssconfirm); // 8 gp2x_text_out15(tl_x, (y+=10), "Save slot %i", CurrentState); gp2x_text_out15(tl_x, (y+=10), "Faster RAM timings %s", Settings.ramtimings?"ON":"OFF"); - gp2x_text_out15(tl_x, (y+=10), "squidgehack (now %s %s", mms, Settings.mmuhack?"ON":"OFF"); // 10 + gp2x_text_out15(tl_x, (y+=10), "squidgehack (now %s %s", mms, Settings.mmuhack?"ON":"OFF"); // 11 gp2x_text_out15(tl_x, (y+=10), "Gamma correction %i.%02i", Settings.gamma / 100, Settings.gamma%100); - gp2x_text_out15(tl_x, (y+=10), "GP2X CPU clock %iMhz", Settings.cpuclock); // 12 + gp2x_text_out15(tl_x, (y+=10), "Perfect VSYNC %s", Settings.perfect_vsync?"ON":"OFF"); + gp2x_text_out15(tl_x, (y+=10), "GP2X CPU clock %iMhz", Settings.cpuclock); // 14 gp2x_text_out15(tl_x, (y+=10), "[FCE Ultra options]"); - gp2x_text_out15(tl_x, (y+=10), "Save cfg as default"); + gp2x_text_out15(tl_x, (y+=10), "Save cfg as default"); // 16 if (fceugi) gp2x_text_out15(tl_x, (y+=10), "Save cfg for current game only"); // draw cursor gp2x_text_out15(tl_x - 16, tl_y + menu_sel*10, ">"); - gp2x_video_flip(); + if (menu_sel == 3) { + gp2x_text_out15(tl_x, 210, "ROM reload required for this"); + gp2x_text_out15(tl_x, 220, "setting to take effect"); + } else if (menu_sel == 10 || menu_sel == 11) { + gp2x_text_out15(tl_x, 210, "Emu restart required for this"); + gp2x_text_out15(tl_x, 220, "setting to take effect"); + } + + menu_darken_text_bg(); + menu_flip(); } static int sndrate_prevnext(int rate, int dir) @@ -1024,7 +1149,6 @@ static int sndrate_prevnext(int rate, int dir) static void config_commit(void) { - gp2x_cpuclock_gamma_update(); if (Settings.region_force) FCEUI_SetVidSystem(Settings.region_force - 1); } @@ -1032,7 +1156,7 @@ static void config_commit(void) static int menu_loop_options(void) { static int menu_sel = 0; - int menu_sel_max = 15; + int ret, menu_sel_max = 16; unsigned long inp = 0; if (fceugi) menu_sel_max++; @@ -1045,19 +1169,25 @@ static int menu_loop_options(void) if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options switch (menu_sel) { - case 1: Settings.showfps = !Settings.showfps; break; - case 3: soundvol = soundvol ? 0 : 100; break; - case 9: Settings.ramtimings = !Settings.ramtimings; break; - case 10: Settings.mmuhack = !Settings.mmuhack; break; - case 13: fcemenu_loop_options(); break; - case 14: // done (update and write) + case 1: Settings.showfps = !Settings.showfps; break; + case 3: Settings.accurate_mode = !Settings.accurate_mode; break; + case 4: soundvol = soundvol ? 0 : 50; break; + case 10: Settings.ramtimings = !Settings.ramtimings; break; + case 11: Settings.mmuhack = !Settings.mmuhack; break; + case 13: Settings.perfect_vsync = !Settings.perfect_vsync; break; + case 15: fcemenu_loop_options(); break; + case 16: // done (update and write) config_commit(); - SaveConfig(NULL); + ret = SaveConfig(NULL); + strcpy(menuErrorMsg, ret == 0 ? "default config saved" : "config save failed"); return 1; - case 15: // done (update and write for current game) - config_commit(); + case 17: // done (update and write for current game) if (lastLoadedGameName[0]) - SaveConfig(lastLoadedGameName); + { + config_commit(); + ret = SaveConfig(lastLoadedGameName); + strcpy(menuErrorMsg, ret == 0 ? "game config saved" : "config save failed"); + } return 1; } } @@ -1069,21 +1199,21 @@ static int menu_loop_options(void) switch (menu_sel) { case 0: int_incdec(&Settings.scaling, (inp & GP2X_LEFT) ? -1 : 1, 0, 3); break; case 2: int_incdec(&Settings.frameskip, (inp & GP2X_LEFT) ? -1 : 1, -1, 32); break; - case 4: + case 5: Settings.sound_rate = sndrate_prevnext(Settings.sound_rate, inp & GP2X_RIGHT); InitSound(); break; - case 5: int_incdec(&Settings.region_force, (inp & GP2X_LEFT) ? -1 : 1, 0, 2); break; - case 6: { + case 6: int_incdec(&Settings.region_force, (inp & GP2X_LEFT) ? -1 : 1, 0, 2); break; + case 7: { int hz = Settings.turbo_rate_add*60/2 >> 24; int_incdec(&hz, (inp & GP2X_LEFT) ? -1 : 1, 1, 30); Settings.turbo_rate_add = (hz*2 << 24) / 60 + 1; break; } - case 7: int_incdec(&Settings.sstate_confirm, (inp & GP2X_LEFT) ? -1 : 1, 0, 3); break; - case 8: int_incdec(&CurrentState, (inp & GP2X_LEFT) ? -1 : 1, 0, 9); break; - case 11: int_incdec(&Settings.gamma, (inp & GP2X_LEFT) ? -1 : 1, 0, 300); break; - case 12: + case 8: int_incdec(&Settings.sstate_confirm, (inp & GP2X_LEFT) ? -1 : 1, 0, 3); break; + case 9: int_incdec(&CurrentState, (inp & GP2X_LEFT) ? -1 : 1, 0, 9); break; + case 12: int_incdec(&Settings.gamma, (inp & GP2X_LEFT) ? -1 : 1, 0, 300); break; + case 14: while ((inp = gp2x_joystick_read(1)) & (GP2X_LEFT|GP2X_RIGHT)) { Settings.cpuclock += (inp & GP2X_LEFT) ? -1 : 1; if (Settings.cpuclock < 0) Settings.cpuclock = 0; // 0 ~ do not change @@ -1121,7 +1251,8 @@ static void draw_menu_credits(void) gp2x_text_out15(20, 180, " cpuctrl, gamma libs"); gp2x_text_out15(20, 190, "Squidge: squidgehack"); - gp2x_video_flip(); + menu_darken_text_bg(); + menu_flip(); } @@ -1129,7 +1260,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; @@ -1146,20 +1277,25 @@ 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, ">"); - // error - if (menuErrorMsg[0]) gp2x_text_out15(1, 230, menuErrorMsg); + + menu_darken_text_bg(); + menu_darken_reset(); + + // error / version + if (menuErrorMsg[0]) gp2x_text_out15(1, 229, menuErrorMsg); else { char vstr[16]; sprintf(vstr, "v" GP2X_PORT_VERSION " r%i", GP2X_PORT_REV); - gp2x_text_out15(320-strlen(vstr)*8-1, 230, vstr); + gp2x_text_out15(320-strlen(vstr)*8-1, 228, vstr); } - gp2x_video_flip(); + menu_darken_text_bg(); + menu_flip(); } @@ -1170,7 +1306,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; @@ -1266,6 +1402,7 @@ static int menu_loop_root(void) case 8: // exit return 1; case 9: // patches/gg + patches_menu_loop(); break; } } @@ -1274,9 +1411,33 @@ static int menu_loop_root(void) } +extern unsigned short gp2x_palette16[256]; + static void menu_prepare_bg(void) { - // TODO... + menu_bg = malloc(320*240*2); + if (menu_bg == NULL) return; + + if (fceugi) + { + /* raw emu frame should now be at gp2x_screen */ + if (Settings.scaling != 0) + { + soft_scale((char *)gp2x_screen + 32, gp2x_palette16, srendline, erendline-srendline); + if (srendline) + memset32((int *)((char *)gp2x_screen + 32), 0, srendline*320*2/4); + memcpy(menu_bg, gp2x_screen + 32, 320*240*2); + } + else + { + convert2RGB555(menu_bg, gp2x_screen, gp2x_palette16, 320*240); + } + } + else + { + memset32((int *)menu_bg, 0, 320*240*2/4); + readpng(menu_bg, "background.png"); + } } static void menu_gfx_prepare(void) @@ -1286,8 +1447,8 @@ static void menu_gfx_prepare(void) // switch bpp gp2x_video_changemode(16); gp2x_video_set_offs(0); - gp2x_video_RGB_setscaling(0, 320, 240); - gp2x_video_flip(); + gp2x_video_RGB_setscaling(320, 240); + menu_flip(); } @@ -1299,6 +1460,8 @@ int gp2x_menu_do(void) ret = menu_loop_root(); + if (menu_bg) free(menu_bg); + menu_bg = NULL; menuErrorMsg[0] = 0; return ret;