bugfixes
[libpicofe.git] / common / menu.c
index 73b41da..8accc25 100644 (file)
@@ -45,7 +45,7 @@ static const int me_sfont_w = 6, me_sfont_h = 10;
 // draws text to current bbp16 screen\r
 static void text_out16_(int x, int y, const char *text, int color)\r
 {\r
-       int i, l, u, tr, tg, tb, len;\r
+       int i, lh, tr, tg, tb, len;\r
        unsigned short *dest = (unsigned short *)g_screen_ptr + x + y * g_screen_width;\r
        tr = (color & 0xf800) >> 8;\r
        tg = (color & 0x07e0) >> 3;\r
@@ -65,11 +65,17 @@ static void text_out16_(int x, int y, const char *text, int color)
                len = p - text;\r
        }\r
 \r
+       lh = me_mfont_h;\r
+       if (y + lh > g_screen_height)\r
+               lh = g_screen_height - y;\r
+\r
        for (i = 0; i < len; i++)\r
        {\r
                unsigned char  *src = menu_font_data + (unsigned int)text[i] * me_mfont_w * me_mfont_h / 2;\r
                unsigned short *dst = dest;\r
-               for (l = 0; l < me_mfont_h; l++, dst += g_screen_width - me_mfont_w)\r
+               int u, l;\r
+\r
+               for (l = 0; l < lh; l++, dst += g_screen_width - me_mfont_w)\r
                {\r
                        for (u = me_mfont_w / 2; u > 0; u--, src++)\r
                        {\r
@@ -590,7 +596,16 @@ static void me_loop(menu_entry *menu, int *menu_sel, void (*draw_more)(void))
 /* ***************************************** */\r
 \r
 /* platform specific options and handlers */\r
+#if   defined(__GP2X__)\r
 #include "../gp2x/menu.c"\r
+#elif defined(PANDORA)\r
+#include "../pandora/menu.c"\r
+#else\r
+#define MENU_OPTIONS_GFX\r
+#define MENU_OPTIONS_ADV\r
+#define mgn_opt_renderer NULL /* TODO */\r
+#define menu_main_plat_draw NULL\r
+#endif\r
 \r
 static void draw_menu_credits(void)\r
 {\r
@@ -668,20 +683,18 @@ static void cdload_progress_cb(const char *fname, int percent)
 void menu_romload_prepare(const char *rom_name)\r
 {\r
        const char *p = rom_name + strlen(rom_name);\r
+       int i;\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, me_sfont_h, p, 0xffff);\r
-       plat_video_menu_end();\r
-\r
-       plat_video_menu_begin();\r
-       smalltext_out16(1, 1, "Loading", 0xffff);\r
-       smalltext_out16(1, me_sfont_h, p, 0xffff);\r
-       plat_video_menu_end();\r
+       /* fill all buffers, callbacks won't update in full */\r
+       for (i = 0; i < 3; i++) {\r
+               plat_video_menu_begin();\r
+               smalltext_out16(1, 1, "Loading", 0xffff);\r
+               smalltext_out16(1, me_sfont_h, p, 0xffff);\r
+               plat_video_menu_end();\r
+       }\r
 \r
        PicoCartLoadProgressCB = load_progress_cb;\r
        PicoCDLoadProgressCB = cdload_progress_cb;\r
@@ -1508,7 +1521,7 @@ static menu_entry e_menu_adv_options[] =
        mee_onoff     ("Don't save last used ROM", MA_OPT2_NO_LAST_ROM,   currentConfig.EmuOpt, EOPT_NO_AUTOSVCFG),\r
        mee_onoff     ("Disable idle loop patching",MA_OPT2_NO_IDLE_LOOPS,PicoOpt, POPT_DIS_IDLE_DET),\r
        mee_onoff     ("Disable frame limiter",    MA_OPT2_NO_FRAME_LIMIT,currentConfig.EmuOpt, EOPT_NO_FRMLIMIT),\r
-       MENU_GP2X_OPTIONS_ADV\r
+       MENU_OPTIONS_ADV\r
        mee_end,\r
 };\r
 \r
@@ -1530,7 +1543,7 @@ static int mh_opt_render(menu_id id, int keys)
 static menu_entry e_menu_gfx_options[] =\r
 {\r
        mee_cust      ("Renderer",                 MA_OPT_RENDERER,       mh_opt_render, mgn_opt_renderer),\r
-       MENU_GP2X_OPTIONS_GFX\r
+       MENU_OPTIONS_GFX\r
        mee_end,\r
 };\r
 \r