X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Fmenu.c;h=5b0474a35be3689522e242fc0bba7c0e93adc382;hb=d227571356afae37e5ed67b1356b2a5a310bd204;hp=8accc2506530646e2ca228fc14df29e9dc85b389;hpb=d5d59eb4793bb5ffaa880bc2dc67908ff824e201;p=libpicofe.git diff --git a/common/menu.c b/common/menu.c index 8accc25..5b0474a 100644 --- a/common/menu.c +++ b/common/menu.c @@ -19,7 +19,7 @@ #include #include -#include +#include #include static char static_buff[64]; @@ -603,7 +603,6 @@ static void me_loop(menu_entry *menu, int *menu_sel, void (*draw_more)(void)) #else #define MENU_OPTIONS_GFX #define MENU_OPTIONS_ADV -#define mgn_opt_renderer NULL /* TODO */ #define menu_main_plat_draw NULL #endif @@ -1040,34 +1039,22 @@ static void state_check_slots(void) static void draw_savestate_bg(int slot) { - struct PicoVideo tmp_pv; - unsigned short tmp_cram[0x40]; - unsigned short tmp_vsram[0x40]; - void *tmp_vram; const char *fname; + void *tmp_state; fname = emu_get_save_fname(1, 0, slot); - if (!fname) return; - - tmp_vram = malloc(sizeof(Pico.vram)); - if (tmp_vram == NULL) return; + if (!fname) + return; - memcpy(tmp_vram, Pico.vram, sizeof(Pico.vram)); - memcpy(tmp_cram, Pico.cram, sizeof(Pico.cram)); - memcpy(tmp_vsram, Pico.vsram, sizeof(Pico.vsram)); - memcpy(&tmp_pv, &Pico.video, sizeof(Pico.video)); + tmp_state = PicoTmpStateSave(); - PicoStateLoadVDP(fname); + PicoStateLoadGfx(fname); /* do a frame and fetch menu bg */ pemu_forced_frame(POPT_EN_SOFTSCALE); menu_enter(1); - memcpy(Pico.vram, tmp_vram, sizeof(Pico.vram)); - memcpy(Pico.cram, tmp_cram, sizeof(Pico.cram)); - memcpy(Pico.vsram, tmp_vsram, sizeof(Pico.vsram)); - memcpy(&Pico.video, &tmp_pv, sizeof(Pico.video)); - free(tmp_vram); + PicoTmpStateRestore(tmp_state); } static void draw_savestate_menu(int menu_sel, int is_loading) @@ -1106,6 +1093,7 @@ static int menu_loop_savestate(int is_loading) static int menu_sel = 10; int menu_sel_max = 10; unsigned long inp = 0; + int ret = 0; state_check_slots(); @@ -1135,15 +1123,18 @@ static int menu_loop_savestate(int is_loading) state_slot = menu_sel; if (emu_save_load_game(is_loading, 0)) { me_update_msg(is_loading ? "Load failed" : "Save failed"); - return 0; + break; } - return 1; + ret = 1; + break; } - return 0; + break; } if (inp & PBTN_MBACK) - return 0; + break; } + + return ret; } // -------------- key config -------------- @@ -1494,16 +1485,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; } @@ -1534,15 +1556,14 @@ 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), + mee_range_cust("Renderer", MA_OPT_RENDERER, currentConfig.renderer, 0, 0, mgn_opt_renderer), MENU_OPTIONS_GFX mee_end, }; @@ -1550,6 +1571,14 @@ static menu_entry e_menu_gfx_options[] = 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; }