home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pctech / 1988_02 / vgares.c < prev    next >
Text File  |  1987-12-16  |  2KB  |  87 lines

  1. /*******************************************************************
  2.  *
  3.  * Name:      vgares.c
  4.  *
  5.  * Function:  select vertical resolution in VGA alphanumeric modes
  6.  *
  7.  * Syntax:    VGARES [vertical resolution]
  8.  *
  9.  * Notes:     Specified vertical resolution must be 200, 350, or 400
  10.  *             scan lines.  If no resolution is specified, the
  11.  *             program displays the current vertical resolution.
  12.  *
  13.  ******************************************************************/
  14.  
  15. #include <dos.h>
  16.  
  17. main( argc, argv )
  18. int     argc;
  19. char    **argv;
  20. {
  21.     struct WORDREGS    regs;            /* used by int86() */
  22.     unsigned char far  *FLAGS = (unsigned char far *)0x00400089;
  23.     int                ScanLines;
  24.  
  25.     /* set vertical resolution if specified in command line */
  26.  
  27.     if( argc == 2 )
  28.     {
  29.       sscanf( argv[1], "%d", &ScanLines );
  30.  
  31.      /* validate scan lines arg & set up for INT 10H func 12H */
  32.  
  33.       switch( ScanLines )
  34.       {
  35.         case 200:
  36.           regs.ax = 0x1200;
  37.           break;
  38.  
  39.         case 350:
  40.           regs.ax = 0x1201;
  41.           break;
  42.  
  43.         case 400:
  44.           regs.ax = 0x1202;
  45.           break;
  46.  
  47.         default:
  48.           printf( "\nError: Scan lines value should be");
  49.           printf( " 200, 350, or 400\n" );
  50.           exit( 1 );
  51.       }                           /* end of switch */
  52.  
  53.       /* bl = 30h, Select scan lines */
  54.       regs.bx = 0x30;
  55.       int86( 0x10, ®s, ®s );
  56.  
  57.       /* set scan lines by setting video mode to current value */
  58.       regs.ax = 0x0F00;           /* Get Video Mode */
  59.       int86( 0x10, ®s, ®s );
  60.  
  61.       regs.ax &= 0x00FF;          /* Set it to same mode (in AL) */
  62.       int86( 0x10, ®s, ®s );
  63.     }                             /* endif argc == 2 */
  64.  
  65.     /* show current vertical resolution */
  66.     /* test bits 4 and 7 of BIOS flags byte  @ addr 40:89 */
  67.     switch( *FLAGS & 0x90 )
  68.     {
  69.       case 0x00:
  70.         ScanLines = 350;
  71.         break;
  72.  
  73.       case 0x10:
  74.         ScanLines = 400;
  75.         break;
  76.  
  77.       case 0x80:
  78.         ScanLines = 200;
  79.         break;
  80.     }
  81.  
  82.     printf( "\nCurrent vertical resolution (scan lines) is %d\n",
  83.       ScanLines );
  84.  
  85.     exit( 0 );
  86. }
  87.