home *** CD-ROM | disk | FTP | other *** search
/ Graphics Programming Black Book (Special Edition) / BlackBook.bin / disk1 / source / chapter45 / l45-2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-18  |  1.3 KB  |  33 lines

  1. /* Mode set routine for VGA 640x400 16-color mode. 
  2.    Tested with Borland C++ 4.02 in small model by Jim Mischel 12/16/94
  3. */
  4. #include <dos.h>
  5.  
  6. void Set640x400()
  7. {
  8.    union REGS regset;
  9.  
  10.    /* First, set to standard 640x350 mode (mode 10h) */
  11.    regset.x.ax = 0x0010;
  12.    int86(0x10, ®set, ®set);
  13.  
  14.    /* Modify the sync polarity bits (bits 7 & 6) of the
  15.       Miscellaneous Output register (readable at 0x3CC, writable at
  16.       0x3C2) to select the 400-scan-line vertical scanning rate */
  17.    outp(0x3C2, ((inp(0x3CC) & 0x3F) | 0x40));
  18.  
  19.    /* Now, tweak the registers needed to convert the vertical
  20.       timings from 350 to 400 scan lines */
  21.    outpw(0x3D4, 0x9C10);   /* adjust the Vertical Sync Start register
  22.                               for 400 scan lines */
  23.    outpw(0x3D4, 0x8E11);   /* adjust the Vertical Sync End register
  24.                               for 400 scan lines */
  25.    outpw(0x3D4, 0x8F12);   /* adjust the Vertical Display End
  26.                               register for 400 scan lines */
  27.    outpw(0x3D4, 0x9615);   /* adjust the Vertical Blank Start
  28.                               register for 400 scan lines */
  29.    outpw(0x3D4, 0xB916);   /* adjust the Vertical Blank End register
  30.                               for 400 scan lines */
  31. }
  32.  
  33.