Detecting Colour and Monochrome Monitors

From OSDev.wiki
Revision as of 01:04, 17 August 2007 by osdev>Yayyak (Fixed syntax, formatted page.)
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 ANSI C) to retrieve this:

The Function

/* 
    video card mono/colour detection by Dark Fiber
    returns 0=mono, 1=colour
*/
int detect_video_type(void)
{
    int rc;
    char c=(*(volatile USHORT*)0x410)&0x30;

    //c can be 0x00 or 0x20 for colour, 0x30 for mono.
    if(c==0x30){
        rc=0;	//Monochrome monitor.
    } else {
        rc=1;	//Colour monitor.
    }
    
    return rc;
}