X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Fmenu.c;h=d8dd50c96795dd4f7bf5cab971a2febc0fe40e60;hb=b79118011b8b1ac835efed1ac5a9ce3bdc55c158;hp=7bf133c59a6e837654ad8cd9088f540cd5eedf65;hpb=45deb4099e6d20780376e6425d43107120a10bc6;p=libpicofe.git diff --git a/common/menu.c b/common/menu.c index 7bf133c..d8dd50c 100644 --- a/common/menu.c +++ b/common/menu.c @@ -1151,6 +1151,7 @@ static int count_bound_keys(int dev_id, int action_mask, int bindtype) static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_idx, int sel, int dev_id, int dev_count, int is_bind) { + char buff[64], buff2[32]; const char *dev_name; int x, y, w, i; @@ -1182,15 +1183,19 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_ x = g_screen_width / 2 - w / 2; - if (dev_count > 1) { - text_out16(x, g_screen_height - 4 * me_mfont_h, "Viewing binds for:"); - text_out16(x, g_screen_height - 3 * me_mfont_h, dev_name); + 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); } + else + text_out16(x, g_screen_height - 4 * me_mfont_h, "Press a button to bind/unbind"); - if (is_bind) - text_out16(x, g_screen_height - 2 * me_mfont_h, "Press a button to bind/unbind"); - else if (dev_count > 1) + 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"); + } plat_video_menu_end(); } @@ -1199,7 +1204,7 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_ { int i, sel = 0, menu_sel_max = opt_cnt - 1; int dev_id, dev_count, kc, is_down, mkey; - int unbind, bindtype, mask; + int unbind, bindtype, mask_shift; for (i = 0, dev_id = -1, dev_count = 0; i < IN_MAX_DEVS; i++) { if (in_get_dev_name(i, 1, 0) != NULL) { @@ -1214,10 +1219,15 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_ return; } + mask_shift = 0; + if (player_idx == 1) + mask_shift = 16; + bindtype = player_idx >= 0 ? IN_BINDTYPE_PLAYER12 : IN_BINDTYPE_EMU; + for (;;) { draw_key_config(opts, opt_cnt, player_idx, sel, dev_id, dev_count, 0); - mkey = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_MBACK|PBTN_MOK, 100); + mkey = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_MBACK|PBTN_MOK|PBTN_MA2, 100); switch (mkey) { case PBTN_UP: sel--; if (sel < 0) sel = menu_sel_max; continue; case PBTN_DOWN: sel++; if (sel > menu_sel_max) sel = 0; continue; @@ -1243,6 +1253,9 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_ return; while (in_menu_wait_any(30) & PBTN_MOK); break; + case PBTN_MA2: + in_unbind_all(dev_id, opts[sel].mask << mask_shift, bindtype); + continue; default:continue; } @@ -1252,12 +1265,7 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_ for (is_down = 1; is_down; ) kc = in_update_keycode(&dev_id, &is_down, -1); - bindtype = player_idx >= 0 ? IN_BINDTYPE_PLAYER12 : IN_BINDTYPE_EMU; - mask = opts[sel].mask; - if (player_idx == 1) - mask <<= 16; - - i = count_bound_keys(dev_id, mask, bindtype); + i = count_bound_keys(dev_id, opts[sel].mask << mask_shift, bindtype); unbind = (i > 0); /* allow combos if device supports them */ @@ -1265,7 +1273,7 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_ in_get_dev_info(dev_id, IN_INFO_DOES_COMBOS)) unbind = 0; - in_bind_key(dev_id, kc, bindtype, mask, unbind); + in_bind_key(dev_id, kc, opts[sel].mask << mask_shift, bindtype, unbind); } } @@ -1369,6 +1377,8 @@ static menu_entry e_menu_keyconfig[] = static int menu_loop_keyconfig(menu_id id, int keys) { static int sel = 0; + + me_enable(e_menu_keyconfig, MA_OPT_SAVECFG_GAME, rom_loaded); me_loop(e_menu_keyconfig, &sel); return 0; } @@ -1447,6 +1457,23 @@ static int menu_loop_adv_options(menu_id id, int keys) // ------------ gfx options menu ------------ +static int mh_opt_render(menu_id id, int keys) +{ + plat_video_toggle_renderer((keys & PBTN_RIGHT) ? 1 : 0, 1); + return 0; +} + +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; @@ -1466,7 +1493,9 @@ static const char *mgn_aopt_gamma(menu_id id, int *offs) static menu_entry e_menu_gfx_options[] = { + mee_cust ("Renderer", MA_OPT_RENDERER, mh_opt_render, mgn_opt_renderer), 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), @@ -1484,20 +1513,6 @@ static int menu_loop_gfx_options(menu_id id, int keys) static menu_entry e_menu_options[]; -/* TODO: move to plat */ -static int mh_opt_render(menu_id id, int keys) -{ - if (keys & PBTN_LEFT) { - if (PicoOpt&0x10) PicoOpt&= ~0x10; - else if (!(currentConfig.EmuOpt &0x80))currentConfig.EmuOpt |= 0x80; - } else { - if (PicoOpt&0x10) return 0; - else if (!(currentConfig.EmuOpt &0x80))PicoOpt|= 0x10; - else if ( currentConfig.EmuOpt &0x80) currentConfig.EmuOpt &= ~0x80; - } - return 0; -} - static int sndrate_prevnext(int rate, int dir) { static const int rates[] = { 8000, 11025, 16000, 22050, 44100 }; @@ -1610,15 +1625,11 @@ static int mh_saveloadcfg(menu_id id, int keys) return 1; } -static const char *mgn_opt_renderer(menu_id id, int *offs) +static int mh_restore_defaults(menu_id id, int keys) { - *offs = -6; - if (PicoOpt & POPT_ALT_RENDERER) - return " 8bit fast"; - else if (currentConfig.EmuOpt & 0x80) - return "16bit accurate"; - else - return " 8bit accurate"; + emu_set_defconfig(); + me_update_msg("defaults restored"); + return 1; } static const char *mgn_opt_fskip(menu_id id, int *offs) @@ -1693,9 +1704,8 @@ static menu_entry e_menu_options[] = mee_range ("Save slot", MA_OPT_SAVE_SLOT, state_slot, 0, 9), mee_range_cust("Frameskip", MA_OPT_FRAMESKIP, currentConfig.Frameskip, -1, 16, mgn_opt_fskip), mee_cust ("Region", MA_OPT_REGION, mh_opt_misc, mgn_opt_region), - mee_cust ("Renderer", MA_OPT_RENDERER, mh_opt_render, mgn_opt_renderer), - mee_onoff ("Show FPS", MA_OPT_SHOW_FPS, currentConfig.EmuOpt, 0x002), - mee_onoff ("Enable sound", MA_OPT_ENABLE_SOUND, currentConfig.EmuOpt, 0x004), + mee_onoff ("Show FPS", MA_OPT_SHOW_FPS, currentConfig.EmuOpt, EOPT_SHOW_FPS), + 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_cust ("Confirm savestate", MA_OPT_CONFIRM_STATES,mh_opt_misc, mgn_opt_c_saves), mee_range (cpu_clk_name, MA_OPT_CPU_CLOCKS, currentConfig.CPUclock, 20, 900), @@ -1705,6 +1715,7 @@ static menu_entry e_menu_options[] = mee_handler_mkname_id(MA_OPT_SAVECFG, mh_saveloadcfg, mgn_savecfg), mee_handler_id("Save cfg for current game only", MA_OPT_SAVECFG_GAME, mh_saveloadcfg), mee_handler_mkname_id(MA_OPT_LOADCFG, mh_saveloadcfg, mgn_loadcfg), + mee_handler ("Restore defaults", mh_restore_defaults), mee_end, };