fix gp2x build and some obvious menu glitches
[picodrive.git] / platform / common / menu.c
index 2f29e87..c2e18fa 100644 (file)
@@ -176,7 +176,7 @@ static void menu_draw_selection(int x, int y, int w)
        for (h = me_mfont_h + 1; h > 0; h--)\r
        {\r
                dst = dest;\r
-               for (i = w; i > 0; i--)\r
+               for (i = w - 14; i > 0; i--)\r
                        *dst++ = menu_sel_color;\r
                dest += g_screen_width;\r
        }\r
@@ -472,7 +472,7 @@ static void me_loop(menu_entry *menu, int *menu_sel)
                return;\r
        }\r
 \r
-       while (!menu[sel].enabled && sel < menu_sel_max)\r
+       while ((!menu[sel].enabled || !menu[sel].selectable) && sel < menu_sel_max)\r
                sel++;\r
 \r
        /* make sure action buttons are not pressed on entering menu */\r
@@ -604,16 +604,16 @@ void menu_romload_prepare(const char *rom_name)
 {\r
        const char *p = rom_name + strlen(rom_name);\r
 \r
-       plat_video_menu_begin();\r
-\r
        while (p > rom_name && *p != '/')\r
                p--;\r
 \r
        /* fill both buffers, callbacks won't update in full */\r
+       plat_video_menu_begin();\r
        smalltext_out16(1, 1, "Loading", 0xffff);\r
        smalltext_out16(1, 10, p, 0xffff);\r
        plat_video_menu_end();\r
 \r
+       plat_video_menu_begin();\r
        smalltext_out16(1, 1, "Loading", 0xffff);\r
        smalltext_out16(1, 10, p, 0xffff);\r
        plat_video_menu_end();\r
@@ -977,7 +977,7 @@ static void draw_savestate_menu(int menu_sel, int is_loading)
        text_out16(x, y, is_loading ? "Load state" : "Save state");\r
        y += 3 * me_mfont_h;\r
 \r
-       menu_draw_selection(x - me_mfont_w * 2, y + menu_sel * me_mfont_h, 13 * me_mfont_w + 4);\r
+       menu_draw_selection(x - me_mfont_w * 2, y + menu_sel * me_mfont_h, (13 + 2) * me_mfont_w + 4);\r
 \r
        /* draw all 10 slots */\r
        for (i = 0; i < 10; i++, y += me_mfont_h)\r
@@ -1091,10 +1091,11 @@ static int count_bound_keys(int dev_id, int action_mask, int player_idx)
 static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_idx,\r
                int sel, int dev_id, int dev_count, int is_bind)\r
 {\r
-       int x, y, w, i;\r
        const char *dev_name;\r
+       int x, y, w, i;\r
 \r
-       x = g_screen_width / 2 - 20 * me_mfont_w / 2;\r
+       w = ((player_idx >= 0) ? 20 : 30) * me_mfont_w;\r
+       x = g_screen_width / 2 - w / 2;\r
        y = (g_screen_height - 4 * me_mfont_h) / 2 - (2 + opt_cnt) * me_mfont_h / 2;\r
        if (x < me_mfont_w * 2)\r
                x = me_mfont_w * 2;\r
@@ -1106,7 +1107,7 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_
                text_out16(x, y, "Emulator controls");\r
 \r
        y += 2 * me_mfont_h;\r
-       menu_draw_selection(x - me_mfont_w * 2, y + sel * me_mfont_h, me_mfont_w); // FIXME last arg\r
+       menu_draw_selection(x - me_mfont_w * 2, y + sel * me_mfont_h, w + 2 * me_mfont_w);\r
 \r
        for (i = 0; i < opt_cnt; i++, y += me_mfont_h)\r
                text_out16(x, y, "%s : %s", opts[i].name,\r
@@ -1885,6 +1886,10 @@ static int main_menu_handler(menu_id id, int keys)
 \r
 static menu_entry e_menu_main[] =\r
 {\r
+       mee_label     ("PicoDrive " VERSION),\r
+       mee_label     (""),\r
+       mee_label     (""),\r
+       mee_label     (""),\r
        mee_handler_id("Resume game",        MA_MAIN_RESUME_GAME, main_menu_handler),\r
        mee_handler_id("Save State",         MA_MAIN_SAVE_STATE,  main_menu_handler),\r
        mee_handler_id("Load State",         MA_MAIN_LOAD_STATE,  main_menu_handler),\r
@@ -1911,13 +1916,15 @@ void menu_loop(void)
        plat_video_menu_enter(rom_loaded);\r
        in_set_blocking(1);\r
        me_loop(e_menu_main, &sel);\r
-       in_set_blocking(0);\r
 \r
-       if (rom_loaded && engineState == PGS_Menu) {\r
+       if (rom_loaded) {\r
+               if (engineState == PGS_Menu)\r
+                       engineState = PGS_Running;\r
                /* wait until menu, ok, back is released */\r
                while (in_menu_wait_any(50) & (PBTN_MENU|PBTN_MOK|PBTN_MBACK));\r
-               engineState = PGS_Running;\r
        }\r
+\r
+       in_set_blocking(0);\r
 }\r
 \r
 // --------- CD tray close menu ----------\r
@@ -1967,7 +1974,6 @@ int menu_loop_tray(void)
 \r
        in_set_blocking(1);\r
        me_loop(e_menu_tray, &sel);\r
-       in_set_blocking(0);\r
 \r
        if (engineState != PGS_RestartRun) {\r
                engineState = PGS_RestartRun;\r
@@ -1975,6 +1981,7 @@ int menu_loop_tray(void)
        }\r
 \r
        while (in_menu_wait_any(50) & (PBTN_MENU|PBTN_MOK|PBTN_MBACK));\r
+       in_set_blocking(0);\r
 \r
        return ret;\r
 }\r