X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2Fmenu.c;h=a9b08257c596e43422c787e4a9fb54d940676789;hb=425cae19e290633047389c7cc3ecd49e8c4610a9;hp=55995b9e7d9063d1c4651eb30fb1a47dfca66382;hpb=558d8e1fdd54558c58fe5f661369f76458e1addc;p=libpicofe.git diff --git a/gp2x/menu.c b/gp2x/menu.c index 55995b9..a9b0825 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -25,12 +25,12 @@ #include #ifndef _DIRENT_HAVE_D_TYPE -#error "need d_type for file browser +#error "need d_type for file browser" #endif extern int mmuhack_status; -const char *keyNames[] = { +const char * const keyNames[] = { "UP", "???", "LEFT", "???", "DOWN", "???", "RIGHT", "???", "START", "SELECT", "L", "R", "A", "B", "X", "Y", "???", "???", "???", "???", "???", "???", "VOL DOWN", "VOL UP", @@ -46,16 +46,16 @@ static int inp_prevjoy = 0; static unsigned long wait_for_input(unsigned long interesting) { unsigned long ret; - static int repeats = 0, wait = 50*1000; + static int repeats = 0, wait = 20; int release = 0, i; - if (repeats == 2 || repeats == 4) wait /= 2; - if (repeats == 6) wait = 15 * 1000; + if (repeats == 2) wait = 3; + else if (repeats == 4) wait = 2; + else if (repeats == 6) wait = 1; - for (i = 0; i < 6 && inp_prev == gp2x_joystick_read(1); i++) { + for (i = 0; i < wait && inp_prev == gp2x_joystick_read(1); i++) { if (i == 0) repeats++; - if (wait >= 30*1000) usleep(wait); // usleep sleeps for ~30ms minimum - else spend_cycles(wait * currentConfig.CPUclock); + usleep(30000); } while ( !((ret = gp2x_joystick_read(1)) & interesting) ) { @@ -65,8 +65,10 @@ static unsigned long wait_for_input(unsigned long interesting) if (release || ret != inp_prev) { repeats = 0; - wait = 50*1000; + wait = 20; } + if (wait > 6 && (ret&(GP2X_UP|GP2X_LEFT|GP2X_DOWN|GP2X_RIGHT|GP2X_L|GP2X_R))) + wait = 6; inp_prev = ret; inp_prevjoy = 0; @@ -200,7 +202,7 @@ void menu_romload_end(void) static unsigned short file2color(const char *fname) { const char *ext = fname + strlen(fname) - 3; - static const char *rom_exts[] = { "zip", "bin", "smd", "gen", "iso", "cso" }; + static const char *rom_exts[] = { "zip", "bin", "smd", "gen", "iso", "cso", "cue" }; static const char *other_exts[] = { "gmv", "pat" }; int i; @@ -256,7 +258,7 @@ static int scandir_cmp(const void *p1, const void *p2) static char *filter_exts[] = { ".mp3", ".MP3", ".srm", ".brm", "s.gz", ".mds", "bcfg", ".txt", ".htm", "html", - ".jpg", ".gpe", ".cue" + ".jpg", ".gpe" }; static int scandir_filter(const struct dirent *ent) @@ -430,8 +432,10 @@ rescan: // ------------ debug menu ------------ char *debugString(void); +void PicoDrawShowSpriteStats(unsigned short *screen, int stride); +void PicoDrawShowPalette(unsigned short *screen, int stride); -static void draw_debug(void) +static void draw_main_debug(void) { char *p, *str = debugString(); int len, line; @@ -448,13 +452,49 @@ static void draw_debug(void) if (*p == 0) break; p++; str = p; } - menu_flip(); +} + +static void draw_frame_debug(void) +{ + char layer_str[48] = "layers: "; + if (PicoDrawMask & PDRAW_LAYERB_ON) memcpy(layer_str + 8, "B", 1); + if (PicoDrawMask & PDRAW_LAYERA_ON) memcpy(layer_str + 10, "A", 1); + if (PicoDrawMask & PDRAW_SPRITES_LOW_ON) memcpy(layer_str + 12, "spr_lo", 6); + if (PicoDrawMask & PDRAW_SPRITES_HI_ON) memcpy(layer_str + 19, "spr_hi", 6); + + memset(gp2x_screen, 0, 320*240*2); + emu_forcedFrame(0); + smalltext_out16(4, 232, layer_str, 0xffff); } static void debug_menu_loop(void) { - draw_debug(); - wait_for_input(GP2X_B|GP2X_X); + int inp, mode = 0; + + while (1) + { + switch (mode) + { + case 0: draw_main_debug(); break; + case 1: draw_frame_debug(); break; + case 2: gp2x_pd_clone_buffer2(); + PicoDrawShowSpriteStats(gp2x_screen, 320); break; + case 3: memset(gp2x_screen, 0, 320*240*2); + PicoDrawShowPalette(gp2x_screen, 320); break; + } + menu_flip(); + + inp = wait_for_input(GP2X_B|GP2X_X|GP2X_L|GP2X_R|GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT); + if (inp & (GP2X_B|GP2X_X)) return; + if (inp & GP2X_L) { mode--; if (mode < 0) mode = 3; } + if (inp & GP2X_R) { mode++; if (mode > 3) mode = 0; } + if (mode == 1) { + if (inp & GP2X_LEFT) PicoDrawMask ^= PDRAW_LAYERB_ON; + if (inp & GP2X_RIGHT) PicoDrawMask ^= PDRAW_LAYERA_ON; + if (inp & GP2X_DOWN) PicoDrawMask ^= PDRAW_SPRITES_LOW_ON; + if (inp & GP2X_UP) PicoDrawMask ^= PDRAW_SPRITES_HI_ON; + } + } } // ------------ patch/gg menu ------------ @@ -553,7 +593,7 @@ static void draw_savestate_bg(int slot) } if (file) { - if (PicoMCD & 1) { + if (PicoAHW & PAHW_MCD) { PicoCdLoadStateGfx(file); } else { areaSeek(file, 0x10020, SEEK_SET); // skip header and RAM in state file @@ -567,7 +607,7 @@ static void draw_savestate_bg(int slot) areaClose(file); } - emu_forcedFrame(); + emu_forcedFrame(POPT_EN_SOFTSCALE); menu_prepare_bg(1); memcpy(Pico.vram, tmp_vram, sizeof(Pico.vram)); @@ -751,7 +791,7 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_ x = 40; } - menu_draw_selection(x - 16, tl_y + sel*10, (player_idx >= 0) ? 66 : 130); + menu_draw_selection(x - 16, tl_y + sel*10, (player_idx >= 0) ? 66 : 140); y = tl_y; for (i = 0; i < opt_cnt; i++, y+=10) @@ -857,28 +897,32 @@ static void draw_kc_sel(int menu_sel) } -// player2_flag, ?, ?, ?, ?, ?, ?, menu +// player2_flag, reserved, ?, ?, +// ?, ?, fast forward, menu // "NEXT SAVE SLOT", "PREV SAVE SLOT", "SWITCH RENDERER", "SAVE STATE", // "LOAD STATE", "VOLUME UP", "VOLUME DOWN", "DONE" me_bind_action emuctrl_actions[] = { - { "Load State ", 1<<28 }, - { "Save State ", 1<<27 }, - { "Prev Save Slot ", 1<<25 }, - { "Next Save Slot ", 1<<24 }, - { "Switch Renderer", 1<<26 }, - { "Volume Down ", 1<<30 }, - { "Volume Up ", 1<<29 }, - { "Fast forward ", 1<<22 }, - { "Enter Menu ", 1<<23 }, - { NULL, 0 } + { "Load State ", 1<<28 }, + { "Save State ", 1<<27 }, + { "Prev Save Slot ", 1<<25 }, + { "Next Save Slot ", 1<<24 }, + { "Switch Renderer ", 1<<26 }, + { "Volume Down ", 1<<30 }, + { "Volume Up ", 1<<29 }, + { "Fast forward ", 1<<22 }, + { "Enter Menu ", 1<<23 }, + { "Pico Next page ", 1<<21 }, + { "Pico Prev page ", 1<<20 }, + { "Pico Switch input", 1<<19 }, + { NULL, 0 } }; static void kc_sel_loop(void) { int menu_sel = 3, menu_sel_max = 3; unsigned long inp = 0; - int is_6button = PicoOpt & 0x020; + int is_6button = PicoOpt & POPT_6BTN_PAD; while (1) { @@ -918,8 +962,8 @@ menu_entry cdopt_entries[] = { "done", MB_NONE, MA_CDOPT_DONE, NULL, 0, 0, 0, 1, 0 }, }; -const int cdopt_entry_count = (sizeof(cdopt_entries) / sizeof(cdopt_entries[0])); #define CDOPT_ENTRY_COUNT (sizeof(cdopt_entries) / sizeof(cdopt_entries[0])) +const int cdopt_entry_count = CDOPT_ENTRY_COUNT; struct bios_names_t @@ -1059,6 +1103,7 @@ menu_entry opt2_entries[] = { NULL, MB_NONE, MA_OPT2_GAMMA, NULL, 0, 0, 0, 1, 1 }, { "A_SN's gamma curve", MB_ONOFF, MA_OPT2_A_SN_GAMMA, ¤tConfig.EmuOpt, 0x1000, 0, 0, 1, 1 }, { "Perfect vsync", MB_ONOFF, MA_OPT2_VSYNC, ¤tConfig.EmuOpt, 0x2000, 0, 0, 1, 1 }, + { "Disable sprite limit", MB_ONOFF, MA_OPT2_NO_SPRITE_LIM, &PicoOpt, 0x40000, 0, 0, 1, 1 }, { "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, &PicoOpt, 0x00004, 0, 0, 1, 1 }, { "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, &PicoOpt, 0x00001, 0, 0, 1, 1 }, { "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496,&PicoOpt, 0x00002, 0, 0, 1, 1 }, @@ -1068,11 +1113,12 @@ menu_entry opt2_entries[] = { "craigix's RAM timings", MB_ONOFF, MA_OPT2_RAMTIMINGS, ¤tConfig.EmuOpt, 0x0100, 0, 0, 1, 1 }, { NULL, MB_ONOFF, MA_OPT2_SQUIDGEHACK, ¤tConfig.EmuOpt, 0x0010, 0, 0, 1, 1 }, { "SVP dynarec", MB_ONOFF, MA_OPT2_SVP_DYNAREC, &PicoOpt, 0x20000, 0, 0, 1, 1 }, + { "Disable idle loop patching",MB_ONOFF, MA_OPT2_NO_IDLE_LOOPS, &PicoOpt, 0x80000, 0, 0, 1, 1 }, { "done", MB_NONE, MA_OPT2_DONE, NULL, 0, 0, 0, 1, 0 }, }; #define OPT2_ENTRY_COUNT (sizeof(opt2_entries) / sizeof(opt2_entries[0])) -const int opt2_entry_count = (sizeof(opt2_entries) / sizeof(opt2_entries[0])); +const int opt2_entry_count = OPT2_ENTRY_COUNT; static void menu_opt2_cust_draw(const menu_entry *entry, int x, int y, void *param) { @@ -1142,8 +1188,7 @@ menu_entry opt_entries[] = { { NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1, 1 }, { NULL, MB_RANGE, MA_OPT_SCALING, ¤tConfig.scaling, 0, 0, 3, 1, 1 }, - { "Accurate timing (slower)", MB_ONOFF, MA_OPT_ACC_TIMING, &PicoOpt, 0x040, 0, 0, 1, 1 }, - { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoOpt, 0x080, 0, 0, 1, 1 }, + { "Accurate sprites", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoOpt, 0x080, 0, 0, 0, 1 }, { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, ¤tConfig.EmuOpt, 0x002, 0, 0, 1, 1 }, { NULL, MB_RANGE, MA_OPT_FRAMESKIP, ¤tConfig.Frameskip, 0, -1, 16, 1, 1 }, { "Enable sound", MB_ONOFF, MA_OPT_ENABLE_SOUND, ¤tConfig.EmuOpt, 0x004, 0, 0, 1, 1 }, @@ -1173,7 +1218,7 @@ static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *para switch (entry->id) { case MA_OPT_RENDERER: - if (PicoOpt&0x10) + if (PicoOpt & POPT_ALT_RENDERER) str = " 8bit fast"; else if (currentConfig.EmuOpt&0x80) str = "16bit accurate"; @@ -1197,7 +1242,7 @@ static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *para text_out16(x, y, "Frameskip %s", str24); break; case MA_OPT_SOUND_QUALITY: - str = (PicoOpt&0x08)?"stereo":"mono"; + str = (PicoOpt & POPT_EN_STEREO) ? "stereo" : "mono"; text_out16(x, y, "Sound Quality: %5iHz %s", PsndRate, str); break; case MA_OPT_REGION: @@ -1287,7 +1332,7 @@ static void menu_options_save(void) // force setting possibly changed.. Pico.m.pal = (PicoRegionOverride == 2 || PicoRegionOverride == 8) ? 1 : 0; } - if (!(PicoOpt & 0x20)) { + if (!(PicoOpt & POPT_6BTN_PAD)) { // unbind XYZ MODE, just in case unbind_action(0xf00, -1, -1); } @@ -1421,27 +1466,29 @@ static int menu_loop_options(void) static void draw_menu_credits(void) { - int tl_x = 15, tl_y = 64, y; + int tl_x = 15, tl_y = 56, y; gp2x_pd_clone_buffer2(); - text_out16(tl_x, 20, "PicoDrive v" VERSION " (c) notaz, 2006,2007"); + text_out16(tl_x, 20, "PicoDrive v" VERSION " (c) notaz, 2006-2008"); y = tl_y; text_out16(tl_x, y, "Credits:"); text_out16(tl_x, (y+=10), "fDave: Cyclone 68000 core,"); text_out16(tl_x, (y+=10), " base code of PicoDrive"); text_out16(tl_x, (y+=10), "Reesy & FluBBa: DrZ80 core"); text_out16(tl_x, (y+=10), "MAME devs: YM2612 and SN76496 cores"); - text_out16(tl_x, (y+=10), "Charles MacDonald: Genesis hw docs"); - text_out16(tl_x, (y+=10), "Stephane Dallongeville:"); - text_out16(tl_x, (y+=10), " opensource Gens"); - text_out16(tl_x, (y+=10), "Haze: Genesis hw info"); text_out16(tl_x, (y+=10), "rlyeh and others: minimal SDK"); text_out16(tl_x, (y+=10), "Squidge: squidgehack"); text_out16(tl_x, (y+=10), "Dzz: ARM940 sample"); - text_out16(tl_x, (y+=10), "GnoStiC / Puck2099: USB joystick"); + text_out16(tl_x, (y+=10), "GnoStiC / Puck2099: USB joy code"); text_out16(tl_x, (y+=10), "craigix: GP2X hardware"); text_out16(tl_x, (y+=10), "ketchupgun: skin design"); + text_out16(tl_x, (y+=20), "special thanks (for docs, ideas):"); + text_out16(tl_x, (y+=10), " Charles MacDonald, Haze,"); + text_out16(tl_x, (y+=10), " Stephane Dallongeville,"); + text_out16(tl_x, (y+=10), " Lordus, Exophase, Rokas,"); + text_out16(tl_x, (y+=10), " Nemesis, Tasco Deluxe"); + menu_flip(); } @@ -1540,6 +1587,7 @@ static void menu_loop_root(void) if (rom_loaded) { if(savestate_menu_loop(1)) continue; + while (gp2x_joystick_read(1) & GP2X_B) usleep(50*1000); engineState = PGS_Running; return; } @@ -1547,6 +1595,7 @@ static void menu_loop_root(void) case MA_MAIN_RESET_GAME: if (rom_loaded) { emu_ResetGame(); + while (gp2x_joystick_read(1) & GP2X_B) usleep(50*1000); engineState = PGS_Running; return; } @@ -1723,10 +1772,11 @@ int menu_loop_tray(void) case 0: // select image selfname = romsel_loop(curr_path); if (selfname) { - int ret = -1, cd_type; + int ret = -1; + cd_img_type cd_type; cd_type = emu_cdCheck(NULL); - if (cd_type > 0) - ret = Insert_CD(romFileName, cd_type == 2); + if (cd_type != CIT_NOT_CD) + ret = Insert_CD(romFileName, cd_type); if (ret != 0) { sprintf(menuErrorMsg, "Load failed, invalid CD image?"); printf("%s\n", menuErrorMsg);