delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/20/09:00:48

From: prefs AT my-deja DOT com
Newsgroups: comp.os.msdos.djgpp
Subject: vesa
Date: Tue, 20 Jul 1999 12:20:47 GMT
Organization: Deja.com - Share what you know. Learn what you don't.
Lines: 122
Message-ID: <7n1pim$q4a$1@nnrp1.deja.com>
NNTP-Posting-Host: 192.138.110.220
X-Article-Creation-Date: Tue Jul 20 12:20:47 1999 GMT
X-Http-User-Agent: Mozilla/4.08 [en] (Win95; I)
X-Http-Proxy: 1.0 fridge1:81 (Squid/2.1.PATCH2), 1.0 x33.deja.com:80 (Squid/1.1.22) for client 131.97.232.156, 192.138.110.220
X-MyDeja-Info: XMYDJUIDprefs
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi.

I have a little problem with my vesa routines They compile as they
should but when I run them they can't get information about some modes.
But when I run them with the "|more" after, they work just as they
should. I can't really figure out
whats going on please help.

/*Beginning of code*/
typedef struct
{
/*You'll have to paste in the vesa info structure here because I removed
it before posting this message*/
}VBEInfo;

typedef struct
{
/*You'll have to paste in the vesa mode info structure here because I
removed it before posting this message*/
}VBEModeInfo;

int vesaDetect(VBEInfo *vesaInfo)
{
 __dpmi_regs regs;

 strncpy(vesaInfo->VESASignature, "VBE2", 4);

 regs.x.ax = 0x4F00;
 regs.x.di = __tb & 0x0F;
 regs.x.es = (__tb >> 4) & 0xFFFF;
 dosmemput(vesaInfo, sizeof(VBEInfo), __tb);
 __dpmi_int(0x10, &regs);

 if(regs.h.ah)
 {
  printf("Failed getting VESAInformation\n");
  return -1;
 }

 dosmemget(__tb, sizeof(VBEInfo), vesaInfo);

 if(strncmp(vesaInfo->VESASignature, "VESA", 4) != 0)
 {
  printf("Weird Vesa Signature\n");
  return -1;
 }

 return 0;
}

int vesaModeInfo(unsigned short mode, VBEModeInfo *modeInfo)
{
 __dpmi_regs regs;

 regs.x.ax = 0x4F01;
 regs.x.cx = mode;
 regs.x.di = __tb & 0x0F;
 regs.x.es = (__tb >> 4) & 0xFFFF;
 dosmemput(modeInfo, sizeof(VBEModeInfo), __tb);
 __dpmi_int(0x10, &regs);

 if(regs.h.ah)
 {
  printf("Failed getting VESAModeInformation\n");
  return -1;
 }

 dosmemget(__tb, sizeof(VBEModeInfo), modeInfo);

 return 0;
}

int countModes(unsigned short *mode, VBEInfo *vesaInfo)
{
 int modes;
 unsigned long modePtr;

 _farsetsel(_dos_ds);
 modes = 0;
 modePtr = ((vesaInfo->VideoModePtr & 0xFFFF0000) >> 12) +
(vesaInfo->VideoModePtr & 0xFFFF);
 mode[modes] = _farnspeekw(modePtr);
 while(mode[modes] != 0xFFFF)
 {
        modes++;
        modePtr += 2;
        mode[modes] = _farnspeekw(modePtr);
 }

 return modes;
}

int main()
{
 unsigned short mode[1024];
 int modes, i;
 VBEInfo vinfo;
 VBEModeInfo minfo;

 vesaDetect(&vinfo);

 modes = countModes(mode, &vinfo);

 printf("Available Modes:\t%d\n",modes);
 for(i=0;i<modes;i++)
 {
        vesaModeInfo(mode[i], &minfo);
        printf("Mode Number:\t0x%-3X [%5dx%-6d%2dbpp]\n",
mode[i],minfo.XResolution, minfo.YResolution, minfo.BitsPerPixel);
 }

}

/*End of code*/

please reply to: thomas DOT p AT vh DOT volvo DOT se

Thanks in advance Thomas


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019