VGA: Remove vmode_g->class - store info in vmode_g->memmodel.
authorKevin O'Connor <kevin@koconnor.net>
Tue, 26 May 2009 03:37:13 +0000 (23:37 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Tue, 26 May 2009 03:37:13 +0000 (23:37 -0400)
vgasrc/vga.c
vgasrc/vgafb.c
vgasrc/vgatables.c
vgasrc/vgatables.h

index 70c6b93b30b5111b4bad61a9fdb781f74c94b681..9d7ca30b61a73f4907b42662d25097a8cdcb3d03 100644 (file)
@@ -149,7 +149,7 @@ biosfn_set_active_page(u8 page)
     struct cursorpos cp = get_cursor_pos(page);
 
     u16 address;
-    if (GET_GLOBAL(vmode_g->class) == TEXT) {
+    if (GET_GLOBAL(vmode_g->memmodel) & TEXT) {
         // Get the dimensions
         u16 nbcols = GET_BDA(video_cols);
         u16 nbrows = GET_BDA(video_rows) + 1;
@@ -229,7 +229,7 @@ biosfn_write_teletype(u8 page, struct carattr ca)
     }
     // Do we need to scroll ?
     if (cp.y == nbrows) {
-        if (GET_GLOBAL(vmode_g->class) == TEXT)
+        if (GET_GLOBAL(vmode_g->memmodel) & TEXT)
             biosfn_scroll(0x01, 0x07, 0, 0, nbrows - 1, nbcols - 1, page,
                           SCROLL_UP);
         else
@@ -427,7 +427,7 @@ handle_1000(struct bregs *regs)
     SET_BDA(video_pal, 0x00); // Unavailable on vanilla vga, but...
 
     // Set cursor shape
-    if (GET_GLOBAL(vmode_g->class) == TEXT)
+    if (GET_GLOBAL(vmode_g->memmodel) & TEXT)
         biosfn_set_cursor_shape(0x06, 0x07);
     // Set cursor pos for page 0..7
     int i;
@@ -440,7 +440,7 @@ handle_1000(struct bregs *regs)
     biosfn_set_active_page(0x00);
 
     // Write the fonts in memory
-    if (GET_GLOBAL(vmode_g->class) == TEXT) {
+    if (GET_GLOBAL(vmode_g->memmodel) & TEXT) {
         call16_vgaint(0x1104, 0);
         call16_vgaint(0x1103, 0);
     }
index fbc180799ffd0295acb4c10ec67bdd4fd97cec3b..231ba1ed957c6b05f39ca09393b768bcf40d5b0c 100644 (file)
@@ -13,7 +13,6 @@
 //  * extract hw code from framebuffer code
 //  * use clear_screen() in scroll code
 //  * read/write_char should take a position; should not take count
-//  * remove vmode_g->class (integrate into vmode_g->memmodel)
 //  * normalize params (don't use AX/BX/CX/etc.)
 
 // XXX
@@ -88,7 +87,7 @@ vgamem_fill_cga(u8 xstart, u8 ystart, u8 cols, u8 nbcols, u8 cheight,
 void
 clear_screen(struct vgamode_s *vmode_g)
 {
-    if (GET_GLOBAL(vmode_g->class) == TEXT) {
+    if (GET_GLOBAL(vmode_g->memmodel) & TEXT) {
         memset16_far(GET_GLOBAL(vmode_g->sstart), 0, 0x0720, 32*1024);
         return;
     }
@@ -134,7 +133,7 @@ biosfn_scroll(u8 nblines, u8 attr, u8 rul, u8 cul, u8 rlr, u8 clr, u8 page,
         nblines = 0;
     u8 cols = clr - cul + 1;
 
-    if (GET_GLOBAL(vmode_g->class) == TEXT) {
+    if (GET_GLOBAL(vmode_g->memmodel) & TEXT) {
         // Compute the address
         void *address_far = (void*)(SCREEN_MEM_START(nbcols, nbrows, page));
         dprintf(3, "Scroll, address %p (%d %d %02x)\n"
@@ -390,7 +389,7 @@ vgafb_write_char(u8 page, struct carattr ca, u16 count)
     u16 nbrows = GET_BDA(video_rows) + 1;
     u16 nbcols = GET_BDA(video_cols);
 
-    if (GET_GLOBAL(vmode_g->class) == TEXT) {
+    if (GET_GLOBAL(vmode_g->memmodel) & TEXT) {
         // Compute the address
         void *address_far = (void*)(SCREEN_MEM_START(nbcols, nbrows, cp.page)
                                     + (cp.x + cp.y * nbcols) * 2);
@@ -445,7 +444,7 @@ vgafb_read_char(u8 page)
     u16 nbrows = GET_BDA(video_rows) + 1;
     u16 nbcols = GET_BDA(video_cols);
 
-    if (GET_GLOBAL(vmode_g->class) == TEXT) {
+    if (GET_GLOBAL(vmode_g->memmodel) & TEXT) {
         // Compute the address
         u16 *address_far = (void*)(SCREEN_MEM_START(nbcols, nbrows, cp.page)
                                    + (cp.x + cp.y * nbcols) * 2);
@@ -473,7 +472,7 @@ biosfn_write_pixel(u8 BH, u8 AL, u16 CX, u16 DX)
     struct vgamode_s *vmode_g = find_vga_entry(GET_BDA(video_mode));
     if (!vmode_g)
         return;
-    if (GET_GLOBAL(vmode_g->class) == TEXT)
+    if (GET_GLOBAL(vmode_g->memmodel) & TEXT)
         return;
 
     u8 *addr_far, mask, attr, data;
@@ -529,7 +528,7 @@ biosfn_read_pixel(u8 BH, u16 CX, u16 DX, u16 *AX)
     struct vgamode_s *vmode_g = find_vga_entry(GET_BDA(video_mode));
     if (!vmode_g)
         return;
-    if (GET_GLOBAL(vmode_g->class) == TEXT)
+    if (GET_GLOBAL(vmode_g->memmodel) & TEXT)
         return;
 
     u8 *addr_far, mask, attr=0, data, i;
index 129f9dcf2af66a1390d0a19bd6d4c0bf7130c156..0587e651c613117ac8a753faf1657eca3ecf215c 100644 (file)
@@ -383,23 +383,23 @@ static u8 palette3[] VAR16 = {
 #define VPARAM(x) &video_param_table[x]
 
 static struct vgamode_s vga_modes[] VAR16 = {
-    //mode vparam        class  model bits  sstart     pelm  dac
-    {0x00, VPARAM(0x17), TEXT,  CTEXT,   4, SEG_CTEXT, 0xFF, PAL(palette2)},
-    {0x01, VPARAM(0x17), TEXT,  CTEXT,   4, SEG_CTEXT, 0xFF, PAL(palette2)},
-    {0x02, VPARAM(0x18), TEXT,  CTEXT,   4, SEG_CTEXT, 0xFF, PAL(palette2)},
-    {0x03, VPARAM(0x18), TEXT,  CTEXT,   4, SEG_CTEXT, 0xFF, PAL(palette2)},
-    {0x04, VPARAM(0x04), GRAPH, CGA,     2, SEG_CTEXT, 0xFF, PAL(palette1)},
-    {0x05, VPARAM(0x05), GRAPH, CGA,     2, SEG_CTEXT, 0xFF, PAL(palette1)},
-    {0x06, VPARAM(0x06), GRAPH, CGA,     1, SEG_CTEXT, 0xFF, PAL(palette1)},
-    {0x07, VPARAM(0x07), TEXT,  MTEXT,   4, SEG_MTEXT, 0xFF, PAL(palette0)},
-    {0x0D, VPARAM(0x0d), GRAPH, PLANAR4, 4, SEG_GRAPH, 0xFF, PAL(palette1)},
-    {0x0E, VPARAM(0x0e), GRAPH, PLANAR4, 4, SEG_GRAPH, 0xFF, PAL(palette1)},
-    {0x0F, VPARAM(0x11), GRAPH, PLANAR1, 1, SEG_GRAPH, 0xFF, PAL(palette0)},
-    {0x10, VPARAM(0x12), GRAPH, PLANAR4, 4, SEG_GRAPH, 0xFF, PAL(palette2)},
-    {0x11, VPARAM(0x1a), GRAPH, PLANAR1, 1, SEG_GRAPH, 0xFF, PAL(palette2)},
-    {0x12, VPARAM(0x1b), GRAPH, PLANAR4, 4, SEG_GRAPH, 0xFF, PAL(palette2)},
-    {0x13, VPARAM(0x1c), GRAPH, LINEAR8, 8, SEG_GRAPH, 0xFF, PAL(palette3)},
-    {0x6A, VPARAM(0x1d), GRAPH, PLANAR4, 4, SEG_GRAPH, 0xFF, PAL(palette2)},
+    //mode vparam        model bits  sstart     pelm  dac
+    {0x00, VPARAM(0x17), CTEXT,   4, SEG_CTEXT, 0xFF, PAL(palette2)},
+    {0x01, VPARAM(0x17), CTEXT,   4, SEG_CTEXT, 0xFF, PAL(palette2)},
+    {0x02, VPARAM(0x18), CTEXT,   4, SEG_CTEXT, 0xFF, PAL(palette2)},
+    {0x03, VPARAM(0x18), CTEXT,   4, SEG_CTEXT, 0xFF, PAL(palette2)},
+    {0x04, VPARAM(0x04), CGA,     2, SEG_CTEXT, 0xFF, PAL(palette1)},
+    {0x05, VPARAM(0x05), CGA,     2, SEG_CTEXT, 0xFF, PAL(palette1)},
+    {0x06, VPARAM(0x06), CGA,     1, SEG_CTEXT, 0xFF, PAL(palette1)},
+    {0x07, VPARAM(0x07), MTEXT,   4, SEG_MTEXT, 0xFF, PAL(palette0)},
+    {0x0D, VPARAM(0x0d), PLANAR4, 4, SEG_GRAPH, 0xFF, PAL(palette1)},
+    {0x0E, VPARAM(0x0e), PLANAR4, 4, SEG_GRAPH, 0xFF, PAL(palette1)},
+    {0x0F, VPARAM(0x11), PLANAR1, 1, SEG_GRAPH, 0xFF, PAL(palette0)},
+    {0x10, VPARAM(0x12), PLANAR4, 4, SEG_GRAPH, 0xFF, PAL(palette2)},
+    {0x11, VPARAM(0x1a), PLANAR1, 1, SEG_GRAPH, 0xFF, PAL(palette2)},
+    {0x12, VPARAM(0x1b), PLANAR4, 4, SEG_GRAPH, 0xFF, PAL(palette2)},
+    {0x13, VPARAM(0x1c), LINEAR8, 8, SEG_GRAPH, 0xFF, PAL(palette3)},
+    {0x6A, VPARAM(0x1d), PLANAR4, 4, SEG_GRAPH, 0xFF, PAL(palette2)},
 };
 
 struct vgamode_s *
index 8b35f0e79fb20f44eab4542163ea4a47634380f2..81e9c3aa44152c497152161d2381dc9c6887de1f 100644 (file)
 #define SEG_MTEXT 0xB000
 
 /*
- *
  * Tables of default values for each mode
- *
  */
-#define TEXT       0x00
-#define GRAPH      0x01
+#define TEXT       0x80
 
-#define CTEXT      0x00
-#define MTEXT      0x01
+#define CTEXT      (0x00 | TEXT)
+#define MTEXT      (0x01 | TEXT)
 #define CGA        0x02
 #define PLANAR1    0x03
 #define PLANAR4    0x04
@@ -71,8 +68,6 @@
 
 #define SCROLL_DOWN 0
 #define SCROLL_UP   1
-#define NO_ATTR     2
-#define WITH_ATTR   3
 
 #define SCREEN_SIZE(x,y) (((x*y*2)|0x00ff)+1)
 #define SCREEN_MEM_START(x,y,p) ((((x*y*2)|0x00ff)+1)*p)
@@ -94,7 +89,6 @@ struct VideoParam_s {
 struct vgamode_s {
     u8 svgamode;
     struct VideoParam_s *vparam;
-    u8 class;       /* TEXT, GRAPH */
     u8 memmodel;    /* CTEXT,MTEXT,CGA,PL1,PL2,PL4,P8,P15,P16,P24,P32 */
     u8 pixbits;
     u16 sstart;