home *** CD-ROM | disk | FTP | other *** search
/ World of Graphics / WOGRAPH.BIN / 452.UVESA.C < prev    next >
C/C++ Source or Header  |  1993-03-07  |  4KB  |  154 lines

  1. /****************************************************************************
  2. *
  3. *                          The Universal VESA TSR
  4. *
  5. *                    Copyright (C) 1993 Kendall Bennett.
  6. *                            All rights reserved.
  7. *
  8. * Filename:        $RCSfile: uvesa.c $
  9. * Version:        $Revision: 1.1 $
  10. *
  11. * Language:        C++ 3.0
  12. * Environment:    any
  13. *
  14. * Description:    Main startup module for the Universal VESA TSR. Performs
  15. *                all of the command line processing, card detection and
  16. *                CPU detection.
  17. *
  18. *                MUST be compiled in the large memory model.
  19. *
  20. * $Id: uvesa.c 1.1 1993/03/07 04:08:09 kjb Exp $
  21. *
  22. * Revision History:
  23. * -----------------
  24. *
  25. * $Log: uvesa.c $
  26. * Revision 1.1  1993/03/07  04:08:09  kjb
  27. * Initial revision
  28. *
  29. ****************************************************************************/
  30.  
  31. #include <stdio.h>
  32. #include <stdlib.h>
  33. #include <dos.h>
  34. #include "drivers.h"
  35. #include "getopt.h"
  36.  
  37. /*---------------------------- Global Variables ---------------------------*/
  38.  
  39. int        driver,chipID,memory,dac;
  40. int        _grResult;
  41. int        _VESAFirst = false;
  42. int        _ignoreSVGA = false;
  43. extern     char *version;
  44.  
  45. /* Routine to parse command line arguments */
  46.  
  47. void parseArguments(int argc,char *argv[]);
  48.  
  49. /* Routines to manage the TSR side of things */
  50.  
  51. bool isLoaded(void);
  52. void goTSR(int driver,int chipID,int memory,int dac);
  53.  
  54. /*----------------------------- Implementation ----------------------------*/
  55.  
  56. typedef struct {
  57.     ushort    attributes;
  58.     uchar    winAAttr;
  59.     uchar    winBAttr;
  60.     ushort    winGran;
  61.     ushort    winSize;
  62.     ushort  startSegA;
  63.     ushort    startSegB;
  64.     ulong    bankSwitch;
  65.     ushort    bytesPerLine;
  66.  
  67.     /* Optional VESA Info */
  68.  
  69.     ushort    width;
  70.     ushort    height;
  71.     uchar    cwidth;
  72.     uchar    cheight;
  73.     uchar    planes;
  74.     uchar    bitsPerPixel;
  75.     uchar    banks;
  76.     uchar    memMode;
  77.     uchar    bankSize;
  78.     uchar    numPages;
  79.     } VesaBuf;
  80.  
  81. void testISR(void)
  82. /****************************************************************************
  83. *
  84. * Function:        testISR
  85. *
  86. * Description:    This routine will be called if testing is turned on
  87. *                during the compilation of the TSR. You can put whatever
  88. *                code you like into this routine, to test the VESA
  89. *                interface on your system.
  90. *
  91. ****************************************************************************/
  92. {
  93. #ifdef    TESTING
  94.     int                i,*modes;
  95.     struct REGPACK    regs;
  96.     VesaBuf            buf;
  97.  
  98.     printf("\n\nInsert your own testing routines in here!\n\n");
  99.     printf("List of available VESA modes:\n");
  100.     regs.r_ax = 0x4F00;
  101.     regs.r_di = (int)&buf;
  102.     regs.r_es = (long)&buf >> 16;
  103.     intr(0x10,®s);
  104.     modes = *((int**)(&(((char*)&buf)[14])));
  105.     while (*modes != -1)
  106.         printf("%X ",*modes++);
  107.     printf("\n\n");
  108.  
  109.     for (i = 0x100; i <= 0x11B; i++) {
  110.         regs.r_ax = 0x4F01;
  111.         regs.r_cx = i;
  112.         regs.r_di = (int)&buf;
  113.         regs.r_es = (long)&buf >> 16;
  114.         intr(0x10,®s);
  115.         if (regs.r_ax == 0x004F) {
  116.             if (buf.attributes & 2) {
  117.                 printf("Mode: %X, %dx%d, %d bytesPerLine, %d plane, %d bit, %d banks, %d page\n",
  118.                     i,buf.width,buf.height,buf.bytesPerLine,buf.planes,
  119.                     buf.bitsPerPixel,buf.banks,buf.numPages);
  120.                 }
  121.             else
  122.                 printf("No optional information\n");
  123.             }
  124.         }
  125. #endif
  126. }
  127.  
  128. void main(int argc,char *argv[])
  129. {
  130.     parseArguments(argc,argv);
  131.  
  132.     printf("UNIVESA - Universal SuperVGA VESA BIOS Extension Version 1.2\n");
  133.     printf("          Release %s\n\n",version);
  134.     printf("Copyright (C) 1993 Kendall Bennett\n\n");
  135.     if (isLoaded()) {
  136.         printf("Universal VESA TSR is already loaded - installation aborted.\n");
  137.         exit(1);
  138.         }
  139.     if (driver <= grSVGA) {
  140.         printf("SuperVGA not detected - installation aborted.\n");
  141.         exit(1);
  142.         }
  143.     printf("Installing for: %s",MGL_driverName(driver));
  144.     if (MGL_chipsetName(driver,chipID) != NULL)
  145.         printf(" (%s)", MGL_chipsetName(driver,chipID));
  146.     printf("\nDAC:            %s\n", MGL_dacName(dac));
  147.     if (memory < 1024)
  148.         printf("Memory:         %d Kb\n",memory);
  149.     else
  150.         printf("Memory:         %d Mb\n",memory / 1024);
  151.  
  152.     goTSR(driver,chipID,memory,dac);
  153. }
  154.