Index: /trunk/src/VBox/Devices/Graphics/DevVGA.cpp
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA.cpp	(revision 472)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA.cpp	(revision 473)
@@ -192,9 +192,6 @@
 //#define DEBUG_VGA_REG
 
-//#define DEBUG_S3
 #define DEBUG_BOCHS_VBE
 
-/* S3 VGA is deprecated - another graphic card will be emulated */
-//#define CONFIG_S3VGA
 #endif
 
@@ -399,9 +396,4 @@
 #ifdef DEBUG_VGA_REG
             printf("vga: read CR%x = 0x%02x\n", s->cr_index, val);
-#endif
-#ifdef DEBUG_S3
-            if (s->cr_index >= 0x20)
-                printf("S3: CR read index=0x%x val=0x%x\n",
-                       s->cr_index, val);
 #endif
             break;
@@ -540,40 +532,8 @@
             break;
 
-#ifdef CONFIG_S3VGA
-            /* S3 registers */
-        case 0x2d:
-        case 0x2e:
-        case 0x2f:
-        case 0x30:
-            /* chip ID, cannot write */
-            break;
-        case 0x31:
-            /* update start address */
-            {
-                int v;
-                s->cr[s->cr_index] = val;
-                v = (val >> 4) & 3;
-                s->cr[0x69] = (s->cr[69] & ~0x03) | v;
-            }
-            break;
-        case 0x51:
-            /* update start address */
-            {
-                int v;
-                s->cr[s->cr_index] = val;
-                v = val & 3;
-                s->cr[0x69] = (s->cr[69] & ~0x0c) | (v << 2);
-            }
-            break;
-#endif
         default:
             s->cr[s->cr_index] = val;
             break;
         }
-#ifdef DEBUG_S3
-        if (s->cr_index >= 0x20)
-            printf("S3: CR write index=0x%x val=0x%x\n",
-                   s->cr_index, val);
-#endif
         break;
     case 0x3ba:
@@ -598,20 +558,27 @@
     uint32_t val;
 
-    if (s->vbe_index <= VBE_DISPI_INDEX_NB)
-#ifndef VBOX
+    if (s->vbe_index <= VBE_DISPI_INDEX_NB) {
+      if (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_GETCAPS) {
+          switch(s->vbe_index) {
+                /* XXX: do not hardcode ? */
+            case VBE_DISPI_INDEX_XRES:
+                val = VBE_DISPI_MAX_XRES;
+                break;
+            case VBE_DISPI_INDEX_YRES:
+                val = VBE_DISPI_MAX_YRES;
+                break;
+            case VBE_DISPI_INDEX_BPP:
+                val = VBE_DISPI_MAX_BPP;
+                break;
+            default:
+                val = s->vbe_regs[s->vbe_index]; 
+                break;
+          }
+      } else {
         val = s->vbe_regs[s->vbe_index];
-#else /* VBOX */
-    {
-        /* VBE_DISPI_GETCAPS && VBE_DISPI_INDEX_BPP should */
-        /* return VBE_DISPI_MAX_BPP instead of current video mode BPP */
-        if (    (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_GETCAPS)
-            &&  s->vbe_index == VBE_DISPI_INDEX_BPP)
-            val = VBE_DISPI_MAX_BPP;
-        else
-            val = s->vbe_regs[s->vbe_index];
-    }
-#endif /* VBOX */
-    else
+      }
+    } else {
         val = 0;
+    }
 #ifdef DEBUG_BOCHS_VBE
     Log(("VBE: read index=0x%x val=0x%x\n", s->vbe_index, val));
@@ -689,4 +656,9 @@
             break;
         case VBE_DISPI_INDEX_BANK:
+            if (s->vbe_regs[VBE_DISPI_INDEX_BPP] == 4) {
+              val &= (s->vbe_bank_mask >> 2);
+            } else {
+              val &= s->vbe_bank_mask;
+            }
             val &= s->vbe_bank_mask;
             s->vbe_regs[s->vbe_index] = val;
@@ -759,5 +731,5 @@
                 /* width */
                 s->cr[0x01] = (s->vbe_regs[VBE_DISPI_INDEX_XRES] >> 3) - 1;
-                /* height */
+                /* height (only meaningful if < 1024) */
                 h = s->vbe_regs[VBE_DISPI_INDEX_YRES] - 1;
                 s->cr[0x12] = h;
@@ -1308,11 +1280,13 @@
 static void vga_get_offsets(VGAState *s,
                             uint32_t *pline_offset,
-                            uint32_t *pstart_addr)
-{
-    uint32_t start_addr, line_offset;
+                            uint32_t *pstart_addr,
+                            uint32_t *pline_compare)
+{
+    uint32_t start_addr, line_offset, line_compare;
 #ifdef CONFIG_BOCHS_VBE
     if (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED) {
         line_offset = s->vbe_line_offset;
         start_addr = s->vbe_start_addr;
+        line_compare = 65535;
     } else
 #endif
@@ -1320,23 +1294,17 @@
         /* compute line_offset in bytes */
         line_offset = s->cr[0x13];
-#ifdef CONFIG_S3VGA
-        {
-            uinr32_t v;
-            v = (s->cr[0x51] >> 4) & 3; /* S3 extension */
-            if (v == 0)
-                v = (s->cr[0x43] >> 2) & 1; /* S3 extension */
-            line_offset |= (v << 8);
-        }
-#endif
         line_offset <<= 3;
 
         /* starting address */
         start_addr = s->cr[0x0d] | (s->cr[0x0c] << 8);
-#ifdef CONFIG_S3VGA
-        start_addr |= (s->cr[0x69] & 0x1f) << 16; /* S3 extension */
-#endif
+
+        /* line compare */
+        line_compare = s->cr[0x18] | 
+            ((s->cr[0x07] & 0x10) << 4) |
+            ((s->cr[0x09] & 0x40) << 3);
     }
     *pline_offset = line_offset;
     *pstart_addr = start_addr;
+    *pline_compare = line_compare;
 }
 
@@ -1349,9 +1317,5 @@
     full_update = 0;
 
-    s->get_offsets(s, &line_offset, &start_addr);
-    /* line compare */
-    line_compare = s->cr[0x18] |
-        ((s->cr[0x07] & 0x10) << 4) |
-        ((s->cr[0x09] & 0x40) << 3);
+    s->get_offsets(s, &line_offset, &start_addr, &line_compare);
 
     if (line_offset != s->line_offset ||
@@ -1720,17 +1684,17 @@
 {
     int width, height;
-#if defined(VBOX) && defined(CONFIG_BOCHS_VBE)
-    if (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED)
-    {
-        *pwidth  = s->vbe_regs[VBE_DISPI_INDEX_XRES];
-        *pheight = s->vbe_regs[VBE_DISPI_INDEX_YRES];
-        return;
-    }
-#endif
-    width = (s->cr[0x01] + 1) * 8;
-    height = s->cr[0x12] |
-        ((s->cr[0x07] & 0x02) << 7) |
-        ((s->cr[0x07] & 0x40) << 3);
-    height = (height + 1);
+#ifdef CONFIG_BOCHS_VBE
+    if (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED) {
+        width = s->vbe_regs[VBE_DISPI_INDEX_XRES];
+        height = s->vbe_regs[VBE_DISPI_INDEX_YRES];
+    } else
+#endif
+    {
+        width = (s->cr[0x01] + 1) * 8;
+        height = s->cr[0x12] |
+            ((s->cr[0x07] & 0x02) << 7) |
+            ((s->cr[0x07] & 0x40) << 3);
+        height = (height + 1);
+    }
     *pwidth = width;
     *pheight = height;
@@ -1815,7 +1779,4 @@
     uint32_t v, addr1, addr;
     vga_draw_line_func *vga_draw_line;
-#if defined(VBOX) && defined(CONFIG_BOCHS_VBE)
-    int line_compare;
-#endif
     bool offsets_changed;
 
@@ -2001,17 +1962,5 @@
         }
         /* line compare acts on the displayed lines */
-#if defined(VBOX) && defined(CONFIG_BOCHS_VBE)
-        /* line_compare is determined from the VGA control registers.
-           However, the formula does not allow for values larger than
-           1023. So in the VBE case, we get it from the current
-           resolution instead. */
-        if (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED)
-            line_compare = s->vbe_regs[VBE_DISPI_INDEX_YRES] - 1;
-        else
-            line_compare = s->line_compare;
-        if (y == line_compare)
-#else
-        if (y == s->line_compare)
-#endif
+        if ((uint32_t)y == s->line_compare)
             addr1 = 0;
         d += linesize;
@@ -2169,11 +2118,4 @@
 {
     memset(s, 0, sizeof(VGAState));
-#ifdef CONFIG_S3VGA
-    /* chip ID for 8c968 */
-    s->cr[0x2d] = 0x88;
-    s->cr[0x2e] = 0xb0;
-    s->cr[0x2f] = 0x01; /* XXX: check revision code */
-    s->cr[0x30] = 0xe1;
-#endif
     s->graphic_mode = -1; /* force full update */
 }
@@ -2626,14 +2568,4 @@
 
 #endif /* !VBOX || !IN_GC || !IN_RING0 */
-
-
-
-
-
-
-
-
-
-
 
 
@@ -3876,5 +3808,5 @@
     uint8_t *pu8Src;
 
-    uint32_t u32OffsetSrc;
+    uint32_t u32OffsetSrc, u32Dummy;
 
     PVGASTATE s = IDISPLAYPORT_2_VGASTATE(pInterface);
@@ -3902,7 +3834,5 @@
     {
         x += w; /* Compute xRight which is also the new width. */
-
-        w = (x < 0)? 0: x;
-
+        w = (x < 0) ? 0 : x;
         x = 0;
     }
@@ -3911,7 +3841,5 @@
     {
         y += h; /* Compute yBottom, which is also the new height. */
-
-        h = (y < 0)? 0: y;
-
+        h = (y < 0) ? 0 : y;
         y = 0;
     }
@@ -3989,5 +3917,5 @@
 
     cbPixelSrc = (s->get_bpp(s) + 7) / 8;
-    s->get_offsets (s, &cbLineSrc, &u32OffsetSrc);
+    s->get_offsets (s, &cbLineSrc, &u32OffsetSrc, &u32Dummy);
 
     /* Assume that rendering is performed only on visible part of VRAM.
@@ -4013,6 +3941,4 @@
     LogFlow(("vgaPortUpdateDisplayRect: completed.\n"));
 #endif /* DEBUG_sunlover */
-
-    return;
 }
 
Index: /trunk/src/VBox/Devices/Graphics/DevVGA.h
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA.h	(revision 472)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA.h	(revision 473)
@@ -56,14 +56,11 @@
 
 #ifdef VBOX
-#define VBE_DISPI_MAX_BPP               32
-#endif
-
-#ifdef VBOX
 #define VBE_DISPI_MAX_XRES              16384
 #define VBE_DISPI_MAX_YRES              16384
 #else
-#define VBE_DISPI_MAX_XRES              1024
-#define VBE_DISPI_MAX_YRES              768
-#endif
+#define VBE_DISPI_MAX_XRES              1600
+#define VBE_DISPI_MAX_YRES              1200
+#endif
+#define VBE_DISPI_MAX_BPP               32
 
 #define VBE_DISPI_INDEX_ID              0x0
@@ -85,8 +82,6 @@
 #define VBE_DISPI_DISABLED              0x00
 #define VBE_DISPI_ENABLED               0x01
-#ifdef VBOX
 #define VBE_DISPI_GETCAPS               0x02
 #define VBE_DISPI_8BIT_DAC              0x20
-#endif
 #define VBE_DISPI_LFB_ENABLED           0x40
 #define VBE_DISPI_NOCLEARMEM            0x80
@@ -141,5 +136,6 @@
     void (*get_offsets)(struct VGAState *s,                             \
                         uint32_t *pline_offset,                         \
-                        uint32_t *pstart_addr);                         \
+                        uint32_t *pstart_addr,                          \
+                        uint32_t *pline_compare);                       \
     void (*get_resolution)(struct VGAState *s,                          \
                         int *pwidth,                                    \
@@ -175,5 +171,5 @@
 struct VGAState;
 typedef int FNGETBPP(struct VGAState *s);
-typedef void FNGETOFFSETS(struct VGAState *s, uint32_t *pline_offset, uint32_t *pstart_addr);
+typedef void FNGETOFFSETS(struct VGAState *s, uint32_t *pline_offset, uint32_t *pstart_addr, uint32_t *pline_compare);
 typedef void FNGETRESOLUTION(struct VGAState *s, int *pwidth, int *pheight);
 typedef unsigned int FNRGBTOPIXEL(unsigned int r, unsigned int g, unsigned b);
