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

  1. /* *** Listing 19.3 ***
  2.  *
  3.  * Draws nested ellipses of varying eccentricities in the VGA's
  4.  * hi-res mode, mode 12h.
  5.  * For VGA only.
  6.  * Compile and link with L19-X.c (where X is 1 or 4) using Borland C++ 4.02:
  7.  *   bcc -ms -el19-3X.exe l19-3.c l19-X.c
  8.  * Checked by Jim Mischel 11/30/94.
  9.  */
  10.  
  11. #include <dos.h>
  12.  
  13. main() {
  14.    int XRadius, YRadius, Temp, Color;
  15.    union REGS Regs;
  16.  
  17.    /* Select VGA's hi-res 640x480 graphics mode, mode 12h */
  18.    Regs.x.ax = 0x0012;
  19.    int86(0x10, &Regs, &Regs);
  20.  
  21.    /* Draw nested ellipses */
  22.    for ( XRadius = 100, YRadius = 2, Color = 7; YRadius < 240;
  23.          XRadius++, YRadius += 2 ) {
  24.       DrawEllipse(640/2, 480/2, XRadius, YRadius, Color);
  25.       Color = (Color + 1) & 0x0F;   /* cycle through 16 colors */
  26.    }
  27.  
  28.    /* Wait for a key, restore text mode, and done */
  29.    scanf("%c", &Temp);
  30.    Regs.x.ax = 0x0003;
  31.    int86(0x10, &Regs, &Regs);
  32. }
  33.