X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Fmenu.c;h=dff1b39ca6d19c5bf86f71bdfac26c47675efc83;hb=2f3ca01638b740bc8ca5530dac8f3e2d2e069cb1;hp=4a01896e23f40b7b5e2cbb5860586fba7ca03d60;hpb=4858c6338ba7ec5a9061ea9b7505acde098c03d9;p=libpicofe.git diff --git a/common/menu.c b/common/menu.c index 4a01896..dff1b39 100644 --- a/common/menu.c +++ b/common/menu.c @@ -17,12 +17,10 @@ #include "plat.h" #include "posix.h" #include +#include #include #include -#include - -#define array_size(x) (sizeof(x) / sizeof(x[0])) static char static_buff[64]; static char menu_error_msg[64] = { 0, }; @@ -602,7 +600,7 @@ static void load_progress_cb(int percent) plat_video_menu_end(); } -static void cdload_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; @@ -610,7 +608,7 @@ static void cdload_progress_cb(int percent) memset(dst, 0xff, g_screen_width * (me_sfont_h - 2) * 2); smalltext_out16(1, 3 * me_sfont_h, "Processing CD image / MP3s", 0xffff); - smalltext_out16(1, 4 * me_sfont_h, rom_fname_loaded, 0xffff); + smalltext_out16(1, 4 * me_sfont_h, fname, 0xffff); dst += g_screen_width * me_sfont_h * 3; if (len > g_screen_width) @@ -647,7 +645,8 @@ void menu_romload_prepare(const char *rom_name) void menu_romload_end(void) { - PicoCartLoadProgressCB = PicoCDLoadProgressCB = NULL; + PicoCartLoadProgressCB = NULL; + PicoCDLoadProgressCB = NULL; smalltext_out16(1, (cdload_called ? 6 : 3) * me_sfont_h, "Starting emulation...", 0xffff); plat_video_menu_end(); @@ -971,8 +970,8 @@ static void draw_savestate_bg(int slot) struct PicoVideo tmp_pv; unsigned short tmp_cram[0x40]; unsigned short tmp_vsram[0x40]; - void *tmp_vram, *file; - char *fname; + void *tmp_vram; + const char *fname; fname = emu_get_save_fname(1, 0, slot); if (!fname) return; @@ -985,28 +984,7 @@ static void draw_savestate_bg(int slot) memcpy(tmp_vsram, Pico.vsram, sizeof(Pico.vsram)); memcpy(&tmp_pv, &Pico.video, sizeof(Pico.video)); - if (strcmp(fname + strlen(fname) - 3, ".gz") == 0) { - file = gzopen(fname, "rb"); - emu_setSaveStateCbs(1); - } else { - file = fopen(fname, "rb"); - emu_setSaveStateCbs(0); - } - - if (file) { - if (PicoAHW & PAHW_MCD) { - PicoCdLoadStateGfx(file); - } else { - areaSeek(file, 0x10020, SEEK_SET); // skip header and RAM in state file - areaRead(Pico.vram, 1, sizeof(Pico.vram), file); - areaSeek(file, 0x2000, SEEK_CUR); - areaRead(Pico.cram, 1, sizeof(Pico.cram), file); - areaRead(Pico.vsram, 1, sizeof(Pico.vsram), file); - areaSeek(file, 0x221a0, SEEK_SET); - areaRead(&Pico.video, 1, sizeof(Pico.video), file); - } - areaClose(file); - } + PicoStateLoadVDP(fname); /* do a frame and fetch menu bg */ pemu_forced_frame(POPT_EN_SOFTSCALE); @@ -1058,6 +1036,9 @@ static int menu_loop_savestate(int is_loading) state_check_slots(); + if (!(state_slot_flags & (1 << menu_sel)) && is_loading) + menu_sel = menu_sel_max; + for (;;) { draw_savestate_menu(menu_sel, is_loading); @@ -1421,7 +1402,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), @@ -1685,8 +1666,8 @@ static menu_entry e_menu_options[] = 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), @@ -1758,6 +1739,12 @@ static void draw_text_debug(const char *str, int skip, int from) } } +#ifdef __GNUC__ +#define COMPILER "gcc " __VERSION__ +#else +#define COMPILER +#endif + static void draw_frame_debug(void) { char layer_str[48] = "layers: "; @@ -1768,7 +1755,7 @@ static void draw_frame_debug(void) memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2); pemu_forced_frame(0); - smalltext_out16(4, 1, "build: " __DATE__ " " __TIME__, 0xffff); + smalltext_out16(4, 1, "build: r" REVISION " "__DATE__ " " __TIME__ " " COMPILER, 0xffff); smalltext_out16(4, g_screen_height - me_sfont_h, layer_str, 0xffff); } @@ -1968,24 +1955,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) @@ -1995,12 +1972,12 @@ static int mh_tray_nothing(menu_id id, int keys) static menu_entry e_menu_tray[] = { - mee_label ("The unit is about to"), - mee_label ("close the CD tray."), + mee_label ("The CD tray has opened."), mee_label (""), 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) @@ -2043,6 +2020,8 @@ void menu_plat_setup(int 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; } @@ -2052,6 +2031,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 */