diff --git a/hw/vga.c b/hw/vga.c
-index e4e27a9..21ea2ac 100644
+index e4e27a9..cd0ce41 100644
--- a/hw/vga.c
+++ b/hw/vga.c
-@@ -638,6 +638,12 @@ static void vbe_ioport_write_data(void *opaque, uint32_t addr, uint32_t val)
+@@ -638,6 +638,13 @@ static void vbe_ioport_write_data(void *opaque, uint32_t addr, uint32_t val)
set_vram_mapping(s, s->lfb_addr, s->lfb_end);
}
+ /* clear the screen (should be done in BIOS) */
+ if (!(val & VBE_DISPI_NOCLEARMEM)) {
++ fprintf(stderr,"VGA Clearing screen at %s:%d\n",__FILE__,__LINE__);
+ memset(s->vram_ptr, 0,
+ s->vbe_regs[VBE_DISPI_INDEX_YRES] * s->vbe_line_offset);
+ }
s->vbe_regs[VBE_DISPI_INDEX_VIRT_WIDTH] =
s->vbe_regs[VBE_DISPI_INDEX_XRES];
s->vbe_regs[VBE_DISPI_INDEX_VIRT_HEIGHT] =
-@@ -1610,6 +1616,7 @@ static void vga_draw_graphic(VGAState *s, int full_update)
+@@ -1554,6 +1561,25 @@ void vga_invalidate_scanlines(VGAState *s, int y1, int y2)
+ }
+ }
+
++static void
++check_cls (VGAState * s, int width, int height, int depth, int line_offset)
++{
++ static int last_width, last_height, last_depth, last_line_offset;
++
++ if ((last_width == width) && (last_height == height)
++ && (last_depth == depth) && (last_line_offset == line_offset))
++ return;
++
++ last_width = width;
++ last_height = height;
++ last_depth = depth;
++ last_line_offset = line_offset;
++
++ fprintf (stderr, "VGA Clearing screen at %s:%d\n", __FILE__, __LINE__);
++
++ memset (s->vram_ptr + (s->start_addr * 4), 0x00, s->line_offset * height);
++}
++
+ /*
+ * graphic modes
+ */
+@@ -1610,6 +1636,9 @@ static void vga_draw_graphic(VGAState *s, int full_update)
disp_width != s->last_width ||
height != s->last_height ||
s->last_depth != depth) {
-+ memset(s->vram_ptr + (s->start_addr * 4), 0x00, s->line_offset * height);
++
++ check_cls(s,width,height,depth,s->line_offset);
++
if (depth == 32) {
if (is_graphic_console()) {
qemu_free_displaysurface(s->ds);