vgabios: Refactor vga_set_mode and stdvga_set_mode.
[seabios.git] / vgasrc / vgafb.c
index 1e1943dc2b6cb126b885a29c33d0f2ff1dbd5969..38ed07040d8c03b820f1452694082c254ecef5d0 100644 (file)
@@ -7,7 +7,8 @@
 
 #include "biosvar.h" // GET_BDA
 #include "util.h" // memset_far
-#include "vgatables.h" // find_vga_entry
+#include "vgabios.h" // find_vga_entry
+#include "stdvga.h" // stdvga_grdc_write
 
 
 /****************************************************************
@@ -56,15 +57,15 @@ scroll_pl4(struct vgamode_s *vmode_g, int nblines, int attr
     int cols = lr.x - ul.x + 1;
     int rows = lr.y - ul.y + 1;
     if (nblines < rows) {
-        vgahw_grdc_write(0x05, 0x01);
+        stdvga_grdc_write(0x05, 0x01);
         dest_far = memcpy_stride(SEG_GRAPH, dest_far, src_far, cols, stride
                                  , (rows - nblines) * cheight);
     }
     if (attr < 0)
         attr = 0;
-    vgahw_grdc_write(0x05, 0x02);
+    stdvga_grdc_write(0x05, 0x02);
     memset_stride(SEG_GRAPH, dest_far, attr, cols, stride, nblines * cheight);
-    vgahw_grdc_write(0x05, 0x00);
+    stdvga_grdc_write(0x05, 0x00);
 }
 
 static void
@@ -157,24 +158,6 @@ vgafb_scroll(int nblines, int attr, struct cursorpos ul, struct cursorpos lr)
     }
 }
 
-void
-clear_screen(struct vgamode_s *vmode_g)
-{
-    switch (GET_GLOBAL(vmode_g->memmodel)) {
-    case CTEXT:
-    case MTEXT:
-        memset16_far(GET_GLOBAL(vmode_g->sstart), 0, 0x0720, 32*1024);
-        break;
-    case CGA:
-        memset16_far(GET_GLOBAL(vmode_g->sstart), 0, 0x0000, 32*1024);
-        break;
-    default:
-        // XXX - old code gets/sets/restores sequ register 2 to 0xf -
-        // but it should always be 0xf anyway.
-        memset16_far(GET_GLOBAL(vmode_g->sstart), 0, 0x0000, 64*1024);
-    }
-}
-
 
 /****************************************************************
  * Read/write characters to screen
@@ -202,19 +185,19 @@ write_gfx_char_pl4(struct vgamode_s *vmode_g
     }
     u16 addr = cp.x + cp.y * cheight * nbcols;
     u16 src = ca.car * cheight;
-    vgahw_sequ_write(0x02, 0x0f);
-    vgahw_grdc_write(0x05, 0x02);
+    stdvga_sequ_write(0x02, 0x0f);
+    stdvga_grdc_write(0x05, 0x02);
     if (ca.attr & 0x80)
-        vgahw_grdc_write(0x03, 0x18);
+        stdvga_grdc_write(0x03, 0x18);
     else
-        vgahw_grdc_write(0x03, 0x00);
+        stdvga_grdc_write(0x03, 0x00);
     u8 i;
     for (i = 0; i < cheight; i++) {
         u8 *dest_far = (void*)(addr + i * nbcols);
         u8 j;
         for (j = 0; j < 8; j++) {
             u8 mask = 0x80 >> j;
-            vgahw_grdc_write(0x08, mask);
+            stdvga_grdc_write(0x08, mask);
             GET_FARVAR(SEG_GRAPH, *dest_far);
             if (GET_GLOBAL(fdata_g[src + i]) & mask)
                 SET_FARVAR(SEG_GRAPH, *dest_far, ca.attr & 0x0f);
@@ -222,9 +205,9 @@ write_gfx_char_pl4(struct vgamode_s *vmode_g
                 SET_FARVAR(SEG_GRAPH, *dest_far, 0x00);
         }
     }
-    vgahw_grdc_write(0x08, 0xff);
-    vgahw_grdc_write(0x05, 0x00);
-    vgahw_grdc_write(0x03, 0x00);
+    stdvga_grdc_write(0x08, 0xff);
+    stdvga_grdc_write(0x05, 0x00);
+    stdvga_grdc_write(0x03, 0x00);
 }
 
 static void
@@ -407,15 +390,15 @@ vgafb_write_pixel(u8 color, u16 x, u16 y)
     case PLANAR1:
         addr_far = (void*)(x / 8 + y * GET_BDA(video_cols));
         mask = 0x80 >> (x & 0x07);
-        vgahw_grdc_write(0x08, mask);
-        vgahw_grdc_write(0x05, 0x02);
+        stdvga_grdc_write(0x08, mask);
+        stdvga_grdc_write(0x05, 0x02);
         data = GET_FARVAR(SEG_GRAPH, *addr_far);
         if (color & 0x80)
-            vgahw_grdc_write(0x03, 0x18);
+            stdvga_grdc_write(0x03, 0x18);
         SET_FARVAR(SEG_GRAPH, *addr_far, color);
-        vgahw_grdc_write(0x08, 0xff);
-        vgahw_grdc_write(0x05, 0x00);
-        vgahw_grdc_write(0x03, 0x00);
+        stdvga_grdc_write(0x08, 0xff);
+        stdvga_grdc_write(0x05, 0x00);
+        stdvga_grdc_write(0x03, 0x00);
         break;
     case CGA:
         if (GET_GLOBAL(vmode_g->pixbits) == 2)
@@ -465,7 +448,7 @@ vgafb_read_pixel(u16 x, u16 y)
         mask = 0x80 >> (x & 0x07);
         attr = 0x00;
         for (i = 0; i < 4; i++) {
-            vgahw_grdc_write(0x04, i);
+            stdvga_grdc_write(0x04, i);
             data = GET_FARVAR(SEG_GRAPH, *addr_far) & mask;
             if (data > 0)
                 attr |= (0x01 << i);
@@ -488,22 +471,3 @@ vgafb_read_pixel(u16 x, u16 y)
     }
     return attr;
 }
-
-
-/****************************************************************
- * Font loading
- ****************************************************************/
-
-void
-vgafb_load_font(u16 seg, void *src_far, u16 count
-                , u16 start, u8 destflags, u8 fontsize)
-{
-    get_font_access();
-    u16 blockaddr = ((destflags & 0x03) << 14) + ((destflags & 0x04) << 11);
-    void *dest_far = (void*)(blockaddr + start*32);
-    u16 i;
-    for (i = 0; i < count; i++)
-        memcpy_far(SEG_GRAPH, dest_far + i*32
-                   , seg, src_far + i*fontsize, fontsize);
-    release_font_access();
-}