VESA / int86 functions in mingw (cross-dev)

277 views Asked by At

Before anyone tells me that in86 and VESA is a dos thing and it will not work on modern system. I know, I'm working on a game that works both on old and new systems. My game works on windows 9x with SDL1, but it's very slow (166Mhz, 640x480@256 colors and only 25 frames in a simple tile drawing "engine") so I thought of using the VESA modes directly. I know how to use them, but my question is... Is it possible to get a int86 and int86x in mingw, so I can compile my game on my linux machine and get a .exe that will work on windows9x. My code works if I use old MS compiler, but I have to use Windows in virtual machine to do that. I'd like to get that in mingw.

Here's an example. I cut it somehow, but you should get the idea.

union REGS r;
struct SREGS s;

char* VbeInfo = malloc(512);

VbeInfo[0] = 'V';
VbeInfo[1] = 'B';
VbeInfo[2] = 'E';
VbeInfo[3] = '2';

r.x.ax = 0x4F00;
r.x.di = FP_OFF(VbeInfo);
s.es = FP_SEG(VbeInfo);
int86x(0x10,&r,&r,&s);

if (r.x.ax != 0x004F)
{
    // vbe_get_info_error
}
if (*(u16*)(VbeInfo+4) < 0x200)
{
    // vbe version too low, has to be 2.0+
}

u32 video_mode_table = *(u32*)(VbeInfo+14);

char* videoInfo = malloc(256);

while (1)
{
    u16 video_mode_number = *(u16*)(video_mode_table);
    if (video_mode_number == 0xFFFF)
    {
        break;
    }
    video_mode_table +=2;

    r.x.ax = 0x4F01;
    r.x.cx = video_mode_number;
    r.x.di = FP_OFF(videoInfo);
    s.es = FP_SEG(videoInfo);
    int86x(0x10, &r, &r, &s);

    /*
    ..
    check for resolution, bit depth and
    if this mode can do linear frame buffer
    if yes, get a pointer to the framebuffer and quit
    ...
    */
}
0

There are 0 answers