bugfixes
[libpicofe.git] / common / menu.c
index ded7bbc..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