VESA Video Modes: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
(Added LFB to mode number)
(Consistent use of struct names (Names according to the vbe spec.))
Line 6: Line 6:
: Get Controller Info. This is the one that returns the array of all supported video modes.
: Get Controller Info. This is the one that returns the array of all supported video modes.
<source lang="c">
<source lang="c">
struct vbeControllerInfo {
struct VbeInfoBlock {
char signature[4]; // == "VESA"
char signature[4]; // == "VESA"
short version; // == 0x0300 for VBE 3.0
short version; // == 0x0300 for VBE 3.0
Line 15: Line 15:
};
};


vbeInfoBlock *vib = dos_alloc(512);
VbeInfoBlock *vib = dos_alloc(512);
v86_bios(0x10, {ax:0x4f00, es:SEG(vib), di:OFF(vib)}, &out);
v86_bios(0x10, {ax:0x4f00, es:SEG(vib), di:OFF(vib)}, &out);
if (out.ax!=0x004f) die("Something wrong with VBE get info");
if (out.ax!=0x004f) die("Something wrong with VBE get info");
Line 24: Line 24:


<source lang="c">
<source lang="c">
struct vbeModeInfo {
struct ModeInfoBlock {
word attributes;
word attributes;
byte winA,winB;
byte winA,winB;
Line 60: Line 60:
VESA stopped assigning codes for video modes long ago -- instead they standardized a much better solution: you can query the video card for what modes it supports, and query it about the attributes of each mode. In your OS, you can have a function that you call with a desired width, height, and depth, and it returns the video mode number for it (or the closest match). Then, just set that mode
VESA stopped assigning codes for video modes long ago -- instead they standardized a much better solution: you can query the video card for what modes it supports, and query it about the attributes of each mode. In your OS, you can have a function that you call with a desired width, height, and depth, and it returns the video mode number for it (or the closest match). Then, just set that mode


Here's a sample code, assuming you have a VirtualMonitor already ... Basically, you will scan the 'modes list' referenced by the vbeInfoBlock.videomodes[] and then call 'get mode info' for each mode. You can then compare width, height and colordepth of each mode with the desired one.
Here's a sample code, assuming you have a VirtualMonitor already ... Basically, you will scan the 'modes list' referenced by the VbeInfoBlock.videomodes[] and then call 'get mode info' for each mode. You can then compare width, height and colordepth of each mode with the desired one.


<source lang="c">
<source lang="c">
UInt16 findMode(int x, int y, int d)
UInt16 findMode(int x, int y, int d)
{
{
struct vbeControllerInfo *ctrl = (ControllerInfo *)0x2000;
struct VbeInfoBlock *ctrl = (VbeInfoBlock *)0x2000;
struct vbeModeInfo *inf = (ModeInfo *)0x3000;
struct ModeInfoBlock *inf = (ModeInfoBlock *)0x3000;
UInt16 *modes;
UInt16 *modes;
int i;
int i;