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

  1. /* Program to demonstrate Mode X (320x240, 256 colors) patterned
  2.    rectangle fills by filling the screen with adjacent 80x60
  3.    rectangles in a variety of patterns.
  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 FillPatternX(int, int, int, int, unsigned int, char*);
  11.  
  12. /* 16 4x4 patterns */
  13. static char Patt0[]={10,0,10,0,0,10,0,10,10,0,10,0,0,10,0,10};
  14. static char Patt1[]={9,0,0,0,0,9,0,0,0,0,9,0,0,0,0,9};
  15. static char Patt2[]={5,0,0,0,0,0,5,0,5,0,0,0,0,0,5,0};
  16. static char Patt3[]={14,0,0,14,0,14,14,0,0,14,14,0,14,0,0,14};
  17. static char Patt4[]={15,15,15,1,15,15,1,1,15,1,1,1,1,1,1,1};
  18. static char Patt5[]={12,12,12,12,6,6,6,12,6,6,6,12,6,6,6,12};
  19. static char Patt6[]={80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,15};
  20. static char Patt7[]={78,78,78,78,80,80,80,80,82,82,82,82,84,84,84,84};
  21. static char Patt8[]={78,80,82,84,80,82,84,78,82,84,78,80,84,78,80,82};
  22. static char Patt9[]={78,80,82,84,78,80,82,84,78,80,82,84,78,80,82,84};
  23. static char Patt10[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
  24. static char Patt11[]={0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
  25. static char Patt12[]={14,14,9,9,14,9,9,14,9,9,14,14,9,14,14,9};
  26. static char Patt13[]={15,8,8,8,15,15,15,8,15,15,15,8,15,8,8,8};
  27. static char Patt14[]={3,3,3,3,3,7,7,3,3,7,7,3,3,3,3,3};
  28. static char Patt15[]={0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,89};
  29. /* Table of pointers to the 16 4x4 patterns with which to draw */
  30. static char* PattTable[] = {Patt0,Patt1,Patt2,Patt3,Patt4,Patt5,Patt6,
  31.       Patt7,Patt8,Patt9,Patt10,Patt11,Patt12,Patt13,Patt14,Patt15};
  32. void main() {
  33.    int i,j;
  34.    union REGS regset;
  35.  
  36.    Set320x240Mode();
  37.    for (j = 0; j < 4; j++) {
  38.       for (i = 0; i < 4; i++) {
  39.          FillPatternX(i*80,j*60,i*80+80,j*60+60,0,PattTable[j*4+i]);
  40.       }
  41.    }
  42.    getch();
  43.    regset.x.ax = 0x0003;   /* switch back to text mode and done */
  44.    int86(0x10, ®set, ®set);
  45. }
  46.  
  47.