X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2Fmenu.c;h=b7bd3f17c4f907fc19282595f2764e18a551041d;hb=61f66fe0ab7ab4047a2c005fc52afeb50c26fc12;hp=db4c9fab7ebea2dfb196e3447a4678dd5223cacc;hpb=6af8fee5348a8f90be23eb8f74fcfe2b5b28e60e;p=libpicofe.git diff --git a/gp2x/menu.c b/gp2x/menu.c index db4c9fa..b7bd3f1 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -25,7 +25,7 @@ #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; @@ -37,13 +37,13 @@ const char * const keyNames[] = { "???", "???", "???", "PUSH", "???", "???", "???", "???" }; -static void menu_darken_bg(void *dst, int pixels, int darker); +void menu_darken_bg(void *dst, int pixels, int darker); static void menu_prepare_bg(int use_game_bg); static unsigned long inp_prev = 0; static int inp_prevjoy = 0; -static unsigned long wait_for_input(unsigned long interesting) +unsigned long wait_for_input(unsigned long interesting) { unsigned long ret; static int repeats = 0, wait = 20; @@ -67,7 +67,7 @@ static unsigned long wait_for_input(unsigned long interesting) repeats = 0; wait = 20; } - if (wait > 6 && (ret&(GP2X_UP|GP2X_LEFT|GP2X_DOWN|GP2X_RIGHT))) + if (wait > 6 && (ret&(GP2X_UP|GP2X_LEFT|GP2X_DOWN|GP2X_RIGHT|GP2X_L|GP2X_R))) wait = 6; inp_prev = ret; inp_prevjoy = 0; @@ -132,7 +132,7 @@ static unsigned long wait_for_input_usbjoy(unsigned long interesting, int *joy) return ret; } -static void menu_flip(void) +void menu_flip(void) { gp2x_video_flush_cache(); gp2x_video_flip2(); @@ -429,36 +429,6 @@ rescan: return ret; } -// ------------ debug menu ------------ - -char *debugString(void); - -static void draw_debug(void) -{ - char *p, *str = debugString(); - int len, line; - - gp2x_pd_clone_buffer2(); - - p = str; - for (line = 0; line < 24; line++) - { - while (*p && *p != '\n') p++; - len = p - str; - if (len > 55) len = 55; - smalltext_out16_lim(1, line*10, str, 0xffff, len); - if (*p == 0) break; - p++; str = p; - } - menu_flip(); -} - -static void debug_menu_loop(void) -{ - draw_debug(); - wait_for_input(GP2X_B|GP2X_X); -} - // ------------ patch/gg menu ------------ static void draw_patchlist(int sel) @@ -569,7 +539,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)); @@ -742,14 +712,14 @@ static int count_bound_keys(int action, int pl_idx, int joy) static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_idx, int sel) { - int x, y, tl_y = 40, i; + int x, y, tl_y = 30, i; gp2x_pd_clone_buffer2(); if (player_idx >= 0) { - text_out16(80, 20, "Player %i controls", player_idx + 1); + text_out16(80, 10, "Player %i controls", player_idx + 1); x = 80; } else { - text_out16(80, 20, "Emulator controls"); + text_out16(80, 10, "Emulator controls"); x = 40; } @@ -762,14 +732,14 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_ text_out16(x, y, "Done"); if (sel < opt_cnt) { - text_out16(30, 180, "Press a button to bind/unbind"); - text_out16(30, 190, "Use SELECT to clear"); - text_out16(30, 200, "To bind UP/DOWN, hold SELECT"); - text_out16(30, 210, "Select \"Done\" to exit"); + text_out16(30, 195, "Press a button to bind/unbind"); + text_out16(30, 205, "Use SELECT to clear"); + text_out16(30, 215, "To bind UP/DOWN, hold SELECT"); + text_out16(30, 225, "Select \"Done\" to exit"); } else { - text_out16(30, 190, "Use Options -> Save cfg"); - text_out16(30, 200, "to save controls"); - text_out16(30, 210, "Press B or X to exit"); + text_out16(30, 205, "Use Options -> Save cfg"); + text_out16(30, 215, "to save controls"); + text_out16(30, 225, "Press B or X to exit"); } menu_flip(); } @@ -830,6 +800,21 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_ } } + +menu_entry ctrlopt_entries[] = +{ + { "Player 1", MB_NONE, MA_CTRL_PLAYER1, NULL, 0, 0, 0, 1, 0 }, + { "Player 2", MB_NONE, MA_CTRL_PLAYER2, NULL, 0, 0, 0, 1, 0 }, + { "Emulator controls", MB_NONE, MA_CTRL_EMU, NULL, 0, 0, 0, 1, 0 }, + { "6 button pad", MB_ONOFF, MA_OPT_6BUTTON_PAD, &PicoOpt, 0x020, 0, 0, 1, 1 }, + { "Turbo rate", MB_RANGE, MA_CTRL_TURBO_RATE, ¤tConfig.turbo_rate, 0, 1, 30, 1, 1 }, + { "Done", MB_NONE, MA_CTRL_DONE, NULL, 0, 0, 0, 1, 0 }, +}; + +#define CTRLOPT_ENTRY_COUNT (sizeof(ctrlopt_entries) / sizeof(ctrlopt_entries[0])) +const int ctrlopt_entry_count = CTRLOPT_ENTRY_COUNT; + + static void draw_kc_sel(int menu_sel) { int tl_x = 25+40, tl_y = 60, y, i; @@ -839,13 +824,10 @@ static void draw_kc_sel(int menu_sel) gp2x_pd_clone_buffer2(); menu_draw_selection(tl_x - 16, tl_y + menu_sel*10, 138); - text_out16(tl_x, y, "Player 1"); - text_out16(tl_x, (y+=10), "Player 2"); - text_out16(tl_x, (y+=10), "Emulator controls"); - text_out16(tl_x, (y+=10), "Done"); + me_draw(ctrlopt_entries, ctrlopt_entry_count, tl_x, tl_y, NULL, NULL); tl_x = 25; - text_out16(tl_x, (y=110), "USB joys detected:"); + text_out16(tl_x, (y=130), "USB joys detected:"); if (num_of_joys > 0) { for (i = 0; i < num_of_joys; i++) { strncpy(joyname, joy_name(joys[i]), 33); joyname[33] = 0; @@ -882,23 +864,27 @@ me_bind_action emuctrl_actions[] = static void kc_sel_loop(void) { - int menu_sel = 3, menu_sel_max = 3; + int menu_sel = 5, menu_sel_max = 5; unsigned long inp = 0; - int is_6button = PicoOpt & POPT_6BTN_PAD; + menu_id selected_id; while (1) { draw_kc_sel(menu_sel); - inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_B|GP2X_X); + inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_RIGHT|GP2X_LEFT|GP2X_B|GP2X_X); + selected_id = me_index2id(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, menu_sel); + if (inp & (GP2X_LEFT|GP2X_RIGHT)) // multi choise + me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&GP2X_RIGHT) ? 1 : 0); if (inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & GP2X_B) { - switch (menu_sel) { - case 0: key_config_loop(me_ctrl_actions, is_6button ? 12 : 8, 0); return; - case 1: key_config_loop(me_ctrl_actions, is_6button ? 12 : 8, 1); return; - case 2: key_config_loop(emuctrl_actions, - sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]) - 1, -1); return; - case 3: if (!rom_loaded) emu_WriteConfig(0); return; + int is_6button = PicoOpt & POPT_6BTN_PAD; + switch (selected_id) { + case MA_CTRL_PLAYER1: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 0); return; + case MA_CTRL_PLAYER2: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 1); return; + case MA_CTRL_EMU: key_config_loop(emuctrl_actions, + sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]) - 1, -1); return; + case MA_CTRL_DONE: if (!rom_loaded) emu_WriteConfig(0); return; default: return; } } @@ -915,7 +901,7 @@ menu_entry cdopt_entries[] = { NULL, MB_NONE, MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1, 0 }, { NULL, MB_NONE, MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1, 0 }, { "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, ¤tConfig.EmuOpt, 0x0400, 0, 0, 1, 1 }, - { "CDDA audio (using mp3s)", MB_ONOFF, MA_CDOPT_CDDA, &PicoOpt, 0x0800, 0, 0, 1, 1 }, + { "CDDA audio", MB_ONOFF, MA_CDOPT_CDDA, &PicoOpt, 0x0800, 0, 0, 1, 1 }, { "PCM audio", MB_ONOFF, MA_CDOPT_PCM, &PicoOpt, 0x0400, 0, 0, 1, 1 }, { NULL, MB_NONE, MA_CDOPT_READAHEAD, NULL, 0, 0, 0, 1, 1 }, { "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, &PicoOpt, 0x8000, 0, 0, 1, 1 }, @@ -1075,6 +1061,7 @@ 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 }, }; @@ -1149,14 +1136,12 @@ 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 }, { NULL, MB_NONE, MA_OPT_SOUND_QUALITY, NULL, 0, 0, 0, 1, 1 }, { "Use ARM940 core for sound", MB_ONOFF, MA_OPT_ARM940_SOUND, &PicoOpt, 0x200, 0, 0, 1, 1 }, - { "6 button pad", MB_ONOFF, MA_OPT_6BUTTON_PAD, &PicoOpt, 0x020, 0, 0, 1, 1 }, { NULL, MB_NONE, MA_OPT_REGION, NULL, 0, 0, 0, 1, 1 }, { "Use SRAM/BRAM savestates", MB_ONOFF, MA_OPT_SRAM_STATES, ¤tConfig.EmuOpt, 0x001, 0, 0, 1, 1 }, { NULL, MB_NONE, MA_OPT_CONFIRM_STATES,NULL, 0, 0, 0, 1, 1 }, @@ -1428,7 +1413,7 @@ 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-2008"); @@ -1438,17 +1423,19 @@ static void draw_menu_credits(void) 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(); } @@ -1564,10 +1551,10 @@ static void menu_loop_root(void) { char curr_path[PATH_MAX], *selfname; FILE *tstf; - if ( (tstf = fopen(lastRomFile, "rb")) ) + if ( (tstf = fopen(loadedRomFName, "rb")) ) { fclose(tstf); - strcpy(curr_path, lastRomFile); + strcpy(curr_path, loadedRomFName); } else getcwd(curr_path, PATH_MAX); @@ -1613,7 +1600,7 @@ static void menu_loop_root(void) } } -static void menu_darken_bg(void *dst, int pixels, int darker) +void menu_darken_bg(void *dst, int pixels, int darker) { unsigned int *screen = dst; pixels /= 2; @@ -1707,10 +1694,10 @@ int menu_loop_tray(void) gp2x_memset_all_buffers(0, 0, 320*240*2); menu_gfx_prepare(); - if ( (tstf = fopen(lastRomFile, "rb")) ) + if ( (tstf = fopen(loadedRomFName, "rb")) ) { fclose(tstf); - strcpy(curr_path, lastRomFile); + strcpy(curr_path, loadedRomFName); } else { @@ -1734,7 +1721,7 @@ int menu_loop_tray(void) if (selfname) { int ret = -1; cd_img_type cd_type; - cd_type = emu_cdCheck(NULL); + cd_type = emu_cdCheck(NULL, romFileName); if (cd_type != CIT_NOT_CD) ret = Insert_CD(romFileName, cd_type); if (ret != 0) {