Can someone please optimize my poor excuse for C code???
PHP Code:/* Set a VBE video mode */
int setVBEMode(int mode)
{
union REGS in,out;
in.x.ax = 0x4F02; in.x.bx = mode;
int86(0x10,&in,&out);
if (mode==0x12)
{ SCREENWIDTH=640;
SCREENHEIGHT=400;
SCREENCOLOR=4; /* for screen color, put the bit-depth */
}
else if (mode==0x13)
{ SCREENWIDTH=320;
SCREENHEIGHT=200;
SCREENCOLOR=8; /* for screen color, put the bit-depth */
}
else if (mode==0x100)
{ SCREENWIDTH=640;
SCREENHEIGHT=400;
SCREENCOLOR=8; /* for screen color, put the bit-depth */
}
else if(mode==0x101)
{ SCREENWIDTH=640;
SCREENHEIGHT=480;
SCREENCOLOR=8; /* for screen color, put the bit-depth */
}
else if(mode==0x102)
{ SCREENWIDTH=800;
SCREENHEIGHT=600;
SCREENCOLOR=4; /* for screen color, put the bit-depth */
}
else if(mode==0x103)
{ SCREENWIDTH=800;
SCREENHEIGHT=600;
SCREENCOLOR=8; /* for screen color, put the bit-depth */
}
else if(mode==0x104)
{ SCREENWIDTH=1024;
SCREENHEIGHT=768;
SCREENCOLOR=4; /* for screen color, put the bit-depth */
}
else if(mode==0x105)
{ SCREENWIDTH=1024;
SCREENHEIGHT=768;
SCREENCOLOR=8; /* for screen color, put the bit-depth */
}
else if(mode==0x106)
{ SCREENWIDTH=1280;
SCREENHEIGHT=1024;
SCREENCOLOR=4; /* for screen color, put the bit-depth */
}
else if(mode==0x107)
{ SCREENWIDTH=1280;
SCREENHEIGHT=1024;
SCREENCOLOR=8; /* for screen color, put the bit-depth */
}
else if(mode==0x108)
{ SCREENWIDTH=80;
SCREENHEIGHT=60;
SCREENCOLOR=1; /* TEXT */
}
else if(mode==0x109)
{ SCREENWIDTH=132;
SCREENHEIGHT=25;
SCREENCOLOR=1; /* TEXT */
}
else if(mode==0x10a)
{ SCREENWIDTH=132;
SCREENHEIGHT=43;
SCREENCOLOR=1; /* TEXT */
}
else if(mode==0x10b)
{ SCREENWIDTH=132;
SCREENHEIGHT=50;
SCREENCOLOR=1; /* TEXT */
}
else if(mode==0x10c)
{ SCREENWIDTH=132;
SCREENHEIGHT=60;
SCREENCOLOR=1; /* TEXT */
}
else if(mode==0x10d)
{ SCREENWIDTH=320;
SCREENHEIGHT=200;
SCREENCOLOR=16; /* for screen color, put the bit-depth */
}
else if(mode==0x10e)
{ SCREENWIDTH=320;
SCREENHEIGHT=200;
SCREENCOLOR=16; /* for screen color, put the bit-depth */
}
else if(mode==0x10f)
{ SCREENWIDTH=320;
SCREENHEIGHT=200;
SCREENCOLOR=24; /* for screen color, put the bit-depth */
}
else if(mode==0x110)
{ SCREENWIDTH=640;
SCREENHEIGHT=480;
SCREENCOLOR=16; /* for screen color, put the bit-depth */
}
else if(mode==0x111)
{ SCREENWIDTH=640;
SCREENHEIGHT=480;
SCREENCOLOR=16; /* for screen color, put the bit-depth */
}
else if(mode==0x112)
{ SCREENWIDTH=640;
SCREENHEIGHT=480;
SCREENCOLOR=24; /* for screen color, put the bit-depth */
}
else if(mode==0x113)
{ SCREENWIDTH=800;
SCREENHEIGHT=600;
SCREENCOLOR=16; /* for screen color, put the bit-depth */
}
else if(mode==0x114)
{ SCREENWIDTH=800;
SCREENHEIGHT=600;
SCREENCOLOR=16; /* for screen color, put the bit-depth */
}
else if(mode==0x115)
{ SCREENWIDTH=800;
SCREENHEIGHT=600;
SCREENCOLOR=24; /* for screen color, put the bit-depth */
}
else if(mode==0x116)
{ SCREENWIDTH=1024;
SCREENHEIGHT=768;
SCREENCOLOR=16; /* for screen color, put the bit-depth */
}
else if(mode==0x117)
{ SCREENWIDTH=1024;
SCREENHEIGHT=768;
SCREENCOLOR=16; /* for screen color, put the bit-depth */
}
else if(mode==0x118)
{ SCREENWIDTH=1024;
SCREENHEIGHT=768;
SCREENCOLOR=24; /* for screen color, put the bit-depth */
}
else if(mode==0x119)
{ SCREENWIDTH=1280;
SCREENHEIGHT=1024;
SCREENCOLOR=16; /* for screen color, put the bit-depth */
}
else if(mode==0x11a)
{ SCREENWIDTH=1280;
SCREENHEIGHT=1024;
SCREENCOLOR=16; /* for screen color, put the bit-depth */
}
else if(mode==0x11b)
{ SCREENWIDTH=1280;
SCREENHEIGHT=1024;
SCREENCOLOR=24; /* for screen color, put the bit-depth */
}
else
return 0; /* Not a VESA/VGA mode */
return 1; /* The mode was set correctly */
}




Reply With Quote