X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Fmenu.c;h=34d5b4996980e3dfb3b2890316d66c2913fa16bf;hb=662e622b59369f975691a70756f80188d8d27ea0;hp=73b41da6338143a36409e5c8fb607e0f0c40df72;hpb=114dfebdbdda18e85effb1fe003d29951fb31fa3;p=libpicofe.git diff --git a/common/menu.c b/common/menu.c index 73b41da..34d5b49 100644 --- a/common/menu.c +++ b/common/menu.c @@ -45,7 +45,7 @@ static const int me_sfont_w = 6, me_sfont_h = 10; // draws text to current bbp16 screen static void text_out16_(int x, int y, const char *text, int color) { - int i, l, u, tr, tg, tb, len; + int i, lh, tr, tg, tb, len; unsigned short *dest = (unsigned short *)g_screen_ptr + x + y * g_screen_width; tr = (color & 0xf800) >> 8; tg = (color & 0x07e0) >> 3; @@ -65,11 +65,17 @@ static void text_out16_(int x, int y, const char *text, int color) len = p - text; } + lh = me_mfont_h; + if (y + lh > g_screen_height) + lh = g_screen_height - y; + for (i = 0; i < len; i++) { unsigned char *src = menu_font_data + (unsigned int)text[i] * me_mfont_w * me_mfont_h / 2; unsigned short *dst = dest; - for (l = 0; l < me_mfont_h; l++, dst += g_screen_width - me_mfont_w) + int u, l; + + for (l = 0; l < lh; l++, dst += g_screen_width - me_mfont_w) { for (u = me_mfont_w / 2; u > 0; u--, src++) { @@ -590,7 +596,15 @@ static void me_loop(menu_entry *menu, int *menu_sel, void (*draw_more)(void)) /* ***************************************** */ /* platform specific options and handlers */ +#if defined(__GP2X__) #include "../gp2x/menu.c" +#elif defined(PANDORA) +#include "../pandora/menu.c" +#else +#define MENU_OPTIONS_GFX +#define MENU_OPTIONS_ADV +#define menu_main_plat_draw NULL +#endif static void draw_menu_credits(void) { @@ -668,20 +682,18 @@ static void cdload_progress_cb(const char *fname, int percent) void menu_romload_prepare(const char *rom_name) { const char *p = rom_name + strlen(rom_name); + int i; while (p > rom_name && *p != '/') p--; - /* fill both buffers, callbacks won't update in full */ - plat_video_menu_begin(); - smalltext_out16(1, 1, "Loading", 0xffff); - smalltext_out16(1, me_sfont_h, p, 0xffff); - plat_video_menu_end(); - - plat_video_menu_begin(); - smalltext_out16(1, 1, "Loading", 0xffff); - smalltext_out16(1, me_sfont_h, p, 0xffff); - plat_video_menu_end(); + /* fill all buffers, callbacks won't update in full */ + for (i = 0; i < 3; i++) { + plat_video_menu_begin(); + smalltext_out16(1, 1, "Loading", 0xffff); + smalltext_out16(1, me_sfont_h, p, 0xffff); + plat_video_menu_end(); + } PicoCartLoadProgressCB = load_progress_cb; PicoCDLoadProgressCB = cdload_progress_cb; @@ -1481,16 +1493,47 @@ static int menu_loop_cd_options(menu_id id, int keys) // ------------ 32X options menu ------------ +static const char *get_rname(const char **rn, int val, int *offs) +{ + int i, len, found = -1, maxlen = 0; + + for (i = 0; rn[i] != NULL; i++) { + len = strlen(rn[i]); + if (len > maxlen) + maxlen = len; + if (i == val) + found = i; + } + + *offs = 3 - maxlen; + if (found >= 0) + return rn[found]; + return "???"; +} + +static const char *mgn_opt_renderer32x(menu_id id, int *offs) +{ + return get_rname(renderer_names32x, currentConfig.renderer32x, offs); +} + static menu_entry e_menu_32x_options[] = { - mee_onoff("32X enabled", MA_32XOPT_ENABLE_32X, PicoOpt, POPT_EN_32X), - mee_onoff("PWM sound", MA_32XOPT_PWM, PicoOpt, POPT_EN_PWM), + mee_onoff ("32X enabled", MA_32XOPT_ENABLE_32X, PicoOpt, POPT_EN_32X), + mee_range_cust("32X renderer", MA_32XOPT_RENDERER, currentConfig.renderer32x, 0, 0, mgn_opt_renderer32x), + mee_onoff ("PWM sound", MA_32XOPT_PWM, PicoOpt, POPT_EN_PWM), mee_end, }; static int menu_loop_32x_options(menu_id id, int keys) { static int sel = 0; + int i, c; + + for (c = 0; renderer_names32x != NULL && renderer_names32x[c] != NULL; ) + c++; + i = me_id2offset(e_menu_32x_options, MA_32XOPT_RENDERER); + e_menu_32x_options[i].max = c > 0 ? (c - 1) : 0; + me_loop(e_menu_32x_options, &sel, NULL); return 0; } @@ -1508,7 +1551,7 @@ static menu_entry e_menu_adv_options[] = mee_onoff ("Don't save last used ROM", MA_OPT2_NO_LAST_ROM, currentConfig.EmuOpt, EOPT_NO_AUTOSVCFG), mee_onoff ("Disable idle loop patching",MA_OPT2_NO_IDLE_LOOPS,PicoOpt, POPT_DIS_IDLE_DET), mee_onoff ("Disable frame limiter", MA_OPT2_NO_FRAME_LIMIT,currentConfig.EmuOpt, EOPT_NO_FRMLIMIT), - MENU_GP2X_OPTIONS_ADV + MENU_OPTIONS_ADV mee_end, }; @@ -1521,22 +1564,29 @@ static int menu_loop_adv_options(menu_id id, int keys) // ------------ gfx options menu ------------ -static int mh_opt_render(menu_id id, int keys) +static const char *mgn_opt_renderer(menu_id id, int *offs) { - plat_video_toggle_renderer((keys & PBTN_RIGHT) ? 1 : 0, 0, 1); - return 0; + return get_rname(renderer_names, currentConfig.renderer, offs); } static menu_entry e_menu_gfx_options[] = { - mee_cust ("Renderer", MA_OPT_RENDERER, mh_opt_render, mgn_opt_renderer), - MENU_GP2X_OPTIONS_GFX + mee_range_cust("Renderer", MA_OPT_RENDERER, currentConfig.renderer, 0, 0, mgn_opt_renderer), + MENU_OPTIONS_GFX mee_end, }; static int menu_loop_gfx_options(menu_id id, int keys) { static int sel = 0; + int i, c; + + for (c = 0; renderer_names != NULL && renderer_names[c] != NULL; ) + c++; + i = me_id2offset(e_menu_gfx_options, MA_OPT_RENDERER); + e_menu_gfx_options[i].max = c > 0 ? (c - 1) : 0; + me_enable(e_menu_gfx_options, MA_OPT_RENDERER, renderer_names != NULL); + me_loop(e_menu_gfx_options, &sel, NULL); return 0; }