--- trunk/src/devices/dev_fb.c 2007/10/08 16:20:32 29 +++ trunk/src/devices/dev_fb.c 2007/10/08 16:20:40 30 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: dev_fb.c,v 1.121 2006/07/08 12:30:02 debug Exp $ + * $Id: dev_fb.c,v 1.123 2006/07/24 08:08:39 debug Exp $ * * Generic framebuffer device. * @@ -235,7 +235,7 @@ * block copy/fill. * * If fillflag is non-zero, then fill_[rgb] should contain the color - * with which to fill. + * with which to fill. (In 8-bit mode, only fill_r is used.) * * If fillflag is zero, copy mode is used, and from_[xy] should contain * the offset on the framebuffer where we should copy from. @@ -246,7 +246,7 @@ int fill_g, int fill_b, int x1, int y1, int x2, int y2, int from_x, int from_y) { - int y; + int x, y; long from_ofs, dest_ofs, linelen; if (fillflag) @@ -269,22 +269,23 @@ if (fillflag) { for (y=y1; y<=y2; y++) { if (y>=0 && yysize) { - int x; - char buf[8192 * 3]; - if (d->bit_depth == 24) + unsigned char *buf = + d->framebuffer + dest_ofs; + + if (d->bit_depth == 24) { for (x=0; xbit_depth == 8) { + memset(buf, fill_r, linelen); + } else { + fatal("Unimplemented bit-depth (%i)" + " for fb fill\n", d->bit_depth); + exit(1); } - - memmove(d->framebuffer + dest_ofs, buf, - linelen); } dest_ofs += d->bytes_per_line; @@ -292,12 +293,16 @@ } else { from_ofs = d->bytes_per_line * from_y + (d->bit_depth/8) * from_x; - for (y=y1; y<=y2; y++) { - if (y>=0 && yysize) - memmove(d->framebuffer + dest_ofs, - d->framebuffer + from_ofs, linelen); - + if (y >= 0 && y < d->ysize) { + if (from_y >= 0 && from_y < d->ysize) + memmove(d->framebuffer + dest_ofs, + d->framebuffer + from_ofs, linelen); + else + memset(d->framebuffer + dest_ofs, + 0, linelen); + } + from_y ++; from_ofs += d->bytes_per_line; dest_ofs += d->bytes_per_line; }