home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_01 / cips1001.exe / DISPLAY.C < prev    next >
C/C++ Source or Header  |  1991-04-27  |  20KB  |  834 lines

  1.  
  2.        /*****************************************************
  3.        *
  4.        *       file d:\cips\display.c
  5.        *
  6.        *       Functions: This file contains
  7.        *          display_image
  8.        *          display_image_portion
  9.        *          display_menu_for_display_image
  10.        *          map_16_shades_of_gray
  11.        *          transform_the_colors
  12.        *
  13.        *       Purpose:
  14.        *          These functions display images on a the
  15.        *          monitor.
  16.        *
  17.        *       External Calls:
  18.        *          rtiff.c - read_tiff_image
  19.        *          cips.c - clear_text_screen
  20.        *          hist.c - zero_histogram
  21.        *                   calculate_histogram
  22.        *                   perform_histogram_equalization
  23.        *
  24.        *       Modifications:
  25.        *          17 June 1987 - created
  26.        *          August 1990 - extension modifications for use
  27.        *              in the C Image Processing System.
  28.        *
  29.        ********************************************************/
  30.  
  31.  
  32. #include "d:\cips\cips.h"
  33.  
  34.  
  35.  
  36.  
  37.  
  38.    /***************************
  39.    *
  40.    *   display_image(...
  41.    *
  42.    ****************************/
  43.  
  44.  
  45. display_image(file_name, image, il, ie, ll, le,
  46.               image_header, monitor_type, color_transform,
  47.               invert, image_colors, display_colors,
  48.               show_hist)
  49.    char    color_transform[],
  50.            file_name[],
  51.            monitor_type[];
  52.    int     display_colors,
  53.            image_colors,
  54.            invert,
  55.            il,
  56.            ie,
  57.            ll,
  58.            le,
  59.        show_hist;
  60.    short   image[ROWS][COLS];
  61.    struct  tiff_header_struct *image_header;
  62. {
  63.    char  channels[80],
  64.          response[80];
  65.  
  66.    int   a,
  67.          b,
  68.          c,
  69.          channel,
  70.          count,
  71.          display_mode,
  72.          key,
  73.          horizontal,
  74.          max_horizontal,
  75.          max_vertical,
  76.          not_finished,
  77.          q,
  78.          r,
  79.          vertical,
  80.          x_offset,
  81.          y_offset;
  82.  
  83.    unsigned int block,
  84.                 color,
  85.                 i,
  86.                 j,
  87.                 x,
  88.                 y;
  89.  
  90.    unsigned long histogram[256], new_hist[256];
  91.  
  92.  
  93.      /*************************************************
  94.      *
  95.      *   If you want to display the histogram and do not
  96.      *   want to perform hist equalization, then
  97.      *   zero the histogram for calculations.
  98.      *
  99.      *************************************************/
  100.  
  101.    if(  (show_hist == 1)   &&
  102.         (color_transform[0] != 'H'))
  103.       zero_histogram(histogram);
  104.  
  105.    not_finished = 1;
  106.    while(not_finished){
  107.  
  108.  
  109.       if(display_colors == 16){
  110.          if(monitor_type[0] == 'V'){
  111.             horizontal   = 4;
  112.         vertical = 6;
  113.         display_mode = _VRES16COLOR; /* MSC 6.0 */
  114.          }  /* ends if V */
  115.          if(monitor_type[0] == 'E'){
  116.             horizontal   = 3;
  117.             vertical     = 6;
  118.             display_mode = _ERESCOLOR; /* MSC 6.0 */
  119.          }  /* ends if E */
  120.  
  121.       }  /* ends if colors == 16 */
  122.  
  123.       else{
  124.          horizontal   = 2;
  125.          vertical     = 2;
  126.          display_mode = _MAXCOLORMODE; /* MSC 6.0 */
  127.       }
  128.  
  129.  
  130.       max_horizontal = (image_header->image_length+50)/100;
  131.       max_vertical   = (image_header->image_width+50)/100;
  132.  
  133.       if(horizontal > max_horizontal) horizontal = max_horizontal;
  134.       if(vertical > max_vertical) vertical = max_vertical;
  135.  
  136.  
  137.  
  138.         /****************************************
  139.         *
  140.         *   If color transform wants histogram
  141.         *   equalization, then read in the
  142.         *   image arrays and calculate the
  143.         *   histogram.   Zero both the histogram
  144.         *   and the new_hist.  You will need the
  145.         *   new_hist if you want to display the
  146.         *   equalized hist.
  147.         *
  148.         *****************************************/
  149.  
  150.       if(color_transform[0] == 'H'){
  151.          count = 1;
  152.          zero_histogram(histogram);
  153.          zero_histogram(new_hist);
  154.          for(a=0; a<vertical; a++){
  155.             for(b=0; b<horizontal; b++){
  156.  
  157.                x = a*100;
  158.                y = b*100;
  159.  
  160.                printf("\nDISPLAY> Calculating histogram");
  161.                printf(" %d of %d",count,vertical*horizontal);
  162.                count++;
  163.                read_tiff_image(file_name, image, il+y,
  164.                             ie+x, ll+y, le+x);
  165.                calculate_histogram(image, histogram);
  166.  
  167.             }  /* ends loop over b */
  168.          }  /* ends loop over a */
  169.       }  /* ends if display_mode == H */
  170.  
  171.  
  172.         /* set graphics mode */
  173.  
  174.    _setvideomode(display_mode); /* MSC 6.0 */
  175.    if(display_colors == 16) map_16_shades_of_gray(display_mode);
  176.    if(display_colors == 256) map_64_shades_of_gray();
  177.  
  178.  
  179.         /****************************************
  180.         *
  181.         *   Loop over this size and
  182.         *   read and display ROWSxCOLS arrays.
  183.         *
  184.         *   If you want to show the histogram AND
  185.         *   do not want to do hist equalization
  186.         *   then calculate the hist from the
  187.         *   original image array.
  188.         *
  189.         *   If you want to do hist equalization
  190.         *   then calculate the new_hist AFTER
  191.         *   the image has been equalized by the
  192.         *   the transform_the_colors function.
  193.         *
  194.         *   NOTE: Remember that the function
  195.         *   transform_the_colors changes the
  196.         *   gray shade values in image array.
  197.         *
  198.         *****************************************/
  199.  
  200.  
  201.       for(a=0; a<vertical; a++){
  202.          for(b=0; b<horizontal; b++){
  203.  
  204.             x = a*100;
  205.             y = b*100;
  206.             read_tiff_image(file_name, image, il+y,
  207.                 ie+x, ll+y, le+x);
  208.             if(  (show_hist == 1)  &&
  209.                  (color_transform[0] != 'H'))
  210.                calculate_histogram(image, histogram);
  211.  
  212.             transform_the_colors(image, color_transform,
  213.                                  display_colors,
  214.                                  image_colors, histogram,
  215.                                  horizontal, vertical);
  216.  
  217.             if(color_transform[0] == 'H')
  218.                calculate_histogram(image, new_hist);
  219.             display_image_portion(image, x, y, display_colors,
  220.                                   image_colors, invert);
  221.          }        /* ends loop over b */
  222.       }        /* ends loop over a */
  223.  
  224.  
  225.          /***************************
  226.          *
  227.          *   if show_hist == 1 then
  228.          *   display the histogram
  229.          *   in the lower right hand
  230.          *   corner of screen
  231.          *
  232.          *   If hist equalization was
  233.          *   performed then show the
  234.          *   new_hist.  If it wasn't
  235.          *   done then show the original
  236.          *   histogram.
  237.          *
  238.          ****************************/
  239.  
  240.       if(show_hist == 1){
  241.          if(monitor_type[0] == 'V')
  242.             y_offset = 470;
  243.          if(monitor_type[0] == 'E')
  244.             y_offset = 310;
  245.          x_offset = 380;
  246.          if(color_transform[0] == 'H')
  247.             display_histogram(new_hist, x_offset,
  248.                    y_offset, 10, 15);
  249.          else
  250.             display_histogram(histogram, x_offset,
  251.                    y_offset, 10, 15);
  252.       }
  253.  
  254.       read_string(response);
  255.       printf("\nEnter 0 to quit 1 to do again");
  256.       get_integer(¬_finished);
  257.  
  258.           /* set display back to text mode */
  259.       clear_text_screen();
  260.  
  261.  
  262.    }  /* ends while not_finished  */
  263.  
  264. }  /* ends main  */
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.    /***********************************************
  272.    *
  273.    *   display_menu_for_display_image(
  274.    *
  275.    ************************************************/
  276.  
  277.  
  278. display_menu_for_display_image(image_colors, display_colors,
  279.                               invert, color_transform,
  280.                               monitor_type,
  281.                               show_hist)
  282.    char color_transform[], monitor_type[];
  283.    int  *invert, *image_colors, *display_colors, *show_hist;
  284. {
  285.    char response[80];
  286.    int  int_response, not_finished, r;
  287.  
  288.    not_finished = 1;
  289.    while(not_finished){
  290.       printf("\n\nDISPLAY> Enter choice (0 for no change) ");
  291.       printf("\nDISPLAY> 1. Invert is %d (1=on 0=off)", *invert);
  292.       printf("\nDISPLAY> 2. Color Transform-- %s",
  293.              color_transform);
  294.       printf("\nDISPLAY> 3. Input image has %d colors",
  295.              *image_colors);
  296.       printf("\nDISPLAY> 4. Display will show %d colors",
  297.              *display_colors);
  298.       printf("\nDISPLAY> 5. Monitor type is %s",
  299.              monitor_type);
  300.       printf("\nDISPLAY> 6. Histogram is %d", *show_hist);
  301.       printf("  (1=show 0=don't show)");
  302.       printf("\nDISPLAY> _\b");
  303.       get_integer(&r);
  304.  
  305.       if(r == 0){
  306.          not_finished = 0;
  307.       }
  308.  
  309.       if(r == 1){
  310.          printf("\nDISPLAY> Enter 1 for invert on");
  311.          printf(" 0 for invert off");
  312.          printf("\nDISPLAY> ___");
  313.          get_integer(&int_response);
  314.          *invert = int_response;
  315.       }  /* ends if r == 1 */
  316.  
  317.       if(r == 2){
  318.          printf("\nDISPLAY> Enter the new color transform mode ");
  319.          printf("\nDISPLAY> (S) Straight mode");
  320.          printf("   (H) Histogram Equalization");
  321.          printf("\nDISPLAY> _\b");
  322.          read_string(response);
  323.          if((response[0] == 'S') ||
  324.             (response[0] == 's'))
  325.                strcpy(color_transform, "Straight mode");
  326.          else
  327.                strcpy(color_transform,
  328.                 "Histogram Equalization mode");
  329.       }  /* ends if r == 2  */
  330.  
  331.       if(r == 3){
  332.          printf("\nDISPLAY> Enter the number of colors");
  333.          printf(" in the input image");
  334.          printf("\nDISPLAY> ___");
  335.          get_integer(&int_response);
  336.          *image_colors = int_response;
  337.       }  /* ends if r == 3 */
  338.  
  339.       if(r == 4){
  340.          printf(
  341.           "\nDISPLAY> Enter the number of colors for the display");
  342.          printf("\nDISPLAY> ___");
  343.          get_integer(&int_response);
  344.          *display_colors = int_response;
  345.       }  /* ends if r == 4 */
  346.  
  347.       if(r == 5){
  348.          printf("\nDISPLAY> Enter the new monitor type");
  349.          printf("\nDISPLAY> (E) EGA   (V) VGA");
  350.          printf("   (C) CGA   (M) Monochrome");
  351.          printf("\nDISPLAY> _\b");
  352.          read_string(response);
  353.          if((response[0] == 'E') ||
  354.             (response[0] == 'e'))
  355.             strcpy(monitor_type, "EGA");
  356.       if((response[0] == 'V') ||
  357.          (response[0] == 'v'))
  358.             strcpy(monitor_type, "VGA");
  359.       if((response[0] == 'C') ||
  360.          (response[0] == 'c'))
  361.             strcpy(monitor_type, "CGA");
  362.       if((response[0] == 'M') ||
  363.          (response[0] == 'm'))
  364.             strcpy(monitor_type, "Monochrome");
  365.       }  /* ends if r == 5  */
  366.  
  367.       if(r == 6){
  368.          printf(
  369.             "\nDISPLAY> Enter 1 for show histogram 0 for don't");
  370.          printf("\nDISPLAY> ___");
  371.          get_integer(&int_response);
  372.          *show_hist = int_response;
  373.       }  /* ends if r == 6 */
  374.  
  375.  
  376.  
  377.    }  /* ends while not_finished  */
  378. }  /* ends display_menu  */
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.    /********************************
  389.    *
  390.    *   display_image_portion(...
  391.    *
  392.    *********************************/
  393.  
  394.  
  395.  
  396.  
  397. display_image_portion(image, x, y, display_colors, image_colors,
  398.                       invert)
  399.    int      invert, display_colors, image_colors;
  400.    short    image[ROWS][COLS];
  401.    unsigned int x, y;
  402. {
  403.    unsigned int color, i, j;
  404.  
  405.       if(invert == 1){
  406.         for(i=0; i<ROWS; i++)
  407.            for(j=0; j<COLS; j++)
  408.               image[i][j] = (display_colors-1)-image[i][j];
  409.       }  /* ends if invert == 1 */
  410.  
  411.  
  412.       for(i=0; i<ROWS; i++){
  413.          for(j=0; j<COLS; j++){
  414.  
  415.         _setcolor(image[i][j]);
  416.     _setpixel(j+x, i+y);
  417. /*****
  418. my_set_pixel(j+x, i+y, image[i][j]);
  419. ******/
  420.  
  421.          }  /* ends loop over j  */
  422.       }     /* ends loop over i  */
  423.  
  424. }  /* ends display_image_portion  */
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.    /**********************************************
  435.    *
  436.    *   map_16_shades_of_gray(...
  437.    *
  438.    *   This function maps 16 shades of gray into
  439.    *   the first 16 color indices.  This allows
  440.    *   you to display a true "black and white"
  441.    *   image on a color monitor.
  442.    *
  443.    *********************************************/
  444.  
  445.  
  446. map_16_shades_of_gray(display_mode)
  447.    int display_mode;
  448. {
  449.    /* all MSC 6.0 statements */
  450. _setvideomode(display_mode);
  451. _remappalette(0,  0x000000L);
  452. _remappalette(1,  0x040404L);
  453. _remappalette(2,  0x080808L);
  454. _remappalette(3,  0x0c0c0cL);
  455. _remappalette(4,  0x101010L);
  456. _remappalette(5,  0x141414L);
  457. _remappalette(6,  0x181818L);
  458. _remappalette(7,  0x1c1c1cL);
  459. _remappalette(8,  0x202020L);
  460. _remappalette(9,  0x242424L);
  461. _remappalette(10, 0x282828L);
  462. _remappalette(11, 0x2c2c2cL);
  463. _remappalette(12, 0x303030L);
  464. _remappalette(13, 0x343434L);
  465. _remappalette(14, 0x383838L);
  466. _remappalette(15, 0x3f3f3fL);
  467. }
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.    /*********************************************
  475.    *
  476.    *   transform_the_colors(...
  477.    *
  478.    *   This function transforms the gray shades
  479.    *   in the image array for display.  It can either
  480.    *   do it in straight mode by multiplying or
  481.    *   dividing or it can do it with hist
  482.    *   equalization by calling the function
  483.    *   perform_histogram_equalization.
  484.    *
  485.    *************************************************/
  486.  
  487.  
  488. transform_the_colors(image, color_transform,
  489.                      display_colors, image_colors,
  490.                      histogram, horizontal,
  491.                      vertical)
  492.    char   color_transform[];
  493.    int    display_colors, horizontal,
  494.           image_colors, vertical;
  495.    short  image[ROWS][COLS];
  496.    unsigned long histogram[];
  497. {
  498.    int         color, i, j;
  499.    float new_grays, area;
  500.    unsigned long x;
  501.  
  502.    if(color_transform[0] == 'S'){
  503.       for(i=0; i<ROWS; i++){
  504.          for(j=0; j<COLS; j++){
  505.  
  506.  
  507.             if( (display_colors == 16) &&
  508.                 (image_colors  == 256))
  509.                color = image[i][j]/16;
  510.             if( (display_colors == 16) &&
  511.                 (image_colors  == 16))
  512.                color = image[i][j];
  513.             if( (display_colors == 256) &&
  514.         (image_colors  == 256))
  515.            color = image[i][j];
  516.             if( (display_colors == 256) &&
  517.                 (image_colors  == 16))
  518.                color = image[i][j]*16;
  519.  
  520.             image[i][j] = color;
  521.  
  522.  
  523.          }  /* ends loop over j        */
  524.       }        /* ends loop over i        */
  525.    }  /* ends if transform is straight */
  526.  
  527.  
  528.    if(color_transform[0] == 'H'){
  529.  
  530.       area      = ((long)(vertical))*((long)(horizontal));
  531.       area      = area*10000.0;
  532.       new_grays = display_colors;
  533.  
  534.       perform_histogram_equalization(image, histogram,
  535.                                      new_grays, area);
  536.  
  537.    }  /* ends if transform is hist equalization */
  538.  
  539. }  /* ends transform_the_colors */
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.    /**********************************
  547.    *
  548.    *   Modes for the SigmaVGA Legend
  549.    *               (hex)
  550.    *   10 - 640x350x64?
  551.    *   12 - 640x480x16
  552.    *   29 - 800x600x16
  553.    *   30 - 800x600x256
  554.    *   38 - 1024x768x256
  555.    *
  556.    ***********************************/
  557.  
  558. my_set_video_mode()
  559. {
  560.  
  561.    union REGS regs;
  562.  
  563.    regs.h.al = 0x29; /* mode */
  564.    regs.h.ah = 0x00;
  565.    int86(0x10, ®s, ®s);
  566.  
  567.  
  568. }  /* ends my_set_video_mode */
  569.  
  570.  
  571.  
  572.  
  573.  
  574. my_set_pixel(x, y, color)
  575.    unsigned int x, y, color;
  576. {
  577.  
  578. union REGS regs;
  579. char  r[80];
  580. int i;
  581.  
  582.    regs.h.ah = 0x0c;
  583.    regs.x.dx = y;
  584.    regs.x.cx = x;
  585.    regs.h.al = color;
  586.    regs.h.bh = 0x00;
  587.  
  588.    int86(0x10, ®s, ®s);
  589.  
  590. }  /* ends my_set_pixel */
  591.  
  592.  
  593.  
  594.  
  595. my_set_colors()
  596. {
  597.  
  598.  union REGS regs;
  599.  int i;
  600.  
  601.  
  602.       /*********************
  603.      this works for 256 color modes
  604.      it does not work for 16 color modes
  605.       *********************/
  606.  
  607.    _asm{
  608.  
  609.       mov   ax,0030h ; set graphics mode 30h=800x600x256
  610.       int   10h
  611.  
  612.       mov ax,0h
  613.       mov dx,3c8h ; select first DAC register
  614.  
  615.       out dx,al
  616.       inc dx      ; set DAC data register
  617.  
  618.       mov al,0h
  619.       out dx,al
  620.       out dx,al
  621.       out dx,al
  622.  
  623.       mov al,4h
  624.       out dx,al
  625.       out dx,al
  626.       out dx,al
  627.  
  628.       mov al,8h
  629.       out dx,al
  630.       out dx,al
  631.       out dx,al
  632.  
  633.       mov al,ch
  634.       out dx,al
  635.       out dx,al
  636.       out dx,al
  637.  
  638.       mov al,10h
  639.       out dx,al
  640.       out dx,al
  641.       out dx,al
  642.  
  643.       mov al,14h
  644.       out dx,al
  645.       out dx,al
  646.       out dx,al
  647.  
  648.       mov al,18h
  649.       out dx,al
  650.       out dx,al
  651.       out dx,al
  652.  
  653.       mov al,1ch
  654.       out dx,al
  655.       out dx,al
  656.       out dx,al
  657.  
  658.       mov al,20h
  659.       out dx,al
  660.       out dx,al
  661.       out dx,al
  662.  
  663.       mov al,24h
  664.       out dx,al
  665.       out dx,al
  666.       out dx,al
  667.  
  668.       mov al,28h
  669.       out dx,al
  670.       out dx,al
  671.       out dx,al
  672.  
  673.       mov al,2ch
  674.       out dx,al
  675.       out dx,al
  676.       out dx,al
  677.  
  678.       mov al,30h
  679.       out dx,al
  680.       out dx,al
  681.       out dx,al
  682.  
  683.       mov al,34h
  684.       out dx,al
  685.       out dx,al
  686.       out dx,al
  687.  
  688.       mov al,38h
  689.       out dx,al
  690.       out dx,al
  691.       out dx,al
  692.  
  693.       mov al,3ch
  694.       out dx,al
  695.       out dx,al
  696.       out dx,al
  697.    } /* ends asm */
  698.  
  699.  
  700.  
  701. }  /* ends my_set_colors */
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710. put_pixel(ppx, ppy, color)
  711.    int color, ppx, ppy;
  712. {
  713.  
  714. int RW_Page=0x0ff;
  715. int W_Page=0x0ff;
  716. int R_Page=0x0ff;
  717. int PAGE_SEL_PORT=0x3cd;
  718.  
  719. printf("\ny=%d x=%d color=%d Page=%d offset=%d", ppy, ppx, color, (ppy*800 + ppx)/0x10000, (ppy*800 + ppx)%0x10000);
  720.  
  721. /******************
  722.  
  723.    _asm{
  724.          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  725.          ;
  726.          ;     taken from file
  727.          ;     d:\supervga\256col\wpixel.asm
  728.          ;
  729.          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  730.  
  731.  
  732.     PUSH    BP            ;Preserve BP
  733.         MOV     BP,SP                   ;Preserve stack pointer
  734.  
  735.         PUSH    ES                      ;Preserve segment and index registers
  736.         PUSH    DS
  737.         PUSH    DI
  738.         PUSH    SI
  739.  
  740.         ; Convert x,y pixel address to Page and Offset
  741.  
  742.     MOV    AX,ppy            ;Fetch y coordinate
  743.                     ;Video_Pitch=SCREEN_PITCH=800
  744.     MUL    cs:800            ;multiply by width in bytes
  745.     ADD    AX,ppx            ;add x coordinate to compute offset
  746.     ADC    DX,0            ;add overflow to upper 16 bits
  747.                     ;Graph_Seg=0aoooh
  748.     MOV    DS,CS:0a000h        ;Put new address in DS:SI
  749.     MOV    DI,AX
  750.         MOV     AL,DL                   ;Copy page number into AL
  751.     JMP    Select_Page        ;Select proper page
  752. Ret_Page:
  753.  
  754.  
  755.         ; Set pixel to supplied value
  756.  
  757.     MOV    AL,color        ;Fetch color to use
  758.         MOV     [DI],AL                 ;Set the pixel
  759.  
  760.         ; Clean up and return
  761.  
  762.         POP     SI                      ;Restore segment and index registers
  763.         POP     DI
  764.         POP     DS
  765.         POP     ES
  766.  
  767.         MOV     SP,BP                   ;Restore stack pointer
  768.         POP     BP                      ;Restore BP
  769.  
  770.     JMP    The_End
  771.  
  772.  
  773. Select_Page:
  774.     CMP    AL,CS:RW_Page        ;Check if already selected
  775.     JNE    SP_Go
  776.     JMP    Ret_Page
  777. SP_Go:
  778.     PUSH    AX
  779.     PUSH    DX
  780.     MOV    DX,PAGE_SEL_PORT    ;Fetch address of page select
  781.     AND    AL,7            ;Force page number into 0-7
  782.     MOV    CS:RW_Page,AL        ;Save most recently selected page
  783.     MOV    CS:R_Page,0FFh
  784.     MOV    CS:W_Page,0FFh
  785.     MOV    AH,AL            ;Copy page into AH
  786.     SHL    AH,1            ;Shift page number
  787.     SHL    AH,1
  788.     SHL    AH,1
  789.     OR    AL,AH            ;Move page number into "write" bits
  790.     OR    AL,40h            ;Force bit 6
  791.     OUT    DX,AL            ;Write out the new page select
  792.     POP    DX
  793.     POP    AX
  794.     JMP    Ret_Page
  795.  
  796. The_End:
  797.  
  798.    }*******/    /* ends _asm */
  799.  
  800. }  /* ends put_pixel */
  801.  
  802.  
  803.  
  804.  
  805.  
  806.  
  807.    /*******************************************
  808.    *
  809.    *   map_64_shades_of_gray()
  810.    *
  811.    *   This function maps 256 DAC registers to
  812.    *   gray shades.  Taken from p. 73 of
  813.    *   Sutty and Blair's text on superVGA
  814.    *
  815.    ********************************************/
  816.  
  817.  
  818. map_64_shades_of_gray()
  819. {
  820.  
  821.    _asm{
  822.       mov ax,0013h ;mod 13h is 320x200x256
  823.       int 10h
  824.  
  825.       mov ah,10h   ; function 10h
  826.       mov al,1bh   ; sub function 1bh
  827.       mov bx,0h    ; first DAC register to change
  828.       mov cx,100h  ; change 256 DAC registers
  829.       int 10h
  830.  
  831.    } /* ends asm */
  832.  
  833. }  /* ends map_64_shades_of_gray */
  834.