]> xenbits.xensource.com Git - seabios.git/commitdiff
VGA: No need to scroll multiple times when writing a tab.
authorKevin O'Connor <kevin@koconnor.net>
Mon, 1 Jun 2009 00:43:06 +0000 (20:43 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Mon, 1 Jun 2009 00:43:06 +0000 (20:43 -0400)
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.

vgasrc/vga.c

index c28d8915f3dee27c592f66a9993e5a097522f95d..403f047b69b5647d284fe65f2f855d7c930870df 100644 (file)
@@ -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));
 }