home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / C-ASM_VI.ARJ / PROGC.ZIP / PROGC080.C < prev    next >
Text File  |  1988-05-25  |  4KB  |  81 lines

  1.  
  2. /************************************************************************/
  3. /* Draw sixteen boxes using pixel write                                 */
  4. /************************************************************************/
  5.  
  6. pixel_box16()
  7.         {
  8.         #define MONO            5
  9.         #define VMONO           7
  10.         #define COLOR           4
  11.         #define ENHANCED        3
  12.         #define VCOLOR          8
  13.         int     box, i, j, color, x, y;
  14.         int     type;
  15.  
  16.         /* Get display type and select mode accordingly                 */
  17.  
  18.         type = get_display_type();              /* Get display type     */
  19.         switch (type)                           /* Set mode according to*/
  20.                 {                               /* type of display      */
  21.                 case VMONO:
  22.                 case MONO:
  23.                         set_mode(0x0F);
  24.                         break;
  25.                 case COLOR:
  26.                         set_mode(0x0E);
  27.                         break;
  28.                 case VCOLOR:
  29.                 case ENHANCED:
  30.                 default:
  31.                         set_mode(0x10);
  32.                         break;
  33.                 }
  34.  
  35.         /* Draw boxes using SET/RESET write mode                        */
  36.  
  37.         printf("Drawing pixels using mode 0, SET/RESET method");
  38.         for (box = 0; box < 16; box++)          /* Loop over boxes      */
  39.             for (j = 0; j < 10; j++)            /* Loop over rasters    */
  40.                                                 /* within box           */
  41.                 for (i = 0; i < 100; i++)       /* Loop over pixels     */
  42.                         {                       /* within raster        */
  43.                         x = i;                  /* Set x                */
  44.                         y = j + 10 * box;       /* Compute y            */
  45.                         color = box;            /* Set color            */
  46.                         pixel_set(x, y, color); /* Fill next pixel      */
  47.                         }
  48.         getchar();                              /* Wait for <Enter>     */
  49.  
  50.         /* Draw boxes using PACKED write mode                           */
  51.  
  52.         cls();
  53.         printf("Drawing pixels using mode 2, packed write method");
  54.         for (box = 0; box < 16; box++)          /* Loop over boxes      */
  55.             for (j = 0; j < 10; j++)            /* Loop over rasters    */
  56.                                                 /* within box           */
  57.                 for (i = 0; i < 100; i++)       /* Loop over pixels     */
  58.                         {                       /* within raster        */
  59.                         x = i;                  /* Set x                */
  60.                         y = j + 10 * box;       /* Compute y            */
  61.                         color = 15 - box;       /* Set color            */
  62.                         pixel_packed_write(x, y, color);/*Fill next pix */
  63.                         }
  64.         getchar();                              /* Wait for <Enter>     */
  65.  
  66.         /* Draw boxes using PLANAR write mode                           */
  67.  
  68.         cls();
  69.         printf("Drawing pixels using mode 0, planar write method");
  70.         for (box = 0; box < 16; box++)          /* Loop over boxes      */
  71.             for (j = 0; j < 10; j++)            /* Loop over rasters    */
  72.                                                 /* within box           */
  73.                 for (i = 0; i < 100; i++)       /* Loop over pixels     */
  74.                         {                       /* within raster        */
  75.                         x = i;                  /* Set x                */
  76.                         y = j + 10 * box;       /* Compute y            */
  77.                         color = box;            /* Set color            */
  78.                         pixel_write(x, y, color);/*Fill next pixel      */
  79.                         }
  80.         }
  81.