diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2009-05-31 01:37:54 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2009-05-31 01:37:54 -0400 |
commit | c3e158732c7a81af8107f651a00cdcc41768d011 (patch) | |
tree | 72514fba89cc830ec328edeea0b09fa0b444fd42 | |
parent | ae6e1c852f6634dc84b63180172d39cb21ffc94a (diff) | |
download | seabios-c3e158732c7a81af8107f651a00cdcc41768d011.tar.gz |
VGA: Simplify scrolling implementation.
Check for nblines==0 in calling function.
Eliminate full screen clearing optimization.
-rw-r--r-- | vgasrc/vga.c | 15 | ||||
-rw-r--r-- | vgasrc/vgafb.c | 57 |
2 files changed, 18 insertions, 54 deletions
diff --git a/vgasrc/vga.c b/vgasrc/vga.c index 180fc991..c28d8915 100644 --- a/vgasrc/vga.c +++ b/vgasrc/vga.c @@ -492,18 +492,21 @@ verify_scroll(struct bregs *regs, int dir) struct cursorpos ul = {regs->cl, regs->ch, page}; struct cursorpos lr = {regs->dl, regs->dh, page}; - if (ul.x > lr.x || ul.y > lr.y) - return; - u16 nbrows = GET_BDA(video_rows) + 1; - u16 nbcols = GET_BDA(video_cols); - if (lr.y >= nbrows) lr.y = nbrows - 1; + u16 nbcols = GET_BDA(video_cols); if (lr.x >= nbcols) lr.x = nbcols - 1; - vgafb_scroll(dir * regs->al, regs->bh, ul, lr); + if (ul.x > lr.x || ul.y > lr.y) + return; + + u16 nblines = regs->al; + if (!nblines || nblines > lr.y - ul.y + 1) + nblines = lr.y - ul.y + 1; + + vgafb_scroll(dir * nblines, regs->bh, ul, lr); } static void diff --git a/vgasrc/vgafb.c b/vgasrc/vgafb.c index 3e36b1cd..dbceb2c1 100644 --- a/vgasrc/vgafb.c +++ b/vgasrc/vgafb.c @@ -64,26 +64,15 @@ scroll_pl4(struct vgamode_s *vmode_g, int nblines, int attr dir = SCROLL_DOWN; } // Get the dimensions - u16 nbrows = GET_BDA(video_rows) + 1; u16 nbcols = GET_BDA(video_cols); - if (nblines > nbrows) - nblines = 0; u8 cols = lr.x - ul.x + 1; struct VideoParam_s *vparam_g = GET_GLOBAL(vmode_g->vparam); u8 cheight = GET_GLOBAL(vparam_g->cheight); - if (nblines == 0 && ul.y == 0 && ul.x == 0 && lr.y == nbrows - 1 - && lr.x == nbcols - 1) { - outw(0x0205, VGAREG_GRDC_ADDRESS); - memset_far(GET_GLOBAL(vmode_g->sstart), 0, attr, - nbrows * nbcols * cheight); - outw(0x0005, VGAREG_GRDC_ADDRESS); - return; - } if (dir == SCROLL_UP) { u16 i; for (i = ul.y; i <= lr.y; i++) - if ((i + nblines > lr.y) || (nblines == 0)) + if (i + nblines > lr.y) vgamem_fill_pl4(ul.x, i, cols, nbcols, cheight, attr); else @@ -92,16 +81,13 @@ scroll_pl4(struct vgamode_s *vmode_g, int nblines, int attr return; } u16 i; - for (i = lr.y; i >= ul.y; i--) { - if ((i < ul.y + nblines) || (nblines == 0)) + for (i = lr.y; i >= ul.y; i--) + if (i < ul.y + nblines) vgamem_fill_pl4(ul.x, i, cols, nbcols, cheight, attr); else vgamem_copy_pl4(ul.x, i, i - nblines, cols, nbcols, cheight); - if (i > lr.y) - break; - } } static void @@ -147,21 +133,12 @@ scroll_cga(struct vgamode_s *vmode_g, int nblines, int attr dir = SCROLL_DOWN; } // Get the dimensions - u16 nbrows = GET_BDA(video_rows) + 1; u16 nbcols = GET_BDA(video_cols); - if (nblines > nbrows) - nblines = 0; u8 cols = lr.x - ul.x + 1; struct VideoParam_s *vparam_g = GET_GLOBAL(vmode_g->vparam); u8 cheight = GET_GLOBAL(vparam_g->cheight); u8 bpp = GET_GLOBAL(vmode_g->pixbits); - if (nblines == 0 && ul.y == 0 && ul.x == 0 && lr.y == nbrows - 1 - && lr.x == nbcols - 1) { - memset_far(GET_GLOBAL(vmode_g->sstart), 0, attr, - nbrows * nbcols * cheight * bpp); - return; - } if (bpp == 2) { ul.x <<= 1; cols <<= 1; @@ -171,7 +148,7 @@ scroll_cga(struct vgamode_s *vmode_g, int nblines, int attr if (dir == SCROLL_UP) { u16 i; for (i = ul.y; i <= lr.y; i++) - if ((i + nblines > lr.y) || (nblines == 0)) + if (i + nblines > lr.y) vgamem_fill_cga(ul.x, i, cols, nbcols, cheight, attr); else @@ -180,16 +157,13 @@ scroll_cga(struct vgamode_s *vmode_g, int nblines, int attr return; } u16 i; - for (i = lr.y; i >= ul.y; i--) { - if ((i < ul.y + nblines) || (nblines == 0)) + for (i = lr.y; i >= ul.y; i--) + if (i < ul.y + nblines) vgamem_fill_cga(ul.x, i, cols, nbcols, cheight, attr); else vgamem_copy_cga(ul.x, i, i - nblines, cols, nbcols, cheight); - if (i > lr.y) - break; - } } static void @@ -206,9 +180,6 @@ scroll_text(struct vgamode_s *vmode_g, int nblines, int attr // Get the dimensions u16 nbrows = GET_BDA(video_rows) + 1; u16 nbcols = GET_BDA(video_cols); - - if (nblines > nbrows) - nblines = 0; u8 cols = lr.x - ul.x + 1; // Compute the address @@ -216,16 +187,10 @@ scroll_text(struct vgamode_s *vmode_g, int nblines, int attr dprintf(3, "Scroll, address %p (%d %d %02x)\n" , address_far, nbrows, nbcols, ul.page); - if (nblines == 0 && ul.y == 0 && ul.x == 0 && lr.y == nbrows - 1 - && lr.x == nbcols - 1) { - memset16_far(GET_GLOBAL(vmode_g->sstart), address_far - , (u16)attr * 0x100 + ' ', nbrows * nbcols * 2); - return; - } if (dir == SCROLL_UP) { u16 i; for (i = ul.y; i <= lr.y; i++) - if ((i + nblines > lr.y) || (nblines == 0)) + if (i + nblines > lr.y) memset16_far(GET_GLOBAL(vmode_g->sstart) , address_far + (i * nbcols + ul.x) * 2 , (u16)attr * 0x100 + ' ', cols * 2); @@ -237,10 +202,9 @@ scroll_text(struct vgamode_s *vmode_g, int nblines, int attr , cols * 2); return; } - u16 i; - for (i = lr.y; i >= ul.y; i--) { - if ((i < ul.y + nblines) || (nblines == 0)) + for (i = lr.y; i >= ul.y; i--) + if (i < ul.y + nblines) memset16_far(GET_GLOBAL(vmode_g->sstart) , address_far + (i * nbcols + ul.x) * 2 , (u16)attr * 0x100 + ' ', cols * 2); @@ -250,9 +214,6 @@ scroll_text(struct vgamode_s *vmode_g, int nblines, int attr , GET_GLOBAL(vmode_g->sstart) , (void*)(((i - nblines) * nbcols + ul.x) * 2) , cols * 2); - if (i > lr.y) - break; - } } void |