(S)VGA Tricks - Part 1
This text comes from IMPHOBIA Issue XII - July 1996
References:
- "Programmer's Guide to the EGA and VGA Cards", Second Edition, Richard
Ferraro, Addison-Wesley. (The Third Edition exists !!!)
- "VGADOC 4/WHATVGA 2.00", Finn Thoegersen. Available on nice FTPs like
ftp.arosnet.se and hagar.arts.kuleuven.ac.be (vgadoc4b.zip)
Well, i just want to speak here about tricking the VGA/SVGA adapter ...
95% of the VLB video cards are SVGA and support at least 15 bits mode (32k).
100% of the PCI video cards support 32k, 65k, and 16M colors (in 24 or 32
bits), and support FLAT linear mode. I don't know any VLB/PCI video cards with
less than 1M ram. So since the scene has moved on 486 VLB more than 2 years
ago, why didn't they use the features of the VLB-videos in demos ???
I'll speak here about 12 points:
(1) History (5) S3 805 bug (9) 50Hz/60Hz
(2) 320x200x256 > 1 page (6) UNIVBE "sure" modes (10) 320x256
(3) 320x200 Hicolor (7) No Mode-X with SVGA (11) 120Hz
(4) S3 Trio/Vision limitations (8) DRAMs speed up (12) BitBLT intro
* History *
As far as i know, the first full SVGA demo i've seen is the demo presented
by Realtech at ASM 95. But, if i remember, the rulez of the ASM 95 party was
that the demo had to run on a 100% VGA display too. Some times before, some
groups like Impact Studios and their "Project Angel" demo implemented stuffs
using the SVGA properties (i.e. 320x200x256 chained and banked). Even Complex
have used some tricks in their famous demo "Dope" to reduce wait states on
Cirrus Logic video cards. The problem of custom SVGA routs is obviously the
incompatibility with future generations of video cards and that is probably
why only a few guyz have attempted to play with SVGA.
But since february 1995, a new weapon is born which is called UNIVBE 5.1.
This nice VBE driver developped by Scitech offers you a 100% VBE 2.0 interface
(giving you an acces to FLAT linear addressing), and last but not least,
plenty of new video modes (the one they can manage with your video cards), in
particular 320x200x65k and 320x200x256 multipages. When i got the beta release
in early february 95, I was just developping my own way to handle the SVGA,
but i had some probs to get my code working on all video cards.
With the release of UniVBE 5.1, i immediatly thought that everyone should
use it in demos, to get really high quality gfx, in particular in 3D demos.
But since most parties were forcing people to use VGA, i think that no many
groups were ready to adopt it, and so we've seen many fake-18 bits modes
and other cheats to make the illusion, and blah blah ...
The opportunity to launch UniVBE 5.1 in the demo scene was Wired 95, because
some members of my crew (not me) were in the organizing staff, and because i
really believed in Wired. I've done all my possible to make them allow SVGA
support (specially Hicolor and even True Color) with UniVBE 5.1... and they
have done it. At Wired 95, i think that 2 demos used SVGA features:
1) Realtech's "Countdown" which supports VBE 2.0 FLAT linear, video modes from
320x100 up to 1600x1200 !!!! (but still in 256 colors), and even S3 BitBLT
support (however some probs on S3-805 ;-) ).
2) Our demo "Hurtless", which also supports VBE 2.00 (or 1.2), and 640x200 &
320x200 32k colors, 320x200x256 16 pages (like "Project Angel"), with
UniVBE 5.1 if present, or with custom routines if not present, BitBLT for
Cirrus Logic, Advanced Logic, S3, Primus, ... ; DRAM speed up for S3 and
Cirrus Logic.
Then, during november 95, the demo A-Colors came, which supports 32k and 16M
(!!) colors. At The Party 95, Realtech used 65K colors in their demo
"6th sense", really nice, (if you can run it !!!). And more recently, Complex
used 65K colors in their intro "Supermax" presented at The Gathering 96.
But in fact UniVBE 5.1 has some limitations that we must consider if we want
to run our code on every Video cards. In newsgroups, i've yet read some mails
speaking about problems to run such demos (like "Why doesn't Supermax run on
my S3 Trio", ...). In fact some video modes are "sure" and some others "not",
and even the new UniVBE 5.2 will not change that ... but i'll speak about that
in the next lines ...
* How to do 320x200x256 with more than 1 page ? *
(without UniVBE 5.1)
The following tricks may be used if UniVBE isn't present.
There are 3 ways:
a) Init mode 13h and enable access to bank registers
You have to do a specific code to enable the bank registers, and then use
a specific code to switch the banks. If you want a nice collection of
specific codes, I suggest you to D/L vgadoc4b.zip (see in the beginning).
This is the only way to get multipage on a S3, for example, because method
'b' doesn't work on such card.
b) Set 640x??? mode en then half the horizontal values
I think this is the best method, because you start from a SVGA mode where
all the bank registers are enabled. So you don't have to do a specific code
to enable the banks and you can even use VESA calls to switch the banks !!!
Moreover, this is the only solution if you want to get 320x200 multipages
on Cirrus Logic video cards. I think this works on 70% of the VGAs.
h320 LABEL WORD
DW 2D00h ; 3d4/00 horizontal total
DW 2701h ; 3d4/01 horizontal display enable end
DW 2802h ; 3d4/02 horizontal blank start
DW 9003h ; 3d4/03 horizontal blank end
DW 2B04h ; 3d4/04 horizontal retrace start
DW 8005h ; 3d4/05 horizontal retrace end
DW 2813h ; 3d4/13 logical width
DW 0901h ; 3c4/01 clock mode register
mov ax,4f01h
mov bx,101h ; 640x480x256 (60Hz)
int 10h
mov dx,3d4h ; remove protection
mov al,11h
out dx,al
inc dl
in al,dx
and al,7fh
out dx,al
dec dl
; horizontal parameters
mov esi,OFFSET h320
REPT 6+1
outsb
inc dl
outsb
dec dl
ENDM
mov dl,0c4h
outsb ; clock
inc dl
outsb
;----------------------------------
; we are in 320x480x256 (60Hz) !!!!
;----------------------------------
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 320x240x256 (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 320x200x256 but in 60Hz :-( !!!!
;---------------------------------------------
c) enable a 128k page in a0000-bffff to get 2 pages
This doesn't work on every cards. It works on the Cirrus Logic and possibly
on some Tsengs (?), and ... I suggest you to do a test. Make sure that you
don't have EMM or QEMM using the space between b0000 and bffff (you can
test it by checking if there is RAM in this zone before enabling the 128k).
On Cirrus Logic, it only works in SVGA modes :-(.
mov dx,3ceh ; active 128k adressing
mov al,06
out dx,al
inc dl
in al,dx ; rem: dx=3cf/3ce=6
and al,NOT(1100y) ; Video RAM should be mapped on a000-b7ff
out dx,al
But even with these 3 methods, there are still video cards on which it is
impossible to get a full working multipage mode (ie. S3 805)