X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Fmenu.c;h=39a71b156ec77fbc56d0c7bf3d9250019e438b8d;hb=209a7eff8b4d8e347bb580c2bd3fe6402f074f9b;hp=940279628bf0ae218ee510a1065845757bda4829;hpb=0c9ae59222a6fa9af18dcc072fdfb06cfca124d6;p=libpicofe.git diff --git a/common/menu.c b/common/menu.c index 9402796..39a71b1 100644 --- a/common/menu.c +++ b/common/menu.c @@ -164,7 +164,7 @@ static void smalltext_out16_(int x, int y, const char *texto, int color) static void smalltext_out16(int x, int y, const char *texto, int color) { char buffer[128]; - int maxw = (g_screen_width - x) / 6; + int maxw = (g_screen_width - x) / me_sfont_w; if (maxw < 0) return; @@ -187,11 +187,11 @@ static void menu_draw_selection(int x, int y, int w) if (menu_sel_color < 0) return; // no selection hilight if (y > 0) y--; - dest = (unsigned short *)g_screen_ptr + x + y * g_screen_width + 14; + dest = (unsigned short *)g_screen_ptr + x + y * g_screen_width + me_mfont_w * 2 - 2; for (h = me_mfont_h + 1; h > 0; h--) { dst = dest; - for (i = w - 14; i > 0; i--) + for (i = w - (me_mfont_w * 2 - 2); i > 0; i--) *dst++ = menu_sel_color; dest += g_screen_width; } @@ -268,12 +268,13 @@ void menu_init(void) // load custom font and selector (stored as 1st symbol in font table) emu_make_path(buff, "skin/font.png", sizeof(buff)); - readpng(menu_font_data, buff, READPNG_FONT); + readpng(menu_font_data, buff, READPNG_FONT, + MENU_X2 ? 256 : 128, MENU_X2 ? 320 : 160); // default selector symbol is '>' memcpy(menu_font_data, menu_font_data + ((int)'>') * me_mfont_w * me_mfont_h / 2, me_mfont_w * me_mfont_h / 2); emu_make_path(buff, "skin/selector.png", sizeof(buff)); - readpng(menu_font_data, buff, READPNG_SELECTOR); + readpng(menu_font_data, buff, READPNG_SELECTOR, me_mfont_w, me_mfont_h); // load custom colors emu_make_path(buff, "skin/skin.txt", sizeof(buff)); @@ -343,7 +344,7 @@ static void menu_enter(int is_rom_loaded) // should really only happen once, on startup.. emu_make_path(buff, "skin/background.png", sizeof(buff)); - if (readpng(g_menubg_ptr, buff, READPNG_BG) < 0) + if (readpng(g_menubg_ptr, buff, READPNG_BG, g_screen_width, g_screen_height) < 0) memset(g_menubg_ptr, 0, g_screen_width * g_screen_height * 2); } @@ -378,11 +379,11 @@ static int me_count(const menu_entry *ent) static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) { - const menu_entry *ent; + const menu_entry *ent, *ent_sel = entries; int x, y, w = 0, h = 0; int offs, col2_offs = 27 * me_mfont_w; + int vi_sel_ln = 0; const char *name; - int asel = 0; int i, n; /* calculate size of menu rect */ @@ -393,8 +394,10 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) if (!ent->enabled) continue; - if (i == sel) - asel = n; + if (i == sel) { + ent_sel = ent; + vi_sel_ln = n; + } name = NULL; wt = strlen(ent->name) * me_mfont_w; @@ -410,9 +413,12 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) wt = col2_offs; switch (ent->beh) { - case MB_NONE: break; + case MB_NONE: + break; case MB_OPT_ONOFF: - case MB_OPT_RANGE: wt += me_mfont_w * 3; break; + case MB_OPT_RANGE: + wt += me_mfont_w * 3; + break; case MB_OPT_CUSTOM: case MB_OPT_CUSTONOFF: case MB_OPT_CUSTRANGE: @@ -450,7 +456,7 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) /* draw */ plat_video_menu_begin(); - menu_draw_selection(x, y + asel * me_mfont_h, w); + menu_draw_selection(x, y + vi_sel_ln * me_mfont_h, w); x += me_mfont_w * 2; for (ent = entries; ent->name; ent++) @@ -517,13 +523,13 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) if (plat_get_ticks_ms() - menu_error_time > 2048) menu_error_msg[0] = 0; } - else if (entries[asel].help != NULL) { - const char *tmp = entries[asel].help; + else if (ent_sel->help != NULL) { + const char *tmp = ent_sel->help; int l; for (l = 0; tmp != NULL && *tmp != 0; l++) tmp = strchr(tmp + 1, '\n'); if (h >= l * me_sfont_h + 4) - for (tmp = entries[asel].help; l > 0; l--, tmp = strchr(tmp, '\n') + 1) + for (tmp = ent_sel->help; l > 0; l--, tmp = strchr(tmp, '\n') + 1) smalltext_out16(5, g_screen_height - (l * me_sfont_h + 4), tmp, 0xffff); } @@ -691,11 +697,11 @@ static int cdload_called = 0; static void load_progress_cb(int percent) { int ln, len = percent * g_screen_width / 100; - unsigned short *dst = (unsigned short *)g_screen_ptr + g_screen_width * 10 * 2; + unsigned short *dst = (unsigned short *)g_screen_ptr + g_screen_width * me_sfont_h * 2; if (len > g_screen_width) len = g_screen_width; - for (ln = 10 - 2; ln > 0; ln--, dst += g_screen_width) + for (ln = me_sfont_h - 2; ln > 0; ln--, dst += g_screen_width) memset(dst, 0xff, len * 2); plat_video_menu_end(); } @@ -703,7 +709,7 @@ static void load_progress_cb(int percent) static void cdload_progress_cb(const char *fname, int percent) { int ln, len = percent * g_screen_width / 100; - unsigned short *dst = (unsigned short *)g_screen_ptr + g_screen_width * 10 * 2; + unsigned short *dst = (unsigned short *)g_screen_ptr + g_screen_width * me_sfont_h * 2; memset(dst, 0xff, g_screen_width * (me_sfont_h - 2) * 2); @@ -764,8 +770,8 @@ static void do_delete(const char *fpath, const char *fname) menu_darken_bg(g_screen_ptr, g_screen_ptr, g_screen_width * g_screen_height, 0); len = strlen(fname); - if (len > g_screen_width/6) - len = g_screen_width/6; + if (len > g_screen_width / me_sfont_w) + len = g_screen_width / me_sfont_w; mid = g_screen_width / 2; text_out16(mid - me_mfont_w * 15 / 2, 8 * me_mfont_h, "About to delete"); @@ -1018,7 +1024,7 @@ static void draw_patchlist(int sel) { int max_cnt, start, i, pos, active; - max_cnt = g_screen_height / 10; + max_cnt = g_screen_height / me_sfont_h; start = max_cnt / 2 - sel; plat_video_menu_begin(); @@ -1028,8 +1034,8 @@ static void draw_patchlist(int sel) if (pos < 0) continue; if (pos >= max_cnt) break; active = PicoPatches[i].active; - smalltext_out16(14, pos * me_sfont_h, active ? "ON " : "OFF", active ? 0xfff6 : 0xffff); - smalltext_out16(14+6*4, pos * me_sfont_h, PicoPatches[i].name, active ? 0xfff6 : 0xffff); + smalltext_out16(14, pos * me_sfont_h, active ? "ON " : "OFF", active ? 0xfff6 : 0xffff); + smalltext_out16(14 + me_sfont_w*4, pos * me_sfont_h, PicoPatches[i].name, active ? 0xfff6 : 0xffff); } pos = start + i; if (pos < max_cnt) @@ -1092,7 +1098,7 @@ static void draw_savestate_bg(int slot) PicoStateLoadGfx(fname); /* do a frame and fetch menu bg */ - pemu_forced_frame(POPT_EN_SOFTSCALE); + pemu_forced_frame(POPT_EN_SOFTSCALE, 0); menu_enter(1); PicoTmpStateRestore(tmp_state); @@ -1536,6 +1542,8 @@ static int menu_loop_cd_options(menu_id id, int keys) // ------------ 32X options menu ------------ +#ifndef NO_32X + // convert from multiplier of VClk static int mh_opt_sh2cycles(menu_id id, int keys) { @@ -1588,6 +1596,8 @@ static int menu_loop_32x_options(menu_id id, int keys) return 0; } +#endif + // ------------ adv options menu ------------ static menu_entry e_menu_adv_options[] = @@ -1811,7 +1821,9 @@ static menu_entry e_menu_options[] = mee_range (cpu_clk_name, MA_OPT_CPU_CLOCKS, currentConfig.CPUclock, 20, 900), mee_handler ("[Display options]", menu_loop_gfx_options), mee_handler ("[Sega/Mega CD options]", menu_loop_cd_options), +#ifndef NO_32X mee_handler ("[32X options]", menu_loop_32x_options), +#endif mee_handler ("[Advanced options]", menu_loop_adv_options), mee_cust_nosave("Save global config", MA_OPT_SAVECFG, mh_saveloadcfg, mgn_saveloadcfg), mee_cust_nosave("Save cfg for loaded game",MA_OPT_SAVECFG_GAME, mh_saveloadcfg, mgn_saveloadcfg), @@ -1896,7 +1908,7 @@ static void draw_frame_debug(void) if (PicoDrawMask & PDRAW_32X_ON) memcpy(layer_str + 26, "32x", 4); memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2); - pemu_forced_frame(0); + pemu_forced_frame(0, 0); smalltext_out16(4, 1, "build: r" REVISION " "__DATE__ " " __TIME__ " " COMPILER, 0xffff); smalltext_out16(4, g_screen_height - me_sfont_h, layer_str, 0xffff); } @@ -1921,12 +1933,14 @@ static void debug_menu_loop(void) dumped = 0; } break; - case 1: draw_frame_debug(); break; + case 1: draw_frame_debug(); + break; case 2: memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2); - pemu_forced_frame(0); + pemu_forced_frame(0, 1); menu_darken_bg(g_screen_ptr, g_screen_ptr, g_screen_width * g_screen_height, 0); PDebugShowSpriteStats((unsigned short *)g_screen_ptr + (g_screen_height/2 - 240/2)*g_screen_width + - g_screen_width/2 - 320/2, g_screen_width); break; + g_screen_width/2 - 320/2, g_screen_width); + break; case 3: memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2); PDebugShowPalette(g_screen_ptr, g_screen_width); PDebugShowSprite((unsigned short *)g_screen_ptr + g_screen_width*120 + g_screen_width/2 + 16, @@ -2196,7 +2210,9 @@ static menu_entry *e_menu_table[] = e_menu_gfx_options, e_menu_adv_options, e_menu_cd_options, +#ifndef NO_32X e_menu_32x_options, +#endif e_menu_keyconfig, e_menu_hidden, };