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"
short VbeVersion; // == 0x0300 for VBE 3.0
uint16_t VbeVersion; // == 0x0300 for VBE 3.0
short OemStringPtr[2]; // isa vbeFarPtr
uint16_t OemStringPtr[2]; // isa vbeFarPtr
unsigned char Capabilities[4];
uint8_t Capabilities[4];
short VideoModePtr[2]; // isa vbeFarPtr
uint16_t VideoModePtr[2]; // isa vbeFarPtr
short TotalMemory; // as # of 64KB blocks
uint16_t TotalMemory; // as # of 64KB blocks
};
};


Line 25: Line 25:
<source lang="c">
<source lang="c">
struct ModeInfoBlock {
struct ModeInfoBlock {
word attributes;
uint16_t attributes;
byte winA,winB;
uint8_t winA,winB;
word granularity;
uint16_t granularity;
word winsize;
uint16_t winsize;
word segmentA, segmentB;
uint16_t segmentA, segmentB;
VBE_FAR(realFctPtr);
VBE_FAR(realFctPtr);
word pitch; // bytes per scanline
uint16_t pitch; // bytes per scanline


word Xres, Yres;
uint16_t Xres, Yres;
byte Wchar, Ychar, planes, bpp, banks;
uint8_t Wchar, Ychar, planes, bpp, banks;
byte memory_model, bank_size, image_pages;
uint8_t memory_model, bank_size, image_pages;
byte reserved0;
uint8_t reserved0;


byte red_mask, red_position;
uint8_t red_mask, red_position;
byte green_mask, green_position;
uint8_t green_mask, green_position;
byte blue_mask, blue_position;
uint8_t blue_mask, blue_position;
byte rsv_mask, rsv_position;
uint8_t rsv_mask, rsv_position;
byte directcolor_attributes;
uint8_t directcolor_attributes;


dword physbase; // your LFB (Linear Framebuffer) address ;)
uint32_t physbase; // your LFB (Linear Framebuffer) address ;)
dword reserved1;
uint32_t reserved1;
short reserved2;
uint16_t reserved2;
};
};
</source>
</source>
Line 63: Line 63:


<source lang="c">
<source lang="c">
UInt16 findMode(int x, int y, int d)
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 *modes;
uint16_t *modes;
int i;
int i;
UInt16 best = 0x13;
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 ( (UInt16)v86.tss.eax != 0x004F ) return best;
if ( (uint16_t)v86.tss.eax != 0x004F ) return best;


modes = (UInt16*)REALPTR(ctrl->VideoModePtr);
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 ( (UInt16)v86.tss.eax != 0x004F ) continue;
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