OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Feb 20, 2018 7:46 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Code for detecting color and monochrome displays
PostPosted: Thu Oct 25, 2007 3:38 pm 
Offline
Member
Member

Joined: Thu Apr 12, 2007 8:15 am
Posts: 204
Location: Michigan
Just noticed this wiki entry while anticipating the next steps for my project:

http://www.osdev.org/wiki/Detecting_Colour_and_Monochrome_Monitors:
Code:
/*
    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.
    }
}


namely the lines:

Quote:
Return values: false=mono
true=colour

then,
Quote:
return(true); //Monochrome monitor.
} else {
return(false); //Colour monitor.


I assume the second block is correct, given the comment explaining the reasoning just before the if statement


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 25, 2007 6:09 pm 
Offline
Member
Member
User avatar

Joined: Thu Dec 21, 2006 3:03 am
Posts: 1029
Location: Hobart, Australia
The page has been fixed. It was an error I put in while correcting the syntax. Sorry for the inconvenience.

_________________
My Personal Blog | My Software Company - Loop Foundry | My Github Page


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 26, 2007 12:15 am 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7189
Location: Germany
Hm... while you were at it brushing up the syntax (and laudably removing a completely redundant local variable in the process), why didn't you do away with the if ( ... ) true; else false stuff altogether? :wink:

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 26, 2007 2:09 am 
Offline
Member
Member
User avatar

Joined: Thu Dec 21, 2006 3:03 am
Posts: 1029
Location: Hobart, Australia
Not clever enough. :P

_________________
My Personal Blog | My Software Company - Loop Foundry | My Github Page


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 26, 2007 10:35 am 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
Solar wrote:
Hm... while you were at it brushing up the syntax (and laudably removing a completely redundant local variable in the process), why didn't you do away with the if ( ... ) true; else false stuff altogether? :wink:


Code:
typedef 0 true;
typedef 1 false;


Who says the above code isn't being used? Noone in their right mind would, but it's possible ;)

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 26, 2007 11:59 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 27, 2007 3:21 pm
Posts: 553
Location: Best, Netherlands
false is allways zero in C/C++ as it is the standard but true is not defined.

_________________
Author of COBOS


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 26, 2007 12:19 pm 
Offline
Member
Member

Joined: Sun Sep 23, 2007 4:52 am
Posts: 360
Code:
_Bool detectVideoType(void) {
    return true; // color monitor
}


Who uses a monochrome monitor anyways?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 26, 2007 12:22 pm 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 9:29 pm
Posts: 2423
Location: Canada
Craze Frog wrote:
Who uses a monochrome monitor anyways?

I'm guilty of owning a few.. nothing wrong with supporting them..

Modern technology is so over rated :wink:

_________________
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
UNIX&BSD's, your only aspirations, to be imitated! 8)
Windows, are an opening in an otherwise solid and opaque surface through which light and, sometimes, even air can pass through; nothing more.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group