debug menu unified, more debug tools
[picodrive.git] / platform / psp / menu.c
index 744c99d..86b1022 100644 (file)
@@ -43,16 +43,16 @@ const char * const keyNames[] = {
 static unsigned short bg_buffer[480*272] __attribute__((aligned(16)));
 #define menu_screen psp_screen
 
-static void menu_darken_bg(void *dst, const void *src, int pixels, int darker);
+void menu_darken_bg(void *dst, const void *src, int pixels, int darker);
 static void menu_prepare_bg(int use_game_bg, int use_fg);
 
 
 static unsigned int inp_prev = 0;
 
-static unsigned long wait_for_input(unsigned int interesting, int is_key_config)
+unsigned long wait_for_input(unsigned int interesting, int is_key_config)
 {
        unsigned int ret;
-       static int repeats = 0, wait = 6;
+       static int repeats = 0, wait = 20;
        int release = 0, count, i;
 
        if (!is_key_config)
@@ -62,8 +62,6 @@ static unsigned long wait_for_input(unsigned int interesting, int is_key_config)
        else if (repeats == 4) wait = 2;
        else if (repeats == 6) wait = 1;
 
-       for (i = 0; i < wait && inp_prev == gp2x_joystick_read(1); i++) {
-
        for (i = 0; i < wait && inp_prev == psp_pad_read(1); i++) {
                if (i == 0) repeats++;
                psp_msleep(30);
@@ -76,12 +74,14 @@ static unsigned long wait_for_input(unsigned int interesting, int is_key_config)
 
        if (release || ret != inp_prev) {
                repeats = 0;
-               wait = 6;
+               wait = 20;
        }
        inp_prev = ret;
 
        if (!is_key_config)
                ret |= (ret & 0xf0000000) >> 24; // use analog as d-pad
+       if (wait > 6 && (ret&(BTN_UP|BTN_LEFT|BTN_DOWN|BTN_RIGHT|BTN_L|BTN_R)))
+               wait = 6;
 
        // we don't need diagonals in menus
        if ((ret&BTN_UP)   && (ret&BTN_LEFT))  ret &= ~BTN_LEFT;
@@ -92,7 +92,7 @@ static unsigned long wait_for_input(unsigned int interesting, int is_key_config)
        return ret;
 }
 
-static void menu_draw_begin(void)
+void menu_draw_begin(void)
 {
        // short *src = (short *)bg_buffer, *dst = (short *)menu_screen;
        // int i;
@@ -108,7 +108,7 @@ static void menu_draw_begin(void)
 }
 
 
-static void menu_draw_end(void)
+void menu_draw_end(void)
 {
        psp_video_flip(1);
 }
@@ -434,38 +434,6 @@ static char *romsel_loop(char *curr_path)
        return ret;
 }
 
-// ------------ debug menu ------------
-
-char *debugString(void);
-
-static void draw_debug(void)
-{
-       char *p, *str = debugString();
-       int len, line;
-
-       menu_draw_begin();
-
-       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_draw_end();
-}
-
-static void debug_menu_loop(void)
-{
-       int ret = 0;
-       draw_debug();
-       while (!(ret & (BTN_X|BTN_CIRCLE)))
-               ret = wait_for_input(BTN_X|BTN_CIRCLE, 0);
-}
-
 // ------------ patch/gg menu ------------
 
 static void draw_patchlist(int sel)
@@ -590,7 +558,7 @@ static void draw_savestate_bg(int slot)
                areaClose(file);
        }
 
-       emu_forcedFrame();
+       emu_forcedFrame(0);
        menu_prepare_bg(1, 0);
 
        restore_oldstate(oldstate);
@@ -795,12 +763,16 @@ static void draw_kc_sel(int menu_sel)
 // "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 },
-       { NULL,              0     }
+       { "Load State       ", 1<<28 },
+       { "Save State       ", 1<<27 },
+       { "Prev Save Slot   ", 1<<25 },
+       { "Next Save Slot   ", 1<<24 },
+       { "Switch Renderer  ", 1<<26 },
+       { "Fast forward     ", 1<<22 },
+       { "Pico Next page   ", 1<<21 },
+       { "Pico Prev page   ", 1<<20 },
+       { "Pico Switch input", 1<<19 },
+       { NULL,                0     }
 };
 
 static void kc_sel_loop(void)
@@ -1063,7 +1035,7 @@ static void menu_opt3_preview(int is_32col)
        }
 
        memset32_uncached(psp_screen, 0, 512*272*2/4);
-       emu_forcedFrame();
+       emu_forcedFrame(0);
        menu_prepare_bg(1, 0);
 
        if (oldstate) restore_oldstate(oldstate);
@@ -1174,7 +1146,7 @@ menu_entry opt2_entries[] =
        { "gzip savestates",           MB_ONOFF, MA_OPT2_GZIP_STATES,    &currentConfig.EmuOpt, 0x00008, 0, 0, 1, 1 },
        { "Don't save last used ROM",  MB_ONOFF, MA_OPT2_NO_LAST_ROM,    &currentConfig.EmuOpt, 0x00020, 0, 0, 1, 1 },
        { "Status line in main menu",  MB_ONOFF, MA_OPT2_STATUS_LINE,    &currentConfig.EmuOpt, 0x20000, 0, 0, 1, 1 },
-       { "Disable frame limitter",    MB_ONOFF, MA_OPT2_NO_FRAME_LIMIT, &currentConfig.EmuOpt, 0x40000, 0, 0, 1, 1 },
+       { "Disable frame limiter",     MB_ONOFF, MA_OPT2_NO_FRAME_LIMIT, &currentConfig.EmuOpt, 0x40000, 0, 0, 1, 1 },
        { "done",                      MB_NONE,  MA_OPT2_DONE,           NULL, 0, 0, 0, 1, 0 },
 };
 
@@ -1233,8 +1205,7 @@ static void amenu_loop_options(void)
 menu_entry opt_entries[] =
 {
        { NULL,                        MB_NONE,  MA_OPT_RENDERER,      NULL, 0, 0, 0, 1, 1 },
-       { "Accurate timing (slower)",  MB_ONOFF, MA_OPT_ACC_TIMING,    &PicoOpt, 0x0040, 0, 0, 1, 1 },
-       { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES,   &PicoOpt, 0x0080, 0, 0, 1, 1 },
+       { "Accurate sprites",          MB_ONOFF, MA_OPT_ACC_SPRITES,   &PicoOpt, 0x0080, 0, 0, 0, 1 },
        { "Show FPS",                  MB_ONOFF, MA_OPT_SHOW_FPS,      &currentConfig.EmuOpt,  0x0002,  0,  0, 1, 1 },
        { NULL,                        MB_RANGE, MA_OPT_FRAMESKIP,     &currentConfig.Frameskip,    0, -1, 16, 1, 1 },
        { "Enable sound",              MB_ONOFF, MA_OPT_ENABLE_SOUND,  &currentConfig.EmuOpt,  0x0004,  0,  0, 1, 1 },
@@ -1510,13 +1481,15 @@ static void draw_menu_credits(void)
        text_out16(tl_x, (y+=10), "Chui: Fame/C");
        text_out16(tl_x, (y+=10), "NJ: CZ80");
        text_out16(tl_x, (y+=10), "MAME devs: YM2612 and SN76496 cores");
-       text_out16(tl_x, (y+=10), "Stephane Dallongeville:");
-       text_out16(tl_x, (y+=10), "    Gens code, base of Fame/C, CZ80");
-       text_out16(tl_x, (y+=10), "Charles MacDonald: Genesis hw docs");
-       text_out16(tl_x, (y+=10), "Haze: Genesis hw info");
        text_out16(tl_x, (y+=10), "ps2dev.org people: PSP SDK/code");
        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_draw_end();
 }
 
@@ -1694,8 +1667,7 @@ static void menu_loop_root(void)
        }
 }
 
-// warning: alignment
-static void menu_darken_bg(void *dst, const void *src, int pixels, int darker)
+void menu_darken_bg(void *dst, const void *src, int pixels, int darker)
 {
        unsigned int *dest = dst;
        const unsigned int *srce = src;