Detecting Colour and Monochrome Monitors: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
m (Fixed syntax, formatted page.)
m (Standardised code to C99.)
Line 4: Line 4:
<pre>
<pre>
/*
/*
video card mono/colour detection by Dark Fiber
Video card mono/colour detection.
returns 0=mono, 1=colour
Return values: false=mono
true=colour
*/
*/
int detect_video_type(void)
_Bool detectVideoType(void)
{
{
int rc;
_Bool type;
char c=(*(volatile USHORT*)0x410)&0x30;
char c=(*(volatile USHORT*)0x410)&0x30;


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

Revision as of 01:20, 17 August 2007

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.
    Return values:  false=mono
                    true=colour
*/
_Bool detectVideoType(void)
{
    _Bool type;
    char c=(*(volatile USHORT*)0x410)&0x30;

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