X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2Fmenu.c;h=05d0903570b66d0858622bcd8da69cf545ed9ce2;hb=446b090ceade65a57b2f97493d6670ffb236a747;hp=df5ff8a436a11df01890e274874d787e2ea2d7bf;hpb=8e708f920ffd20b026aed616e58c8c8e94c8fb8d;p=libpicofe.git diff --git a/gp2x/menu.c b/gp2x/menu.c index df5ff8a..05d0903 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -30,7 +30,7 @@ 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 = 6; 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,7 +65,7 @@ static unsigned long wait_for_input(unsigned long interesting) if (release || ret != inp_prev) { repeats = 0; - wait = 50*1000; + wait = 6; } inp_prev = ret; inp_prevjoy = 0; @@ -124,6 +124,8 @@ static unsigned long wait_for_input_usbjoy(unsigned long interesting, int *joy) // handle only 1 event at a time for (i = 1; i != 0; i <<= 1) if (ret & i) { ret &= i; break; } + // ... but allow select + ret |= inp_prev & GP2X_SELECT; return ret; } @@ -198,7 +200,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; @@ -254,7 +256,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) @@ -275,6 +277,31 @@ static int scandir_filter(const struct dirent *ent) return 1; } +static void do_delete(const char *fpath, const char *fname) +{ + int len, inp; + + gp2x_pd_clone_buffer2(); + + if (!rom_loaded) + menu_darken_bg(gp2x_screen, 320*240, 0); + + len = strlen(fname); + if (len > 320/6) len = 320/6; + + text_out16(320/2 - 15*8/2, 80, "About to delete"); + smalltext_out16_lim(320/2 - len*6/2, 95, fname, 0xbdff, len); + text_out16(320/2 - 13*8/2, 110, "Are you sure?"); + text_out16(320/2 - 25*8/2, 120, "(Y - confirm, X - cancel)"); + menu_flip(); + + + while (gp2x_joystick_read(1) & (GP2X_A|GP2X_SELECT)) usleep(50*1000); + inp = wait_for_input(GP2X_Y|GP2X_X); + if (inp & GP2X_Y) + remove(fpath); +} + static char *romsel_loop(char *curr_path) { struct dirent **namelist; @@ -283,6 +310,7 @@ static char *romsel_loop(char *curr_path) unsigned long inp = 0; char *ret = NULL, *fname = NULL; +rescan: // is this a dir or a full path? if ((dir = opendir(curr_path))) { closedir(dir); @@ -319,24 +347,39 @@ static char *romsel_loop(char *curr_path) for (;;) { draw_dirlist(curr_path, namelist, n, sel); - inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_L|GP2X_R|GP2X_B|GP2X_X); + inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_L|GP2X_R|GP2X_A|GP2X_B|GP2X_X|GP2X_SELECT); if(inp & GP2X_UP ) { sel--; if (sel < 0) sel = n-2; } if(inp & GP2X_DOWN) { sel++; if (sel > n-2) sel = 0; } if(inp & GP2X_LEFT) { sel-=10; if (sel < 0) sel = 0; } if(inp & GP2X_L) { sel-=24; if (sel < 0) sel = 0; } if(inp & GP2X_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; } if(inp & GP2X_R) { sel+=24; if (sel > n-2) sel = n-2; } - if(inp & GP2X_B) { // enter dir/select + if ((inp & GP2X_B) || (inp & (GP2X_SELECT|GP2X_A)) == (GP2X_SELECT|GP2X_A)) // enter dir/select || delete + { again: - if (namelist[sel+1]->d_type == DT_REG) { + if (namelist[sel+1]->d_type == DT_REG) + { strcpy(romFileName, curr_path); strcat(romFileName, "/"); strcat(romFileName, namelist[sel+1]->d_name); - ret = romFileName; - break; - } else if (namelist[sel+1]->d_type == DT_DIR) { - int newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2; - char *p, *newdir = malloc(newlen); + if (inp & GP2X_B) { // return sel + ret = romFileName; + break; + } + do_delete(romFileName, namelist[sel+1]->d_name); + if (n > 0) { + while (n--) free(namelist[n]); + free(namelist); + } + goto rescan; + } + else if (namelist[sel+1]->d_type == DT_DIR) + { + int newlen; + char *p, *newdir; + if (!(inp & GP2X_B)) continue; + newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2; + newdir = malloc(newlen); if (strcmp(namelist[sel+1]->d_name, "..") == 0) { char *start = curr_path; p = start + strlen(start) - 1; @@ -354,7 +397,9 @@ static char *romsel_loop(char *curr_path) ret = romsel_loop(newdir); free(newdir); break; - } else { + } + else + { // unknown file type, happens on NTFS mounts. Try to guess. FILE *tstf; int tmp; strcpy(romFileName, curr_path); @@ -375,7 +420,7 @@ static char *romsel_loop(char *curr_path) } if (n > 0) { - while(n--) free(namelist[n]); + while (n--) free(namelist[n]); free(namelist); } @@ -508,7 +553,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 @@ -706,7 +751,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) @@ -737,7 +782,8 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_ draw_key_config(opts, opt_cnt, player_idx, sel); inp = wait_for_input_usbjoy(CONFIGURABLE_KEYS, &joy); // printf("got %08lX from joy %i\n", inp, joy); - if (joy == 0) { + if (joy == 0) + { if (!(inp & GP2X_SELECT)) { prev_select = 0; if(inp & GP2X_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; } @@ -811,28 +857,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) { @@ -872,8 +922,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 @@ -960,9 +1010,9 @@ static void cd_menu_loop_options(void) selected_id == MA_CDOPT_READAHEAD) { if (inp & GP2X_LEFT) { PicoCDBuffers >>= 1; - if (PicoCDBuffers < 64) PicoCDBuffers = 0; + if (PicoCDBuffers < 2) PicoCDBuffers = 0; } else { - if (PicoCDBuffers < 64) PicoCDBuffers = 64; + if (PicoCDBuffers < 2) PicoCDBuffers = 2; else PicoCDBuffers <<= 1; if (PicoCDBuffers > 8*1024) PicoCDBuffers = 8*1024; // 16M } @@ -1013,6 +1063,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 }, @@ -1026,7 +1077,7 @@ menu_entry opt2_entries[] = }; #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) { @@ -1127,7 +1178,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"; @@ -1151,7 +1202,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: @@ -1241,7 +1292,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); } @@ -1378,7 +1429,7 @@ static void draw_menu_credits(void) int tl_x = 15, tl_y = 64, 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,"); @@ -1494,6 +1545,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; } @@ -1501,6 +1553,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; } @@ -1677,10 +1730,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);