home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / fgl / fglight / exc.arj / TEMP / 05-16.C < prev    next >
Text File  |  1995-01-20  |  2KB  |  86 lines

  1. #include <fastgraf.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. void main(void);
  6.  
  7. void main()
  8. {
  9.    int mode, old_mode;
  10.    char string[5];
  11.  
  12. /* Ask for the video mode number */
  13.  
  14.    printf("Which video mode? ");
  15.    scanf("%d",&mode);
  16.  
  17. /* Make sure the entered value is valid */
  18.  
  19.    if (mode < 0 || mode > 29)
  20.    {
  21.       printf("%d is not a valid video mode number.\n",mode);
  22.       exit(1);
  23.    }
  24.  
  25. /* Make sure the requested video mode is available */
  26.  
  27.    fg_initpm();
  28.    if (mode > 23) fg_svgainit(0);
  29.    if (fg_testmode(mode,1) == 0)
  30.    {
  31.       printf("Mode %d is not available on this system.\n",mode);
  32.       exit(1);
  33.    }
  34.  
  35. /* Establish the video mode */
  36.  
  37.    old_mode = fg_getmode();
  38.    fg_setmode(mode);
  39.  
  40. /* Perform mode-specific initializations */
  41.  
  42.    if (mode <= 3 || mode == 7)   /* text modes */
  43.       fg_cursor(0);
  44.  
  45.    else if (mode == 4 || mode == 5)  /* CGA color modes */
  46.    {
  47.       fg_palette(0,0);
  48.       fg_defcolor(14,3);
  49.    }
  50.  
  51.    else if (mode == 6)           /* CGA two-color mode */
  52.    {
  53.       fg_palette(0,14);
  54.       fg_defcolor(14,1);
  55.    }
  56.  
  57.    else if (mode == 11)          /* Hercules mode */
  58.       fg_defcolor(14,1);
  59.  
  60.    else if (mode == 12)          /* Hercules low-res mode */
  61.       fg_defcolor(14,3);
  62.  
  63.    else if (mode == 17)          /* VGA two-color mode */
  64.    {
  65.       fg_palette(1,14);
  66.       fg_setrgb(14,63,63,21);
  67.       fg_defcolor(14,1);
  68.    }
  69.  
  70. /* Display a message that includes the video mode number */
  71.  
  72.    fg_setcolor(14);
  73.    fg_text("I'm running in mode ",20);
  74.    sprintf(string,"%d. ",mode);
  75.    fg_text(string,3);
  76.  
  77. /* Wait for a keystroke */
  78.  
  79.    fg_waitkey();
  80.  
  81. /* Restore the original video mode and screen attributes */
  82.  
  83.    fg_setmode(old_mode);
  84.    fg_reset();
  85. }
  86.