(S)VGA Tricks - Part 2

This text comes from IMPHOBIA Issue XII - July 1996




* How to do 320x200 HiColor w/o UniVBE 5.1 *

The following trick may be used if UniVBE is not present.

On most SVGA HiColor cards, you can obtain 320x200 HiColor from a 640x480x256 or 640x400x256 mode (VESA 101h and 100h respectively). This is because most HiColor DACs are inspired from early Sierra DAC (which combines 2 consecutive bytes to form a color), but they don't use the same value to enter in HiColor. So we also need 640x480 Hicolor, just to dump the DAC value in this mode. 640x480 Hicolor should be supported by every BIOS because it's a Windows mode ;-).

For example, if your video card has a Sierra like DAC, you can do 320x200 hicolor using the following method:
         ;  SIERRA DAC like method (works on 75% of the cards) !!!

         mov   ax,4f01h
         mov   bx,110h  ; set VESA 640x480x32K colors (works on VESA 1.2)
         int   10h      ; (60 Hz)

         mov   dx,3c8h
         in    al,dx    ; reset to normal mode
         mov   dx,3c6h
         in    al,dx    ; FLIP-FLOP (see Ferraro's book for more precisions)
         in    al,dx
         in    al,dx
         in    al,dx    ; enable RS1

         in    al,dx    ; dump the DAC value in HiColor
         mov   HDAC,al  ; save it !!!

         mov   dx,3c8h
         in    al,dx    ; reset to normal mode

         mov   ax,4f01h
         mov   bx,101h  ; set VESA 640x480x256 colors (works on VESA 1.2)
         int   10h      ; (60 Hz)

         mov   dx,3c8h
         in    al,dx    ; reset to normal mode
         mov   dx,3c6h
         in    al,dx
         in    al,dx
         in    al,dx
         in    al,dx    ; enable RS1

         mov   al,HDAC  ; get HiColor DAC value
         out   dx,al    ; set IT !!!!

         mov   dx,3c8h
         in    al,dx    ; reset to normal mode

         ;----------------------------------------
         ; You are now in 320x480x32K (60 Hz) !!!!
         ;----------------------------------------

         mov   dx,3d4h  ; double the lines
         mov   al,9
         out   dx,al
         inc   dl
         in    al,dx
         and   al, NOT(31)
         or    al, 1
         out   dx,al

         ;------------------------------------
         ; Now we have 320x240x32K (60Hz) !!!!
         ;------------------------------------

 ***     ; hey these values are dumped from Mode 13h ;-)
         ;
         ; misc output
         mov   dx,3cch   ; clock reg read
         in    al,dx     ; get current Vertical/Horizontal clock
         and   al,0Fh    ; keep horizontal clock
         or    al,60h    ; 400 scanlines V-clock
         mov   dl,0c2h   ; clock reg write
         out   dx,al

         mov   dl,0d4h   ; CRTC port
         mov   ax,0bf06h ; vertical total
         out   dx,ax
         mov   ax,01f07h ; overflow reg
         out   dx,ax
         mov   ax,09c10h ; vertical retrace start
         out   dx,ax
         mov   ax,08e11h ; vertical retrace end
         out   dx,ax
         mov   ax,08f12h ; vertical display enable end
         out   dx,ax
         mov   ax,09615h ; vertical blank start
         out   dx,ax
         mov   ax,0b916h ; vertical blank end
         out   dx,ax

         ;---------------------------------------------
         ; Now we have 320x200x32K but in 60Hz :-( !!!!
         ;---------------------------------------------
Notes:
- If you start from 640x400, you'll get a 320x200x32K 70Hz,  but  the  problem
  is  that  640x400x256 is not present on every video cards (ie. Cirrus Logic,
  ...). However 640x400x256 is done on every video cards by UniVBE 5.1, but in
  this case,  if 320x200x32K is possible, UniVBE will provide it to you and it
  is not necessary to do it by hand !!!

- You can switch in a 65K mode in a similar manner.

- You  can  get 320x350 or multiples if instead of the values dumped from Mode
  13h in ***, you use the values of the EGA mode 640x350... (the 350 scanlines
  V-clock is A0h)

- You can call the "setdac15_" procedure of VGADOC4 to switch the DAC  and  to
  avoid  the  Sierra  FLIP-FLOP.  setdac15_, (or setdac16_, setdac24_) is more
  general, it supports BrookTree DAC, ...  and even S3 Trio (but in this case,
  the screen becomes totally crasy ;-) ). This works on 85% of the cards.
If your application is designed to run on 486s, I suggest you use a 32K display (becoz there are VLB and ISA boards supporting only 15bits/pix) with both LINEAR and BANKED adressing support. If it's designed for Pentium, 65K LINEAR is preferable ( I don't think there exists a PCI card without 65K and LINEAR adressing support).

* S3 Trio/Vision 864/964 Limitations *

The new S3 family uses a new integrated RAMDAC wich is not compatible with the old "Sierra"-like DAC wich was on S3-805, ...

This new RAMDAC seems not to be able to handle 320x200 in Hicolor/Truecolor mode, so you have to make a version of your application runing in a mode derivated from 640x480 Hicolor to be certain.

S3 Trios are only able to display 16.7M colors with 32 bits/pix and not 24 bits/pix !!! This require a 2M adapter, so maybe 65K is to preferable to 16.7M.

We can't ignore S3 Trios because they are one of the best-selled videocards.

* S3 805 Problems with 320x200x256 Multipage *

In particular the mode offered by UniVBE 5.1.. This mode is obtained by enabling banking in mode 13h. This works on all S3, but on the 805 series (many S3 VLBs) and may be on the 911 (i haven't tested), the pair and impair rows are inverted ! Which is far to be aesthetic !!! So regular mode 13h has still a reason to exist !!!

* The UniVBE Modes that are "sure" *

The UNIVBE modes that you will get on every 1M True colors VLB/PCI cards are (I don't consider modes above 640x480) :
          ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
          640x480x256 (60Hz)  640x480x32k (60Hz)  640x480x65k (60Hz)
          640x400x256 (70Hz)  640x400x32k (70Hz)  640x480x65k (70Hz)
          640x350x256 (70Hz)  640x350x32k (70Hz)  640x480x65k (70Hz)
          ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
But you can alter the vertical ratio without problem, simply by ajusting the character height:
            mov dx,3d4h
            mov al,9
            out dx,al
            inc dl
            in  al,dx
            and al, NOT(31)
            or  al, height
            out dx,al

            with 0 <= height <= 31
Example: if you set 640x480x256, you have
         with height = 0 : 640x480x256   -> /1
                     = 1 : 640x240x256   -> /2
                     = 2 : 640x160x256   -> /3
                     = ...
Note:
However the 800x600 and 1024x768 modes are sure, they can have problems with a video projector, so use them as a bonus.

* No X-Mode in SVGA *

I've read some articles on the Net and in the PCGPE, I think, talking about using Mode X with a 640x400x256 or 640x240x256 display. The idea is not bad , because with conventionnal Mode X, you can address 256k of Video RAM without banking. So Mode X should offer a way to use such videos modes without banking on every video cards (even old ISA).

But... this is true if you suppose that your SVGA card works like a VGA card in such modes ... and that is NOT true !!! New generations of cards are no more Mode X compatible in Hi-Res !!! If you try such code on S3, for example, you will get some surprises.