From 89e6909b3f4e2d45b6cff6502d632ae0b5486158 Mon Sep 17 00:00:00 2001
From: notaz <notasas@gmail.com>
Date: Mon, 21 Dec 2009 16:43:30 +0000
Subject: [PATCH] bugfixes

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@846 be3aeb3a-fb24-0410-a615-afba39da0efa
---
 platform/common/menu.c | 10 ++++++++--
 platform/linux/fbdev.c |  2 ++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/platform/common/menu.c b/platform/common/menu.c
index ded7bbcf..8accc250 100644
--- a/platform/common/menu.c
+++ b/platform/common/menu.c
@@ -45,7 +45,7 @@ static const int me_sfont_w = 6, me_sfont_h = 10;
 // draws text to current bbp16 screen
 static void text_out16_(int x, int y, const char *text, int color)
 {
-	int i, l, u, tr, tg, tb, len;
+	int i, lh, tr, tg, tb, len;
 	unsigned short *dest = (unsigned short *)g_screen_ptr + x + y * g_screen_width;
 	tr = (color & 0xf800) >> 8;
 	tg = (color & 0x07e0) >> 3;
@@ -65,11 +65,17 @@ static void text_out16_(int x, int y, const char *text, int color)
 		len = p - text;
 	}
 
+	lh = me_mfont_h;
+	if (y + lh > g_screen_height)
+		lh = g_screen_height - y;
+
 	for (i = 0; i < len; i++)
 	{
 		unsigned char  *src = menu_font_data + (unsigned int)text[i] * me_mfont_w * me_mfont_h / 2;
 		unsigned short *dst = dest;
-		for (l = 0; l < me_mfont_h; l++, dst += g_screen_width - me_mfont_w)
+		int u, l;
+
+		for (l = 0; l < lh; l++, dst += g_screen_width - me_mfont_w)
 		{
 			for (u = me_mfont_w / 2; u > 0; u--, src++)
 			{
diff --git a/platform/linux/fbdev.c b/platform/linux/fbdev.c
index 6ad1d4ec..474f708e 100644
--- a/platform/linux/fbdev.c
+++ b/platform/linux/fbdev.c
@@ -38,6 +38,8 @@ void plat_video_flip(void)
 
 	fbvar_new.yoffset = fbvar_old.yres * draw_buf;
 	g_screen_ptr = fbdev_buffers[fbdev_buffer_write];
+
+	ioctl(fbdev, FBIOPAN_DISPLAY, &fbvar_new);
 }
 
 void plat_video_wait_vsync(void)
-- 
2.39.5