From: Kevin O'Connor Date: Mon, 1 Jun 2009 00:43:06 +0000 (-0400) Subject: VGA: No need to scroll multiple times when writing a tab. X-Git-Tag: rel-0.4.1~31 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=2e86c6a805ef57686ad8af067f010e602adb5d84;p=seabios.git VGA: No need to scroll multiple times when writing a tab. A tab can only scroll the screen once. Inline the code from check_scroll into write_teletype. Also, move row check in write_string to handle_1013. --- diff --git a/vgasrc/vga.c b/vgasrc/vga.c index c28d891..403f047 100644 --- a/vgasrc/vga.c +++ b/vgasrc/vga.c @@ -176,78 +176,62 @@ biosfn_set_active_page(u8 page) } static struct cursorpos -check_scroll(struct cursorpos cp) +write_teletype(struct cursorpos cp, struct carattr ca) { // 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) { - struct cursorpos ul = {0, 0, cp.page}; - struct cursorpos lr = {nbcols-1, nbrows-1, cp.page}; - vgafb_scroll(1, -1, ul, lr); - cp.y--; - } - - return cp; -} - -static struct cursorpos -write_teletype(struct cursorpos cp, struct carattr ca) -{ switch (ca.car) { case 7: //FIXME should beep break; - case 8: if (cp.x > 0) cp.x--; break; - case '\r': cp.x = 0; break; - case '\n': cp.y++; break; - case '\t': do { struct carattr dummyca = {' ', ca.attr, ca.use_attr}; vgafb_write_char(cp, dummyca); cp.x++; - cp = check_scroll(cp); - } while (cp.x % 8); + } while (cp.x < nbcols && cp.x % 8); break; - default: vgafb_write_char(cp, ca); cp.x++; } - return check_scroll(cp); + // Do we need to wrap ? + if (cp.x == nbcols) { + cp.x = 0; + cp.y++; + } + // Do we need to scroll ? + if (cp.y == nbrows) { + struct cursorpos ul = {0, 0, cp.page}; + struct cursorpos lr = {nbcols-1, nbrows-1, cp.page}; + vgafb_scroll(1, -1, ul, lr); + cp.y--; + } + + return cp; } static void write_string(struct cursorpos cp, u8 flag, u8 attr, u16 count, u16 seg, u8 *offset_far) { - // if row=0xff special case : use current cursor position - if (cp.y == 0xff) - cp = get_cursor_pos(cp.page); - - while (count-- != 0) { + while (count--) { u8 car = GET_FARVAR(seg, *offset_far); offset_far++; - if ((flag & 0x02) != 0) { + if (flag & 0x02) { attr = GET_FARVAR(seg, *offset_far); offset_far++; } @@ -1006,8 +990,10 @@ handle_1012(struct bregs *regs) static void handle_1013(struct bregs *regs) { - // XXX - inline struct cursorpos cp = {regs->dl, regs->dh, regs->bh}; + // if row=0xff special case : use current cursor position + if (cp.y == 0xff) + cp = get_cursor_pos(cp.page); write_string(cp, regs->al, regs->bl, regs->cx , regs->es, (void*)(regs->bp + 0)); }