use system's zlib
[picodrive.git] / platform / gizmondo / menu.c
index 6a2a8f2..dd6740a 100644 (file)
@@ -1,7 +1,10 @@
-// (c) Copyright 2006,2007 notaz, All rights reserved.\r
-// Free for non-commercial use.\r
-\r
-// For commercial use, separate licencing terms must be obtained.\r
+/*\r
+ * PicoDrive\r
+ * (C) notaz, 2006-2008\r
+ *\r
+ * This work is licensed under the terms of MAME license.\r
+ * See COPYING file in the top-level directory.\r
+ */\r
 \r
 // don't like to use loads of #ifdefs, so duplicating GP2X code\r
 // horribly instead\r
 #include "../common/menu.h"\r
 #include "../common/emu.h"\r
 #include "../common/readpng.h"\r
+#include "../common/input.h"\r
 #include "version.h"\r
 \r
 #include <pico/pico_int.h>\r
 #include <pico/patch.h>\r
-#include <zlib/zlib.h>\r
+#include <zlib.h>\r
 \r
 \r
 #define gizKeyUnkn "???"\r
@@ -47,44 +51,6 @@ static void menu_prepare_bg(int use_game_bg);
 \r
 static unsigned int inp_prev = 0;\r
 \r
-unsigned long wait_for_input(unsigned int interesting)\r
-{\r
-       unsigned long ret;\r
-       static int repeats = 0, wait = 20;\r
-       int release = 0, i;\r
-\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 < wait && inp_prev == Framework_PollGetButtons(); i++) {\r
-               if (i == 0) repeats++;\r
-               Sleep(30);\r
-       }\r
-\r
-       while ( !((ret = Framework_PollGetButtons()) & interesting) ) {\r
-               Sleep(50);\r
-               release = 1;\r
-       }\r
-\r
-       if (release || ret != inp_prev) {\r
-               repeats = 0;\r
-               wait = 20;\r
-       }\r
-       if (wait > 6 && (ret&(PBTN_UP|PBTN_LEFT|PBTN_DOWN|PBTN_RIGHT|PBTN_L|PBTN_R)))\r
-               wait = 6;\r
-       inp_prev = ret;\r
-\r
-       // we don't need diagonals in menus\r
-       if ((ret&PBTN_UP)   && (ret&PBTN_LEFT))  ret &= ~PBTN_LEFT;\r
-       if ((ret&PBTN_UP)   && (ret&PBTN_RIGHT)) ret &= ~PBTN_RIGHT;\r
-       if ((ret&PBTN_DOWN) && (ret&PBTN_LEFT))  ret &= ~PBTN_LEFT;\r
-       if ((ret&PBTN_DOWN) && (ret&PBTN_RIGHT)) ret &= ~PBTN_RIGHT;\r
-\r
-       return ret;\r
-}\r
-\r
-\r
 void menu_draw_begin(int use_bgbuff)\r
 {\r
        if (use_bgbuff)\r
@@ -386,7 +352,7 @@ static char *romsel_loop(char *curr_path)
        for (;;)\r
        {\r
                draw_dirlist(curr_path, namelist, n, sel);\r
-               inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_PLAY|PBTN_STOP);\r
+               inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_PLAY|PBTN_STOP);\r
                if(inp & PBTN_UP  )  { sel--;   if (sel < 0)   sel = n-2; }\r
                if(inp & PBTN_DOWN)  { sel++;   if (sel > n-2) sel = 0; }\r
                if(inp & PBTN_LEFT)  { sel-=10; if (sel < 0)   sel = 0; }\r
@@ -473,7 +439,7 @@ static void patches_menu_loop(void)
        for(;;)\r
        {\r
                draw_patchlist(menu_sel);\r
-               inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_PLAY|PBTN_STOP);\r
+               inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_PLAY|PBTN_STOP);\r
                if(inp & PBTN_UP  ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; }\r
                if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; }\r
                if(inp &(PBTN_LEFT|PBTN_L))  { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; }\r
@@ -593,7 +559,7 @@ static int savestate_menu_loop(int is_loading)
        for(;;)\r
        {\r
                draw_savestate_menu(menu_sel, is_loading);\r
-               inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP);\r
+               inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP);\r
                if(inp & PBTN_UP  ) {\r
                        do {\r
                                menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max;\r
@@ -703,7 +669,7 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
        for (;;)\r
        {\r
                draw_key_config(opts, opt_cnt, player_idx, sel);\r
-               inp = wait_for_input(CONFIGURABLE_KEYS|PBTN_HOME);\r
+               inp = in_menu_wait(CONFIGURABLE_KEYS|PBTN_HOME);\r
                if (!(inp & PBTN_HOME)) {\r
                        prev_select = 0;\r
                        if(inp & PBTN_UP  ) { sel--; if (sel < 0) sel = menu_sel_max; continue; }\r
@@ -783,7 +749,7 @@ static void kc_sel_loop(void)
        while (1)\r
        {\r
                draw_kc_sel(menu_sel);\r
-               inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP);\r
+               inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP);\r
                selected_id = me_index2id(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, menu_sel);\r
                if (inp & (PBTN_LEFT|PBTN_RIGHT)) // multi choise\r
                        me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0);\r
@@ -904,7 +870,7 @@ static void cd_menu_loop_options(void)
        for(;;)\r
        {\r
                draw_cd_menu_options(menu_sel, &bios_names);\r
-               inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);\r
+               inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);\r
                if (inp & PBTN_UP  ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
                if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
                selected_id = me_index2id(cdopt_entries, CDOPT_ENTRY_COUNT, menu_sel);\r
@@ -1003,7 +969,7 @@ static void amenu_loop_options(void)
        for(;;)\r
        {\r
                draw_amenu_options(menu_sel);\r
-               inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);\r
+               inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);\r
                if (inp & PBTN_UP  ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
                if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
                selected_id = me_index2id(opt2_entries, OPT2_ENTRY_COUNT, menu_sel);\r
@@ -1187,7 +1153,7 @@ static int menu_loop_options(void)
        while (1)\r
        {\r
                draw_menu_options(menu_sel);\r
-               inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);\r
+               inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);\r
                if (inp & PBTN_UP  ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
                if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
                selected_id = me_index2id(opt_entries, OPT_ENTRY_COUNT, menu_sel);\r
@@ -1388,7 +1354,7 @@ static void menu_loop_root(void)
        for (;;)\r
        {\r
                draw_menu_root(menu_sel);\r
-               inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP|PBTN_HOME|PBTN_L|PBTN_R);\r
+               inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP|PBTN_HOME|PBTN_L|PBTN_R);\r
                if(inp & PBTN_UP  )  { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
                if(inp & PBTN_DOWN)  { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
                if((inp & (PBTN_L|PBTN_R)) == (PBTN_L|PBTN_R)) debug_menu_loop();\r
@@ -1465,7 +1431,7 @@ static void menu_loop_root(void)
                                case MA_MAIN_CREDITS:\r
                                        draw_menu_credits();\r
                                        Sleep(500);\r
-                                       inp = wait_for_input(PBTN_PLAY|PBTN_STOP);\r
+                                       inp = in_menu_wait(PBTN_PLAY|PBTN_STOP);\r
                                        break;\r
                                case MA_MAIN_EXIT:\r
                                        engineState = PGS_Quit;\r
@@ -1603,7 +1569,7 @@ int menu_loop_tray(void)
        for (;;)\r
        {\r
                draw_menu_tray(menu_sel);\r
-               inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_PLAY);\r
+               inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_PLAY);\r
                if(inp & PBTN_UP  )  { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
                if(inp & PBTN_DOWN)  { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
                if(inp & PBTN_PLAY)  {\r