VESA Video Modes: Difference between revisions

Consistent use of struct names (Names according to the vbe spec.)
[unchecked revision][unchecked revision]
(Added LFB to mode number)
(Consistent use of struct names (Names according to the vbe spec.))
Line 6:
: Get Controller Info. This is the one that returns the array of all supported video modes.
<source lang="c">
struct vbeControllerInfoVbeInfoBlock {
char signature[4]; // == "VESA"
short version; // == 0x0300 for VBE 3.0
Line 15:
};
 
vbeInfoBlockVbeInfoBlock *vib = dos_alloc(512);
v86_bios(0x10, {ax:0x4f00, es:SEG(vib), di:OFF(vib)}, &out);
if (out.ax!=0x004f) die("Something wrong with VBE get info");
Line 24:
 
<source lang="c">
struct vbeModeInfoModeInfoBlock {
word attributes;
byte winA,winB;
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
 
Here's a sample code, assuming you have a VirtualMonitor already ... Basically, you will scan the 'modes list' referenced by the vbeInfoBlockVbeInfoBlock.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">
UInt16 findMode(int x, int y, int d)
{
struct vbeControllerInfoVbeInfoBlock *ctrl = (ControllerInfoVbeInfoBlock *)0x2000;
struct vbeModeInfoModeInfoBlock *inf = (ModeInfoModeInfoBlock *)0x3000;
UInt16 *modes;
int i;
1,490

edits