From: Nicolas Blais Newsgroups: comp.os.msdos.djgpp Subject: HELP!!: Can anyone optimize my code here? (vesa.cpp) Date: Sat, 28 Mar 1998 20:51:31 -0500 Organization: Elemental Technologies Lines: 225 Message-ID: <351DA923.7E2A8732@netrover.com> NNTP-Posting-Host: 198.168.87.18 Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------522A660E1EEFE22AFAF23509" To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk This is a multi-part message in MIME format. --------------522A660E1EEFE22AFAF23509 Content-Type: multipart/alternative; boundary="------------B9D95652519785CB5F740CEC" --------------B9D95652519785CB5F740CEC Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I need a pro who can optimize my code and send it back to me. This is a kind of a VESA sub-routine. My main problem with it is that to show text on the screen, I have to use 2 lines of codes for just one line of text. (Put_char) Also, how do I set the VESA mode to 640x480x16k? Thanks, Nicolas Blais --------------B9D95652519785CB5F740CEC Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit I need a pro who can optimize my code and send it back to me.  This is a kind of a VESA sub-routine.  My main problem with it is that to show text on the screen, I have to use 2 lines of codes for just one line of text.  (Put_char)
Also, how do I set the VESA mode to 640x480x16k?

Thanks, Nicolas Blais
 
  --------------B9D95652519785CB5F740CEC-- --------------522A660E1EEFE22AFAF23509 Content-Type: text/plain; charset=us-ascii; name="Vesa.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="Vesa.cpp" #include #include #include #include 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; VESA_INFO vesa_info; int get_vesa_info() { __dpmi_regs r; long dosbuf; int c; dosbuf = __tb & 0xFFFFF; for (c=0; c>4) & 0xFFFF; __dpmi_int(0x10, &r); if (r.h.ah) return -1; dosmemget(dosbuf, sizeof(VESA_INFO), &vesa_info); if (strncmp(vesa_info.VESASignature, "VESA", 4) != 0) return -1; return 0; } 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; dosbuf = __tb & 0xFFFFF; for (c=0; c>4) & 0xFFFF; r.x.cx = mode; __dpmi_int(0x10, &r); if (r.h.ah) return -1; dosmemget(dosbuf, sizeof(MODE_INFO), &mode_info); return 0; } int find_vesa_mode(int w, int h) { int mode_list[256]; int number_of_modes; long mode_ptr; int c; if (get_vesa_info() != 0) return 0; mode_ptr = ((vesa_info.VideoModePtr & 0xFFFF0000) >> 12) + (vesa_info.VideoModePtr & 0xFFFF); number_of_modes = 0; while (_farpeekw(_dos_ds, mode_ptr) != 0xFFFF) { mode_list[number_of_modes] = _farpeekw(_dos_ds, mode_ptr); number_of_modes++; mode_ptr += 2; } for (c=0; c