delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/05/19:04:19

From: dcn DOT bbs AT titan DOT cc DOT ntu DOT edu DOT tw (天才)
Newsgroups: comp.os.msdos.djgpp
Subject: Why doesn't my program run correctly?
Date: 05 Sep 1997 21:50:46 GMT
Organization: Computer Science BBS
Lines: 115
Message-ID: <3KQHUN$Qiz@titan.cc.ntu.edu.tw>
NNTP-Posting-Host: @titan.cc.ntu.edu.tw
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Why doesn't my program run correctly?
What's wrong ?
This is my source code.
#include <dpmi.h>

#include <go32.h>

#define MASK_LINEAR(addr)     (addr & 0x000FFFFF)

#define RM_TO_LINEAR(addr)    (((addr & 0xFFFF0000) >> 12) + (addr & 0xFFFF))

#define RM_OFFSET(addr)       (MASK_LINEAR(addr) & 0xFFFF)

#define RM_SEGMENT(addr)      ((MASK_LINEAR(addr) & 0xFFFF0000) >> 4)

typedef struct VESA_INFO         /* VESA information block structure */

{

   unsigned char  VESASignature[4]     __attribute__ ((packed));

   unsigned short VESAVersion          __attribute__ ((packed));

   unsigned char *OEMStringPtr         __attribute__ ((packed));

   unsigned char  Capabilities[4]      __attribute__ ((packed));

   unsigned long  VideoModePtr         __attribute__ ((packed));

   unsigned short TotalMemory          __attribute__ ((packed));

   unsigned short OemSoftwareRev       __attribute__ ((packed));

   unsigned char *OemVendorNamePtr     __attribute__ ((packed));

   unsigned char *OemProductNamePtr    __attribute__ ((packed));

   unsigned char *OemProductRevPtr     __attribute__ ((packed));

   unsigned char  Reserved[222]        __attribute__ ((packed));

   unsigned char  OemData[256]         __attribute__ ((packed));

} VESA_INFO;

static VESA_INFO vesa_info;            /* SVGA info block */

__dpmi_regs _dpmi_reg;                 /* for calling int 10 bank switch */

static int get_vesa_info()

{

   int c;



   for (c=0; c<sizeof(VESA_INFO); c++)

      _farpokeb(_dos_ds, MASK_LINEAR(__tb)+c, 0);



   dosmemput("VBE2", 4, MASK_LINEAR(__tb));



   _dpmi_reg.x.ax = 0x4F00;

   _dpmi_reg.x.di = RM_OFFSET(__tb);

   _dpmi_reg.x.es = RM_SEGMENT(__tb);

   __dpmi_int(0x10, &_dpmi_reg);

   if (_dpmi_reg.h.ah)

      return -1;



   dosmemget(MASK_LINEAR(__tb), sizeof(VESA_INFO), &vesa_info);



   if (strncmp(vesa_info.VESASignature, "VESA", 4) != 0)

      return -1;



   return 0;

}



void main()

{

get_vesa_info();

puts(vesa_info.OEMStringPtr);

}






--
※ Origin: 程式設計樂園BBS(CS Zone) -- titan.cc.ntu.edu.tw
◆ From: h213.s197.ts.hin}4

- Raw text -


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