return ret;\r
}\r
\r
-static void me_draw(const menu_entry *entries, int sel)\r
+static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void))\r
{\r
const menu_entry *ent;\r
int x, y, w = 0, h = 0;\r
menu_error_msg[0] = 0;\r
}\r
\r
+ if (draw_more != NULL)\r
+ draw_more();\r
+\r
plat_video_menu_end();\r
}\r
\r
\r
static void debug_menu_loop(void);\r
\r
-static void me_loop(menu_entry *menu, int *menu_sel)\r
+static void me_loop(menu_entry *menu, int *menu_sel, void (*draw_more)(void))\r
{\r
int ret, inp, sel = *menu_sel, menu_sel_max;\r
\r
menu_sel_max = me_count(menu) - 1;\r
- if (menu_sel_max < 1) {\r
+ if (menu_sel_max < 0) {\r
lprintf("no enabled menu entries\n");\r
return;\r
}\r
sel++;\r
\r
/* make sure action buttons are not pressed on entering menu */\r
- me_draw(menu, sel);\r
+ me_draw(menu, sel, NULL);\r
while (in_menu_wait_any(50) & (PBTN_MOK|PBTN_MBACK|PBTN_MENU));\r
\r
for (;;)\r
{\r
- me_draw(menu, sel);\r
+ me_draw(menu, sel, draw_more);\r
inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|\r
PBTN_MOK|PBTN_MBACK|PBTN_MENU|PBTN_L|PBTN_R, 70);\r
if (inp & (PBTN_MENU|PBTN_MBACK))\r
\r
/* ***************************************** */\r
\r
+/* platform specific options and handlers */\r
+#include "../gp2x/menu.c"\r
+\r
static void draw_menu_credits(void)\r
{\r
const char *creds, *p;\r
static int sel = 0;\r
\r
me_enable(e_menu_keyconfig, MA_OPT_SAVECFG_GAME, rom_loaded);\r
- me_loop(e_menu_keyconfig, &sel);\r
+ me_loop(e_menu_keyconfig, &sel, NULL);\r
return 0;\r
}\r
\r
static int menu_loop_cd_options(menu_id id, int keys)\r
{\r
static int sel = 0;\r
- me_loop(e_menu_cd_options, &sel);\r
+ me_loop(e_menu_cd_options, &sel, NULL);\r
return 0;\r
}\r
\r
{\r
mee_onoff ("SRAM/BRAM saves", MA_OPT_SRAM_STATES, currentConfig.EmuOpt, EOPT_EN_SRAM),\r
mee_onoff ("Disable sprite limit", MA_OPT2_NO_SPRITE_LIM, PicoOpt, POPT_DIS_SPRITE_LIM),\r
- mee_onoff ("Use second CPU for sound", MA_OPT_ARM940_SOUND, PicoOpt, POPT_EXT_FM),\r
mee_onoff ("Emulate Z80", MA_OPT2_ENABLE_Z80, PicoOpt, POPT_EN_Z80),\r
mee_onoff ("Emulate YM2612 (FM)", MA_OPT2_ENABLE_YM2612, PicoOpt, POPT_EN_FM),\r
mee_onoff ("Emulate SN76496 (PSG)", MA_OPT2_ENABLE_SN76496,PicoOpt, POPT_EN_PSG),\r
mee_onoff ("gzip savestates", MA_OPT2_GZIP_STATES, currentConfig.EmuOpt, EOPT_GZIP_SAVES),\r
mee_onoff ("Don't save last used ROM", MA_OPT2_NO_LAST_ROM, currentConfig.EmuOpt, EOPT_NO_AUTOSVCFG),\r
- mee_onoff ("RAM overclock", MA_OPT2_RAMTIMINGS, currentConfig.EmuOpt, EOPT_RAM_TIMINGS),\r
- mee_onoff ("MMU hack", MA_OPT2_SQUIDGEHACK, currentConfig.EmuOpt, EOPT_MMUHACK),\r
- mee_onoff ("SVP dynarec", MA_OPT2_SVP_DYNAREC, PicoOpt, POPT_EN_SVP_DRC),\r
mee_onoff ("Disable idle loop patching",MA_OPT2_NO_IDLE_LOOPS,PicoOpt, POPT_DIS_IDLE_DET),\r
+ MENU_GP2X_OPTIONS_ADV\r
mee_end,\r
};\r
\r
static int menu_loop_adv_options(menu_id id, int keys)\r
{\r
static int sel = 0;\r
- me_loop(e_menu_adv_options, &sel);\r
+ me_loop(e_menu_adv_options, &sel, NULL);\r
return 0;\r
}\r
\r
return 0;\r
}\r
\r
-static const char *mgn_opt_renderer(menu_id id, int *offs)\r
-{\r
- *offs = -11;\r
- if (PicoOpt & POPT_ALT_RENDERER)\r
- return " 8bit fast";\r
- else if (currentConfig.EmuOpt & EOPT_16BPP)\r
- return "16bit accurate";\r
- else\r
- return " 8bit accurate";\r
-}\r
-\r
-static const char *mgn_opt_scaling(menu_id id, int *offs)\r
-{\r
- *offs = -13;\r
- switch (currentConfig.scaling) {\r
- default: return " OFF";\r
- case EOPT_SCALE_HW_H: return " hw horizontal";\r
- case EOPT_SCALE_HW_HV: return "hw horiz. + vert";\r
- case EOPT_SCALE_SW_H: return " sw horizontal";\r
- }\r
-}\r
-\r
-static const char *mgn_aopt_gamma(menu_id id, int *offs)\r
-{\r
- sprintf(static_buff, "%i.%02i", currentConfig.gamma / 100, currentConfig.gamma%100);\r
- return static_buff;\r
-}\r
-\r
static menu_entry e_menu_gfx_options[] =\r
{\r
mee_cust ("Renderer", MA_OPT_RENDERER, mh_opt_render, mgn_opt_renderer),\r
- mee_range_cust("Scaling", MA_OPT_SCALING, currentConfig.scaling, 0, 3, mgn_opt_scaling),\r
- mee_onoff ("Tearing Fix", MA_OPT_TEARING_FIX, currentConfig.EmuOpt, EOPT_WIZ_TEAR_FIX),\r
- mee_range_cust("Gamma correction", MA_OPT2_GAMMA, currentConfig.gamma, 1, 300, mgn_aopt_gamma),\r
- mee_onoff ("A_SN's gamma curve", MA_OPT2_A_SN_GAMMA, currentConfig.EmuOpt, EOPT_A_SN_GAMMA),\r
- mee_onoff ("Perfect vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, EOPT_PSYNC),\r
+ MENU_GP2X_OPTIONS_GFX\r
mee_end,\r
};\r
\r
static int menu_loop_gfx_options(menu_id id, int keys)\r
{\r
static int sel = 0;\r
- me_loop(e_menu_gfx_options, &sel);\r
+ me_loop(e_menu_gfx_options, &sel, NULL);\r
return 0;\r
}\r
\r
me_enable(e_menu_options, MA_OPT_SAVECFG_GAME, rom_loaded);\r
me_enable(e_menu_options, MA_OPT_LOADCFG, config_slot != config_slot_current);\r
\r
- me_loop(e_menu_options, &sel);\r
+ me_loop(e_menu_options, &sel, NULL);\r
\r
if (PicoRegionOverride)\r
// force setting possibly changed..\r
\r
plat_video_menu_enter(rom_loaded);\r
in_set_blocking(1);\r
- me_loop(e_menu_main, &sel);\r
+ me_loop(e_menu_main, &sel, menu_main_plat_draw);\r
\r
if (rom_loaded) {\r
if (engineState == PGS_Menu)\r
plat_video_menu_enter(rom_loaded);\r
\r
in_set_blocking(1);\r
- me_loop(e_menu_tray, &sel);\r
+ me_loop(e_menu_tray, &sel, NULL);\r
\r
if (engineState != PGS_RestartRun) {\r
engineState = PGS_RestartRun;\r
\r
// ------------ util ------------\r
\r
-/* wiz for now, probably extend later */\r
+/* GP2X/wiz for now, probably extend later */\r
void menu_plat_setup(int is_wiz)\r
{\r
int i;\r
\r
- if (!is_wiz)\r
+ if (!is_wiz) {\r
+ me_enable(e_menu_gfx_options, MA_OPT_TEARING_FIX, 0);\r
return;\r
+ }\r
\r
me_enable(e_menu_adv_options, MA_OPT_ARM940_SOUND, 0);\r
me_enable(e_menu_gfx_options, MA_OPT2_GAMMA, 0);\r
--- /dev/null
+#ifdef __GP2X_H__
+
+#include <time.h>
+#include "soc.h"
+
+static void menu_main_plat_draw(void)
+{
+ static time_t last_bat_read = 0;
+ static int last_bat_val = -1;
+ unsigned short *bp = g_screen_ptr;
+ int bat_h = me_mfont_h * 2 / 3;
+ int i, u, w, wfill, batt_val;
+ struct tm *tmp;
+ time_t ltime;
+ char time_s[16];
+
+ if (!(currentConfig.EmuOpt & EOPT_SHOW_RTC))
+ return;
+
+ ltime = time(NULL);
+ tmp = gmtime(<ime);
+ strftime(time_s, sizeof(time_s), "%H:%M", tmp);
+
+ text_out16(g_screen_width - me_mfont_w * 6, me_mfont_h + 2, time_s);
+
+ if (ltime - last_bat_read > 10) {
+ last_bat_read = ltime;
+ last_bat_val = batt_val = gp2x_read_battery();
+ }
+ else
+ batt_val = last_bat_val;
+
+ if (batt_val < 0 || batt_val > 100)
+ return;
+
+ /* battery info */
+ bp += (me_mfont_h * 2 + 2) * g_screen_width + g_screen_width - me_mfont_w * 3 - 3;
+ for (i = 0; i < me_mfont_w * 2; i++)
+ bp[i] = menu_text_color;
+ for (i = 0; i < me_mfont_w * 2; i++)
+ bp[i + g_screen_width * bat_h] = menu_text_color;
+ for (i = 0; i <= bat_h; i++)
+ bp[i * g_screen_width] =
+ bp[i * g_screen_width + me_mfont_w * 2] = menu_text_color;
+ for (i = 2; i < bat_h - 1; i++)
+ bp[i * g_screen_width - 1] =
+ bp[i * g_screen_width - 2] = menu_text_color;
+
+ w = me_mfont_w * 2 - 1;
+ wfill = batt_val * w / 100;
+ for (u = 1; u < bat_h; u++)
+ for (i = 0; i < wfill; i++)
+ bp[(w - i) + g_screen_width * u] = menu_text_color;
+}
+
+// ------------ gfx options menu ------------
+
+static const char *mgn_opt_renderer(menu_id id, int *offs)
+{
+ *offs = -11;
+ if (PicoOpt & POPT_ALT_RENDERER)
+ return " 8bit fast";
+ else if (currentConfig.EmuOpt & EOPT_16BPP)
+ return "16bit accurate";
+ else
+ return " 8bit accurate";
+}
+
+static const char *mgn_opt_scaling(menu_id id, int *offs)
+{
+ *offs = -13;
+ switch (currentConfig.scaling) {
+ default: return " OFF";
+ case EOPT_SCALE_HW_H: return " hw horizontal";
+ case EOPT_SCALE_HW_HV: return "hw horiz. + vert";
+ case EOPT_SCALE_SW_H: return " sw horizontal";
+ }
+}
+
+static const char *mgn_aopt_gamma(menu_id id, int *offs)
+{
+ sprintf(static_buff, "%i.%02i", currentConfig.gamma / 100, currentConfig.gamma%100);
+ return static_buff;
+}
+
+
+#define MENU_GP2X_OPTIONS_GFX \
+ mee_range_cust("Scaling", MA_OPT_SCALING, currentConfig.scaling, 0, 3, mgn_opt_scaling), \
+ mee_onoff ("Tearing Fix", MA_OPT_TEARING_FIX, currentConfig.EmuOpt, EOPT_WIZ_TEAR_FIX), \
+ mee_range_cust("Gamma correction", MA_OPT2_GAMMA, currentConfig.gamma, 1, 300, mgn_aopt_gamma), \
+ mee_onoff ("A_SN's gamma curve", MA_OPT2_A_SN_GAMMA, currentConfig.EmuOpt, EOPT_A_SN_GAMMA), \
+ mee_onoff ("Perfect vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, EOPT_PSYNC),
+
+#define MENU_GP2X_OPTIONS_ADV \
+ mee_onoff ("Use second CPU for sound", MA_OPT_ARM940_SOUND, PicoOpt, POPT_EXT_FM), \
+ mee_onoff ("RAM overclock", MA_OPT2_RAMTIMINGS, currentConfig.EmuOpt, EOPT_RAM_TIMINGS), \
+ mee_onoff ("MMU hack", MA_OPT2_SQUIDGEHACK, currentConfig.EmuOpt, EOPT_MMUHACK), \
+ mee_onoff ("SVP dynarec", MA_OPT2_SVP_DYNAREC, PicoOpt, POPT_EN_SVP_DRC), \
+ mee_onoff ("Status line in main menu", MA_OPT2_STATUS_LINE, currentConfig.EmuOpt, EOPT_SHOW_RTC ),
+
+#else
+
+#define MENU_GP2X_OPTIONS_GFX
+#define MENU_GP2X_OPTIONS_ADV
+#define mgn_opt_renderer NULL /* TODO */
+
+#endif