From: trapforcannedmeatproduct AT hotmail DOT com (R. Charles Henry) Newsgroups: comp.os.msdos.djgpp Subject: Trying to use VESA under Windows XP Date: 25 Oct 2002 08:06:45 -0700 Organization: http://groups.google.com/ Lines: 468 Message-ID: <8ed56b42.0210250706.4d2222c6@posting.google.com> NNTP-Posting-Host: 194.164.77.251 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1035558405 6944 127.0.0.1 (25 Oct 2002 15:06:45 GMT) X-Complaints-To: groups-abuse AT google DOT com NNTP-Posting-Date: 25 Oct 2002 15:06:45 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Having a bit of trouble trying to use VESA under Windows XP. I've compiled the code below which is mainly taken from: "Guide: VESA graphics modes" http://www.delorie.com/djgpp/doc/ug/graphics/vesa.html using DJGPP v2.03 The executable produced runs fine on Win 95 (not tried 98), showing a uniform field of random pixels across the whole display. On XP, however, the display becomes garbled, the pixel fields split into several bands at 640 x 480, higher modes do nothing. (Monitor flashes up an 'invalid signal' warning at 1024 x 768). Does anyone have any tips? I don't have a lot of experience with C or DJGPP and am a little puzzled. I appreciate any help that might be forthcoming. Here's my code, which I was using to try and figure things out.. /* assembled from "Guide: VESA graphics modes" at: */ /* http://www.delorie.com/djgpp/doc/ug/graphics/vesa.html */ #include #include #include #include #include #include #include #include #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 #define NUM_COLORS 256 int i; int x; int y; int color; /* make sure that a VESA driver is present, and retrieve a copy of the VESA information structure */ typedef struct VESA_INFO { unsigned char VESASignature[4] __attribute__ ((packed)); unsigned short VESAVersion __attribute__ ((packed)); unsigned long 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 long OemVendorNamePtr __attribute__ ((packed)); unsigned long OemProductNamePtr __attribute__ ((packed)); unsigned long OemProductRevPtr __attribute__ ((packed)); unsigned char Reserved[222] __attribute__ ((packed)); unsigned char OemData[256] __attribute__ ((packed)); } VESA_INFO; /* call VESA function 0x4F00 to fill it with information about the current driver. */ /*Because VESA was designed as a real mode API for use by 16 bit programs, */ /*this data must be transferred via a buffer in conventional memory with the */ /*dosmemput() and dosmemget() functions: see the DPMI chapter for details of this. */ /*The function below will copy the VESA driver information into a global VESA_INFO */ /*structure, returning zero on success or -1 if anything goes wrong (ie. no driver is available). */ VESA_INFO vesa_info; int get_vesa_info() { __dpmi_regs r; long dosbuf; int c; /* use the conventional memory transfer buffer */ dosbuf = __tb & 0xFFFFF; /* initialize the buffer to zero */ for (c=0; c>4) & 0xFFFF; __dpmi_int(0x10, &r); /* quit if there was an error */ if (r.h.ah) return -1; /* copy the resulting data into our structure */ dosmemget(dosbuf, sizeof(VESA_INFO), &vesa_info); /* check that we got the right magic marker value */ if (strncmp(vesa_info.VESASignature, "VESA", 4) != 0) return -1; /* it worked! */ return 0; } /*Information about a particular mode can be obtained in a similar way to the main VESA information block, but using function 0x4F01 with a different structure, eg: */ typedef struct MODE_INFO { unsigned short ModeAttributes __attribute__ ((packed)); unsigned char WinAAttributes __attribute__ ((packed)); unsigned char WinBAttributes __attribute__ ((packed)); unsigned short WinGranularity __attribute__ ((packed)); unsigned short WinSize __attribute__ ((packed)); unsigned short WinASegment __attribute__ ((packed)); unsigned short WinBSegment __attribute__ ((packed)); unsigned long WinFuncPtr __attribute__ ((packed)); unsigned short BytesPerScanLine __attribute__ ((packed)); unsigned short XResolution __attribute__ ((packed)); unsigned short YResolution __attribute__ ((packed)); unsigned char XCharSize __attribute__ ((packed)); unsigned char YCharSize __attribute__ ((packed)); unsigned char NumberOfPlanes __attribute__ ((packed)); unsigned char BitsPerPixel __attribute__ ((packed)); unsigned char NumberOfBanks __attribute__ ((packed)); unsigned char MemoryModel __attribute__ ((packed)); unsigned char BankSize __attribute__ ((packed)); unsigned char NumberOfImagePages __attribute__ ((packed)); unsigned char Reserved_page __attribute__ ((packed)); unsigned char RedMaskSize __attribute__ ((packed)); unsigned char RedMaskPos __attribute__ ((packed)); unsigned char GreenMaskSize __attribute__ ((packed)); unsigned char GreenMaskPos __attribute__ ((packed)); unsigned char BlueMaskSize __attribute__ ((packed)); unsigned char BlueMaskPos __attribute__ ((packed)); unsigned char ReservedMaskSize __attribute__ ((packed)); unsigned char ReservedMaskPos __attribute__ ((packed)); unsigned char DirectColorModeInfo __attribute__ ((packed)); unsigned long PhysBasePtr __attribute__ ((packed)); unsigned long OffScreenMemOffset __attribute__ ((packed)); unsigned short OffScreenMemSize __attribute__ ((packed)); unsigned char Reserved[206] __attribute__ ((packed)); } MODE_INFO; MODE_INFO mode_info; int get_mode_info(int mode) { __dpmi_regs r; long dosbuf; int c; /* use the conventional memory transfer buffer */ dosbuf = __tb & 0xFFFFF; /* initialize the buffer to zero */ for (c=0; c>4) & 0xFFFF; r.x.cx = mode; __dpmi_int(0x10, &r); /* quit if there was an error */ if (r.h.ah) return -1; /* copy the resulting data into our structure */ dosmemget(dosbuf, sizeof(MODE_INFO), &mode_info); /* it worked! */ return 0; } /* information can easily be obtained from the main VESA information block. This contains a list of all the possible modes that are supported by the driver, so you can write a little routine that will loop through all these modes, retrieving information about each one in turn until it finds the one that you are looking for. For example: */ int find_vesa_mode(int w, int h) { int mode_list[256]; int number_of_modes; long mode_ptr; int c; /* check that the VESA driver exists, and get information about it */ if (get_vesa_info() != 0) return 0; /* convert the mode list pointer from seg:offset to a linear address */ mode_ptr = ((vesa_info.VideoModePtr & 0xFFFF0000) >> 12) + (vesa_info.VideoModePtr & 0xFFFF); number_of_modes = 0; /* read the list of available modes */ while (_farpeekw(_dos_ds, mode_ptr) != 0xFFFF) { mode_list[number_of_modes] = _farpeekw(_dos_ds, mode_ptr); number_of_modes++; mode_ptr += 2; } /* scan through the list of modes looking for the one that we want */ for (c=0; c