X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Fmenu.c;h=b7f9e4d0dba10113fa1b8166abe2debc75d55324;hb=7bc9a680a24582b2cb3a82cbdaf383b2330c3b21;hp=b32546fd9fa8cd01f27769de34ea35bd8c22f79d;hpb=92068389d87084380eae2e1c03314ef13c59e1df;p=libpicofe.git diff --git a/common/menu.c b/common/menu.c index b32546f..b7f9e4d 100644 --- a/common/menu.c +++ b/common/menu.c @@ -327,7 +327,7 @@ static int me_count(const menu_entry *ent) return ret; } -static void me_draw(const menu_entry *entries, int sel) +static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) { const menu_entry *ent; int x, y, w = 0, h = 0; @@ -449,11 +449,15 @@ static void me_draw(const menu_entry *entries, int sel) menu_error_msg[0] = 0; } + if (draw_more != NULL) + draw_more(); + plat_video_menu_end(); } -static int me_process(menu_entry *entry, int is_next) +static int me_process(menu_entry *entry, int is_next, int is_lr) { + int c; switch (entry->beh) { case MB_OPT_ONOFF: @@ -462,7 +466,8 @@ static int me_process(menu_entry *entry, int is_next) return 1; case MB_OPT_RANGE: case MB_OPT_CUSTRANGE: - *(int *)entry->var += is_next ? 1 : -1; + c = is_lr ? 10 : 1; + *(int *)entry->var += is_next ? c : -c; if (*(int *)entry->var < (int)entry->min) *(int *)entry->var = (int)entry->max; if (*(int *)entry->var > (int)entry->max) @@ -475,12 +480,12 @@ static int me_process(menu_entry *entry, int is_next) static void debug_menu_loop(void); -static void me_loop(menu_entry *menu, int *menu_sel) +static void me_loop(menu_entry *menu, int *menu_sel, void (*draw_more)(void)) { int ret, inp, sel = *menu_sel, menu_sel_max; menu_sel_max = me_count(menu) - 1; - if (menu_sel_max < 1) { + if (menu_sel_max < 0) { lprintf("no enabled menu entries\n"); return; } @@ -489,12 +494,12 @@ static void me_loop(menu_entry *menu, int *menu_sel) sel++; /* make sure action buttons are not pressed on entering menu */ - me_draw(menu, sel); + me_draw(menu, sel, NULL); while (in_menu_wait_any(50) & (PBTN_MOK|PBTN_MBACK|PBTN_MENU)); for (;;) { - me_draw(menu, sel); + me_draw(menu, sel, draw_more); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT| PBTN_MOK|PBTN_MBACK|PBTN_MENU|PBTN_L|PBTN_R, 70); if (inp & (PBTN_MENU|PBTN_MBACK)) @@ -521,8 +526,9 @@ static void me_loop(menu_entry *menu, int *menu_sel) if ((inp & (PBTN_L|PBTN_R)) == (PBTN_L|PBTN_R)) debug_menu_loop(); - if (inp & (PBTN_LEFT|PBTN_RIGHT)) { /* multi choice */ - if (me_process(&menu[sel], (inp & PBTN_RIGHT) ? 1 : 0)) + if (inp & (PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R)) { /* multi choice */ + if (me_process(&menu[sel], (inp & (PBTN_RIGHT|PBTN_R)) ? 1 : 0, + inp & (PBTN_L|PBTN_R))) continue; } @@ -540,6 +546,9 @@ static void me_loop(menu_entry *menu, int *menu_sel) /* ***************************************** */ +/* platform specific options and handlers */ +#include "../gp2x/menu.c" + static void draw_menu_credits(void) { const char *creds, *p; @@ -1379,7 +1388,7 @@ 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); + me_loop(e_menu_keyconfig, &sel, NULL); return 0; } @@ -1412,7 +1421,7 @@ static int mh_cdopt_ra(menu_id id, int keys) static menu_entry e_menu_cd_options[] = { - mee_onoff("CD LEDs", MA_CDOPT_LEDS, currentConfig.EmuOpt, 0x0400), + mee_onoff("CD LEDs", MA_CDOPT_LEDS, currentConfig.EmuOpt, EOPT_EN_CD_LEDS), mee_onoff("CDDA audio", MA_CDOPT_CDDA, PicoOpt, POPT_EN_MCD_CDDA), mee_onoff("PCM audio", MA_CDOPT_PCM, PicoOpt, POPT_EN_MCD_PCM), mee_cust ("ReadAhead buffer", MA_CDOPT_READAHEAD, mh_cdopt_ra, mgn_cdopt_ra), @@ -1425,7 +1434,7 @@ static menu_entry e_menu_cd_options[] = static int menu_loop_cd_options(menu_id id, int keys) { static int sel = 0; - me_loop(e_menu_cd_options, &sel); + me_loop(e_menu_cd_options, &sel, NULL); return 0; } @@ -1435,58 +1444,43 @@ static menu_entry e_menu_adv_options[] = { mee_onoff ("SRAM/BRAM saves", MA_OPT_SRAM_STATES, currentConfig.EmuOpt, EOPT_EN_SRAM), mee_onoff ("Disable sprite limit", MA_OPT2_NO_SPRITE_LIM, PicoOpt, POPT_DIS_SPRITE_LIM), - mee_onoff ("Use second CPU for sound", MA_OPT_ARM940_SOUND, PicoOpt, POPT_EXT_FM), mee_onoff ("Emulate Z80", MA_OPT2_ENABLE_Z80, PicoOpt, POPT_EN_Z80), mee_onoff ("Emulate YM2612 (FM)", MA_OPT2_ENABLE_YM2612, PicoOpt, POPT_EN_FM), mee_onoff ("Emulate SN76496 (PSG)", MA_OPT2_ENABLE_SN76496,PicoOpt, POPT_EN_PSG), mee_onoff ("gzip savestates", MA_OPT2_GZIP_STATES, currentConfig.EmuOpt, EOPT_GZIP_SAVES), mee_onoff ("Don't save last used ROM", MA_OPT2_NO_LAST_ROM, currentConfig.EmuOpt, EOPT_NO_AUTOSVCFG), - 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 ("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 mee_end, }; static int menu_loop_adv_options(menu_id id, int keys) { static int sel = 0; - me_loop(e_menu_adv_options, &sel); + me_loop(e_menu_adv_options, &sel, NULL); return 0; } // ------------ gfx options menu ------------ -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) +static int mh_opt_render(menu_id id, int keys) { - sprintf(static_buff, "%i.%02i", currentConfig.gamma / 100, currentConfig.gamma%100); - return static_buff; + plat_video_toggle_renderer((keys & PBTN_RIGHT) ? 1 : 0, 1); + return 0; } static menu_entry e_menu_gfx_options[] = { - mee_range_cust("Scaling", MA_OPT_SCALING, currentConfig.scaling, 0, 3, mgn_opt_scaling), - 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), + mee_cust ("Renderer", MA_OPT_RENDERER, mh_opt_render, mgn_opt_renderer), + MENU_GP2X_OPTIONS_GFX mee_end, }; static int menu_loop_gfx_options(menu_id id, int keys) { static int sel = 0; - me_loop(e_menu_gfx_options, &sel); + me_loop(e_menu_gfx_options, &sel, NULL); return 0; } @@ -1494,20 +1488,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 }; @@ -1620,15 +1600,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) @@ -1703,18 +1679,18 @@ 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), mee_handler ("[Display options]", menu_loop_gfx_options), - mee_handler ("[Advanced options]", menu_loop_adv_options), mee_handler ("[Sega/Mega CD options]", menu_loop_cd_options), + mee_handler ("[Advanced options]", menu_loop_adv_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, }; @@ -1725,7 +1701,7 @@ static int menu_loop_options(menu_id id, int keys) me_enable(e_menu_options, MA_OPT_SAVECFG_GAME, rom_loaded); me_enable(e_menu_options, MA_OPT_LOADCFG, config_slot != config_slot_current); - me_loop(e_menu_options, &sel); + me_loop(e_menu_options, &sel, NULL); if (PicoRegionOverride) // force setting possibly changed.. @@ -1976,7 +1952,7 @@ void menu_loop(void) plat_video_menu_enter(rom_loaded); in_set_blocking(1); - me_loop(e_menu_main, &sel); + me_loop(e_menu_main, &sel, menu_main_plat_draw); if (rom_loaded) { if (engineState == PGS_Menu) @@ -1992,24 +1968,14 @@ void menu_loop(void) static int mh_tray_load_cd(menu_id id, int keys) { - cd_img_type cd_type; char *ret_name; - int ret = -1; ret_name = romsel_run(); if (ret_name == NULL) return 0; - cd_type = emu_cd_check(NULL, ret_name); - if (cd_type != CIT_NOT_CD) - ret = Insert_CD(ret_name, cd_type); - if (ret != 0) { - me_update_msg("Load failed, invalid CD image?"); - return 0; - } - engineState = PGS_RestartRun; - return 1; + return emu_swap_cd(ret_name); } static int mh_tray_nothing(menu_id id, int keys) @@ -2025,6 +1991,7 @@ static menu_entry e_menu_tray[] = mee_label (""), mee_handler("Load CD image", mh_tray_load_cd), mee_handler("Insert nothing", mh_tray_nothing), + mee_end, }; int menu_loop_tray(void) @@ -2034,7 +2001,7 @@ int menu_loop_tray(void) plat_video_menu_enter(rom_loaded); in_set_blocking(1); - me_loop(e_menu_tray, &sel); + me_loop(e_menu_tray, &sel, NULL); if (engineState != PGS_RestartRun) { engineState = PGS_RestartRun; @@ -2060,13 +2027,17 @@ void me_update_msg(const char *msg) // ------------ util ------------ -/* wiz for now, probably extend later */ +/* GP2X/wiz for now, probably extend later */ void menu_plat_setup(int is_wiz) { int i; - if (!is_wiz) + 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); @@ -2074,6 +2045,8 @@ void menu_plat_setup(int is_wiz) 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; } /* TODO: rename */