aboutsummaryrefslogtreecommitdiffstats
path: root/vgasrc/vgabios.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-07-15 10:54:51 -0400
committerKevin O'Connor <kevin@koconnor.net>2016-07-21 10:51:32 -0400
commit09e24ac187d586c6a287927afffefe4da319fd3e (patch)
treea14b9f9b3d2675b164ab47c41a5c2f660a11de27 /vgasrc/vgabios.c
parentae3f78f3fa1a4c32600132df2f78fa31b6d775f1 (diff)
downloadseabios-09e24ac187d586c6a287927afffefe4da319fd3e.tar.gz
vgabios: Simplify scroll logic
Introduce a new function vgafb_scroll() to scroll a window on the screen and update vgabios.c to use only that function for scrolling. This makes the low-level vgafb_move_chars() and vgafb_clear_chars() local to vgafb.c, and it simplifies the callers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'vgasrc/vgabios.c')
-rw-r--r--vgasrc/vgabios.c57
1 files changed, 14 insertions, 43 deletions
diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c
index cfb6ba25..2c8cc79d 100644
--- a/vgasrc/vgabios.c
+++ b/vgasrc/vgabios.c
@@ -198,15 +198,10 @@ write_teletype(struct cursorpos *pcp, struct carattr ca)
if (pcp->y > nbrows) {
pcp->y--;
- struct cursorpos dest = {0, 0, pcp->page};
- struct cursorpos src = {0, 1, pcp->page};
- struct cursorpos size = {GET_BDA(video_cols), nbrows};
- vgafb_move_chars(dest, src, size);
-
- struct cursorpos clr = {0, nbrows, pcp->page};
+ struct cursorpos win = {0, 0, pcp->page};
+ struct cursorpos winsize = {GET_BDA(video_cols), nbrows+1};
struct carattr attr = {' ', 0, 0};
- struct cursorpos clrsize = {GET_BDA(video_cols), 1};
- vgafb_clear_chars(clr, attr, clrsize);
+ vgafb_scroll(win, winsize, 1, attr);
}
}
@@ -400,6 +395,7 @@ handle_1005(struct bregs *regs)
static void
verify_scroll(struct bregs *regs, int dir)
{
+ // Verify parameters
u8 ulx = regs->cl, uly = regs->ch, lrx = regs->dl, lry = regs->dh;
u16 nbrows = GET_BDA(video_rows) + 1;
if (lry >= nbrows)
@@ -410,41 +406,16 @@ verify_scroll(struct bregs *regs, int dir)
int wincols = lrx - ulx + 1, winrows = lry - uly + 1;
if (wincols <= 0 || winrows <= 0)
return;
-
- u8 page = GET_BDA(video_page);
- int clearlines = regs->al, movelines = winrows - clearlines;
- if (!clearlines || movelines <= 0) {
- // Clear whole area.
- struct cursorpos clr = {ulx, uly, page};
- struct carattr attr = {' ', regs->bh, 1};
- struct cursorpos clrsize = {wincols, winrows};
- vgafb_clear_chars(clr, attr, clrsize);
- return;
- }
-
- if (dir > 0) {
- // Normal scroll
- struct cursorpos dest = {ulx, uly, page};
- struct cursorpos src = {ulx, uly + clearlines, page};
- struct cursorpos size = {wincols, movelines};
- vgafb_move_chars(dest, src, size);
-
- struct cursorpos clr = {ulx, uly + movelines, page};
- struct carattr attr = {' ', regs->bh, 1};
- struct cursorpos clrsize = {wincols, clearlines};
- vgafb_clear_chars(clr, attr, clrsize);
- } else {
- // Scroll down
- struct cursorpos dest = {ulx, uly + clearlines, page};
- struct cursorpos src = {ulx, uly, page};
- struct cursorpos size = {wincols, movelines};
- vgafb_move_chars(dest, src, size);
-
- struct cursorpos clr = {ulx, uly, page};
- struct carattr attr = {' ', regs->bh, 1};
- struct cursorpos clrsize = {wincols, clearlines};
- vgafb_clear_chars(clr, attr, clrsize);
- }
+ int lines = regs->al;
+ if (lines >= winrows)
+ lines = 0;
+ lines *= dir;
+
+ // Scroll (or clear) window
+ struct cursorpos win = {ulx, uly, GET_BDA(video_page)};
+ struct cursorpos winsize = {wincols, winrows};
+ struct carattr attr = {' ', regs->bh, 1};
+ vgafb_scroll(win, winsize, lines, attr);
}
static void