Detecting Colour and Monochrome Monitors

From OSDev.wiki
Revision as of 19:53, 23 November 2010 by Graham (talk | contribs) (removed unused variable from the code snippet)
Jump to navigation Jump to search

Detecting whether a user has a colour or monochrome video card is a trivial task. The BIOS data segment has a value in it for this information. Below is a function (in ISO C) to retrieve this:

The Function

/* 
    Video card mono/colour detection.
    Return values:  false=colour
                    true=monochrome
*/
_Bool detectVideoType(void)
{
    char c=(*(volatile USHORT*)0x410)&0x30;

    //c can be 0x00 or 0x20 for colour, 0x30 for mono.
    return (c==0x30);
}