/*\r
- * (C) Gražvydas "notaz" Ignotas, 2006-2011\r
+ * (C) Gražvydas "notaz" Ignotas, 2006-2012\r
*\r
* This work is licensed under the terms of any of these licenses\r
* (at your option):\r
void *g_menuscreen_ptr;\r
void *g_menubg_src_ptr;\r
void *g_menubg_ptr;\r
+static char rom_fname_reload[256];\r
\r
#if !MSCREEN_SIZE_FIXED\r
int g_menuscreen_w;\r
static const int me_sfont_w = 6, me_sfont_h = 10;\r
#endif\r
\r
+static int g_border_style;\r
+static int border_left, border_right, border_top, border_bottom;\r
+\r
// draws text to current bbp16 screen\r
static void text_out16_(int x, int y, const char *text, int color)\r
{\r
}\r
dest += me_mfont_w;\r
}\r
+\r
+ if (x < border_left)\r
+ border_left = x;\r
+ if (x + i * me_mfont_w > border_right)\r
+ border_right = x + i * me_mfont_w;\r
+ if (y < border_top)\r
+ border_top = y;\r
+ if (y + me_mfont_h > border_bottom)\r
+ border_bottom = y + me_mfont_h;\r
}\r
\r
void text_out16(int x, int y, const char *texto, ...)\r
return c;\r
}\r
\r
-void menu_init(void)\r
+void menu_init_base(void)\r
{\r
int i, c, l;\r
unsigned char *fd, *fds;\r
setlocale(LC_TIME, "");\r
}\r
\r
-static void menu_draw_begin(int need_bg)\r
-{\r
- plat_video_menu_begin();\r
- if (need_bg)\r
- memcpy(g_menuscreen_ptr, g_menubg_ptr, g_menuscreen_w * g_menuscreen_h * 2);\r
-}\r
-\r
-static void menu_draw_end(void)\r
-{\r
- plat_video_menu_end();\r
-}\r
-\r
static void menu_darken_bg(void *dst, void *src, int pixels, int darker)\r
{\r
unsigned int *dest = dst;\r
}\r
}\r
\r
+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_w + x] = 0xa514;\r
+ for (y++; y < ymax; y++)\r
+ {\r
+ ls = y * g_menuscreen_w;\r
+ screen[ls + xmin] = 0xffff;\r
+ for (x = xmin + 1; x < xmax; x++)\r
+ {\r
+ unsigned int p = screen[ls + x];\r
+ if (p != 0xffff)\r
+ screen[ls + x] = ((p&0xf79e)>>1) - ((p&0xc618)>>3);\r
+ }\r
+ screen[ls + xmax] = 0xffff;\r
+ }\r
+ ls = y * g_menuscreen_w;\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
+ 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
+ menu_darken_bg(g_menuscreen_ptr, g_menubg_ptr,\r
+ g_menuscreen_w * g_menuscreen_h, 1);\r
+ }\r
+ else {\r
+ memcpy(g_menuscreen_ptr, g_menubg_ptr,\r
+ g_menuscreen_w * g_menuscreen_h * 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
static int me_id2offset(const menu_entry *ent, menu_id id)\r
{\r
int i;\r
#endif\r
\r
/* draw */\r
- menu_draw_begin(1);\r
+ menu_draw_begin(1, 0);\r
menu_draw_selection(x, y + vi_sel_ln * me_mfont_h, w);\r
x += me_mfont_w * 2;\r
\r
smalltext_out16(5, g_menuscreen_h - (l * me_sfont_h + 4), tmp, 0xffff);\r
}\r
\r
+ menu_separation();\r
+\r
if (draw_more != NULL)\r
draw_more();\r
\r
if (x < 0) x = 0;\r
if (y < 0) y = 0;\r
\r
- menu_draw_begin(1);\r
+ menu_draw_begin(1, 0);\r
\r
for (p = msg; *p != 0 && y <= g_menuscreen_h - me_mfont_h; y += me_mfont_h) {\r
text_out16(x, y, p);\r
p++;\r
}\r
\r
+ menu_separation();\r
+\r
if (draw_more != NULL)\r
draw_more();\r
\r
const char *nm;\r
char tmp[64];\r
\r
- menu_draw_begin(1);\r
+ menu_draw_begin(1, 0);\r
\r
len = strlen(fname);\r
if (len > g_menuscreen_w / me_sfont_w)\r
start = max_cnt / 2 - sel;\r
n--; // exclude current dir (".")\r
\r
- menu_draw_begin(1);\r
+ menu_draw_begin(1, 1);\r
\r
// if (!rom_loaded)\r
// menu_darken_bg(gp2x_screen, 320*240, 0);\r
x = 12 + me_mfont_w * 2;\r
#endif\r
\r
- menu_draw_begin(1);\r
+ menu_draw_begin(1, 1);\r
\r
text_out16(x, y, is_loading ? "Load state" : "Save state");\r
y += 3 * me_mfont_h;\r
if (menu_sel < STATE_SLOT_COUNT) {\r
state_slot = menu_sel;\r
if (emu_save_load_game(is_loading, 0)) {\r
- me_update_msg(is_loading ? "Load failed" : "Save failed");\r
+ menu_update_msg(is_loading ? "Load failed" : "Save failed");\r
break;\r
}\r
ret = 1;\r
if (x < me_mfont_w * 2)\r
x = me_mfont_w * 2;\r
\r
- menu_draw_begin(1);\r
+ menu_draw_begin(1, 0);\r
if (player_idx >= 0)\r
text_out16(x, y, "Player %i controls", player_idx + 1);\r
else\r
text_out16(x, y, "%s : %s", opts[i].name,\r
action_binds(player_idx, opts[i].mask, dev_id));\r
\r
+ menu_separation();\r
+\r
if (dev_id < 0)\r
dev_name = "(all devices)";\r
else\r