vgabios: Add scrolling for linear (packed pixel) graphics mode.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 1 Jan 2012 16:04:42 +0000 (11:04 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 1 Jan 2012 16:04:42 +0000 (11:04 -0500)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
vgasrc/vgafb.c

index 2104b44838b079c2c1db06da96f33ab496a653ed..85e4ab3e9fbc6d26479625c04c517de3036992c4 100644 (file)
@@ -104,6 +104,35 @@ scroll_cga(struct vgamode_s *vmode_g, int nblines, int attr
                   , stride, nblines * cheight);
 }
 
+static void
+scroll_lin(struct vgamode_s *vmode_g, int nblines, int attr
+           , struct cursorpos ul, struct cursorpos lr)
+{
+    int cheight = 8;
+    int cwidth = 8;
+    int stride = GET_BDA(video_cols) * cwidth;
+    void *src_far, *dest_far;
+    if (nblines >= 0) {
+        dest_far = (void*)(ul.y * cheight * stride + ul.x * cwidth);
+        src_far = dest_far + nblines * cheight * stride;
+    } else {
+        // Scroll down
+        nblines = -nblines;
+        dest_far = (void*)(lr.y * cheight * stride + ul.x * cwidth);
+        src_far = dest_far - nblines * cheight * stride;
+        stride = -stride;
+    }
+    int cols = lr.x - ul.x + 1;
+    int rows = lr.y - ul.y + 1;
+    if (nblines < rows)
+        dest_far = memcpy_stride(SEG_GRAPH, dest_far, src_far, cols * cwidth
+                                 , stride, (rows - nblines) * cheight);
+    if (attr < 0)
+        attr = 0;
+    memset_stride(SEG_GRAPH, dest_far, attr, cols * cwidth
+                  , stride, nblines * cheight);
+}
+
 static void
 scroll_text(struct vgamode_s *vmode_g, int nblines, int attr
             , struct cursorpos ul, struct cursorpos lr)
@@ -158,8 +187,9 @@ vgafb_scroll(int nblines, int attr, struct cursorpos ul, struct cursorpos lr)
     case CGA:
         scroll_cga(vmode_g, nblines, attr, ul, lr);
         break;
-    default:
-        dprintf(1, "Scroll in graphics mode\n");
+    case LINEAR8:
+        scroll_lin(vmode_g, nblines, attr, ul, lr);
+        break;
     }
 }