home *** CD-ROM | disk | FTP | other *** search
-
- TITLE 'VideoID'
- NAME VideoID
- PAGE 55,132
-
- ; This routine to identify the PC's graphics card comes from:
- ; Programmers Guide to PC & PS/2 Video Systems.
- ; R. Wilton, Microsoft Press, Redmond, WA. 1987
-
- ARGpVID EQU word ptr [bp+4]
- ; If you want to use this in a large memory model, above line should be:
- ;ARGpVID EQU word ptr [bp+6]
-
- VIDstruct STRUC
- Video0Type DB ?
- Display0Type DB ?
- Video1Type DB ?
- Display1Type DB ?
-
- VIDstruct ENDS
-
- Device0 EQU word ptr Video0Type[di]
- Device1 EQU word ptr Video1Type[di]
-
- MDA EQU 1
- CGA EQU 2
- EGA EQU 3
- MCGA EQU 4
- VGA EQU 5
- HGC EQU 80h
- HGCPlus EQU 81h
- InColor EQU 82h
-
- MDADisplay EQU 1
- CGADisplay EQU 2
- EGAColorDisplay EQU 3
- PS2MonoDisplay EQU 4
- PS2ColorDisplay EQU 5
-
- True EQU 1
- False EQU 0
-
-
- DGROUP GROUP _DATA
- _text SEGMENT byte public 'CODE'
- ASSUME cs:_text,ds:DGROUP
-
- PUBLIC _VideoID
- _VideoID PROC near
-
- ;If you want to use this in a large memory model, above lines should be:
- ;vid_text SEGMENT byte public 'CODE'
- ; ASSUME cs:vid_text,ds:DGROUP
- ;_VideoID PROC far
-
- push bp
- mov bp,sp
- push si
- push di
-
- mov di,ARGpVID
-
- mov Device0,0
- mov Device1,0
-
- mov byte ptr CGAflag,TRUE
- mov byte ptr EGAflag,TRUE
- mov byte ptr Monoflag,TRUE
- mov cx, NumberOfTests
- mov si, offset DGROUP:TestSequence
-
- L01: lodsb
- test al,al
- lodsw
- jz L02
- push si
- push cx
- call ax
- pop cx
- pop si
-
- L02: loop L01
- call FindActive
- pop di
- pop si
- mov sp,bp
- pop bp
- ret
-
- _VideoID ENDP
-
- FindPS2 PROC near
-
- mov ax,1A00h
- int 10h
- cmp al,1Ah
- jne L13
-
- mov cx,bx
- xor bh,bh
- or ch,ch
- jz L11
-
- mov bl,ch
- add bx,bx
- mov ax,[bx+offset DGROUP:DCCtable]
-
- mov Device1,ax
-
- mov bl,cl
- xor bh,bh
-
- L11: add bx,bx
- mov ax,[bx+offset DGROUP:DCCtable]
-
- mov Device0,ax
-
- mov byte ptr CGAflag,FALSE
- mov byte ptr EGAflag,FALSE
- mov byte ptr Monoflag,FALSE
-
- lea bx,Video0Type[di]
- cmp byte ptr [bx],MDA
- je L12
-
-
- lea bx,Video1Type[di]
- cmp byte ptr [bx],MDA
- jne L13
-
- L12: mov word ptr [bx],0
- mov byte ptr Monoflag,TRUE
-
- L13: ret
-
- FindPS2 ENDP
-
- FindEGA PROC near
- mov bl,10h
- mov ah,12h
- int 10h
-
- cmp bl,10h
- je L22
- mov al,cl
- shr al,1
- mov bx,offset DGROUP:EGADisplays
- xlat
- mov ah,al
- mov al,EGA
- call FoundDevice
-
- cmp ah,MDADisplay
- je L21
- mov CGAflag,FALSE
- jmp short L22
-
- L21: mov Monoflag,FALSE
-
- L22: ret
- FindEGA ENDP
-
- FindCGA PROC near
- mov dx,3D4h
- call find6845
- jc L31
-
- mov al,CGA
- mov ah,CGADisplay
- call FoundDevice
-
- L31: ret
- FindCGA ENDP
-
-
- FindMono PROC near
-
- mov dx,3B4h
- call Find6845
- jc L44
-
- mov dl,0BAh
- in al,dx
- and al,80h
- mov ah,al
- mov cx,8000h
- L41: in al,dx
- and al,80h
- cmp ah,al
- loope L41
-
- jne L42
- mov al,MDA
- mov ah,MDADisplay
- call FoundDevice
- jmp short L44
-
- L42: in al,dx
- mov dl,al
- mov ah,MDADisplay
-
- mov al,HGC
- and dl,01110000b
- jz L43
-
- mov al,HGCPlus
- and dl,00010000b
- je L43
-
-
-
- mov al,InColor
- mov ah,EGAColorDisplay
-
- L43: call FoundDevice
- L44: ret
- FindMono ENDP
-
- Find6845 PROC near
- mov al,0Fh
- out dx,al
- inc dx
- in al,dx
- mov ah,al
- mov al,66h
- out dx,al
- mov cx,100h
-
- L51: loop L51
- in al,dx
- xchg ah,al
- out dx,al
- cmp ah,66h
- je L52
- stc
-
- L52: ret
- Find6845 ENDP
-
- FindActive PROC near
- cmp word ptr Device1,0
- je L63
- cmp Video0Type[di],4
- jge L63
- cmp Video1Type[di],4
- jge L63
-
- mov ah,0Fh
- int 10h
- and al,7
- cmp al,7
- je L61
-
- cmp Display0Type[di],MDADisplay
- jne L63
- jmp short L62
-
- L61: cmp Display0Type[di],MDADisplay
- je L63
-
- L62: mov ax,Device0
- xchg ax,Device1
- mov Device0,ax
-
- L63: ret
- FindActive ENDP
-
- FoundDevice PROC near
- lea bx,Video0Type[di]
- cmp byte ptr [bx],0
- je L71
- lea bx,Video1Type[di]
-
- L71: mov [bx],ax
- ret
-
- FoundDevice ENDP
-
- ;If you want to use this in a large memory model, next line should be:
- ;vid_text ENDS
- _text ENDS
-
- _DATA SEGMENT word public 'DATA'
-
- EGADisplays DB CGADisplay
- DB EGAColorDisplay
- DB MDADisplay
- DB CGADisplay
- DB EGAColorDisplay
- DB MDADisplay
-
- DCCtable DB 0,0
- DB MDA,MDADisplay
- DB CGA,CGADisplay
- DB 0,0
- DB EGA,EGAColorDisplay
- DB EGA,MDADisplay
- DB 0,0
- DB VGA,PS2MonoDisplay
- DB VGA,PS2ColorDisplay
- DB 0,0
- DB MCGA,EGAColorDisplay
- DB MCGA,PS2MonoDisplay
- DB MCGA,PS2ColorDisplay
-
- TestSequence DB ?
- DW FindPS2
-
- EGAflag DB ?
- DW FindEGA
-
- CGAflag DB ?
- DW FindCGA
-
- Monoflag DB ?
- DW FindMono
-
- NumberOfTests EQU ($-TestSequence) /3
-
- _DATA ENDS
-
- END
-
-
-
-
-