+// menu system for gpfce - FCE Ultra port\r
// (c) Copyright 2006,2007 notaz, All rights reserved.\r
-// Free for non-commercial use.\r
-\r
-// For commercial use, separate licencing terms must be obtained.\r
\r
#include <stdio.h>\r
#include <string.h>\r
\r
char menuErrorMsg[40] = {0, };\r
\r
-static void gp2x_fceu_darken_reset(void)\r
+static void menu_flip(void)\r
+{\r
+ gp2x_video_flush_cache();\r
+ gp2x_video_flip();\r
+}\r
+\r
+static void menu_darken_reset(void)\r
{\r
txt_xmin = 320; txt_xmax = 0;\r
txt_ymin = 240; txt_ymax = 0;\r
if (menu_bg)\r
memcpy(gp2x_screen, menu_bg, 320*240*2);\r
else memset(gp2x_screen, 0, 320*240*2);\r
- gp2x_fceu_darken_reset();\r
+ menu_darken_reset();\r
}\r
\r
-static void gp2x_fceu_darken_text_bg(void)\r
+static void menu_darken_text_bg(void)\r
{\r
int x, y, xmin, xmax, ymax;\r
unsigned short *screen = gp2x_screen;\r
}\r
}\r
gp2x_text_out15(5, 120, ">");\r
- gp2x_video_flip();\r
+ menu_flip();\r
}\r
\r
static int scandir_cmp(const void *p1, const void *p2)\r
if (pos < 24) gp2x_smalltext16_lim(14, pos*10, "done", 4);\r
\r
gp2x_text_out15(5, 120, ">");\r
- gp2x_video_flip();\r
+ menu_flip();\r
}\r
\r
void patches_menu_loop(void)\r
// draw cursor\r
gp2x_text_out15(tl_x - 16, tl_y + menu_sel*10, ">");\r
\r
- gp2x_video_flip();\r
+ menu_flip();\r
}\r
\r
static int savestate_menu_loop(int is_loading)\r
Settings.JoyBinds[u][i] &= ~action;\r
}\r
\r
-static int count_bound_keys(int action, int is_joy)\r
+static int count_bound_keys(int action, int joy)\r
{\r
- int i, u, keys = 0;\r
+ int i, keys = 0;\r
\r
- if (is_joy)\r
+ if (joy)\r
{\r
- for (u = 0; u < 4; u++)\r
- for (i = 0; i < 32; i++)\r
- if (Settings.JoyBinds[u][i] & action) keys++;\r
+ for (i = 0; i < 32; i++)\r
+ if (Settings.JoyBinds[joy-1][i] & action) keys++;\r
}\r
else\r
{\r
// draw cursor\r
gp2x_text_out15(x - 16, tl_y + sel*10, ">");\r
\r
- gp2x_fceu_darken_text_bg();\r
- gp2x_fceu_darken_reset();\r
+ menu_darken_text_bg();\r
+ menu_darken_reset();\r
\r
if (sel < opt_cnt) {\r
gp2x_text_out15(30, 190, "Press a button to bind/unbind");\r
gp2x_text_out15(30, 210, "to save controls");\r
gp2x_text_out15(30, 220, "Press B or X to exit");\r
}\r
- gp2x_fceu_darken_text_bg();\r
- gp2x_video_flip();\r
+ menu_darken_text_bg();\r
+ menu_flip();\r
}\r
\r
static void key_config_loop(const bind_action_t *opts, int opt_cnt, int player_idx)\r
{\r
for (i = 0; i < 32; i++)\r
if (inp & (1 << i)) {\r
- if (count_bound_keys(opts[sel].mask, 1) >= 1) // disallow combos for usbjoy\r
+ if (count_bound_keys(opts[sel].mask, joy) >= 1) // disallow combos for usbjoy\r
Settings.JoyBinds[joy-1][i] &= ~opts[sel].mask;\r
else Settings.JoyBinds[joy-1][i] ^= opts[sel].mask;\r
if (player_idx >= 0) {\r
gp2x_text_out15(tl_x, (y+=10), "none");\r
}\r
\r
- gp2x_fceu_darken_text_bg();\r
- gp2x_video_flip();\r
+ menu_darken_text_bg();\r
+ menu_flip();\r
}\r
\r
// b_turbo,a_turbo RLDU SEBA\r
gp2x_text_out15(tl_x - 16, tl_y + menu_sel*10, ">");\r
\r
if (menu_sel == 0) {\r
- gp2x_fceu_darken_text_bg();\r
- gp2x_fceu_darken_reset();\r
+ menu_darken_text_bg();\r
+ menu_darken_reset();\r
\r
gp2x_text_out15(30, 210, "Press B to browse,");\r
gp2x_text_out15(30, 220, "START to use default");\r
}\r
\r
- gp2x_fceu_darken_text_bg();\r
- gp2x_video_flip();\r
+ menu_darken_text_bg();\r
+ menu_flip();\r
}\r
\r
static void fcemenu_loop_options(void)\r
gp2x_text_out15(tl_x, (y+=10), "Faster RAM timings %s", Settings.ramtimings?"ON":"OFF");\r
gp2x_text_out15(tl_x, (y+=10), "squidgehack (now %s %s", mms, Settings.mmuhack?"ON":"OFF"); // 10\r
gp2x_text_out15(tl_x, (y+=10), "Gamma correction %i.%02i", Settings.gamma / 100, Settings.gamma%100);\r
- gp2x_text_out15(tl_x, (y+=10), "GP2X CPU clock %iMhz", Settings.cpuclock); // 12\r
+ gp2x_text_out15(tl_x, (y+=10), "Perfect VSYNC %s", Settings.perfect_vsync?"ON":"OFF");\r
+ gp2x_text_out15(tl_x, (y+=10), "GP2X CPU clock %iMhz", Settings.cpuclock); // 13\r
gp2x_text_out15(tl_x, (y+=10), "[FCE Ultra options]");\r
- gp2x_text_out15(tl_x, (y+=10), "Save cfg as default");\r
+ gp2x_text_out15(tl_x, (y+=10), "Save cfg as default"); // 15\r
if (fceugi)\r
gp2x_text_out15(tl_x, (y+=10), "Save cfg for current game only");\r
\r
// draw cursor\r
gp2x_text_out15(tl_x - 16, tl_y + menu_sel*10, ">");\r
\r
- gp2x_fceu_darken_text_bg();\r
- gp2x_video_flip();\r
+ menu_darken_text_bg();\r
+ menu_flip();\r
}\r
\r
static int sndrate_prevnext(int rate, int dir)\r
\r
static void config_commit(void)\r
{\r
- gp2x_cpuclock_gamma_update();\r
if (Settings.region_force)\r
FCEUI_SetVidSystem(Settings.region_force - 1);\r
}\r
static int menu_loop_options(void)\r
{\r
static int menu_sel = 0;\r
- int menu_sel_max = 14;\r
+ int menu_sel_max = 15;\r
unsigned long inp = 0;\r
\r
if (fceugi) menu_sel_max++;\r
if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options\r
switch (menu_sel) {\r
case 1: Settings.showfps = !Settings.showfps; break;\r
- case 3: soundvol = soundvol ? 0 : 100; break;\r
+ case 3: soundvol = soundvol ? 0 : 50; break;\r
case 9: Settings.ramtimings = !Settings.ramtimings; break;\r
case 10: Settings.mmuhack = !Settings.mmuhack; break;\r
- case 13: fcemenu_loop_options(); break;\r
- case 14: // done (update and write)\r
+ case 12: Settings.perfect_vsync = !Settings.perfect_vsync; break;\r
+ case 14: fcemenu_loop_options(); break;\r
+ case 15: // done (update and write)\r
config_commit();\r
SaveConfig(NULL);\r
return 1;\r
- case 15: // done (update and write for current game)\r
+ case 16: // done (update and write for current game)\r
config_commit();\r
if (lastLoadedGameName[0])\r
SaveConfig(lastLoadedGameName);\r
case 7: int_incdec(&Settings.sstate_confirm, (inp & GP2X_LEFT) ? -1 : 1, 0, 3); break;\r
case 8: int_incdec(&CurrentState, (inp & GP2X_LEFT) ? -1 : 1, 0, 9); break;\r
case 11: int_incdec(&Settings.gamma, (inp & GP2X_LEFT) ? -1 : 1, 0, 300); break;\r
- case 12:\r
+ case 13:\r
while ((inp = gp2x_joystick_read(1)) & (GP2X_LEFT|GP2X_RIGHT)) {\r
Settings.cpuclock += (inp & GP2X_LEFT) ? -1 : 1;\r
if (Settings.cpuclock < 0) Settings.cpuclock = 0; // 0 ~ do not change\r
gp2x_text_out15(20, 180, " cpuctrl, gamma libs");\r
gp2x_text_out15(20, 190, "Squidge: squidgehack");\r
\r
- gp2x_fceu_darken_text_bg();\r
- gp2x_video_flip();\r
+ menu_darken_text_bg();\r
+ menu_flip();\r
}\r
\r
\r
// draw cursor\r
gp2x_text_out15(tl_x - 16, tl_y + menu_sel*10, ">");\r
\r
- gp2x_fceu_darken_text_bg();\r
- gp2x_fceu_darken_reset();\r
+ menu_darken_text_bg();\r
+ menu_darken_reset();\r
\r
// error / version\r
if (menuErrorMsg[0]) gp2x_text_out15(1, 229, menuErrorMsg);\r
sprintf(vstr, "v" GP2X_PORT_VERSION " r%i", GP2X_PORT_REV);\r
gp2x_text_out15(320-strlen(vstr)*8-1, 228, vstr);\r
}\r
- gp2x_fceu_darken_text_bg();\r
- gp2x_video_flip();\r
+ menu_darken_text_bg();\r
+ menu_flip();\r
}\r
\r
\r
if (fceugi)\r
{\r
/* raw emu frame should now be at gp2x_screen */\r
- soft_scale((char *)gp2x_screen + 32, gp2x_palette16, srendline, erendline-srendline);\r
- if (srendline)\r
- memset32((int *)((char *)gp2x_screen + 32), 0, srendline*320*2/4);\r
- memcpy(menu_bg, gp2x_screen + 32, 320*240*2);\r
+ if (Settings.scaling != 0)\r
+ {\r
+ soft_scale((char *)gp2x_screen + 32, gp2x_palette16, srendline, erendline-srendline);\r
+ if (srendline)\r
+ memset32((int *)((char *)gp2x_screen + 32), 0, srendline*320*2/4);\r
+ memcpy(menu_bg, gp2x_screen + 32, 320*240*2);\r
+ }\r
+ else\r
+ {\r
+ convert2RGB555(menu_bg, gp2x_screen, gp2x_palette16, 320*240);\r
+ }\r
}\r
else\r
{\r
// switch bpp\r
gp2x_video_changemode(16);\r
gp2x_video_set_offs(0);\r
- gp2x_video_RGB_setscaling(0, 320, 240);\r
- gp2x_video_flip();\r
+ gp2x_video_RGB_setscaling(320, 240);\r
+ menu_flip();\r
}\r
\r
\r