Mail Archives: djgpp/1998/08/27/20:30:06
Ludvig Larsson wrote:
> I had the same problem.
>
> On my Matrox, mode 0x111 or 0x211 worked fine, but on another
> my graphic functions just wrote lot of scrambled stuff.
> My way around it(which surely won't work on all machines)
> was to use mode 0x4111(fifteen bit set).
Doesn't that make it a linear frame buffer?
> I would also apreciate a codesnippet that could set
> mode 640x480x16bit with 64-kb graphic windows on any machine
> but I'm to lazy to check the Allegro sourcecode etc.
Well, you asked for it. This should work for ALL video cards VESA 1.2 or
LATER! I've experimented, and it has worked on every card I've tried (ATI,
Cirrus Logic, Trident, ...)
struct VGAInfoBlock
{
char Sig[4] pack;
word Version pack;
lword OEM pack; //really it's a seg:offset for a string
char Capabilities[4] pack;
short *VideoModes pack;
word VRAM pack;
char Reserved[236] pack;
};
struct ModeInfoBlock
{
word Supported:1,
ReservedforPrevious:1,
OutPut:1,
ColorMode:1,
Graphics:1,
ReservedforIdontknow:11;
byte WinAAtt pack,
WinBAtt pack;
word WinGranularity pack,
WinSize pack,
WinASeg pack,
WinBSeg pack;
lword WinFunc pack;
word BytesPerScanLine pack,
XRes pack,
YRes pack;
byte XCharSize pack,
YCharSize pack,
NumOfPlanes pack,
BitsPerPixel pack,
NumOfBanks pack,
MemModel pack,
BankSize pack,
NumOfImagePages pack,
Reserved pack,
RedMaskSize pack,
RedFieldPosition pack,
GreenMaskSize pack,
GreenFieldPosition pack,
BlueMaskSize pack,
BlueFieldPosition pack,
ReservedMaskSize pack,
DirectColorModeInfo pack,
Rsvd[216] pack;
};
short GetInfoBlock(VGAInfoBlock &Fred)
{
__dpmi_regs regs;
regs.x.ax = 0x4F00;
regs.x.di = __tb & 0x0f;
regs.x.es = (__tb >> 4) & 0xffff;
__dpmi_int(0x10, ®s);
dosmemget(__tb, sizeof(VGAInfoBlock), &Fred);
lword a = (lword)Fred.VideoModes;
a = ((a>>12)&0xFFFF0)+(a&0xFFFF);//+__djgpp_conventional_base;
Fred.VideoModes = (short*)a;
short* V = new short[100];
dosmemget((unsigned long int)Fred.VideoModes, 100, V);
Fred.VideoModes = V;
return (Fred.Sig[0]=='V' && Fred.Sig[1]=='E' && Fred.Sig[2]=='S' &&
Fred.Sig[3]=='A');
}
void GetModeBlock(short Mode, ModeInfoBlock &Fred)
{
__dpmi_regs regs;
regs.x.ax = 0x4F01;
regs.x.di = __tb & 0x0f;
regs.x.es = (__tb >> 4) & 0xffff;
regs.x.cx = Mode;
__dpmi_int(0x10, ®s);
dosmemget(__tb, sizeof(ModeInfoBlock), &Fred);
}
void Vid640x480x16bit()
{
VGAInfoBlock VGA;
ModeInfoBlock Mode;
GetInfoBlock(VGA);
int VidMode;
for(;*VGA.VideoModes != -1; VGA.VideoModes++)
{
GetModeBlock(*VGA.VideoModes, Mode);
if (Mode.BitsPerPixel==16
&& Mode.XRes == 640 && Mode.YRes == 480)
VidMode = *VGA.VideoModes;
}
__dpmi_regs Regs;
Regs.x.ax = 0x4F02;
Regs.x.bx = VidMode;
__dpmi_int(0x10, &Regs);
}
--
(\/) Endlisnis (\/)
s257m AT unb DOT ca
Endlisnis AT GeoCities DOT com
Endlis AT nbnet DOT nb DOT ca
- Raw text -