+static void menu_darken_text_bg(void)\r
+{\r
+ int x, y, xmin, xmax, ymax, ls;\r
+ unsigned short *screen = g_menuscreen_ptr;\r
+\r
+ xmin = border_left - 3;\r
+ if (xmin < 0)\r
+ xmin = 0;\r
+ xmax = border_right + 2;\r
+ if (xmax > g_menuscreen_w - 1)\r
+ xmax = g_menuscreen_w - 1;\r
+\r
+ y = border_top - 3;\r
+ if (y < 0)\r
+ y = 0;\r
+ ymax = border_bottom + 2;\r
+ if (ymax > g_menuscreen_h - 1)\r
+ ymax = g_menuscreen_h - 1;\r
+\r
+ for (x = xmin; x <= xmax; x++)\r
+ screen[y * g_menuscreen_pp + x] = 0xa514;\r
+ for (y++; y < ymax; y++)\r
+ {\r
+ ls = y * g_menuscreen_pp;\r
+ screen[ls + xmin] = 0xffff;\r
+ for (x = xmin + 1; x < xmax; x++)\r
+ {\r
+ unsigned int p = screen[ls + x];\r
+ if (p != menu_text_color)\r
+ screen[ls + x] = ((p&0xf79e)>>1) - ((p&0xc618)>>3);\r
+ }\r
+ screen[ls + xmax] = 0xffff;\r
+ }\r
+ ls = y * g_menuscreen_pp;\r
+ for (x = xmin; x <= xmax; x++)\r
+ screen[ls + x] = 0xffff;\r
+}\r
+\r
+static int borders_pending;\r
+\r
+static void menu_reset_borders(void)\r
+{\r
+ border_left = g_menuscreen_w;\r
+ border_right = 0;\r
+ border_top = g_menuscreen_h;\r
+ border_bottom = 0;\r
+}\r
+\r
+static void menu_draw_begin(int need_bg, int no_borders)\r
+{\r
+ int y;\r
+\r
+ plat_video_menu_begin();\r
+\r
+ menu_reset_borders();\r
+ borders_pending = g_border_style && !no_borders;\r
+\r
+ if (need_bg) {\r
+ if (g_border_style && no_borders) {\r
+ for (y = 0; y < g_menuscreen_h; y++)\r
+ menu_darken_bg((short *)g_menuscreen_ptr + g_menuscreen_pp * y,\r
+ (short *)g_menubg_ptr + g_menuscreen_w * y, g_menuscreen_w, 1);\r
+ }\r
+ else {\r
+ for (y = 0; y < g_menuscreen_h; y++)\r
+ memcpy((short *)g_menuscreen_ptr + g_menuscreen_pp * y,\r
+ (short *)g_menubg_ptr + g_menuscreen_w * y, g_menuscreen_w * 2);\r
+ }\r
+ }\r
+}\r
+\r
+static void menu_draw_end(void)\r
+{\r
+ if (borders_pending)\r
+ menu_darken_text_bg();\r
+ plat_video_menu_end();\r
+}\r
+\r
+static void menu_separation(void)\r
+{\r
+ if (borders_pending) {\r
+ menu_darken_text_bg();\r
+ menu_reset_borders();\r
+ }\r
+}\r
+\r