home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_09_11 / cips911.exe / DISPLAY.C < prev    next >
C/C++ Source or Header  |  1990-10-13  |  20KB  |  833 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.       for(a=0; a<vertical; a++){
  201.          for(b=0; b<horizontal; b++){
  202.  
  203.             x = a*100;
  204.             y = b*100;
  205.             read_tiff_image(file_name, image, il+y, 
  206.                 ie+x, ll+y, le+x);
  207.             if(  (show_hist == 1)  &&
  208.                  (color_transform[0] != 'H'))
  209.                calculate_histogram(image, histogram);
  210.  
  211.             transform_the_colors(image, color_transform,
  212.                                  display_colors,
  213.                                  image_colors, histogram,
  214.                                  horizontal, vertical);
  215.  
  216.             if(color_transform[0] == 'H')
  217.            calculate_histogram(image, new_hist);
  218.             display_image_portion(image, x, y, display_colors, 
  219.                                   image_colors, invert);
  220.          }        /* ends loop over b */
  221.       }        /* ends loop over a */
  222.  
  223.  
  224.          /***************************
  225.          *
  226.          *   if show_hist == 1 then
  227.          *   display the histogram
  228.          *   in the lower right hand
  229.          *   corner of screen
  230.          *
  231.          *   If hist equalization was
  232.          *   performed then show the
  233.          *   new_hist.  If it wasn't
  234.          *   done then show the original
  235.          *   histogram.
  236.          *
  237.          ****************************/
  238.  
  239.       if(show_hist == 1){
  240.          if(monitor_type[0] == 'V')
  241.             y_offset = 470;
  242.          if(monitor_type[0] == 'E')
  243.             y_offset = 310;
  244.          x_offset = 380;
  245.          if(color_transform[0] == 'H')
  246.             display_histogram(new_hist, x_offset,
  247.                    y_offset, 10, 15);
  248.          else
  249.             display_histogram(histogram, x_offset,
  250.                    y_offset, 10, 15);
  251.       }
  252.  
  253.       read_string(response);
  254.       printf("\nEnter 0 to quit 1 to do again");
  255.       get_integer(¬_finished);
  256.  
  257.           /* set display back to text mode */
  258.       clear_text_screen();
  259.  
  260.  
  261.    }  /* ends while not_finished  */
  262.  
  263. }  /* ends main  */
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.    /***********************************************
  271.    *
  272.    *   display_menu_for_display_image(
  273.    *
  274.    ************************************************/
  275.  
  276.  
  277. display_menu_for_display_image(image_colors, display_colors,
  278.                               invert, color_transform, 
  279.                               monitor_type, 
  280.                               show_hist)
  281.    char color_transform[], monitor_type[];
  282.    int  *invert, *image_colors, *display_colors, *show_hist;
  283. {
  284.    char response[80];
  285.    int  int_response, not_finished, r;
  286.  
  287.    not_finished = 1;
  288.    while(not_finished){
  289.       printf("\n\nDISPLAY> Enter choice (0 for no change) ");
  290.       printf("\nDISPLAY> 1. Invert is %d (1=on 0=off)", *invert);
  291.       printf("\nDISPLAY> 2. Color Transform-- %s", 
  292.              color_transform);
  293.       printf("\nDISPLAY> 3. Input image has %d colors", 
  294.              *image_colors);
  295.       printf("\nDISPLAY> 4. Display will show %d colors", 
  296.              *display_colors);
  297.       printf("\nDISPLAY> 5. Monitor type is %s",
  298.              monitor_type);
  299.       printf("\nDISPLAY> 6. Histogram is %d", *show_hist);
  300.       printf("  (1=show 0=don't show)");
  301.       printf("\nDISPLAY> _\b");
  302.       get_integer(&r);
  303.  
  304.       if(r == 0){
  305.          not_finished = 0;
  306.       }
  307.  
  308.       if(r == 1){
  309.          printf("\nDISPLAY> Enter 1 for invert on");
  310.          printf(" 0 for invert off");
  311.          printf("\nDISPLAY> ___");
  312.          get_integer(&int_response);
  313.          *invert = int_response;
  314.       }  /* ends if r == 1 */
  315.  
  316.       if(r == 2){
  317.          printf("\nDISPLAY> Enter the new color transform mode ");
  318.          printf("\nDISPLAY> (S) Straight mode");
  319.          printf("   (H) Histogram Equalization");
  320.          printf("\nDISPLAY> _\b");
  321.          read_string(response);
  322.          if((response[0] == 'S') ||
  323.             (response[0] == 's'))
  324.                strcpy(color_transform, "Straight mode");
  325.          else
  326.                strcpy(color_transform,
  327.                 "Histogram Equalization mode");
  328.       }  /* ends if r == 2  */
  329.  
  330.       if(r == 3){
  331.          printf("\nDISPLAY> Enter the number of colors");
  332.          printf(" in the input image");
  333.          printf("\nDISPLAY> ___");
  334.          get_integer(&int_response);
  335.          *image_colors = int_response;
  336.       }  /* ends if r == 3 */
  337.  
  338.       if(r == 4){
  339.          printf( 
  340.           "\nDISPLAY> Enter the number of colors for the display");
  341.          printf("\nDISPLAY> ___");
  342.          get_integer(&int_response);
  343.          *display_colors = int_response;
  344.       }  /* ends if r == 4 */
  345.  
  346.       if(r == 5){
  347.          printf("\nDISPLAY> Enter the new monitor type");
  348.          printf("\nDISPLAY> (E) EGA   (V) VGA");
  349.          printf("   (C) CGA   (M) Monochrome");
  350.          printf("\nDISPLAY> _\b");
  351.          read_string(response);
  352.          if((response[0] == 'E') ||
  353.             (response[0] == 'e'))
  354.             strcpy(monitor_type, "EGA");
  355.       if((response[0] == 'V') ||
  356.          (response[0] == 'v'))
  357.             strcpy(monitor_type, "VGA");
  358.       if((response[0] == 'C') ||
  359.          (response[0] == 'c'))
  360.             strcpy(monitor_type, "CGA");
  361.       if((response[0] == 'M') ||
  362.          (response[0] == 'm'))
  363.             strcpy(monitor_type, "Monochrome");
  364.       }  /* ends if r == 5  */
  365.  
  366.       if(r == 6){
  367.          printf(
  368.             "\nDISPLAY> Enter 1 for show histogram 0 for don't");
  369.          printf("\nDISPLAY> ___");
  370.          get_integer(&int_response);
  371.          *show_hist = int_response;
  372.       }  /* ends if r == 6 */
  373.  
  374.  
  375.  
  376.    }  /* ends while not_finished  */
  377. }  /* ends display_menu  */
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.    /********************************
  388.    *
  389.    *   display_image_portion(...
  390.    *
  391.    *********************************/
  392.  
  393.  
  394.  
  395.  
  396. display_image_portion(image, x, y, display_colors, image_colors,
  397.                       invert)
  398.    int      invert, display_colors, image_colors;
  399.    short    image[ROWS][COLS];
  400.    unsigned int x, y;
  401. {
  402.    unsigned int color, i, j;
  403.  
  404.       if(invert == 1){
  405.         for(i=0; i<ROWS; i++)
  406.            for(j=0; j<COLS; j++)
  407.               image[i][j] = (display_colors-1)-image[i][j];
  408.       }  /* ends if invert == 1 */
  409.  
  410.  
  411.       for(i=0; i<ROWS; i++){
  412.          for(j=0; j<COLS; j++){
  413.  
  414.         _setcolor(image[i][j]);
  415.     _setpixel(j+x, i+y);
  416. /*****
  417. my_set_pixel(j+x, i+y, image[i][j]);
  418. ******/
  419.  
  420.          }  /* ends loop over j  */
  421.       }     /* ends loop over i  */
  422.  
  423. }  /* ends display_image_portion  */
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.    /**********************************************
  434.    *
  435.    *   map_16_shades_of_gray(...
  436.    *
  437.    *   This function maps 16 shades of gray into
  438.    *   the first 16 color indices.  This allows
  439.    *   you to display a true "black and white"
  440.    *   image on a color monitor.
  441.    *
  442.    *********************************************/
  443.  
  444.  
  445. map_16_shades_of_gray(display_mode)
  446.    int display_mode;
  447. {
  448.    /* all MSC 6.0 statements */
  449. _setvideomode(display_mode);
  450. _remappalette(0,  0x000000L);
  451. _remappalette(1,  0x040404L);
  452. _remappalette(2,  0x080808L);
  453. _remappalette(3,  0x0c0c0cL);
  454. _remappalette(4,  0x101010L);
  455. _remappalette(5,  0x141414L);
  456. _remappalette(6,  0x181818L);
  457. _remappalette(7,  0x1c1c1cL);
  458. _remappalette(8,  0x202020L);
  459. _remappalette(9,  0x242424L);
  460. _remappalette(10, 0x282828L);
  461. _remappalette(11, 0x2c2c2cL);
  462. _remappalette(12, 0x303030L);
  463. _remappalette(13, 0x343434L);
  464. _remappalette(14, 0x383838L);
  465. _remappalette(15, 0x3f3f3fL);
  466. }
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.    /*********************************************
  474.    *
  475.    *   transform_the_colors(...
  476.    *
  477.    *   This function transforms the gray shades
  478.    *   in the image array for display.  It can either
  479.    *   do it in straight mode by multiplying or 
  480.    *   dividing or it can do it with hist 
  481.    *   equalization by calling the function
  482.    *   perform_histogram_equalization.
  483.    *
  484.    *************************************************/
  485.  
  486.  
  487. transform_the_colors(image, color_transform,
  488.                      display_colors, image_colors,
  489.                      histogram, horizontal,
  490.                      vertical)
  491.    char   color_transform[];
  492.    int    display_colors, horizontal,
  493.           image_colors, vertical;
  494.    short  image[ROWS][COLS];
  495.    unsigned long histogram[];
  496. {
  497.    int         color, i, j;
  498.    float new_grays, area;
  499.    unsigned long x;
  500.  
  501.    if(color_transform[0] == 'S'){
  502.       for(i=0; i<ROWS; i++){
  503.          for(j=0; j<COLS; j++){
  504.  
  505.  
  506.             if( (display_colors == 16) &&
  507.                 (image_colors  == 256))
  508.                color = image[i][j]/16;
  509.             if( (display_colors == 16) &&
  510.                 (image_colors  == 16))
  511.                color = image[i][j];
  512.             if( (display_colors == 256) &&
  513.         (image_colors  == 256))
  514.            color = image[i][j];
  515.             if( (display_colors == 256) &&
  516.                 (image_colors  == 16))
  517.                color = image[i][j]*16;
  518.  
  519.             image[i][j] = color;
  520.  
  521.  
  522.          }  /* ends loop over j        */
  523.       }        /* ends loop over i        */
  524.    }  /* ends if transform is straight */
  525.  
  526.  
  527.    if(color_transform[0] == 'H'){
  528.  
  529.       area      = ((long)(vertical))*((long)(horizontal));
  530.       area      = area*10000.0;
  531.       new_grays = display_colors;
  532.  
  533.       perform_histogram_equalization(image, histogram,
  534.                                      new_grays, area);
  535.  
  536.    }  /* ends if transform is hist equalization */
  537.  
  538. }  /* ends transform_the_colors */
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.    /**********************************
  546.    *
  547.    *   Modes for the SigmaVGA Legend
  548.    *               (hex)
  549.    *   10 - 640x350x64?
  550.    *   12 - 640x480x16
  551.    *   29 - 800x600x16
  552.    *   30 - 800x600x256
  553.    *   38 - 1024x768x256
  554.    *
  555.    ***********************************/
  556.  
  557. my_set_video_mode()
  558. {
  559.  
  560.    union REGS regs;
  561.  
  562.    regs.h.al = 0x29; /* mode */
  563.    regs.h.ah = 0x00;
  564.    int86(0x10, ®s, ®s);
  565.  
  566.  
  567. }  /* ends my_set_video_mode */
  568.  
  569.  
  570.  
  571.  
  572.  
  573. my_set_pixel(x, y, color)
  574.    unsigned int x, y, color;
  575. {
  576.  
  577. union REGS regs;
  578. char  r[80];
  579. int i;
  580.  
  581.    regs.h.ah = 0x0c;
  582.    regs.x.dx = y;
  583.    regs.x.cx = x;
  584.    regs.h.al = color;
  585.    regs.h.bh = 0x00;
  586.  
  587.    int86(0x10, ®s, ®s);
  588.  
  589. }  /* ends my_set_pixel */
  590.  
  591.  
  592.  
  593.  
  594. my_set_colors()
  595. {
  596.  
  597.  union REGS regs;
  598.  int i;
  599.  
  600.  
  601.       /*********************
  602.      this works for 256 color modes
  603.      it does not work for 16 color modes
  604.       *********************/
  605.  
  606.    _asm{
  607.  
  608.       mov   ax,0030h ; set graphics mode 30h=800x600x256
  609.       int   10h
  610.  
  611.       mov ax,0h
  612.       mov dx,3c8h ; select first DAC register
  613.  
  614.       out dx,al
  615.       inc dx      ; set DAC data register
  616.  
  617.       mov al,0h
  618.       out dx,al
  619.       out dx,al
  620.       out dx,al
  621.  
  622.       mov al,4h
  623.       out dx,al
  624.       out dx,al
  625.       out dx,al
  626.  
  627.       mov al,8h
  628.       out dx,al
  629.       out dx,al
  630.       out dx,al
  631.  
  632.       mov al,ch
  633.       out dx,al
  634.       out dx,al
  635.       out dx,al
  636.  
  637.       mov al,10h
  638.       out dx,al
  639.       out dx,al
  640.       out dx,al
  641.  
  642.       mov al,14h
  643.       out dx,al
  644.       out dx,al
  645.       out dx,al
  646.  
  647.       mov al,18h
  648.       out dx,al
  649.       out dx,al
  650.       out dx,al
  651.  
  652.       mov al,1ch
  653.       out dx,al
  654.       out dx,al
  655.       out dx,al
  656.  
  657.       mov al,20h
  658.       out dx,al
  659.       out dx,al
  660.       out dx,al
  661.  
  662.       mov al,24h
  663.       out dx,al
  664.       out dx,al
  665.       out dx,al
  666.  
  667.       mov al,28h
  668.       out dx,al
  669.       out dx,al
  670.       out dx,al
  671.  
  672.       mov al,2ch
  673.       out dx,al
  674.       out dx,al
  675.       out dx,al
  676.  
  677.       mov al,30h
  678.       out dx,al
  679.       out dx,al
  680.       out dx,al
  681.  
  682.       mov al,34h
  683.       out dx,al
  684.       out dx,al
  685.       out dx,al
  686.  
  687.       mov al,38h
  688.       out dx,al
  689.       out dx,al
  690.       out dx,al
  691.  
  692.       mov al,3ch
  693.       out dx,al
  694.       out dx,al
  695.       out dx,al
  696.    } /* ends asm */
  697.  
  698.  
  699.  
  700. }  /* ends my_set_colors */
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709. put_pixel(ppx, ppy, color)
  710.    int color, ppx, ppy;
  711. {
  712.  
  713. int RW_Page=0x0ff;
  714. int W_Page=0x0ff;
  715. int R_Page=0x0ff;
  716. int PAGE_SEL_PORT=0x3cd;
  717.  
  718. printf("\ny=%d x=%d color=%d Page=%d offset=%d", ppy, ppx, color, (ppy*800 + ppx)/0x10000, (ppy*800 + ppx)%0x10000);
  719.  
  720. /******************
  721.  
  722.    _asm{
  723.          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  724.          ;
  725.          ;     taken from file
  726.          ;     d:\supervga\256col\wpixel.asm
  727.          ;
  728.          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  729.  
  730.  
  731.     PUSH    BP            ;Preserve BP
  732.         MOV     BP,SP                   ;Preserve stack pointer
  733.  
  734.         PUSH    ES                      ;Preserve segment and index registers
  735.         PUSH    DS
  736.         PUSH    DI
  737.         PUSH    SI
  738.  
  739.         ; Convert x,y pixel address to Page and Offset
  740.  
  741.     MOV    AX,ppy            ;Fetch y coordinate
  742.                     ;Video_Pitch=SCREEN_PITCH=800
  743.     MUL    cs:800            ;multiply by width in bytes
  744.     ADD    AX,ppx            ;add x coordinate to compute offset
  745.     ADC    DX,0            ;add overflow to upper 16 bits
  746.                     ;Graph_Seg=0aoooh
  747.     MOV    DS,CS:0a000h        ;Put new address in DS:SI
  748.     MOV    DI,AX
  749.         MOV     AL,DL                   ;Copy page number into AL
  750.     JMP    Select_Page        ;Select proper page
  751. Ret_Page:
  752.  
  753.  
  754.         ; Set pixel to supplied value
  755.  
  756.     MOV    AL,color        ;Fetch color to use
  757.         MOV     [DI],AL                 ;Set the pixel
  758.  
  759.         ; Clean up and return
  760.  
  761.         POP     SI                      ;Restore segment and index registers
  762.         POP     DI
  763.         POP     DS
  764.         POP     ES
  765.  
  766.         MOV     SP,BP                   ;Restore stack pointer
  767.         POP     BP                      ;Restore BP
  768.  
  769.     JMP    The_End
  770.  
  771.  
  772. Select_Page:
  773.     CMP    AL,CS:RW_Page        ;Check if already selected
  774.     JNE    SP_Go
  775.     JMP    Ret_Page
  776. SP_Go:
  777.     PUSH    AX
  778.     PUSH    DX
  779.     MOV    DX,PAGE_SEL_PORT    ;Fetch address of page select
  780.     AND    AL,7            ;Force page number into 0-7
  781.     MOV    CS:RW_Page,AL        ;Save most recently selected page
  782.     MOV    CS:R_Page,0FFh
  783.     MOV    CS:W_Page,0FFh
  784.     MOV    AH,AL            ;Copy page into AH
  785.     SHL    AH,1            ;Shift page number
  786.     SHL    AH,1
  787.     SHL    AH,1
  788.     OR    AL,AH            ;Move page number into "write" bits
  789.     OR    AL,40h            ;Force bit 6
  790.     OUT    DX,AL            ;Write out the new page select
  791.     POP    DX
  792.     POP    AX
  793.     JMP    Ret_Page
  794.  
  795. The_End:
  796.  
  797.    }*******/    /* ends _asm */
  798.  
  799. }  /* ends put_pixel */
  800.  
  801.  
  802.  
  803.  
  804.  
  805.  
  806.    /*******************************************
  807.    *
  808.    *   map_64_shades_of_gray()
  809.    *
  810.    *   This function maps 256 DAC registers to
  811.    *   gray shades.  Taken from p. 73 of
  812.    *   Sutty and Blair's text on superVGA
  813.    *
  814.    ********************************************/
  815.  
  816.  
  817. map_64_shades_of_gray()
  818. {
  819.  
  820.    _asm{
  821.       mov ax,0013h ;mod 13h is 320x200x256
  822.       int 10h
  823.  
  824.       mov ah,10h   ; function 10h
  825.       mov al,1bh   ; sub function 1bh
  826.       mov bx,0h    ; first DAC register to change
  827.       mov cx,100h  ; change 256 DAC registers
  828.       int 10h
  829.  
  830.    } /* ends asm */
  831.  
  832. }  /* ends map_64_shades_of_gray */
  833.