Mail Archives: djgpp/1996/08/01/08:31:43
antoine AT stack DOT urc DOT tue DOT nl (Antoine van Wel) wrote:
>// Antoine
>----------------------- THE LISTING ! ----------------------
>// Based on Sandmann's "VBETEST.C"
>// Show Mode List : compile with DJGPP
>// Programmed by Antoine van Wel,
>// IRC: ProphecY, EMAIL: antoine AT stack DOT urc DOT tue DOT nl
>#include <pc.h>
>#include <dpmi.h>
>#include <go32.h>
>#include <dos.h>
>#include <crt0.h>
>#include <sys/farptr.h>
>#define BYTE unsigned char
>#define INT __dpmi_int
>#define REGS __dpmi_regs
>typedef struct {
> char Signature [4];
> short Version;
> unsigned OemStringPtr;
> BYTE Capabilities [4];
>// short VideoModePtrSeg;
>// short VideoModePtrOff;
> unsigned VideoModePtr;
> short TotalMemory;
> char bogus [236];
>} VBEInfoBlock;
>int main (void)
>{
> VBEInfoBlock VBEInfo;
> REGS reg;
> int i;
> short *p;
> reg.x.ax = 0x4f00;
> reg.x.es = __tb / 16;
> reg.x.di = 0;
> INT (0x10, ®);
> if (reg.x.ax != 0x004f) {
> printf ("Get VBE info failed.\n");
> exit (1);
> }
> dosmemget (__tb, sizeof(VBEInfoBlock), &VBEInfo);
> for (i=0; i<4; i++) printf("%c",VBEInfo.Signature[i]);
> printf("\n");
>// p = (short *)(16*VBEInfo.VideoModePtrSeg+VBEInfo.VideoModePtrOff);
> p = (short *)VBEInfo.VideoModePtr;
> do {
> printf("0x%x\n",*p);
> p++;
> } while (*p!=-1);
> return 0;
>}
Muhahah! You're correctly grabbing the struct from DOS memory, but
don't forget that those pointers point into DOS memory as well!
Use the PtrSeg and PtrOfs variation of the struct, and:
int p = 16*VBEInfo.VideoModePtrSeg+VBEInfo.VideoModePtrOff;
short int temp;
do {
dosmemget(p,2,&temp);
if(temp != -1) printf("0x%x\n",temp);
temp += 2;
} while (temp!=-1)
Untested, of course, purely from the top of my head... but I'm sure
you get the idea.
Regards,
ABW
--
I have become... Comfortably numb...
Alaric B. Williams Internet : alaric AT abwillms DOT demon DOT co DOT uk
<A HREF="http://www.hardcafe.co.uk/Alaric/">http://www.hardcafe.co.uk/Alaric/</A>
- Raw text -