idle loop hack, psp bugfix, plat debug str
[picodrive.git] / platform / gizmondo / menu.c
index 3445aaf..1ee99e4 100644 (file)
@@ -48,16 +48,17 @@ static unsigned int inp_prev = 0;
 \r
 static unsigned long wait_for_input(unsigned int interesting)\r
 {\r
-       unsigned int ret;\r
-       static int repeats = 0, wait = 50;\r
+       unsigned long ret;\r
+       static int repeats = 0, wait = 20;\r
        int release = 0, i;\r
 \r
-       if (repeats == 2 || repeats == 4) wait /= 2;\r
-       if (repeats == 6) wait = 15;\r
+       if      (repeats == 2) wait = 3;\r
+       else if (repeats == 4) wait = 2;\r
+       else if (repeats == 6) wait = 1;\r
 \r
-       for (i = 0; i < 6 && inp_prev == Framework_PollGetButtons(); i++) {\r
+       for (i = 0; i < wait && inp_prev == Framework_PollGetButtons(); i++) {\r
                if (i == 0) repeats++;\r
-               Sleep(wait);\r
+               Sleep(30);\r
        }\r
 \r
        while ( !((ret = Framework_PollGetButtons()) & interesting) ) {\r
@@ -67,8 +68,10 @@ static unsigned long wait_for_input(unsigned int interesting)
 \r
        if (release || ret != inp_prev) {\r
                repeats = 0;\r
-               wait = 50;\r
+               wait = 20;\r
        }\r
+       if (wait > 6 && (ret&(BTN_UP|BTN_LEFT|BTN_DOWN|BTN_RIGHT|BTN_L|BTN_R)))\r
+               wait = 6;\r
        inp_prev = ret;\r
 \r
        // we don't need diagonals in menus\r
@@ -435,36 +438,6 @@ static char *romsel_loop(char *curr_path)
 }\r
 #endif\r
 \r
-// ------------ debug menu ------------\r
-\r
-char *debugString(void);\r
-\r
-static void draw_debug(void)\r
-{\r
-       char *p, *str = debugString();\r
-       int len, line;\r
-\r
-       menu_draw_begin(1);\r
-\r
-       p = str;\r
-       for (line = 0; line < 24; line++)\r
-       {\r
-               while (*p && *p != '\n') p++;\r
-               len = p - str;\r
-               if (len > 55) len = 55;\r
-               smalltext_out16_lim(1, line*10, str, 0xffff, len);\r
-               if (*p == 0) break;\r
-               p++; str = p;\r
-       }\r
-       menu_draw_end();\r
-}\r
-\r
-static void debug_menu_loop(void)\r
-{\r
-       draw_debug();\r
-       wait_for_input(BTN_PLAY|BTN_STOP);\r
-}\r
-\r
 // ------------ patch/gg menu ------------\r
 \r
 static void draw_patchlist(int sel)\r
@@ -575,7 +548,7 @@ static void draw_savestate_bg(int slot)
                areaClose(file);\r
        }\r
 \r
-       emu_forcedFrame();\r
+       emu_forcedFrame(POPT_EN_SOFTSCALE);\r
        menu_prepare_bg(1);\r
 \r
        memcpy(Pico.vram, tmp_vram, sizeof(Pico.vram));\r
@@ -689,14 +662,14 @@ static int count_bound_keys(int action, int pl_idx)
 \r
 static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_idx, int sel)\r
 {\r
-       int x, y, tl_y = 40, i;\r
+       int x, y, tl_y = 30, i;\r
 \r
        menu_draw_begin(1);\r
        if (player_idx >= 0) {\r
-               text_out16(80, 20, "Player %i controls", player_idx + 1);\r
+               text_out16(80, 10, "Player %i controls", player_idx + 1);\r
                x = 80;\r
        } else {\r
-               text_out16(80, 20, "Emulator controls");\r
+               text_out16(80, 10, "Emulator controls");\r
                x = 40;\r
        }\r
 \r
@@ -709,14 +682,14 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_
        text_out16(x, y, "Done");\r
 \r
        if (sel < opt_cnt) {\r
-               text_out16(30, 180, "Press a button to bind/unbind");\r
-               text_out16(30, 190, "Use HOME to clear");\r
-               text_out16(30, 200, "To bind UP/DOWN, hold HOME");\r
-               text_out16(30, 210, "Select \"Done\" to exit");\r
+               text_out16(30, 195, "Press a button to bind/unbind");\r
+               text_out16(30, 205, "Use HOME to clear");\r
+               text_out16(30, 215, "To bind UP/DOWN, hold HOME");\r
+               text_out16(30, 225, "Select \"Done\" to exit");\r
        } else {\r
-               text_out16(30, 190, "Use Options -> Save cfg");\r
-               text_out16(30, 200, "to save controls");\r
-               text_out16(30, 210, "Press PLAY or STOP to exit");\r
+               text_out16(30, 205, "Use Options -> Save cfg");\r
+               text_out16(30, 215, "to save controls");\r
+               text_out16(30, 225, "Press PLAY or STOP to exit");\r
        }\r
        menu_draw_end();\r
 }\r
@@ -758,6 +731,19 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
        }\r
 }\r
 \r
+menu_entry ctrlopt_entries[] =\r
+{\r
+       { "Player 1",                  MB_NONE,  MA_CTRL_PLAYER1,       NULL, 0, 0, 0, 1, 0 },\r
+       { "Player 2",                  MB_NONE,  MA_CTRL_PLAYER2,       NULL, 0, 0, 0, 1, 0 },\r
+       { "Emulator controls",         MB_NONE,  MA_CTRL_EMU,           NULL, 0, 0, 0, 1, 0 },\r
+       { "6 button pad",              MB_ONOFF, MA_OPT_6BUTTON_PAD,   &PicoOpt, 0x020, 0, 0, 1, 1 },\r
+       { "Turbo rate",                MB_RANGE, MA_CTRL_TURBO_RATE,   &currentConfig.turbo_rate, 0, 1, 30, 1, 1 },\r
+       { "Done",                      MB_NONE,  MA_CTRL_DONE,          NULL, 0, 0, 0, 1, 0 },\r
+};\r
+\r
+#define CTRLOPT_ENTRY_COUNT (sizeof(ctrlopt_entries) / sizeof(ctrlopt_entries[0]))\r
+const int ctrlopt_entry_count = CTRLOPT_ENTRY_COUNT;\r
+\r
 static void draw_kc_sel(int menu_sel)\r
 {\r
        int tl_x = 25+40, tl_y = 60, y;\r
@@ -766,10 +752,7 @@ static void draw_kc_sel(int menu_sel)
        menu_draw_begin(1);\r
        menu_draw_selection(tl_x - 16, tl_y + menu_sel*10, 138);\r
 \r
-       text_out16(tl_x, y,       "Player 1");\r
-       text_out16(tl_x, (y+=10), "Player 2");\r
-       text_out16(tl_x, (y+=10), "Emulator controls");\r
-       text_out16(tl_x, (y+=10), "Done");\r
+       me_draw(ctrlopt_entries, ctrlopt_entry_count, tl_x, tl_y, NULL, NULL);\r
 \r
        menu_draw_end();\r
 }\r
@@ -792,23 +775,27 @@ me_bind_action emuctrl_actions[] =
 \r
 static void kc_sel_loop(void)\r
 {\r
-       int menu_sel = 3, menu_sel_max = 3;\r
+       int menu_sel = 5, menu_sel_max = 5;\r
        unsigned long inp = 0;\r
-       int is_6button = currentConfig.PicoOpt & 0x020;\r
+       menu_id selected_id;\r
 \r
        while (1)\r
        {\r
                draw_kc_sel(menu_sel);\r
                inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_PLAY|BTN_STOP);\r
+               selected_id = me_index2id(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, menu_sel);\r
+               if (inp & (BTN_LEFT|BTN_RIGHT)) // multi choise\r
+                       me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0);\r
                if (inp & BTN_UP  ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
                if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
                if (inp & BTN_PLAY) {\r
-                       switch (menu_sel) {\r
-                               case 0: key_config_loop(me_ctrl_actions, is_6button ? 12 : 8, 0); return;\r
-                               case 1: key_config_loop(me_ctrl_actions, is_6button ? 12 : 8, 1); return;\r
-                               case 2: key_config_loop(emuctrl_actions,\r
-                                               sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]) - 1, -1); return;\r
-                               case 3: if (!rom_loaded) emu_WriteConfig(0); return;\r
+                       int is_6button = currentConfig.PicoOpt & 0x020;\r
+                       switch (selected_id) {\r
+                               case MA_CTRL_PLAYER1: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 0); return;\r
+                               case MA_CTRL_PLAYER2: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 1); return;\r
+                               case MA_CTRL_EMU:     key_config_loop(emuctrl_actions,\r
+                                                       sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]) - 1, -1); return;\r
+                               case MA_CTRL_DONE:    if (!rom_loaded) emu_WriteConfig(0); return;\r
                                default: return;\r
                        }\r
                }\r
@@ -969,6 +956,7 @@ static void cd_menu_loop_options(void)
 \r
 menu_entry opt2_entries[] =\r
 {\r
+       { "Disable sprite limit",      MB_ONOFF, MA_OPT2_NO_SPRITE_LIM, &PicoOpt, 0x40000, 0, 0, 1, 1 },\r
        { "Emulate Z80",               MB_ONOFF, MA_OPT2_ENABLE_Z80,    &currentConfig.PicoOpt,0x0004, 0, 0, 1 },\r
        { "Emulate YM2612 (FM)",       MB_ONOFF, MA_OPT2_ENABLE_YM2612, &currentConfig.PicoOpt,0x0001, 0, 0, 1 },\r
        { "Emulate SN76496 (PSG)",     MB_ONOFF, MA_OPT2_ENABLE_SN76496,&currentConfig.PicoOpt,0x0002, 0, 0, 1 },\r
@@ -1039,15 +1027,13 @@ static void amenu_loop_options(void)
 menu_entry opt_entries[] =\r
 {\r
        { NULL,                        MB_NONE,  MA_OPT_RENDERER,      NULL, 0, 0, 0, 1 },\r
+       { "Accurate sprites",          MB_ONOFF, MA_OPT_ACC_SPRITES,   &PicoOpt, 0x080, 0, 0, 0, 1 },\r
        { "Scanline mode (faster)",    MB_ONOFF, MA_OPT_INTERLACED,    &currentConfig.EmuOpt,  0x4000, 0, 0, 1 },\r
        { "Scale low res mode",        MB_ONOFF, MA_OPT_SCALING,       &currentConfig.scaling, 0x0001, 0, 3, 1 },\r
-       { "Accurate timing (slower)",  MB_ONOFF, MA_OPT_ACC_TIMING,    &currentConfig.PicoOpt, 0x0040, 0, 0, 1 },\r
-       { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES,   &currentConfig.PicoOpt, 0x0080, 0, 0, 1 },\r
        { "Show FPS",                  MB_ONOFF, MA_OPT_SHOW_FPS,      &currentConfig.EmuOpt,  0x0002, 0, 0, 1 },\r
        { NULL,                        MB_RANGE, MA_OPT_FRAMESKIP,     &currentConfig.Frameskip, 0, -1, 16, 1 },\r
        { "Enable sound",              MB_ONOFF, MA_OPT_ENABLE_SOUND,  &currentConfig.EmuOpt,  0x0004, 0, 0, 1 },\r
        { NULL,                        MB_NONE,  MA_OPT_SOUND_QUALITY, NULL, 0, 0, 0, 1 },\r
-       { "6 button pad",              MB_ONOFF, MA_OPT_6BUTTON_PAD,   &currentConfig.PicoOpt, 0x0020, 0, 0, 1 },\r
        { NULL,                        MB_NONE,  MA_OPT_REGION,        NULL, 0, 0, 0, 1 },\r
        { "Use SRAM/BRAM savestates",  MB_ONOFF, MA_OPT_SRAM_STATES,   &currentConfig.EmuOpt,  0x0001, 0, 0, 1 },\r
        { NULL,                        MB_NONE,  MA_OPT_CONFIRM_STATES,NULL, 0, 0, 0, 1 },\r
@@ -1311,10 +1297,10 @@ static int menu_loop_options(void)
 \r
 static void draw_menu_credits(void)\r
 {\r
-       int tl_x = 15, tl_y = 64, y;\r
+       int tl_x = 15, tl_y = 56, y;\r
        menu_draw_begin(1);\r
 \r
-       text_out16(tl_x, 20, "PicoDrive v" VERSION " (c) notaz, 2006,2007");\r
+       text_out16(tl_x, 20, "PicoDrive v" VERSION " (c) notaz, 2006-2008");\r
 \r
        y = tl_y;\r
        text_out16(tl_x, y, "Credits:");\r
@@ -1322,14 +1308,16 @@ static void draw_menu_credits(void)
        text_out16(tl_x, (y+=10), "      base code of PicoDrive");\r
        text_out16(tl_x, (y+=10), "Reesy & FluBBa: DrZ80 core");\r
        text_out16(tl_x, (y+=10), "MAME devs: YM2612 and SN76496 cores");\r
-       text_out16(tl_x, (y+=10), "Charles MacDonald: Genesis hw docs");\r
-       text_out16(tl_x, (y+=10), "Stephane Dallongeville:");\r
-       text_out16(tl_x, (y+=10), "      opensource Gens");\r
-       text_out16(tl_x, (y+=10), "Haze: Genesis hw info");\r
        text_out16(tl_x, (y+=10), "Reesy: kgsdk wrapper, sound code");\r
        text_out16(tl_x, (y+=10), "jens.l: gizmondo hardware");\r
        text_out16(tl_x, (y+=10), "ketchupgun: skin design");\r
 \r
+       text_out16(tl_x, (y+=20), "special thanks (for docs, ideas)");\r
+       text_out16(tl_x, (y+=10), " Charles MacDonald, Haze,");\r
+       text_out16(tl_x, (y+=10), " Stephane Dallongeville,");\r
+       text_out16(tl_x, (y+=10), " Lordus, Exophase, Rokas,");\r
+       text_out16(tl_x, (y+=10), " Nemesis, Tasco Deluxe");\r
+\r
        menu_draw_end();\r
 }\r
 \r
@@ -1429,6 +1417,7 @@ static void menu_loop_root(void)
                                        if (rom_loaded) {\r
                                                if(savestate_menu_loop(1))\r
                                                        continue;\r
+                                               while (Framework_PollGetButtons() & BTN_PLAY) Sleep(50);\r
                                                engineState = PGS_Running;\r
                                                return;\r
                                        }\r
@@ -1436,6 +1425,7 @@ static void menu_loop_root(void)
                                case MA_MAIN_RESET_GAME:\r
                                        if (rom_loaded) {\r
                                                emu_ResetGame();\r
+                                               while (Framework_PollGetButtons() & BTN_PLAY) Sleep(50);\r
                                                engineState = PGS_Running;\r
                                                return;\r
                                        }\r
@@ -1617,10 +1607,11 @@ int menu_loop_tray(void)
                                case 0: // select image\r
                                        selfname = romsel_loop(curr_path);\r
                                        if (selfname) {\r
-                                               int ret = -1, cd_type;\r
+                                               int ret = -1;\r
+                                               cd_img_type cd_type;\r
                                                cd_type = emu_cdCheck(NULL);\r
-                                               if (cd_type > 0)\r
-                                                       ret = Insert_CD(romFileName, cd_type == 2);\r
+                                               if (cd_type != CIT_NOT_CD)\r
+                                                       ret = Insert_CD(romFileName, cd_type);\r
                                                if (ret != 0) {\r
                                                        sprintf(menuErrorMsg, "Load failed, invalid CD image?");\r
                                                        lprintf("%s\n", menuErrorMsg);\r