X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Fmenu.c;h=d11343b383b8ab2862021b972aa805e5ed7167a7;hb=b6eccda3174977ced5e654b2278dd24381c713d8;hp=39a71b156ec77fbc56d0c7bf3d9250019e438b8d;hpb=209a7eff8b4d8e347bb580c2bd3fe6402f074f9b;p=libpicofe.git diff --git a/common/menu.c b/common/menu.c index 39a71b1..d11343b 100644 --- a/common/menu.c +++ b/common/menu.c @@ -1,4 +1,4 @@ -// (c) Copyright 2006-2009 notaz, All rights reserved. +// (c) Copyright 2006-2010 notaz, All rights reserved. // Free for non-commercial use. // For commercial use, separate licencing terms must be obtained. @@ -25,10 +25,17 @@ static char static_buff[64]; static int menu_error_time = 0; char menu_error_msg[64] = { 0, }; +void *g_menuscreen_ptr; +void *g_menubg_src_ptr; void *g_menubg_ptr; #ifndef UIQ3 +#if !MSCREEN_SIZE_FIXED +int g_menuscreen_w = MSCREEN_WIDTH; +int g_menuscreen_h = MSCREEN_HEIGHT; +#endif + static unsigned char *menu_font_data = NULL; static int menu_text_color = 0xffff; // default to white static int menu_sel_color = -1; // disabled @@ -46,7 +53,7 @@ static const int me_sfont_w = 6, me_sfont_h = 10; static void text_out16_(int x, int y, const char *text, int color) { int i, lh, tr, tg, tb, len; - unsigned short *dest = (unsigned short *)g_screen_ptr + x + y * g_screen_width; + unsigned short *dest = (unsigned short *)g_menuscreen_ptr + x + y * g_menuscreen_w; tr = (color & 0xf800) >> 8; tg = (color & 0x07e0) >> 3; tb = (color & 0x001f) << 3; @@ -66,8 +73,8 @@ static void text_out16_(int x, int y, const char *text, int color) } lh = me_mfont_h; - if (y + lh > g_screen_height) - lh = g_screen_height - y; + if (y + lh > g_menuscreen_h) + lh = g_menuscreen_h - y; for (i = 0; i < len; i++) { @@ -75,7 +82,7 @@ static void text_out16_(int x, int y, const char *text, int color) unsigned short *dst = dest; int u, l; - for (l = 0; l < lh; l++, dst += g_screen_width - me_mfont_w) + for (l = 0; l < lh; l++, dst += g_menuscreen_w - me_mfont_w) { for (u = me_mfont_w / 2; u > 0; u--, src++) { @@ -106,7 +113,7 @@ void text_out16(int x, int y, const char *texto, ...) { va_list args; char buffer[256]; - int maxw = (g_screen_width - x) / me_mfont_w; + int maxw = (g_menuscreen_w - x) / me_mfont_w; if (maxw < 0) return; @@ -139,7 +146,7 @@ static void smalltext_out16_(int x, int y, const char *texto, int color) break; src = fontdata6x8[c]; - dst = (unsigned short *)g_screen_ptr + x + y * g_screen_width; + dst = (unsigned short *)g_menuscreen_ptr + x + y * g_menuscreen_w; while (h--) { @@ -154,7 +161,7 @@ static void smalltext_out16_(int x, int y, const char *texto, int color) dst += multiplier; } - dst += g_screen_width - me_sfont_w; + dst += g_menuscreen_w - me_sfont_w; } src++; } @@ -164,7 +171,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) / me_sfont_w; + int maxw = (g_menuscreen_w - x) / me_sfont_w; if (maxw < 0) return; @@ -187,13 +194,13 @@ 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 + me_mfont_w * 2 - 2; + dest = (unsigned short *)g_menuscreen_ptr + x + y * g_menuscreen_w + me_mfont_w * 2 - 2; for (h = me_mfont_h + 1; h > 0; h--) { dst = dest; for (i = w - (me_mfont_w * 2 - 2); i > 0; i--) *dst++ = menu_sel_color; - dest += g_screen_width; + dest += g_menuscreen_w; } } @@ -307,6 +314,17 @@ void menu_init(void) } } +static void menu_draw_begin(int need_bg) +{ + plat_video_menu_begin(); + if (need_bg) + memcpy(g_menuscreen_ptr, g_menubg_ptr, g_menuscreen_w * g_menuscreen_h * 2); +} + +static void menu_draw_end(void) +{ + plat_video_menu_end(); +} static void menu_darken_bg(void *dst, void *src, int pixels, int darker) { @@ -336,7 +354,7 @@ static void menu_enter(int is_rom_loaded) if (is_rom_loaded) { // darken the active framebuffer - menu_darken_bg(g_menubg_ptr, g_screen_ptr, g_screen_width * g_screen_height, 1); + menu_darken_bg(g_menubg_ptr, g_menubg_src_ptr, g_menuscreen_w * g_menuscreen_h, 1); } else { @@ -344,8 +362,8 @@ 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, g_screen_width, g_screen_height) < 0) - memset(g_menubg_ptr, 0, g_screen_width * g_screen_height * 2); + if (readpng(g_menubg_ptr, buff, READPNG_BG, g_menuscreen_w, g_menuscreen_h) < 0) + memset(g_menubg_ptr, 0, g_menuscreen_w * g_menuscreen_h * 2); } plat_video_menu_enter(is_rom_loaded); @@ -442,20 +460,20 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) h = n * me_mfont_h; w += me_mfont_w * 2; /* selector */ - if (w > g_screen_width) { - lprintf("width %d > %d\n", w, g_screen_width); - w = g_screen_width; + if (w > g_menuscreen_w) { + lprintf("width %d > %d\n", w, g_menuscreen_w); + w = g_menuscreen_w; } - if (h > g_screen_height) { - lprintf("height %d > %d\n", w, g_screen_height); - h = g_screen_height; + if (h > g_menuscreen_h) { + lprintf("height %d > %d\n", w, g_menuscreen_h); + h = g_menuscreen_h; } - x = g_screen_width / 2 - w / 2; - y = g_screen_height / 2 - h / 2; + x = g_menuscreen_w / 2 - w / 2; + y = g_menuscreen_h / 2 - h / 2; /* draw */ - plat_video_menu_begin(); + menu_draw_begin(1); menu_draw_selection(x, y + vi_sel_ln * me_mfont_h, w); x += me_mfont_w * 2; @@ -513,10 +531,10 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) } /* display help or message if we have one */ - h = (g_screen_height - h) / 2; // bottom area height + h = (g_menuscreen_h - h) / 2; // bottom area height if (menu_error_msg[0] != 0) { if (h >= me_mfont_h + 4) - text_out16(5, g_screen_height - me_mfont_h - 4, menu_error_msg); + text_out16(5, g_menuscreen_h - me_mfont_h - 4, menu_error_msg); else lprintf("menu msg doesn't fit!\n"); @@ -530,13 +548,13 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) tmp = strchr(tmp + 1, '\n'); if (h >= l * me_sfont_h + 4) 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); + smalltext_out16(5, g_menuscreen_h - (l * me_sfont_h + 4), tmp, 0xffff); } if (draw_more != NULL) draw_more(); - plat_video_menu_end(); + menu_draw_end(); } static int me_process(menu_entry *entry, int is_next, int is_lr) @@ -671,14 +689,14 @@ static void draw_menu_credits(void) p++; } - x = g_screen_width / 2 - w * me_mfont_w / 2; - y = g_screen_height / 2 - h * me_mfont_h / 2; + x = g_menuscreen_w / 2 - w * me_mfont_w / 2; + y = g_menuscreen_h / 2 - h * me_mfont_h / 2; if (x < 0) x = 0; if (y < 0) y = 0; - plat_video_menu_begin(); + menu_draw_begin(1); - for (p = creds; *p != 0 && y <= g_screen_height - me_mfont_h; y += me_mfont_h) { + for (p = creds; *p != 0 && y <= g_menuscreen_h - me_mfont_h; y += me_mfont_h) { text_out16(x, y, p); for (; *p != 0 && *p != '\n'; p++) @@ -687,7 +705,7 @@ static void draw_menu_credits(void) p++; } - plat_video_menu_end(); + menu_draw_end(); } // --------- loading ROM screen ---------- @@ -696,33 +714,39 @@ 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 * me_sfont_h * 2; + int ln, len = percent * g_menuscreen_w / 100; + unsigned short *dst; + + if (len > g_menuscreen_w) + len = g_menuscreen_w; - if (len > g_screen_width) - len = g_screen_width; - for (ln = me_sfont_h - 2; ln > 0; ln--, dst += g_screen_width) + menu_draw_begin(0); + dst = (unsigned short *)g_menuscreen_ptr + g_menuscreen_w * me_sfont_h * 2; + for (ln = me_sfont_h - 2; ln > 0; ln--, dst += g_menuscreen_w) memset(dst, 0xff, len * 2); - plat_video_menu_end(); + menu_draw_end(); } 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 * me_sfont_h * 2; + int ln, len = percent * g_menuscreen_w / 100; + unsigned short *dst; - memset(dst, 0xff, g_screen_width * (me_sfont_h - 2) * 2); + menu_draw_begin(0); + dst = (unsigned short *)g_menuscreen_ptr + g_menuscreen_w * me_sfont_h * 2; + memset(dst, 0xff, g_menuscreen_w * (me_sfont_h - 2) * 2); smalltext_out16(1, 3 * me_sfont_h, "Processing CD image / MP3s", 0xffff); smalltext_out16(1, 4 * me_sfont_h, fname, 0xffff); - dst += g_screen_width * me_sfont_h * 3; + dst += g_menuscreen_w * me_sfont_h * 3; + + if (len > g_menuscreen_w) + len = g_menuscreen_w; - if (len > g_screen_width) - len = g_screen_width; - for (ln = (me_sfont_h - 2); ln > 0; ln--, dst += g_screen_width) + for (ln = (me_sfont_h - 2); ln > 0; ln--, dst += g_menuscreen_w) memset(dst, 0xff, len * 2); + menu_draw_end(); - plat_video_menu_end(); cdload_called = 1; } @@ -736,10 +760,10 @@ void menu_romload_prepare(const char *rom_name) /* fill all buffers, callbacks won't update in full */ for (i = 0; i < 3; i++) { - plat_video_menu_begin(); + menu_draw_begin(1); smalltext_out16(1, 1, "Loading", 0xffff); smalltext_out16(1, me_sfont_h, p, 0xffff); - plat_video_menu_end(); + menu_draw_end(); } PicoCartLoadProgressCB = load_progress_cb; @@ -751,9 +775,11 @@ void menu_romload_end(void) { PicoCartLoadProgressCB = NULL; PicoCDLoadProgressCB = NULL; + + menu_draw_begin(0); smalltext_out16(1, (cdload_called ? 6 : 3) * me_sfont_h, "Starting emulation...", 0xffff); - plat_video_menu_end(); + menu_draw_end(); } // -------------- del confirm --------------- @@ -764,16 +790,16 @@ static void do_delete(const char *fpath, const char *fname) const char *nm; char tmp[64]; - plat_video_menu_begin(); + menu_draw_begin(1); if (!rom_loaded) - menu_darken_bg(g_screen_ptr, g_screen_ptr, g_screen_width * g_screen_height, 0); + menu_darken_bg(g_menuscreen_ptr, g_menuscreen_ptr, g_menuscreen_w * g_menuscreen_h, 0); len = strlen(fname); - if (len > g_screen_width / me_sfont_w) - len = g_screen_width / me_sfont_w; + if (len > g_menuscreen_w / me_sfont_w) + len = g_menuscreen_w / me_sfont_w; - mid = g_screen_width / 2; + mid = g_menuscreen_w / 2; text_out16(mid - me_mfont_w * 15 / 2, 8 * me_mfont_h, "About to delete"); smalltext_out16(mid - len * me_sfont_w / 2, 9 * me_mfont_h + 5, fname, 0xbdff); text_out16(mid - me_mfont_w * 13 / 2, 11 * me_mfont_h, "Are you sure?"); @@ -786,7 +812,7 @@ static void do_delete(const char *fpath, const char *fname) len = strlen(tmp); text_out16(mid - me_mfont_w * len / 2, 12 * me_mfont_h, tmp); - plat_video_menu_end(); + menu_draw_end(); while (in_menu_wait_any(50) & (PBTN_MENU|PBTN_MA2)); inp = in_menu_wait(PBTN_MA3|PBTN_MBACK, 100); @@ -817,17 +843,17 @@ static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel) int max_cnt, start, i, x, pos; void *darken_ptr; - max_cnt = g_screen_height / me_sfont_h; + max_cnt = g_menuscreen_h / me_sfont_h; start = max_cnt / 2 - sel; n--; // exclude current dir (".") - plat_video_menu_begin(); + menu_draw_begin(1); // if (!rom_loaded) // menu_darken_bg(gp2x_screen, 320*240, 0); - darken_ptr = (short *)g_screen_ptr + g_screen_width * max_cnt/2 * me_sfont_h; - menu_darken_bg(darken_ptr, darken_ptr, g_screen_width * me_sfont_h * 8 / 10, 0); + darken_ptr = (short *)g_menuscreen_ptr + g_menuscreen_w * max_cnt/2 * me_sfont_h; + menu_darken_bg(darken_ptr, darken_ptr, g_menuscreen_w * me_sfont_h * 8 / 10, 0); x = 5 + me_mfont_w + 1; if (start - 2 >= 0) @@ -845,7 +871,7 @@ static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel) } } smalltext_out16(5, max_cnt/2 * me_sfont_h, ">", 0xffff); - plat_video_menu_end(); + menu_draw_end(); } static int scandir_cmp(const void *p1, const void *p2) @@ -1024,10 +1050,10 @@ static void draw_patchlist(int sel) { int max_cnt, start, i, pos, active; - max_cnt = g_screen_height / me_sfont_h; + max_cnt = g_menuscreen_h / me_sfont_h; start = max_cnt / 2 - sel; - plat_video_menu_begin(); + menu_draw_begin(1); for (i = 0; i < PicoPatchCount; i++) { pos = start + i; @@ -1042,7 +1068,7 @@ static void draw_patchlist(int sel) smalltext_out16(14, pos * me_sfont_h, "done", 0xffff); text_out16(5, max_cnt / 2 * me_sfont_h, ">"); - plat_video_menu_end(); + menu_draw_end(); } static void menu_loop_patches(void) @@ -1098,8 +1124,9 @@ static void draw_savestate_bg(int slot) PicoStateLoadGfx(fname); /* do a frame and fetch menu bg */ - pemu_forced_frame(POPT_EN_SOFTSCALE, 0); - menu_enter(1); + pemu_forced_frame(0, 0); + + menu_darken_bg(g_menubg_ptr, g_menubg_src_ptr, g_menuscreen_w * g_menuscreen_h, 1); PicoTmpStateRestore(tmp_state); } @@ -1113,12 +1140,12 @@ static void draw_savestate_menu(int menu_sel, int is_loading) w = (13 + 2) * me_mfont_w; h = (1+2+10+1) * me_mfont_h; - x = g_screen_width / 2 - w / 2; + x = g_menuscreen_w / 2 - w / 2; if (x < 0) x = 0; - y = g_screen_height / 2 - h / 2; + y = g_menuscreen_h / 2 - h / 2; if (y < 0) y = 0; - plat_video_menu_begin(); + menu_draw_begin(1); text_out16(x, y, is_loading ? "Load state" : "Save state"); y += 3 * me_mfont_h; @@ -1132,7 +1159,7 @@ static void draw_savestate_menu(int menu_sel, int is_loading) } text_out16(x, y, "back"); - plat_video_menu_end(); + menu_draw_end(); } static int menu_loop_savestate(int is_loading) @@ -1188,7 +1215,7 @@ static int menu_loop_savestate(int is_loading) static char *action_binds(int player_idx, int action_mask, int dev_id) { - int k, count, can_combo, type; + int k, count = 0, can_combo = 0, type; const int *binds; static_buff[0] = 0; @@ -1197,8 +1224,8 @@ static char *action_binds(int player_idx, int action_mask, int dev_id) if (binds == NULL) return static_buff; - count = in_get_dev_info(dev_id, IN_INFO_BIND_COUNT); - can_combo = in_get_dev_info(dev_id, IN_INFO_DOES_COMBOS); + in_get_config(dev_id, IN_CFG_BIND_COUNT, &count); + in_get_config(dev_id, IN_CFG_DOES_COMBOS, &can_combo); type = IN_BINDTYPE_EMU; if (player_idx >= 0) { @@ -1233,13 +1260,13 @@ static int count_bound_keys(int dev_id, int action_mask, int bindtype) { const int *binds; int k, keys = 0; - int count; + int count = 0; binds = in_get_dev_binds(dev_id); if (binds == NULL) return 0; - count = in_get_dev_info(dev_id, IN_INFO_BIND_COUNT); + in_get_config(dev_id, IN_CFG_BIND_COUNT, &count); for (k = 0; k < count; k++) { if (binds[IN_BIND_OFFS(k, bindtype)] & action_mask) @@ -1257,12 +1284,12 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_ int x, y, w, i; w = ((player_idx >= 0) ? 20 : 30) * me_mfont_w; - x = g_screen_width / 2 - w / 2; - y = (g_screen_height - 4 * me_mfont_h) / 2 - (2 + opt_cnt) * me_mfont_h / 2; + x = g_menuscreen_w / 2 - w / 2; + y = (g_menuscreen_h - 4 * me_mfont_h) / 2 - (2 + opt_cnt) * me_mfont_h / 2; if (x < me_mfont_w * 2) x = me_mfont_w * 2; - plat_video_menu_begin(); + menu_draw_begin(1); if (player_idx >= 0) text_out16(x, y, "Player %i controls", player_idx + 1); else @@ -1279,31 +1306,31 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_ w = strlen(dev_name) * me_mfont_w; if (w < 30 * me_mfont_w) w = 30 * me_mfont_w; - if (w > g_screen_width) - w = g_screen_width; + if (w > g_menuscreen_w) + w = g_menuscreen_w; - x = g_screen_width / 2 - w / 2; + x = g_menuscreen_w / 2 - w / 2; if (!is_bind) { snprintf(buff2, sizeof(buff2), "%s", in_get_key_name(-1, -PBTN_MOK)); snprintf(buff, sizeof(buff), "%s - bind, %s - clear", buff2, in_get_key_name(-1, -PBTN_MA2)); - text_out16(x, g_screen_height - 4 * me_mfont_h, buff); + text_out16(x, g_menuscreen_h - 4 * me_mfont_h, buff); } else - text_out16(x, g_screen_height - 4 * me_mfont_h, "Press a button to bind/unbind"); + text_out16(x, g_menuscreen_h - 4 * me_mfont_h, "Press a button to bind/unbind"); if (dev_count > 1) { - text_out16(x, g_screen_height - 3 * me_mfont_h, dev_name); - text_out16(x, g_screen_height - 2 * me_mfont_h, "Press left/right for other devs"); + text_out16(x, g_menuscreen_h - 3 * me_mfont_h, dev_name); + text_out16(x, g_menuscreen_h - 2 * me_mfont_h, "Press left/right for other devs"); } - plat_video_menu_end(); + menu_draw_end(); } static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_idx) { - int i, sel = 0, menu_sel_max = opt_cnt - 1; + int i, sel = 0, menu_sel_max = opt_cnt - 1, does_combos = 0; int dev_id, dev_count, kc, is_down, mkey; int unbind, bindtype, mask_shift; @@ -1348,11 +1375,13 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_ break; } continue; - case PBTN_MBACK: return; + case PBTN_MBACK: + return; case PBTN_MOK: if (sel >= opt_cnt) return; - while (in_menu_wait_any(30) & PBTN_MOK); + while (in_menu_wait_any(30) & PBTN_MOK) + ; break; case PBTN_MA2: in_unbind_all(dev_id, opts[sel].mask << mask_shift, bindtype); @@ -1370,11 +1399,14 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_ unbind = (i > 0); /* allow combos if device supports them */ - if (i == 1 && bindtype == IN_BINDTYPE_EMU && - in_get_dev_info(dev_id, IN_INFO_DOES_COMBOS)) + in_get_config(dev_id, IN_CFG_DOES_COMBOS, &does_combos); + if (i == 1 && bindtype == IN_BINDTYPE_EMU && does_combos) unbind = 0; - in_bind_key(dev_id, kc, opts[sel].mask << mask_shift, bindtype, unbind); + if (unbind) + in_unbind_all(dev_id, opts[sel].mask << mask_shift, bindtype); + + in_bind_key(dev_id, kc, opts[sel].mask << mask_shift, bindtype, 0); } } @@ -1461,6 +1493,7 @@ static menu_entry e_menu_keyconfig[] = mee_handler_id("Emulator controls", MA_CTRL_EMU, key_config_loop_wrap), mee_onoff ("6 button pad", MA_OPT_6BUTTON_PAD, PicoOpt, POPT_6BTN_PAD), mee_range ("Turbo rate", MA_CTRL_TURBO_RATE, currentConfig.turbo_rate, 1, 30), + mee_range ("Analog deadzone", MA_CTRL_DEADZONE, currentConfig.analog_deadzone, 1, 99), 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), mee_label (""), @@ -1590,7 +1623,7 @@ static int menu_loop_32x_options(menu_id id, int keys) { static int sel = 0; - me_enable(e_menu_32x_options, MA_32XOPT_RENDERER, renderer_names32x != NULL); + me_enable(e_menu_32x_options, MA_32XOPT_RENDERER, renderer_names32x[0] != NULL); me_loop(e_menu_32x_options, &sel, NULL); return 0; @@ -1818,7 +1851,7 @@ static menu_entry e_menu_options[] = mee_onoff ("Enable sound", MA_OPT_ENABLE_SOUND, currentConfig.EmuOpt, EOPT_EN_SOUND), mee_cust ("Sound Quality", MA_OPT_SOUND_QUALITY, mh_opt_misc, mgn_opt_sound), mee_enum_h ("Confirm savestate", MA_OPT_CONFIRM_STATES,currentConfig.confirm_save, men_confirm_save, h_confirm_save), - mee_range (cpu_clk_name, MA_OPT_CPU_CLOCKS, currentConfig.CPUclock, 20, 900), + mee_range ("", MA_OPT_CPU_CLOCKS, currentConfig.CPUclock, 20, 1200), mee_handler ("[Display options]", menu_loop_gfx_options), mee_handler ("[Sega/Mega CD options]", menu_loop_cd_options), #ifndef NO_32X @@ -1835,7 +1868,10 @@ static menu_entry e_menu_options[] = static int menu_loop_options(menu_id id, int keys) { static int sel = 0; + int i; + i = me_id2offset(e_menu_options, MA_OPT_CPU_CLOCKS); + e_menu_options[i].enabled = e_menu_options[i].name[0] ? 1 : 0; me_enable(e_menu_options, MA_OPT_SAVECFG_GAME, rom_loaded); me_enable(e_menu_options, MA_OPT_LOADCFG, config_slot != config_slot_current); @@ -1881,7 +1917,7 @@ static void draw_text_debug(const char *str, int skip, int from) } str = p; - for (line = from; line < g_screen_height / me_sfont_h; line++) + for (line = from; line < g_menuscreen_h / me_sfont_h; line++) { smalltext_out16(1, line * me_sfont_h, str, 0xffff); while (*p && *p != '\n') @@ -1907,10 +1943,10 @@ static void draw_frame_debug(void) if (PicoDrawMask & PDRAW_SPRITES_HI_ON) memcpy(layer_str + 19, "spr_hi", 6); 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, 0); + pemu_forced_frame(1, 0); + memcpy(g_menuscreen_ptr, g_menubg_src_ptr, g_menuscreen_w * g_menuscreen_h * 2); smalltext_out16(4, 1, "build: r" REVISION " "__DATE__ " " __TIME__ " " COMPILER, 0xffff); - smalltext_out16(4, g_screen_height - me_sfont_h, layer_str, 0xffff); + smalltext_out16(4, g_menuscreen_h - me_sfont_h, layer_str, 0xffff); } static void debug_menu_loop(void) @@ -1921,38 +1957,36 @@ static void debug_menu_loop(void) while (1) { + menu_draw_begin(1); switch (mode) { - case 0: plat_video_menu_begin(); - tmp = PDebugMain(); + case 0: tmp = PDebugMain(); plat_debug_cat(tmp); draw_text_debug(tmp, 0, 0); if (dumped) { - smalltext_out16(g_screen_width - 6 * me_sfont_h, - g_screen_height - me_mfont_h, "dumped", 0xffff); + smalltext_out16(g_menuscreen_w - 6 * me_sfont_h, + g_menuscreen_h - me_mfont_h, "dumped", 0xffff); dumped = 0; } 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, 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); + case 2: pemu_forced_frame(1, 0); + menu_darken_bg(g_menuscreen_ptr, g_menubg_src_ptr, g_menuscreen_w * g_menuscreen_h, 0); + PDebugShowSpriteStats((unsigned short *)g_menuscreen_ptr + (g_menuscreen_h/2 - 240/2)*g_menuscreen_w + + g_menuscreen_w/2 - 320/2, g_menuscreen_w); 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, - g_screen_width, spr_offs); + case 3: memset(g_menuscreen_ptr, 0, g_menuscreen_w * g_menuscreen_h * 2); + PDebugShowPalette(g_menuscreen_ptr, g_menuscreen_w); + PDebugShowSprite((unsigned short *)g_menuscreen_ptr + g_menuscreen_w*120 + g_menuscreen_w/2 + 16, + g_menuscreen_w, spr_offs); draw_text_debug(PDebugSpriteList(), spr_offs, 6); break; - case 4: plat_video_menu_begin(); - tmp = PDebug32x(); + case 4: tmp = PDebug32x(); draw_text_debug(tmp, 0, 0); break; } - plat_video_menu_end(); + menu_draw_end(); inp = in_menu_wait(PBTN_MOK|PBTN_MBACK|PBTN_MA2|PBTN_MA3|PBTN_L|PBTN_R | PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT, 70); @@ -2099,7 +2133,7 @@ void menu_loop(void) me_enable(e_menu_main, MA_MAIN_PATCHES, PicoPatches != NULL); menu_enter(rom_loaded); - in_set_blocking(1); + in_set_config_int(0, IN_CFG_BLOCKING, 1); me_loop(e_menu_main, &sel, menu_main_plat_draw); if (rom_loaded) { @@ -2110,7 +2144,7 @@ void menu_loop(void) ; } - in_set_blocking(0); + in_set_config_int(0, IN_CFG_BLOCKING, 0); } // --------- CD tray close menu ---------- @@ -2148,7 +2182,7 @@ int menu_loop_tray(void) menu_enter(rom_loaded); - in_set_blocking(1); + in_set_config_int(0, IN_CFG_BLOCKING, 1); me_loop(e_menu_tray, &sel, NULL); if (engineState != PGS_RestartRun) { @@ -2157,7 +2191,7 @@ int menu_loop_tray(void) } while (in_menu_wait_any(50) & (PBTN_MENU|PBTN_MOK|PBTN_MBACK)); - in_set_blocking(0); + in_set_config_int(0, IN_CFG_BLOCKING, 0); return ret; } @@ -2175,28 +2209,6 @@ void me_update_msg(const char *msg) // ------------ util ------------ -/* GP2X/wiz for now, probably extend later */ -void menu_plat_setup(int is_wiz) -{ - int i; - - if (!is_wiz) { - me_enable(e_menu_gfx_options, MA_OPT_TEARING_FIX, 0); - i = me_id2offset(e_menu_gfx_options, MA_OPT_TEARING_FIX); - e_menu_gfx_options[i].need_to_save = 0; - return; - } - - me_enable(e_menu_adv_options, MA_OPT_ARM940_SOUND, 0); - me_enable(e_menu_gfx_options, MA_OPT2_GAMMA, 0); - me_enable(e_menu_gfx_options, MA_OPT2_A_SN_GAMMA, 0); - - i = me_id2offset(e_menu_gfx_options, MA_OPT_SCALING); - e_menu_gfx_options[i].max = 1; /* only off and sw */ - i = me_id2offset(e_menu_gfx_options, MA_OPT_ARM940_SOUND); - e_menu_gfx_options[i].need_to_save = 0; -} - /* hidden options for config engine only */ static menu_entry e_menu_hidden[] = {