Detecting Colour and Monochrome Monitors: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content deleted Content added
m Update function to ISO and better coding convention |
m Bot: Replace deprecated source tag with syntaxhighlight |
||
(One intermediate revision by one other user not shown) | |||
Line 2: | Line 2: | ||
== The Function == |
== The Function == |
||
< |
<syntaxhighlight lang="c"> |
||
#include <stdint.h> |
#include <stdint.h> |
||
Line 22: | Line 22: | ||
return (enum video_type) (detect_bios_area_hardware() & 0x30); |
return (enum video_type) (detect_bios_area_hardware() & 0x30); |
||
} |
} |
||
</syntaxhighlight> |
|||
</source> |
|||
[[Category:Video]] |
[[Category:Video]] |
||
[[Category:Hardware Detection]] |
Latest revision as of 05:13, 9 June 2024
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
#include <stdint.h>
enum video_type
{
VIDEO_TYPE_NONE = 0x00,
VIDEO_TYPE_COLOUR = 0x20,
VIDEO_TYPE_MONOCHROME = 0x30,
};
uint16_t detect_bios_area_hardware(void)
{
const uint16_t* bda_detected_hardware_ptr = (const uint16_t*) 0x410;
return *bda_detected_hardware_ptr;
}
enum video_type get_bios_area_video_type(void)
{
return (enum video_type) (detect_bios_area_hardware() & 0x30);
}