diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2009-05-26 00:20:40 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2009-05-26 00:20:40 -0400 |
commit | 82221b2bf19d69dc0bd76e72043abeb2136227c4 (patch) | |
tree | 147948ac7d5bac54d5f0332db22a77fa7c723583 /vgasrc | |
parent | d3b381514a57a3c77dd05753ea9852fa6e80996c (diff) | |
download | seabios-82221b2bf19d69dc0bd76e72043abeb2136227c4.tar.gz |
VGA: Remove recursion from biosfn_write_teletype().
Diffstat (limited to 'vgasrc')
-rw-r--r-- | vgasrc/vga.c | 65 |
1 files changed, 37 insertions, 28 deletions
diff --git a/vgasrc/vga.c b/vgasrc/vga.c index 53e8dd83..6f954f37 100644 --- a/vgasrc/vga.c +++ b/vgasrc/vga.c @@ -7,7 +7,6 @@ // TODO: -// * remove recursion from biosfn_write_teletype() // * review correctness of converted asm by comparing with RBIL // * refactor redundant code into sub-functions // * See if there is a method to the in/out stuff that can be encapsulated. @@ -176,21 +175,43 @@ biosfn_set_active_page(u8 page) set_cursor_pos(cp); } +static struct cursorpos +check_scroll(struct cursorpos cp) +{ + // Get the dimensions + u16 nbrows = GET_BDA(video_rows) + 1; + u16 nbcols = GET_BDA(video_cols); + + // Do we need to wrap ? + if (cp.x == nbcols) { + cp.x = 0; + cp.y++; + } + // Do we need to scroll ? + if (cp.y == nbrows) { + // Get the mode + struct vgamode_s *vmode_g = find_vga_entry(GET_BDA(video_mode)); + if (!vmode_g) + return cp; + + if (GET_GLOBAL(vmode_g->memmodel) & TEXT) + biosfn_scroll(0x01, 0x07, 0, 0, nbrows - 1, nbcols - 1, cp.page, + SCROLL_UP); + else + biosfn_scroll(0x01, 0x00, 0, 0, nbrows - 1, nbcols - 1, cp.page, + SCROLL_UP); + cp.y--; + } + + return cp; +} + static void biosfn_write_teletype(u8 page, struct carattr ca) { - // Get the mode - struct vgamode_s *vmode_g = find_vga_entry(GET_BDA(video_mode)); - if (!vmode_g) - return; - // Get the cursor pos for the page struct cursorpos cp = get_cursor_pos(page); - // Get the dimensions - u16 nbrows = GET_BDA(video_rows) + 1; - u16 nbcols = GET_BDA(video_cols); - switch (ca.car) { case 7: //FIXME should beep @@ -212,9 +233,10 @@ biosfn_write_teletype(u8 page, struct carattr ca) case '\t': do { struct carattr dummyca = {' ', ca.attr, ca.use_attr}; - biosfn_write_teletype(page, dummyca); - cp = get_cursor_pos(page); - } while (cp.x % 8 == 0); + vgafb_write_char(cp, dummyca); + cp.x++; + cp = check_scroll(cp); + } while (cp.x % 8); break; default: @@ -222,21 +244,8 @@ biosfn_write_teletype(u8 page, struct carattr ca) cp.x++; } - // Do we need to wrap ? - if (cp.x == nbcols) { - cp.x = 0; - cp.y++; - } - // Do we need to scroll ? - if (cp.y == nbrows) { - if (GET_GLOBAL(vmode_g->memmodel) & TEXT) - biosfn_scroll(0x01, 0x07, 0, 0, nbrows - 1, nbcols - 1, page, - SCROLL_UP); - else - biosfn_scroll(0x01, 0x00, 0, 0, nbrows - 1, nbcols - 1, page, - SCROLL_UP); - cp.y--; - } + cp = check_scroll(cp); + // Set the cursor for the page set_cursor_pos(cp); } |