VESA Video Modes: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content added Content deleted
m (→VESA Functions: 0x400 is bit 10, which is reserved. should be bit 14 (hence 0x4000) instead.) |
m (Convert to standard ISO data types) |
||
Line 8: | Line 8: | ||
struct VbeInfoBlock { |
struct VbeInfoBlock { |
||
char VbeSignature[4]; // == "VESA" |
char VbeSignature[4]; // == "VESA" |
||
uint16_t VbeVersion; // == 0x0300 for VBE 3.0 |
|||
uint16_t OemStringPtr[2]; // isa vbeFarPtr |
|||
uint8_t Capabilities[4]; |
|||
uint16_t VideoModePtr[2]; // isa vbeFarPtr |
|||
uint16_t TotalMemory; // as # of 64KB blocks |
|||
}; |
}; |
||
Line 25: | Line 25: | ||
<source lang="c"> |
<source lang="c"> |
||
struct ModeInfoBlock { |
struct ModeInfoBlock { |
||
uint16_t attributes; |
|||
uint8_t winA,winB; |
|||
uint16_t granularity; |
|||
uint16_t winsize; |
|||
uint16_t segmentA, segmentB; |
|||
VBE_FAR(realFctPtr); |
VBE_FAR(realFctPtr); |
||
uint16_t pitch; // bytes per scanline |
|||
uint16_t Xres, Yres; |
|||
uint8_t Wchar, Ychar, planes, bpp, banks; |
|||
uint8_t memory_model, bank_size, image_pages; |
|||
uint8_t reserved0; |
|||
uint8_t red_mask, red_position; |
|||
uint8_t green_mask, green_position; |
|||
uint8_t blue_mask, blue_position; |
|||
uint8_t rsv_mask, rsv_position; |
|||
uint8_t directcolor_attributes; |
|||
uint32_t physbase; // your LFB (Linear Framebuffer) address ;) |
|||
uint32_t reserved1; |
|||
uint16_t reserved2; |
|||
}; |
}; |
||
</source> |
</source> |
||
Line 63: | Line 63: | ||
<source lang="c"> |
<source lang="c"> |
||
uint16_t findMode(int x, int y, int d) |
|||
{ |
{ |
||
struct VbeInfoBlock *ctrl = (VbeInfoBlock *)0x2000; |
struct VbeInfoBlock *ctrl = (VbeInfoBlock *)0x2000; |
||
struct ModeInfoBlock *inf = (ModeInfoBlock *)0x3000; |
struct ModeInfoBlock *inf = (ModeInfoBlock *)0x3000; |
||
uint16_t *modes; |
|||
int i; |
int i; |
||
uint16_t best = 0x13; |
|||
int pixdiff, bestpixdiff = DIFF(320 * 200, x * y); |
int pixdiff, bestpixdiff = DIFF(320 * 200, x * y); |
||
int depthdiff, bestdepthdiff = 8 >= d ? 8 - d : (d - 8) * 2; |
int depthdiff, bestdepthdiff = 8 >= d ? 8 - d : (d - 8) * 2; |
||
Line 75: | Line 75: | ||
strncpy(ctrl->VbeSignature, "VBE2", 4); |
strncpy(ctrl->VbeSignature, "VBE2", 4); |
||
intV86(0x10, "ax,es:di", 0x4F00, 0, ctrl); // Get Controller Info |
intV86(0x10, "ax,es:di", 0x4F00, 0, ctrl); // Get Controller Info |
||
if ( ( |
if ( (uint16_t)v86.tss.eax != 0x004F ) return best; |
||
modes = ( |
modes = (uint16_t*)REALPTR(ctrl->VideoModePtr); |
||
for ( i = 0 ; modes[i] != 0xFFFF ; ++i ) { |
for ( i = 0 ; modes[i] != 0xFFFF ; ++i ) { |
||
intV86(0x10, "ax,cx,es:di", 0x4F01, modes[i], 0, inf); // Get Mode Info |
intV86(0x10, "ax,cx,es:di", 0x4F01, modes[i], 0, inf); // Get Mode Info |
||
if ( ( |
if ( (uint16_t)v86.tss.eax != 0x004F ) continue; |
||
// Check if this is a graphics mode with linear frame buffer support |
// Check if this is a graphics mode with linear frame buffer support |