### Detecting video adapter types (CGA/MDA/EGA/VGA) ###
       
       
       This article has been copied from the PC MAGAZINE issued September 26, 1989 (also referenced as "volume 8, number 16"). The article appears on page 383 of the magazine.
       
       -----------------------------------------------------------
       
       DETECTING VIDEO ADAPTER TYPES
       
       Occasionally a program needs to be able to detect what type of display it's running on. What is the best way to figure out what kind of video adapter is installed in a system? I have heard a rumor that Microsoft once used the IBM signature in EGA ROM to identify an EGA. Is this still a valid method? If so, what should a program look for to identify a VGA?
        -- Ned Phillips, Gainesville, Florida
       
       PC Magazine:
       
       It is true that Microsoft Windows once identified an EGA by the IBM signature in ROM, but that was back in the early days of EGA, when IBM was the sole manufacturer of EGA boards. It also happens to be true that most third-party EGA makers followed IBM's lead and included the letters "IBM" in the same ROM location, for compatibility reasons. But this is a poor argument for using such an unreliable method to detect the presence of an EGA. In addition, you would still have to find another means of detecting a VGA, since there most certainly isn't a ROM signature of any type in the same location on every VGA board on the market.
       
       The best way for your program to determine what video adapter is in a given system is to begin by having the program make the assumption that the highest-level adapter exists in the system. You then work your way down a decision tree until you reach an assumption that cannot be disproved. To check for any VGA, EGA, CGA, or MDA, your program simply needs to follow this three-step sequence:
        * Check for the presence of a VGA by calling interrupt 10h with AH set to 1Ah and AL set to 0. If, on return, AL is set to 1Ah, then the system is equipped with a VGA. If is not, proceed to the following step.
        * Check for the presence of an EGA by executing an interrupt 10h with AH set to 12h and BL set to 10h.  If BL is still equal to 10h on return, then assume there is no EGA and proceed to the next step. Otherwise, an EGA is installed.
        * Assume that either a CGA or MDA is installed and determine which of the two it is by inspecting the word value at address 0040:0063, which holds the base address of the CRT controller. If this value is 3Bxh, then the adapter is monochrome (an MDA). If it is 3Dxh, then a CGA is installed.
       
       One configuration detail every program should watch for is the possibility that an EGA is installed but isn't the currently active display device. An EGA connected to a color monitor can share the same bus with an MDA, and an EGA driving a monochrome monitor will coreside with a CGA. The user can switch back and forth between monitors with the DOS MODE command. To tell wheter the EGA is the active display adapter once its presence is confirmed, check bit 3 of the EGA information byte in the BIOS data area at 0040:0087. If bit 3 is set, the EGA is not active; if bit 3 is clear, then the EGA is the active adapter. When the EGA isn't active, a program can tell whether the active adapter is a CGA or an MDA by checking the base address of the CRT controller as described above in the third step.
       
       Another important point to remember is that both the EGA and the VGA can operate in monochrome or color. If your program accesses the video buffer directly, you'll need to know what mode the display adapter is running in to determine where the video buffer lies. Again, the easiest way to tell is by checking the CRT controller address in the BIOS data area.
       -- Jeff Prosise
       
       === Attachments ==========================================
       
 (BIN) original article scan.png