On Mon, 16 Jul 2018 05:51:09 -0500, David McMackins wrote:
> I'm doing some graphics programming, and I want to support many
> different graphics modes, but I need a way of checking to see if they
> are available. Currently I'm working on VGA. How do I check if it's
> available without just trying to enter graphics mode?

The PC MAGAZINE issued Sep 26, 1989, has a very nice article by Jeff 
Prosise about that. Page 383.

Below's a reprint for you.

Mateusz


========================================================================
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.
========================================================================



-- 
FreeDOS is present on the USENET, too! alt.os.free-dos


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to