⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vidtype.asm

📁 80386单片机
💻 ASM
字号:
comment *

        Author:
        Yousuf J. Khan

        Purpose:
        To detect what type of video adapter is installed.

        Note:
        Work was based on source code inside Richard Wilton's
        "Programmer's Guide to PC & PS/2 Video Systems" book. However
        it's been heavily reworked to a more (dare I say?)
        understandable format. Also Super VGA tests were put in,
        something completely missing from Wilton's book.

        *

.model tiny

;.stack 200h

.data
std0type        db      0       ;first video subsystem type
ext0type        db      0       ;extended info on first subsystem
std1type        db      0       ;second video subsystem type
ext1type        db      0       ;extended info on second subsystem
vidflag         record  monofound:1,colorfound:1
egatype         vidflag <0,0>   ;Was a mono or color EGA found?
;
;video adapter codes (based on codes returned by VGA BIOS DC codes):
;-these codes are used when a VGA BIOS is not found and other tests
; need to be performed to determine video type
;-it was decided to use the VGA BIOS DC codes for simplicity
;-see findVGA procedure for list of VGA DCCs.
;
NoDISP  equ     0       ;no display
MONO    equ     1
CGA     equ     2
cEGA    equ     4       ;color EGA
mEGA    equ     5       ;mono EGA

.code
        org     100h            ;*.COM start offset
start:
        call    findVGA         ;look for a VGA or MCGA
        comment \

        After executing VGA BIOS routines, the VGA BIOS itself will have
        done all the work of determining what is installed so no need to
        do any further tests. The "findVGA" subprocedure will set the CF
        upon returning, if a VGA BIOS was found.

                \
        jc      endtests        ;found VGA/MCGA, end of tests
        call    findEGA         ;look for an EGA
        call    findCGA         ;look for a CGA
        call    findMono        ;look for an MDA or HGC
endtests:
        call    write_msg       ;write found info to screen, set
                                ; errorlevel
        mov     ah, 4ch         ;end program
        int     21h

findVGA         proc
comment *

        Purpose:
        determine if a MCGA/VGA/SVGA display is installed

        Entry:
        nothing

        Return:
        CF set if found, clear if not

        *
        mov     ax, 1A00h       ;get Displ Combo Code info
        int     10h
        cmp     al, 1Ah         ;VGA-only BIOS function
        jne     noVGA           ; not supported => no VGA
comment \

        Upon Return from Int 10h, AX=1A00h:
        BL=primary adapter DCC
        BH=secondary adapter DCC

        Values for display combination code:
        00h no display
        01h monochrome adapter w/ monochrome display
        02h CGA w/ color display
        03h reserved
        04h EGA w/ color display
        05h EGA w/ monochrome display
        06h PGA w/ color display
        07h VGA w/ monochrome analog display
        08h VGA w/ color analog display
        09h reserved
        0Ah MCGA w/ digital color display
        0Bh MCGA w/ monochrome analog display
        0Ch MCGA w/ color analog display
        FFh unknown display type

        \
        push    bx              ;interpretDCC destroys contents of BH
        call    interpretDCC    ;this proc looks for extended info
        mov     [std0type], bl  ;save normal info
        mov     [ext0type], bh  ;save extended info
        pop     bx
        push    bx
        ;Since proc interpretDCC only works on info in BL, we must
        ; exchange BL with BH.
        xchg    bh, bl          
        call    interpretDCC
        mov     [std1type], bl  ;save normal info
        mov     [ext1type], bh  ;save extended info
        pop     bx
        stc             ;found VGA/MCGA, so set CF before ret
        jmp     endVGAtest
noVGA:
        clc
endVGAtest:
        ret

        interpretDCC    proc
        comment *

                Purpose:
                Interprets information returned by the DCC

                Upon Entry:
                BL=normal DCC of desired video subsystem
                BH=will be destroyed, replaced with ext code

                Upon Return:
                BL=normal DCC returned (MDA,CGA,EGA,PGA,MCGA,VGA,etc)
                BH=extended code (HGC,SVGA), 0 if none

                *
                mov     bh, 0   ;Assume no extended attribs
                cmp     bl, 0   ;If 0, then no display card
                je      end_interpret
                cmp     bl, 1   ;Mono
                je      monotests
                jmp     CGAtests
        monotests:
        ;
        ;If we find a monochrome adapter, then we need to do special
        ; further tests to see if we have just an MDA or one of the
        ; Hercules cards.
        ;
                mov     bh, bl          ;save normal DCC in BH
                call    findHGC         ;MDA or HGC? value returned in
                                        ; BL
                xchg    bh, bl          ;BL=normal,BH=extended
                jmp     end_interpret
        CGAtests:
                cmp     bl, 2           ;CGA
                je      end_interpret
                cmp     bl, 6           ;EGA or PGA
                jbe     end_interpret
                cmp     bl, 8           ;BL=7,8: VGA
                ja      end_interpret
        ;
        ;If we find a VGA, then we need to do extra tests to see whose
        ; VGA chipset it is.
        ;
                mov     bh, bl          ;save BL in BH
                call    findSVGA        ;search for SVGA adapter
                xchg    bh, bl          ;BH=extended, BL=normal
        end_interpret:
                ret
                endp
        endp

findSVGA        proc
comment *

        Purpose:
        To search for specific SVGA types, including VESA compatibility.

        Entry:
        Nothing

        Return:
        BL=SVGA type

        *
comment \

        List of SVGA types:
        Brand           Type
        -----           ----
        ATI             1目
        Ahead           2 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -