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

  1. /****************************************************************************
  2. *
  3. *                           SuperVGA Test Library
  4. *
  5. *                   Copyright (C) 1993 Kendall Bennett.
  6. *                            All rights reserved.
  7. *
  8. * Filename:        $RCSfile: common.c $
  9. * Version:        $Revision: 1.1 $
  10. *
  11. * Language:        ANSI C
  12. * Environment:    IBM PC (MSDOS)
  13. *
  14. * Description:    Module containing code common to all the SuperVGA test
  15. *                programs.
  16. *
  17. * $Id: common.c 1.1 1993/03/07 04:07:47 kjb Exp $
  18. *
  19. * Revision History:
  20. * -----------------
  21. *
  22. * $Log: common.c $
  23. * Revision 1.1  1993/03/07  04:07:47  kjb
  24. * Initial revision
  25. *
  26. ****************************************************************************/
  27.  
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #include <ctype.h>
  31. #include <string.h>
  32. #include "drivers.h"
  33. #include "getopt.h"
  34.  
  35. /*---------------------------- Global Variables ---------------------------*/
  36.  
  37. extern int _ignoreSVGA,_VESAFirst,driver,chipID,memory,dac;
  38. char    *version = "3.1";
  39.  
  40. int queryCpu(void);
  41.  
  42. /*----------------------------- Implementation ----------------------------*/
  43.  
  44. void help(void)
  45. /****************************************************************************
  46. *
  47. * Function:        help
  48. *
  49. * Description:    Provide command line usage information.
  50. *
  51. ****************************************************************************/
  52. {
  53.     printf("Options are:\n");
  54.     printf("    -v       - Check for VESA BIOS first\n");
  55.     printf("    -s<name> - Force detection of SuperVGA 'name'\n");
  56.     printf("    -c<x>    - Force detection of SuperVGA chipset (numerical id)\n");
  57.     printf("    -m<size> - Force memory size to 'size'\n");
  58.     printf("    -d<x>    - Force DAC type (0 normal, 1 HiColor, 3 TrueColor)\n");
  59.     printf("    -i       - Do not perform SuperVGA detection\n");
  60.     printf("\n");
  61.     printf("It is possible the SuperVGA detection code will hang the machine on old\n");
  62.     printf("VGA/SVGA cards. You can optionally force the program to work with any\n");
  63.     printf("combination of card, chipset, memory size and DAC, but unless you specify\n");
  64.     printf("the -i option, unspecified values will be filled in automatically for you.\n");
  65.     exit(1);
  66. }
  67.  
  68. void parseArguments(int argc,char *argv[])
  69. /****************************************************************************
  70. *
  71. * Function:        parseArguments
  72. * Parameters:    argc    - Number of command line arguments
  73. *                argv    - Array of command line arguments
  74. *
  75. * Description:    Parses the command line and forces detection of specific
  76. *                SuperVGA's if specified.
  77. *
  78. ****************************************************************************/
  79. {
  80.     int        i,forceSVGA = -1,forceCHIP = -1,forceMEM = -1;
  81.     int        forceDAC = grDETECTDAC;
  82.     int        option;
  83.     char    *argument;
  84.  
  85.     if (queryCpu() < 4) {
  86.         printf("This program requires an 80386 or better processor to run.\n");
  87.         exit(1);
  88.         }
  89.  
  90.     /* Parse command line options */
  91.  
  92.     do {
  93.         option = getopt(argc,argv,"VvS:s:C:c:M:m:D:d:Iih",&argument);
  94.         if (isascii(option))
  95.             option = tolower(option);
  96.         switch(option) {
  97.             case 'v':
  98.                 _VESAFirst = true;
  99.                 break;
  100.             case 'i':
  101.                 _ignoreSVGA = true;
  102.                 break;
  103.             case 's':
  104.                 i = __FIRST_SVGA+1;
  105.                 while (1) {
  106.                     if (stricmp(MGL_driverName(i),argument) == 0) {
  107.                         forceSVGA = i;
  108.                         break;
  109.                         }
  110.                     if (++i > __LAST_SVGA) {
  111.                         printf("Unknown SuperVGA chip. Valid values are:\n\n");
  112.                         for (i = __FIRST_SVGA+1; i <= __LAST_SVGA; i++)
  113.                             printf("    %s\n", MGL_driverName(i));
  114.                         exit(1);
  115.                         }
  116.                     }
  117.                 break;
  118.             case 'c':
  119.                 forceCHIP = atoi(argument);
  120.                 break;
  121.             case 'm':
  122.                 forceMEM = atoi(argument);
  123.                 break;
  124.             case 'd':
  125.                 forceDAC = atoi(argument);
  126.                 break;
  127.             case 'h':
  128.             case INVALID:
  129.                 help();
  130.             }
  131.         } while (option != ALLDONE);
  132.  
  133.     driver = grDETECT;
  134.     dac = forceDAC;
  135.     MGL_detectGraph(&driver,&chipID,&memory,&dac,&i);
  136.     if (forceSVGA != -1) driver = forceSVGA;
  137.     if (forceCHIP != -1) chipID = forceCHIP;
  138.     if (forceMEM != -1) memory = forceMEM;
  139. }
  140.