home *** CD-ROM | disk | FTP | other *** search
-
- include grphdrvr.inc
-
- ;******************************************************************************}
- ; TEGL Windows ToolKit II }
- ; Copyright (C) 1990, TEGL Systems Corporation }
- ; All Rights Reserved. }
- ;******************************************************************************}
-
- .code
-
- vga512flag dw ?
- vga1024flag dw ?
- svgatype dw 0
-
- x_cirrus equ 1
- x_everex equ 2
- x_paradise equ 3
- x_tseng equ 4
- x_trident equ 5
- x_t8900 equ 6
- x_ativga equ 7
- x_aheada equ 8
- x_aheadb equ 9
- x_oaktech equ 10
- x_video7 equ 11
- x_chipstech equ 12
- x_tseng4 equ 13
- x_genoa equ 14
- x_ncr equ 15
- x_compaq equ 16
- x_vesa equ 17
-
-
- getsvgatype proc far vgatype:dword,memsize:dword
- public getsvgatype
-
- push es
- push di
- push ds
- push si
- push dx
- push cx
- push bx
-
- mov cs:vga512flag,0
- mov cs:vga1024flag,0
- mov cs:svgatype,-10
-
- call getvgatype
-
- lds si,vgatype ;get variable address
- mov ax,cs:svgatype
- mov ds:[si],ax
-
- lds si,memsize ;get variable address
-
- mov ax,1024
- test cs:vga1024flag,1
- jnz okmem
- mov ax,512
- test cs:vga512flag,1
- jnz okmem
- mov ax,256
- okmem: mov ds:[si],ax
-
- pop bx
- pop cx
- pop dx
- pop si
- pop ds
- pop di
- pop es
- ret
- getsvgatype endp
-
- ;----------------------------------------------------------------------------;
- ; ;
- ;----------------------------------------------------------------------------;
- nojmp macro
- local lbl
- jmp lbl
- lbl:
- endm
-
-
- getvgatype proc near
- mov si,1
- mov ax,0c000h
- mov es,ax
- cmp word ptr es:[40h],'13' ;ATI Signiture on the Video BIOS
- jnz noati
-
- mov cs:svgatype,x_ativga
- cli
- mov dx,1ceh
- mov al,0bbh
- out dx,al
- inc dl
- in al,dx
- sti
- and al,20h
- jz no512
- mov cs:vga512flag,1
- no512: jmp fini
-
- noati: mov ax,7000h ;Test for Everex
- xor bx,bx
- cld
- int 10h
- cmp al,70h
- jnz noev
-
- mov cs:svgatype,x_everex
- and ch,11000000b ;how much memory on board
- jz skp
- mov cs:vga512flag,1
- skp: ;fall through for Everex boards using Trident or Tseng4000
-
- noev: mov ax,0bf03h ;Test for Compaq
- xor bx,bx
- mov cx,bx
- int 10h
- cmp ax,0bf03h
- jnz nocp
- test cl,40h ;is 640x480x256 available?
- jz nocp
- mov cs:svgatype,x_compaq
- mov cs:vga512flag,1
- jmp fini
-
- nocp: mov dx,3c4h ;Test for NCR 77C22E
- mov ax,0ff05h
- call _isport2
- jnz noncr
- mov ax,5 ;Disable extended registers
- out dx,ax
- mov ax,0ff10h ;Try to write to extended register 10
- call _isport2 ;If it writes then not NCR
- jz noncr
- mov ax,105h ;Enable extended registers
- out dx,ax
- mov ax,0ff10h
- call _isport2
- jnz noncr ;If it does NOT write then not NCR
- mov cs:svgatype,x_ncr
- mov cs:vga512flag,1
- jmp fini
-
- noncr: mov dx,3c4h ;Test for Trident
- mov al,0bh
- out dx,al
- inc dl
- in al,dx
- cmp al,06h
- ja notri
- cmp al,2
- jb notri
- mov cs:svgatype,x_trident
- cmp al,3
- jb no89
- mov cs:svgatype,x_t8900
- mov dx,3d5h
- mov al,1fh
- out dx,al
- inc dx
- in al,dx
- and al,3
- cmp al,1
- jb notmem
- mov cs:vga512flag,1
- je notmem
- mov cs:vga1024flag,1
- notmem: jmp fini
-
- no89: mov cs:vga512flag,1
- jmp fini
-
- notri: mov ax,6f00h ;Test for Video 7
- xor bx,bx
- cld
- int 10h
- cmp bx,'V7'
- jnz nov7
- mov cs:svgatype,x_video7
- mov ax,6f07h
- cld
- int 10h
- and ah,7fh
- cmp ah,1
- jbe skp2
- mov cs:vga512flag,1
- skp2: cmp ah,3
- jbe skp3
- mov cs:vga1024flag,1
- skp3: jmp fini
-
- nov7: mov dx,3d4h ;Test for GENOA GVGA
- mov ax,032eh ;check for Herchi Register
- call _isport2
- jnz nogn
- mov dx,3c4h ;check for memory segment register
- mov ax,3f06h
- call _isport2
- jnz nogn
- mov cs:svgatype,x_genoa
- mov cs:vga512flag,1
- jmp fini
-
- nogn: call _cirrus ;Test for Cirrus
- cmp cs:svgatype,x_cirrus
- jne noci
- jmp fini
-
- noci: mov dx,3ceh ;Test for Paradise
- mov al,9 ;check Bank switch register
- out dx,al
- inc dx
- in al,dx
- dec dx
- or al,al
- jnz nopd
-
- mov ax,50fh ;turn off write protect on VGA registers
- out dx,ax
- mov cx,1
- mov dx,3ceh ;Test for Paradise
- call _chkbk
- jc nopd ;if bank 0 and 1 same not paradise
- mov cs:svgatype,x_paradise
- mov dx,3ceh
- mov al,0bh ;512k detect from Bob Berry
- out dx,al
- inc dx
- in al,dx
- test al,80h ;if top bit set then 512k
- jz nop512
- mov cs:vga512flag,1
- nop512: jmp fini
-
- nopd: mov ax,5f00h ;Test for Chips & Tech
- xor bx,bx
- cld
- int 10h
- cmp al,5fh
- jnz noct
- mov cs:svgatype,x_chipstech
- cmp bh,1
- jb skp4
- mov cs:vga512flag,1
- skp4: jmp fini
-
- noct: mov ch,0
- mov dx,3d4h ;check for Tseng 4000 series
- mov ax,0f33h
- call _isport2
- jnz not4
- mov ch,1
-
- mov dx,3bfh ;Enable access to extended registers
- mov al,3
- out dx,al
- mov dx,3d8h
- mov al,0a0h
- out dx,al
- jmp short yes4
-
- not4: mov dx,3d4h ;Test for Tseng 3000 or 4000
- mov ax,1f25h ;is the Overflow High register there?
- call _isport2
- jnz nots
- mov al,03fh ;bottom six bits only
- jmp short yes3
- yes4: mov al,0ffh
- yes3: mov dx,3cdh ;test bank switch register
- call _isport1
- jnz nots
- mov cs:svgatype,x_tseng
- cmp ch,0
- jnz t4mem
- mov cs:vga512flag,1
- jmp fini
-
- t4mem: mov dx,3d4h ;Tseng 4000 memory detect 1meg
- mov al,37h
- out dx,al
- inc dx
- in al,dx
- test al,1000b ;if using 64kx4 RAMs then no more than 256k
- jz nomem
- and al,3
- cmp al,1 ;if 8 bit wide bus then only two 256kx4 RAMs
- jbe nomem
- mov cs:vga512flag,1
- cmp al,2 ;if 16 bit wide bus then four 256kx4 RAMs
- je nomem
- mov cs:vga1024flag,1 ;full meg with eight 256kx4 RAMs
- nomem: mov cs:svgatype,x_tseng4
- jmp fini
-
- nots:
- mov dx,3ceh ;Test for Above A or B chipsets
- mov ax,200fh
- out dx,ax
- inc dx
- nojmp
- in al,dx
- cmp al,21h
- jz verb
- cmp al,20h
- jnz noab
- mov cs:svgatype,x_aheada
- mov cs:vga512flag,1
- jmp short fini
-
- verb: mov cs:svgatype,x_aheadb
- mov cs:vga512flag,1
- jmp short fini
-
- noab: mov dx,3deh ;Test for Oak Technology
- mov ax,0ff11h ;look for bank switch register
- call _isport2
- jz oakok
-
- push es
- push di
- push cx
-
- cld
- mov ax,0c000h
- mov es,ax
- xor di,di
- mov cx,256
-
- mov al,'O'
- findoak: repne scasb
- jcxz notoak
-
- cmp byte ptr es:[di],'A'
- jne findoak
-
- cmp byte ptr es:[di+1],'K'
- jne findoak
-
- pop cx
- pop di
- pop es
- jmp short oakok
-
-
- notoak: pop cx
- pop di
- pop es
- jmp short nooak
-
- oakok: mov cs:svgatype,x_oaktech
- mov al,0dh
- out dx,al
- inc dx
- nojmp
- in al,dx
- test al,80h
- jz no4ram
- mov cs:vga512flag,1
- no4ram: jmp short fini
-
- nooak: mov si,0
-
- fini: mov ax,si
- ret
- getvgatype endp
-
-
- _cirrus proc near
- mov dx,3d4h ; assume 3dx addressing
- mov al,0ch ; screen a start address hi
- out dx,al ; select index
- inc dx ; point to data
- mov ah,al ; save index in ah
- in al,dx ; get screen a start address hi
- xchg ah,al ; swap index and data
- push ax ; save old value
- push dx ; save crtc address
- xor al,al ; clear crc
- out dx,al ; and out to the crtc
-
- mov al,1fh ; Eagle ID register
- dec dx ; back to index
- out dx,al ; select index
- inc dx ; point to data
- in al,dx ; read the id register
- mov bh,al ; and save it in bh
-
- mov cl,4 ; nibble swap rotate count
- mov dx,3c4h ; sequencer/extensions
- mov bl,6 ; extensions enable register
-
- ror bh,cl ; compute extensions disable value
- mov ax,bx ; extensions disable
- out dx,ax ; disable extensions
- inc dx ; point to data
- in al,dx ; read enable flag
- or al,al ; disabled ?
- jnz exit ; nope, not an cirrus
-
- ror bh,cl ; compute extensions enable value
- dec dx ; point to index
- mov ax,bx ; extensions enable
- out dx,ax ; enable extensions
- inc dx ; point to data
- in al,dx ; read enable flag
- cmp al,1 ; enabled ?
- jne exit ; nope, not an cirrus
- mov cs:svgatype,x_cirrus
-
- exit: pop dx ; restore crtc address
- dec dx ; point to index
- pop ax ; recover crc index and data
- out dx,ax ; restore crc value
- ret
- _cirrus endp
-
- _chkbk proc near ;bank switch check routine
- push es
- mov di,0b800h
- mov es,di
- xor di,di
- mov bx,1234h
- call _gochk
- jnz badchk
- mov bx,4321h
- call _gochk
- jnz badchk
- clc
- pop es
- ret
- badchk: stc
- pop es
- ret
- _chkbk endp
-
- _gochk proc near
- push si
- push es
- mov si,bx
-
- mov al,cl
- call _pdrsub
- xchg bl,es:[di]
- mov al,ch
- call _pdrsub
- xchg bh,es:[di]
-
- xchg si,bx
-
- mov al,cl
- call _pdrsub
- xor bl,es:[di]
- mov al,ch
- call _pdrsub
- xor bh,es:[di]
-
- xchg si,bx
-
- mov al,ch
- call _pdrsub
- mov es:[di],bh
- mov al,cl
- call _pdrsub
- mov es:[di],bl
-
- mov al,0
- call _pdrsub
- or si,si
- pop es
- pop si
- ret
- _gochk endp
-
-
- _pdrsub proc near ;Paradise
- mov ah,al
- mov al,9
- out dx,ax
- ret
- _pdrsub endp
-
-
- _isport2 proc near
- push bx
- mov bx,ax
- out dx,al
- mov ah,al
- inc dx
- in al,dx
- dec dx
- xchg al,ah
- push ax
- mov ax,bx
- out dx,ax
- out dx,al
- mov ah,al
- inc dx
- in al,dx
- dec dx
- and al,bh
- cmp al,bh
- jnz noport2
- mov al,ah
- mov ah,0
- out dx,ax
- out dx,al
- mov ah,al
- inc dx
- in al,dx
- dec dx
- and al,bh
- cmp al,0
- noport2: pop ax
- out dx,ax
- pop bx
- ret
- _isport2 endp
-
- _isport1 proc near
- mov ah,al
- in al,dx
- push ax
- mov al,ah
- out dx,al
- in al,dx
- and al,ah
- cmp al,ah
- jnz noport1
- mov al,0
- out dx,al
- in al,dx
- and al,ah
- cmp al,0
- noport1: pop ax
- out dx,al
- ret
- _isport1 endp
-
- end