(S)VGA Tricks - Part 3
This text comes from IMPHOBIA Issue XII - July 1996
* DRAMs Speed Up / Booster *
a) You can obtain better performance with a Cirrus Logic 542x, if you add
these lines in your code (even with Mode X !) :
mov dx,3c4h
mov al,0fh
out dx,al
inc dl
in al,dx
and al,NOT(8+16+32)
or al,(6 SHL 3) ; 32 bit mode + CRT FIFO depth control
out dx,al
dec dl
mov al,16h
out dx,al
inc dl
in al,dx
and al,15
or al,(0 SHL 4)+(2 SHL 6) ; delay for mem Write I/O
out dx,al
It basically reduces the DRAMs wait states. I think that Complex used a
similar trick in "Dope". Normally there are no probs, but it's always a good
idea to allow the user to disable the booster.
b) S3 cards can be accelerated by the following code :
; code hacked from S3SPEEDUP / meschede
; available on ftp.uni-muenster.de /pub/meschede/...
; read(port, index, value) ; write(port, index, value)
; dx = port ; dx = port
; al = index ; al = index
; value -> ah ; ah = value
Read3D4 PROC NEAR Write3D4 PROC NEAR
mov dx,3d4h mov dx,3d4h
out dx,al out dx,al
mov ah,al xchg ah,al
inc dx inc dx
in al,dx out dx,al
xchg ah,al xchg ah,al
dec dx dec dx
ret ret
Read3D4 ENDP Write3D4 ENDP
; enable extensions
ExtON PROC NEAR
mov ax,4838h ; extensions enable (enable extended registers)
call Write3D4 ; write(3d4h, 38h, 48h)
mov ax,0A039h; extensions enable2
call Write3D4 ; write(3d4h, 39h, a0h)
ret
ExtON ENDP
; disable extensions
ExtOFF PROC NEAR
mov ax,0038h ; disable extended registers
call Write3D4 ; write(3d4h, 38h, 00h)
mov ax,0039h ; disable2
call Write3D4 ; write(3d4h, 39h, 00h)
ret
ExtOFF ENDP
; enable linear and set vidmem to 0a0000h !!!!!!
MAP_A000H PROC NEAR
pusha
mov bl,0ECh
mov bh,10h
mov cx,000Ah
call ExtON ; enable extensions
mov al,058h ; linear aperture options / bit 2
call Read3D4 ; ah = read(3d4h, 58h)
and ah,0ECh ; clear bit 0,1 and 4
call Write3D4; write(3d4h, 58h, new AH)
mov al,059h ; bit 0-1: linear memory address bit 8-9
mov ah,ch
call Write3D4; write(3d4h, 59h, 00h)
inc al ; 05Ah : bit 0-7 = linear mem address bit 0-7
mov ah,cl ; in 64k units ???
call Write3D4; write(3d4h, 5Ah, 0Ah)
mov al,058h ; linear aperture options
call Read3D4 ; ah = read(3d4h, 58h)
and ah,bl ; and ah,ECh -> clear bit 0,1 and 4
or ah,bh ; or ah,10h (OR or ah,00h) -> set bit 4
call Write3D4; write(3d4h, 58h, new AH)
call ExtOFF ; disable extensions
popa
ret
MAP_A000H ENDP
FAST_WRITE_BUFFER_ON PROC NEAR
pusha
call ExtON ; enable extensions
mov al,40h ; bit 0: if set enables 8514/A mode
call Read3D4 ; * 3: (801,805,928) Fast Write Buffer ON *
or ah,08h ; 6: (801,805,928) Zero Wait State OFF (EISA)
call Write3D4; set bit 3 to ON
call ExtOFF ; disable extensions
popa
ret
FAST_WRITE_BUFFER_ON ENDP
If you want to boost an SVGA mode banked, just type:
call MAP_A000h
call FAST_WRITE_BUFFER_ON
If you want to boost an SVGA mode FLAT linear, just type:
call FAST_WRITE_BUFFER_ON
* 320x200x256 50Hz and 60Hz Chained *
If you want 50Hz chained mode (why ???), as in the demo "Xtal" by Complex,
just type this code:
mov ax,13h
int 10h ; regular mode 13h chained
mov dx,3c2h ; misc output
mov al,0e3h ; clock
out dx,al
mov dx,3d4h
mov ax,07006h ; Vertical Total
out dx,ax
mov ax,03E07h ; Overflow
out dx,ax
mov ax,0F310h ; Vertical start retrace
out dx,ax
mov ax,08C11h ; Vertical end retrace
out dx,ax
mov ax,08F12h ; Vertical display enable end
out dx,ax
mov ax,0E715h ; Vertical blank start
out dx,ax
mov ax,00416h ; Vertical blank end
out dx,ax
It works on every VGA !!! Maybe some probs with VGA-2-RGB converters or
projectors... (like at The Party 5 !!! - note from MagicFred - :) )
The 320x200x256 60Hz version is normally more adapted for RGB projector :
mov ax,13h
int 10h ; regular mode 13h chained
mov dx,3c2h ; misc output
mov al,0e3h ; clock
out dx,al
mov dx,3d4h
mov ax,0B006h ; Vertical Total
out dx,ax
mov ax,03E07h ; Overflow
out dx,ax
mov ax,0C310h ; Vertical start retrace
out dx,ax
mov ax,08C11h ; Vertical end retrace
out dx,ax
mov ax,08F12h ; Vertical display enable end
out dx,ax
mov ax,0E715h ; Vertical blank start
out dx,ax
mov ax,00416h ; Vertical blank end
out dx,ax
* 320x256x256 60Hz *
Or the "Amiga PAL mode" ;-), like in "Ninja II" by Melon & Scoop, just type
this code:
mov ax,13h
int 10h ; regular mode 13h chained
mov dx,3c4h
mov ax,0604h
out dx,ax ; unchain
mov dx,3c2h ; misc output
mov al,0e3h ; clock
out dx,al
mov dx,3d4h
mov ax,0D006h ; Vertical Total
out dx,ax
mov ax,03E07h ; Overflow
out dx,ax
mov ax,0FF10h ; Vertical start retrace
out dx,ax
mov ax,0FF11h ; Vertical end retrace
out dx,ax
mov ax,0FF12h ; Vertical display enable end
out dx,ax
mov ax,00014h ; for mode X
out dx,ax
mov ax,0FF15h ; Vertical blank start
out dx,ax
mov ax,00616h ; Vertical blank end
out dx,ax
mov ax,0e317h ; for mode X
out dx,ax
This mode works like Mode-X and it works on every VGA !!! Normally, it will
pass on every RGB converter/projector ...
* 320x200x256 120Hz *
(16 Bits Mode on VGA)
The mode used by Tran in his famous demos "Ambiance" and "Luminati" :
mov ax,13h
int 10h ; regular mode 13h chained
mov dx,3c4h
mov ax,0604h
out dx,ax ; unchain
mov dx,3d4h
mov ax,00506h ; Vertical Total
out dx,ax
mov ax,01107h ; Overflow
out dx,ax
mov ax,0E710h ; Vertical start retrace
out dx,ax
mov ax,00011h ; Vertical end retrace
out dx,ax
mov ax,0C712h ; Vertical display enable end
out dx,ax
mov ax,00014h ; for mode X
out dx,ax
mov ax,0EF15h ; Vertical blank start
out dx,ax
mov ax,00816h ; Vertical blank end
out dx,ax
mov ax,0e317h ; for mode X
out dx,ax
It works in mode X in order to get 4 pages.
- You just have to flip between 2 screens, one containing the first 8 bits and
the other containing the other 8 bits of the RGB colors.
RRRRR GGGGGG BBBBB
to split in
RRRRRGGG GGGBBBBB
(pal and pic 1) and (pal and pic 2)
1st page 2nd page
- You can also flip between two traditionnal 256 colors screens to get some transparency !
The only problem with this mode is that it is totally incompatible with RGB
projectors used in demos parties. So, this kind of modes is to be used in
BBStros, or if you want to use it in a party, you have to do a regular version
for RGB projector (using true HiColor, or using fake 18 bits -like Orange, for
example-, ...).
It works on every VGA !!!!