测试代码很多人应该都很熟悉的。
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <conio.h>
// SuperVGA CRTCInfoBlock structure
struct
{
short HTotal;
short HSyncStart;
short HSyncEnd;
short VTotal;
short VSyncStart;
short VSyncEnd;
char Flags;
long PixelClock;
short RefreshRate;
char Reserved[40];
} CRTCInfoBlock;
/* Set a VBE video mode */
void setVBEMode()
{
char far *CRTCInfo = (char far *)&CRTCInfoBlock;
union REGS in,out;
struct SREGS segs;
in.x.ax = 0x4F02;
//in.x.bx = mode;
in.x.bx = 0x905;
// 1024*768 @ 60Hz
CRTCInfoBlock.HTotal=1328;
CRTCInfoBlock.HSyncStart=1048;
CRTCInfoBlock.HSyncEnd=1184;
CRTCInfoBlock.VTotal=806;
CRTCInfoBlock.VSyncStart=771;
CRTCInfoBlock.VSyncEnd=777;
CRTCInfoBlock.Flags=0xa;
CRTCInfoBlock.PixelClock=96333120;
CRTCInfoBlock.RefreshRate=6000;
/*// 1024*768 @ 70Hz
CRTCInfoBlock.HTotal=1328;
CRTCInfoBlock.HSyncStart=1048;
CRTCInfoBlock.HSyncEnd=1184;
CRTCInfoBlock.VTotal=806;
CRTCInfoBlock.VSyncStart=771;
CRTCInfoBlock.VSyncEnd=777;
CRTCInfoBlock.Flags=0x8;
CRTCInfoBlock.PixelClock=75000000;
CRTCInfoBlock.RefreshRate=7007;
*/
/*
// 1024*768 @ 75Hz
CRTCInfoBlock.HTotal=1312;
CRTCInfoBlock.HSyncStart=1040;
CRTCInfoBlock.HSyncEnd=1136;
CRTCInfoBlock.VTotal=800;
CRTCInfoBlock.VSyncStart=769;
CRTCInfoBlock.VSyncEnd=772;
CRTCInfoBlock.Flags=0xa;
CRTCInfoBlock.PixelClock=78750000;
CRTCInfoBlock.RefreshRate=75.03;
*/
in.x.di = FP_OFF(CRTCInfo);
segs.es = FP_SEG(CRTCInfo);
int86x(0x10, &in, &out, &segs);
//int86(0x10,&in,&out);
printf("%x : %d", out.h.al, out.h.ah);
}
/* Initialize the specified video mode. Notice how we determine a shift
* factor for adjusting the Window granularity for bank switching. This
* is much faster than doing it with a multiply (especially with direct
* banking enabled).
*/
void main()
{
setVBEMode();
getch();
_AX = 0x4f02;
_BX = 0x13;
geninterrupt(0x10);
}