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

  1. /* Program to demonstrate mode X (320x240, 256-colors) rectangle
  2.    fill by drawing adjacent 20x20 rectangles in successive colors from
  3.    0 on up across and down the screen
  4.    Tested with Borland C++ 4.02 in small model by Jim Mischel 12/16/94.
  5. */
  6. #include <conio.h>
  7. #include <dos.h>
  8.  
  9. void Set320x240Mode(void);
  10. void FillRectangleX(int, int, int, int, unsigned int, int);
  11.  
  12. void main() {
  13.    int i,j;
  14.    union REGS regset;
  15.  
  16.    Set320x240Mode();
  17.    FillRectangleX(0,0,320,240,0,0); /* clear the screen to black */
  18.    for (j = 1; j < 220; j += 21) {
  19.       for (i = 1; i < 300; i += 21) {
  20.          FillRectangleX(i, j, i+20, j+20, 0, ((j/21*15)+i/21) & 0xFF);
  21.       }
  22.    }
  23.    getch();
  24.    regset.x.ax = 0x0003;   /* switch back to text mode and done */
  25.    int86(0x10, ®set, ®set);
  26. }
  27.  
  28.