Mail Archives: djgpp/1996/06/10/09:39:03
Xref: | news2.mv.net comp.os.msdos.djgpp:4804
|
From: | fwk AT pacific DOT net DOT sg (Foo Wan Kin)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Help on SVGA 640X480X256
|
Date: | Mon, 10 Jun 1996 10:33:23 GMT
|
Organization: | Pacific Internet, Singapore
|
Lines: | 117
|
Message-ID: | <4ph17q$cqo@raffles.technet.sg>
|
NNTP-Posting-Host: | max85ppp39.pacific.net.sg
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Hi all,
I have encountered some problems when I try to experiment with
VESA video mode 0x101 (640 X 480 X 256 colours). I tried to map the
linear video memory and fill all the 640 X 480 bytes with a single
color. However, it seems there are some 'holes' on the screen that are
not filled. I have used the grx 2.0 graphics library to do the same
thing but the problem does not show up.
Can anyone help me on this? Below is the codes.
TIA,
Wan Kin
-- begin codes --
#include <stdio.h>
#include <stdlib.h>
#include <dpmi.h>
#include <go32.h>
#include <dos.h>
#define FnGetVBEModeInfo 0x4F01
#define FnSetVBEMode 0x4F02
#define MODE80X25TEXT 0x0003
#define MODE640X480X256 0x101
#define LINEAR_FRAME_BUFFER 0x80
#define LINEAR_BIT_ENABLE 0x4000
// VBE Mode Information Block Structure
typedef struct VBEModeInfoBlock
{
short ModeAttributes __attribute__ ((packed));
char WinAAttributes __attribute__ ((packed));
char WinBAttributes __attribute__ ((packed));
short WinGranularity __attribute__ ((packed));
short WinSize __attribute__ ((packed));
short WinASegment __attribute__ ((packed));
short WinBSegment __attribute__ ((packed));
int WinFuncPtr __attribute__ ((packed));
short BytesPerScanLine __attribute__ ((packed));
short XResolution __attribute__ ((packed));
short YResolution __attribute__ ((packed));
char XCharSize __attribute__ ((packed));
char YCharSize __attribute__ ((packed));
char NumberOfPlanes __attribute__ ((packed));
char BitsPerPixel __attribute__ ((packed));
char NumberOfBanks __attribute__ ((packed));
char MemoryModel __attribute__ ((packed));
char BankSize __attribute__ ((packed));
char NumberOfImagePages __attribute__ ((packed));
char PageReserved __attribute__ ((packed));
char Blank[9] __attribute__ ((packed));
int PhysBasePtr __attribute__ ((packed));
int OffScreenMemOffset __attribute__ ((packed));
short OffScreenMemSize __attribute__ ((packed));
char Reserved[206] __attribute__ ((packed));
} VBEModeInfo;
int main()
{
VBEModeInfo modeinfo;
__dpmi_regs r;
__dpmi_meminfo meminfo;
int video_address,video_ds,pixel;
// Get mode 0x101 info
r.x.ax = FnGetVBEModeInfo;
r.x.cx = MODE640X480X256;
r.x.es = __tb / 16;
r.x.di = 0;
__dpmi_int(0x10, &r);
if (!r.h.ah)
{
dosmemget(__tb,sizeof(VBEModeInfo),&modeinfo);
if (modeinfo.ModeAttributes&LINEAR_FRAME_BUFFER)
{
meminfo.size = modeinfo.XResolution*modeinfo.YResolution;
meminfo.address = modeinfo.PhysBasePtr;
if (__dpmi_physical_address_mapping(&meminfo) != -1)
{
// Set video to mode 0x101
video_address = meminfo.address;
r.x.ax = FnSetVBEMode;
r.x.bx = MODE640X480X256|LINEAR_BIT_ENABLE;
__dpmi_int(0x10,&r);
if ( r.h.al == 0x4F && !r.h.ah)
{
//Assign a selector to video memory
video_ds = __dpmi_allocate_ldt_descriptors(1);
__dpmi_set_segment_base_address(video_ds,video_address);
video_address = 0;
__dpmi_set_segment_limit(video_ds,
(modeinfo.XResolution*modeinfo.YResolution)|0xFFF);
for (pixel=0;pixel<modeinfo.XResolution*modeinfo.YResolution;
pixel++)
_farpokeb(video_ds,pixel,7);
getch();
r.x.ax = MODE80X25TEXT;
__dpmi_int(0x10,&r);
}
}
}
}
}
-- end codes --
- Raw text -