VESA Video Modes: Difference between revisions

m
Bot: Replace deprecated source tag with syntaxhighlight
[unchecked revision][unchecked revision]
m (→‎VESA Functions: VbeInfoBlock struct fixed)
m (Bot: Replace deprecated source tag with syntaxhighlight)
 
Line 9:
;INT 0x10, AX=0x4F00
: Get Controller Info. This is the one that returns the array of all supported video modes.
<sourcesyntaxhighlight lang="c">
struct VbeInfoBlock {
char VbeSignature[4]; // == "VESA"
Line 23:
v86_bios(0x10, {ax:0x4f00, es:SEG(vib), di:OFF(vib)}, &out);
if (out.ax!=0x004f) die("Something wrong with VBE get info");
</syntaxhighlight>
</source>
 
In assembly(nasm):
<sourcesyntaxhighlight lang="asm">
struc VesaInfoBlock ; VesaInfoBlock_size = 512 bytes
.Signature resb 4 ; must be 'VESA'
Line 73:
times 508 db 0
iend
</syntaxhighlight>
</source>
 
'''INT 0x10, AX=0x4F01, CX=mode, ES:DI=256 byte buffer'''
: Get Mode Info. Call this for each member of the mode array to find out the details of that mode. The 256 byte buffer will be filled by the mode info block.
 
<sourcesyntaxhighlight lang="c">
struct vbe_mode_info_structure {
uint16_t attributes; // deprecated, only bit 7 should be of interest to you, and it indicates the mode supports a linear frame buffer.
Line 116:
uint8_t reserved1[206];
} __attribute__ ((packed));
</syntaxhighlight>
</source>
 
In assembly(nasm):
<sourcesyntaxhighlight lang="asm">
struc VesaModeInfoBlock ; VesaModeInfoBlock_size = 256 bytes
.ModeAttributes resw 1
Line 196:
times VesaModeInfoBlock_size db 0
iend
</syntaxhighlight>
</source>
 
'''INT 0x10, AX=0x4F02, BX=mode, ES:DI=CRTCInfoBlock'''
Line 213:
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.
 
<sourcesyntaxhighlight lang="c">
uint16_t findMode(int x, int y, int d)
{
Line 257:
return best;
}
</syntaxhighlight>
</source>
 
== Common Mistakes ==