home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / demos / GL / snoop / snoop.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  16.4 KB  |  733 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  *    Kurt Akeley
  19.  *    1 March 1988
  20.  *
  21.  *    Magnify the region under the cursor.  Use two mouse buttons to
  22.  *    control display mode and source (do not interpret ID plane info).
  23.  */
  24.  
  25. #include <stdio.h>
  26. #include <gl.h>
  27. #include <device.h>
  28. #include <string.h>
  29.  
  30. /* mode values */
  31. #define RGBMODE    0
  32. #define COLORINDEX 1
  33.  
  34. /* offset used in snoopmode display */
  35. #define OFFSET 5
  36.  
  37. /* steps used by arrow keys */
  38. #define LARGESTEP 16
  39. #define SMALLSTEP 1
  40.  
  41. /* takes argv[0] stripped of path */
  42. char *progname;
  43.  
  44. /* takes return of gversion */
  45. char gv[20];
  46.  
  47. /* initial zoom and window size */
  48. #define INITZOOM 6
  49. #define INITSIZE (INITZOOM * 51)
  50.  
  51. /* initialized modes */
  52. long readsrc = SRC_FRONT;
  53. long toggle = SRC_FRONT;
  54. long dspmode = RGBMODE;
  55. long shademode = FLAT;
  56. long snoopmode = TRUE;
  57. long arrowmode = FALSE;
  58. long Backbuffer = FALSE;
  59. long Cmode = FALSE;
  60. long widauxmode = FALSE;
  61. long zoom = INITZOOM;
  62. long leftshift = FALSE;
  63. long rightshift = FALSE;
  64. long ctrlkey = FALSE;
  65. long blocked = FALSE;
  66.  
  67. /* updated by getorigin() and getsize() whenever window is changed */
  68. long xorigin,yorigin;
  69. long xsize,ysize;
  70. long xll,yll,xur,yur;
  71.  
  72. int rgbmode_avail = TRUE;
  73.  
  74. unsigned long *cbuf;
  75. unsigned short *cbufs;
  76.  
  77. main(argc,argv)
  78. int argc;
  79. char *argv[];
  80. {
  81.     int i;
  82.     int x, y;
  83.     int xmouse,ymouse;
  84.     short dev,val;
  85.     int menu,mval;
  86.     int zoommenu;
  87.     char *t;
  88.  
  89.     if ((t=strrchr(argv[0],'/')) == NULL)
  90.     progname = argv[0];
  91.     else
  92.     progname = t + 1;
  93.     if (argc > 1)
  94.     zoom = atoi(argv[1]);
  95.     gversion(gv);
  96.     prefsize(INITSIZE,INITSIZE);
  97.     winopen(progname);
  98.     stepunit(zoom,zoom);
  99.     winconstraints();
  100.     if (getgdesc(GD_BITS_NORM_DBL_RED) == 0)
  101.     rgbmode_avail = FALSE;
  102.     if (rgbmode_avail) {
  103.     RGBmode();
  104.     doublebuffer();
  105.     } else {
  106.     Cmode = TRUE;
  107.     dspmode = COLORINDEX;
  108.     cmode();
  109.     }
  110.     changetitle();
  111.     gconfig();
  112.     shademodel(GOURAUD);
  113.     qdevice(RIGHTMOUSE);
  114.     qdevice(ESCKEY);
  115.     qdevice(REDRAW);
  116.     qdevice(ONEKEY);
  117.     qdevice(TWOKEY);
  118.     qdevice(THREEKEY);
  119.     qdevice(FOURKEY);
  120.     qdevice(FIVEKEY);
  121.     qdevice(SIXKEY);
  122.     qdevice(SEVENKEY);
  123.     qdevice(EIGHTKEY);
  124.     qdevice(NINEKEY);
  125.     qdevice(ZEROKEY);
  126.     qdevice(LEFTARROWKEY);
  127.     qdevice(RIGHTARROWKEY);
  128.     qdevice(UPARROWKEY);
  129.     qdevice(DOWNARROWKEY);
  130.     qdevice(LEFTSHIFTKEY);
  131.     qdevice(RIGHTSHIFTKEY);
  132.     qdevice(CTRLKEY);
  133.     qdevice(AKEY);
  134.     qdevice(BKEY);
  135.     qdevice(CKEY);
  136.     qdevice(GKEY);
  137.     qdevice(QKEY);
  138.     qdevice(SKEY);
  139.     qdevice(WKEY);
  140.     newwindow();
  141.     makebuf();
  142.     zoommenu = defpup("1 %x1|2 %x2|3 %x3|4 %x4|6 %x6|8 %x8|10 %x10|16 %x16|32 %x32");
  143.     menu = defpup("Options %t");
  144.     addtopup(menu, "Arrow %x100"); setpup(menu, 1, PUP_BOX);
  145.     addtopup(menu, "Backbuffer %x105");
  146.     if (rgbmode_avail) setpup(menu, 2, PUP_BOX);
  147.     else setpup(menu, 2, PUP_GREY);
  148.     addtopup(menu, "RGBmode %x106");
  149.     if (rgbmode_avail) setpup(menu, 3, PUP_CHECK);
  150.     else setpup(menu, 3, PUP_GREY);
  151.     addtopup(menu, "Gouraud %x102"); setpup(menu, 4, PUP_BOX);
  152.     addtopup(menu, "Snoop %x103"); setpup(menu, 5, PUP_CHECK);
  153.     addtopup(menu, "Zoom %m", zoommenu);
  154.     addtopup(menu, "Stop %x101"); setpup(menu, 7, PUP_BOX);
  155.     addtopup(menu, "Exit %x104");
  156.  
  157.     while (1) {
  158.     while (blocked || qtest()) {
  159.         dev = qread(&val);
  160.         switch (dev) {
  161.         case RIGHTMOUSE:
  162.             if (val) {
  163.             switch(dopup(menu)) {
  164.                 case 1:
  165.                 zoom = 1;
  166.                 break;
  167.                 case 2:
  168.                 zoom = 2;
  169.                 break;
  170.                 case 3:
  171.                 zoom = 3;
  172.                 break;
  173.                 case 4:
  174.                 zoom = 4;
  175.                 break;
  176.                 case 6:
  177.                 zoom = 6;
  178.                 break;
  179.                 case 8:
  180.                 zoom = 8;
  181.                 break;
  182.                 case 10:
  183.                 zoom = 10;
  184.                 break;
  185.                 case 16:
  186.                 zoom = 16;
  187.                 break;
  188.                 case 32:
  189.                 zoom = 32;
  190.                 break;
  191.                 case 100:
  192.                 arrowmode = !arrowmode;
  193.                 if (arrowmode)
  194.                     setpup(menu, 1, PUP_CHECK);
  195.                 else setpup(menu, 1, PUP_BOX);
  196.                 break;
  197.                 case 101:
  198.                 blocked = !blocked;
  199.                 if (blocked)
  200.                     setpup(menu, 7, PUP_CHECK);
  201.                 else setpup(menu, 7, PUP_BOX);
  202.                 drawblock();
  203.                 break;
  204.                 case 102:
  205.                 shademode = (shademode==GOURAUD)?FLAT:GOURAUD;
  206.                 if (shademode == GOURAUD)
  207.                     setpup(menu, 4, PUP_CHECK);
  208.                 else setpup(menu, 4, PUP_BOX);
  209.                 break;
  210.                 case 103:
  211.                 snoopmode = !snoopmode;
  212.                 if (snoopmode)
  213.                     setpup(menu, 5, PUP_CHECK);
  214.                 else setpup(menu, 5, PUP_BOX);
  215.                 break;
  216.                 case 104:
  217.                 doexit(0);
  218.                 break;
  219.                 case 105:
  220.                 Backbuffer = !Backbuffer;
  221.                 if (Backbuffer)
  222.                     setpup(menu, 2, PUP_CHECK);
  223.                 else setpup(menu, 2, PUP_BOX);
  224.                 break;
  225.                 case 106:
  226.                 Cmode = !Cmode;
  227.                 if (!Cmode)
  228.                     setpup(menu, 3, PUP_CHECK);
  229.                 else setpup(menu, 3, PUP_BOX);
  230.                 break;
  231.             }
  232.             }
  233.             break;
  234.         case ESCKEY:
  235.             if (!val)
  236.                 doexit(0);
  237.             break;
  238.         case REDRAW:
  239.             newwindow();
  240.             if (blocked)
  241.             drawblock();
  242.             break;
  243.         case AKEY:
  244.             if (val)
  245.             arrowmode = !arrowmode;
  246.             if (arrowmode)
  247.             setpup(menu, 1, PUP_CHECK);
  248.             else setpup(menu, 1, PUP_BOX);
  249.             break;
  250.         case BKEY:
  251.             if (val)
  252.             Backbuffer = !Backbuffer;
  253.             if (Backbuffer)
  254.             setpup(menu, 2, PUP_CHECK);
  255.             else setpup(menu, 2, PUP_BOX);
  256.             break;
  257.         case CKEY:
  258.             if (val)
  259.             Cmode = !Cmode;
  260.             if (!Cmode)
  261.             setpup(menu, 3, PUP_CHECK);
  262.             else setpup(menu, 3, PUP_BOX);
  263.             break;
  264.         case GKEY:
  265.             if (val)
  266.             shademode = (shademode==GOURAUD) ? FLAT : GOURAUD;
  267.             if (shademode == GOURAUD)
  268.             setpup(menu, 4, PUP_CHECK);
  269.             else setpup(menu, 4, PUP_BOX);
  270.             break;
  271.         case QKEY:
  272.             if (val && ctrlkey)
  273.             blocked = FALSE;
  274.             if (blocked)
  275.             setpup(menu, 7, PUP_CHECK);
  276.             else setpup(menu, 7, PUP_BOX);
  277.             break;
  278.         case SKEY:
  279.             if (val) {
  280.             if (ctrlkey) {
  281.                 blocked = TRUE;
  282.                 setpup(menu, 7, PUP_CHECK);
  283.                 drawblock();
  284.             } else
  285.                 snoopmode = !snoopmode;
  286.             if (snoopmode)
  287.                 setpup(menu, 5, PUP_CHECK);
  288.             else setpup(menu, 5, PUP_BOX);
  289.             }
  290.             break;
  291.         case WKEY:
  292.             if (val)
  293.             widauxmode = !widauxmode;
  294.             break;
  295.         case LEFTSHIFTKEY:
  296.             leftshift = val;
  297.             break;
  298.         case RIGHTSHIFTKEY:
  299.             rightshift = val;
  300.             break;
  301.         case CTRLKEY:
  302.             ctrlkey = val;
  303.             break;
  304.         case LEFTARROWKEY:
  305.             if (val) {
  306.             if (leftshift || rightshift)
  307.                 xmouse -= LARGESTEP;
  308.             else
  309.                 xmouse -= SMALLSTEP;
  310.             if (xmouse < 0)
  311.                 xmouse = 0;
  312.             }
  313.             break;
  314.         case RIGHTARROWKEY:
  315.             if (val) {
  316.             if (leftshift || rightshift)
  317.                 xmouse += LARGESTEP;
  318.             else
  319.                 xmouse += SMALLSTEP;
  320.             if (xmouse > getgdesc(GD_XPMAX))
  321.                 xmouse = getgdesc(GD_XPMAX);
  322.             }
  323.             break;
  324.         case DOWNARROWKEY:
  325.             if (val) {
  326.             if (leftshift || rightshift)
  327.                 ymouse -= LARGESTEP;
  328.             else
  329.                 ymouse -= SMALLSTEP;
  330.             if (ymouse < 0)
  331.                 ymouse = 0;
  332.             }
  333.             break;
  334.         case UPARROWKEY:
  335.             if (val) {
  336.             if (leftshift || rightshift)
  337.                 ymouse += LARGESTEP;
  338.             else
  339.                 ymouse += SMALLSTEP;
  340.             if (ymouse > getgdesc(GD_YPMAX))
  341.                 ymouse = getgdesc(GD_YPMAX);
  342.             }
  343.             break;
  344.         case ONEKEY:
  345.             zoom = 1;
  346.             break;
  347.         case TWOKEY:
  348.             zoom = 2;
  349.             break;
  350.         case THREEKEY:
  351.             zoom = 3;
  352.             break;
  353.         case FOURKEY:
  354.             zoom = 4;
  355.             break;
  356.         case FIVEKEY:
  357.             zoom = 5;
  358.             break;
  359.         case SIXKEY:
  360.             zoom = 6;
  361.             break;
  362.         case SEVENKEY:
  363.             zoom = 7;
  364.             break;
  365.         case EIGHTKEY:
  366.             zoom = 8;
  367.             break;
  368.         case NINEKEY:
  369.             zoom = 9;
  370.             break;
  371.         case ZEROKEY:
  372.             zoom = 10;
  373.             break;
  374.         }
  375.         changetitle();
  376.         makebuf();
  377.     }
  378.  
  379.     /* control source buffer with left mouse button */
  380.     if (Backbuffer)
  381.         i = getbutton(LEFTMOUSE) ? SRC_FRONT : SRC_BACK;
  382.     else
  383.         i = getbutton(LEFTMOUSE) ? SRC_BACK : SRC_FRONT;
  384.     if (i != readsrc && rgbmode_avail) {
  385.         readsrc = i;
  386.         changetitle();
  387.     }
  388.     setreadsource(readsrc);
  389.  
  390.     /* control display mode with middle mouse button */
  391.     if (Cmode)
  392.         i = getbutton(MIDDLEMOUSE) ? RGBMODE : COLORINDEX;
  393.     else
  394.         i = getbutton(MIDDLEMOUSE) ? COLORINDEX : RGBMODE;
  395.     if (rgbmode_avail)
  396.         if (i != dspmode) {
  397.         dspmode = i;
  398.         if (dspmode == COLORINDEX)
  399.             cmode();
  400.         else
  401.             RGBmode();
  402.         gconfig();
  403.         changetitle();
  404.         }
  405.  
  406.     /* track mouse and do the zoom */
  407.     if (!arrowmode) {
  408.         xmouse = getvaluator(MOUSEX);
  409.         ymouse = getvaluator(MOUSEY);
  410.     }
  411.     x = xmouse - xorigin;
  412.     y = ymouse - yorigin;
  413.     finish(); /* avoid latency problems */
  414.     if (shademode == FLAT) {
  415.         rectzoom((float)zoom,(float)zoom);
  416.         if (dspmode == RGBMODE && readsrc == SRC_FRONT)
  417.         {
  418.         readdisplay(x+xorigin+xll, y+yorigin+yll,
  419.                 x+xorigin+xur, y+yorigin+yur, cbuf,
  420.               RD_IGNORE_PUP|RD_IGNORE_OVERLAY|RD_IGNORE_UNDERLAY);
  421.         lrectwrite(0, 0, xur-xll, yur-yll, cbuf);
  422.         }
  423.         else
  424.         {
  425.         rectcopy(x+xll,y+yll,x+xur,y+yur,0,0);
  426.         }
  427.     }
  428.     else
  429.         smoothcopy(x+xll,y+yll,x+xur,y+yur);
  430.  
  431.     /* display pixel information if in snoopmode */
  432.     if (snoopmode)
  433.         dosnoop(x,y,xmouse,ymouse);
  434.     swap();
  435.     }
  436. } /* end of main */
  437.  
  438. newwindow() {
  439.     getorigin(&xorigin,&yorigin);
  440.     getsize(&xsize,&ysize);
  441.     viewport(0,xsize-1,0,ysize-1);
  442.     ortho2(-0.5,(float)xsize-0.5,-0.5,(float)ysize-0.5);
  443. }
  444.  
  445. swap() {
  446.     /* swap buffers and toggle the notion of front and back */
  447.     if (rgbmode_avail) {
  448.     swapbuffers();
  449.     toggle = (toggle==SRC_FRONT) ? SRC_BACK : SRC_FRONT;
  450.     }
  451. }
  452.  
  453. setreadsource(src) {
  454.     if (!rgbmode_avail)
  455.     return;
  456.  
  457.     /* set readsource using toggle to avoid swapbuffer problem */
  458.     switch (src) {
  459.     case SRC_FRONT:
  460.     case SRC_BACK:
  461.         if (src == toggle)
  462.         readsource(SRC_FRONT);
  463.         else
  464.         readsource(SRC_BACK);
  465.         break;
  466.     case SRC_ZBUFFER:
  467.         readsource(SRC_ZBUFFER);
  468.         break;
  469.     case SRC_OVER:
  470.         readsource(SRC_OVER);
  471.         break;
  472.     }
  473. }
  474.  
  475. changetitle()
  476. {
  477.     /* change the window title based on mode switches */
  478.     static char oldtitle[100] = "";
  479.     char title[100];
  480.     if (blocked) {
  481.     sprintf(title,"%s - stopped",progname);
  482.     } else {
  483.     sprintf(title,"%s %d%s%s%s%s",progname,zoom,
  484.         (arrowmode==FALSE)?"":" arrow",
  485.         (readsrc==SRC_FRONT)?"":" backbuffer",
  486.         (dspmode==RGBMODE)?"":" cmode",
  487.         (shademode==FLAT)?"":" gouraud");
  488.     }
  489.     if (strcmp(title,oldtitle) != 0)
  490.     wintitle(title);
  491.     strcpy(oldtitle,title);
  492. }
  493.  
  494. makebuf() {
  495.     /* compute source rect size based on window size and zoom factor */
  496.     /* malloc a buffer based on the computed size */
  497.     static size = 0;
  498.     int msize;
  499.     long xsrc,ysrc;
  500.  
  501.     xsrc = xsize / zoom;
  502.     ysrc = ysize / zoom;
  503.     xll = -(xsrc/2);
  504.     xur = xll + xsrc + 1;
  505.     yll = -(ysrc/2);
  506.     yur = yll + ysrc + 1;
  507.     msize = ((xur-xll) + 1) * ((yur-yll) + 1);
  508.     if (msize != size) {
  509.     stepunit(zoom,zoom);
  510.     winconstraints();
  511.     if (size > 0)
  512.         free(cbuf);
  513.     if ((cbuf=(unsigned long*)malloc(msize*4)) == 0) {
  514.         fprintf(stderr,"  ERROR: can't malloc %d longs. abort.\n",msize);
  515.         doexit(1);
  516.     }
  517.     size = msize;
  518.     }
  519. }
  520.  
  521. smoothcopy(xll,yll,xur,yur) {
  522.     /* read specified pixels, then draw gouraud shaded polygons */
  523.     /* assume that matrix and viewport are set up 1-to-1 object-to-pixel */
  524.     register x,y;
  525.     register unsigned long *cp0,*cp1;
  526.     register unsigned short *cp0s,*cp1s;
  527.     long width;
  528.     long height;
  529.     long xfinal,yfinal;
  530.     long vbuf[8];
  531.     float fzoom;
  532.  
  533.     width = xur - xll + 1;
  534.     height = yur - yll + 1;
  535.     xfinal = width - 1;
  536.     yfinal = height - 1;
  537.     if (dspmode == RGBMODE)
  538.     if (readsrc == SRC_FRONT)
  539.         readdisplay(xll+xorigin, yll+yorigin,
  540.             xur+xorigin, yur+yorigin, cbuf,
  541.             RD_IGNORE_PUP|RD_IGNORE_OVERLAY|RD_IGNORE_UNDERLAY);
  542.     else lrectread(xll, yll, xur, yur, cbuf);
  543.     else {
  544.     cbufs = (unsigned short*)cbuf;
  545.     rectread(xll,yll,xur,yur,cbufs);
  546.     maskindex(cbuf,(xur-xll+1)*(yur-yll+1),0xfff);
  547.     }
  548.     pushmatrix();
  549.     fzoom = (float)zoom;
  550.     scale(fzoom,fzoom,fzoom);
  551.     for (y=0; y<yfinal; y++) {
  552.     vbuf[1] = vbuf[3] = y;
  553.     vbuf[5] = vbuf[7] = y+1;
  554.     if (dspmode == RGBMODE) {
  555.         cp0 = &cbuf[y * width];
  556.         cp1 = &cbuf[(y+1) * width + 1];
  557.         for (x=0; x<xfinal; x++) {
  558.         vbuf[0] = vbuf[6] = x;
  559.         vbuf[2] = vbuf[4] = x+1;
  560.         bgnpolygon();
  561.         cpack(*cp0++);
  562.         v2i(vbuf);
  563.         cpack(*cp0);
  564.         v2i(vbuf+2);
  565.         cpack(*cp1--);
  566.         v2i(vbuf+4);
  567.         cpack(*cp1++);
  568.         v2i(vbuf+6);
  569.         endpolygon();
  570.         cp1 += 1;
  571.         }
  572.     }
  573.     else {
  574.         cp0s = &cbufs[y * width];
  575.         cp1s = &cbufs[(y+1) * width + 1];
  576.         for (x=0; x<xfinal; x++) {
  577.         vbuf[0] = vbuf[6] = x;
  578.         vbuf[2] = vbuf[4] = x+1;
  579.         bgnpolygon();
  580.         color(*cp0s++);
  581.         v2i(vbuf);
  582.         color(*cp0s);
  583.         v2i(vbuf+2);
  584.         color(*cp1s--);
  585.         v2i(vbuf+4);
  586.         color(*cp1s++);
  587.         v2i(vbuf+6);
  588.         endpolygon();
  589.         cp1s += 1;
  590.         }
  591.     }
  592.     }
  593.     popmatrix();
  594. }
  595.  
  596. maskindex(buf,size,mask)
  597. unsigned long *buf;    /* long-aligned buffer of shorts */
  598. long size;        /* number of shorts in buffer */
  599. unsigned long mask;
  600. {
  601.     /* mask upper 4 bits of each short - do two at a time */
  602.     register i;
  603.     register unsigned long *p;
  604.     register unsigned long m;
  605.  
  606.     p = buf;
  607.     m = mask | (mask<<16);
  608.     for (i=size/2; i--;)
  609.     *p++ &= m;
  610. }
  611.  
  612. drawblock() {
  613.     /* draw routine called when blocked */
  614.     if (Cmode)
  615.     color(0x19);
  616.     else
  617.     cpack(0xbfbfbf);
  618.     clear();
  619.     swap();
  620. }
  621.  
  622. doexit(i) {
  623.     gexit();
  624.     exit(i);
  625. }
  626.  
  627. dosnoop(x,y,xmouse,ymouse) {
  628.     unsigned long front,back,z,wid,aux,pup;
  629.     char s[100];
  630.     setreadsource(SRC_FRONT);
  631.     lrectread(x,y,x,y,&front);
  632.     if (rgbmode_avail) {
  633.     setreadsource(SRC_BACK);
  634.     lrectread(x,y,x,y,&back);
  635.     setreadsource(SRC_ZBUFFER);
  636.     lrectread(x,y,x,y,&z);
  637.         /* GAB -- mask Z to 24 bits to fix problems on VGX.
  638.          * This code should be taught about VGX's stencil bitplanes
  639.          * eventually.
  640.          */
  641.         z = z & 0xFFFFFF;
  642.     }
  643.  
  644.     if (widauxmode) {
  645.     readsource(SRC_AUTO);        /* this call required for PI to work */
  646.     drawmode(PUPDRAW);
  647.     lrectread(x,y,x,y,&pup);
  648.     pup &= 3;
  649.     drawmode(OVERDRAW);
  650.     lrectread(x,y,x,y,&aux);
  651.     aux &= 0xf;
  652.     drawmode(1000);
  653.     lrectread(x,y,x,y,&wid);
  654.     wid &= 0xf;
  655.     drawmode(NORMALDRAW);
  656.     }
  657.     if (dspmode == RGBMODE) {
  658.     cpack(0x000000);
  659.     if (widauxmode)
  660.         if (strncmp(gv, "GL4DGT", strlen("GL4DGT")) == 0)
  661.         sprintf(s,"%03x %03x %08x %08x %x %x %x",
  662.             xmouse,ymouse,front,back,(aux>>2)&3,aux&3,wid);
  663.         else
  664.         sprintf(s,"%03x %03x %08x %08x %x %x %x",
  665.             xmouse,ymouse,front,back,pup,aux,wid);
  666.     else
  667.         sprintf(s,"%03x %03x %08x %08x %06x",
  668.         xmouse,ymouse,front,back,z);
  669.     rectfi(OFFSET,OFFSET,
  670.         OFFSET+strwidth(s)+6,OFFSET+2*getheight()+4);
  671.     cpack(0xFFFFFF);
  672.     recti(OFFSET,OFFSET,
  673.         OFFSET+strwidth(s)+6,OFFSET+2*getheight()+4);
  674.     cmov2i(OFFSET+5,OFFSET+5);
  675.     charstr(s);
  676.     if (widauxmode)
  677.         sprintf(s," X   Y    FRONT    BACK   P O W");
  678.     else
  679.         sprintf(s," X   Y    FRONT    BACK      Z");
  680.     cmov2i(OFFSET+5,OFFSET+5+getheight());
  681.     charstr(s);
  682.     /* invert color of outline of selected pixel */
  683.     if (shademode == FLAT) {
  684.         long tmp;
  685.         tmp = (readsrc==SRC_FRONT) ? front : back;
  686.         RGBcolor(tmp&0x80     ? 0 : 0xff,
  687.              tmp&0x8000   ? 0 : 0xff,
  688.              tmp&0x800000 ? 0 : 0xff);
  689.         recti(-xll*zoom,-yll*zoom,
  690.         -xll*zoom+zoom-1,-yll*zoom+zoom-1);
  691.     }
  692.      } else {
  693.     color(BLACK);
  694.     if (!rgbmode_avail) {
  695.         sprintf(s,"%03x %03x %03x",
  696.         xmouse,ymouse,front&0xFFF);
  697.     }
  698.     else if (widauxmode) {
  699.         if (strncmp(gv, "GL4DGT", strlen("GL4DGT")) == 0)
  700.         sprintf(s,"%03x %03x %03x %03x %06x %x %x %x",
  701.           xmouse,ymouse,front&0xFFF,back&0xFFF,z,(aux>>2)&3,aux&3,wid);
  702.         else
  703.         sprintf(s,"%03x %03x %03x %03x %06x %x %x %x",
  704.           xmouse,ymouse,front&0xFFF,back&0xFFF,z,pup,aux,wid);
  705.     }
  706.     else {
  707.         sprintf(s,"%03x %03x %03x %03x %06x",
  708.         xmouse,ymouse,front&0xFFF,back&0xFFF,z);
  709.     }
  710.     rectfi(OFFSET,OFFSET,
  711.         OFFSET+strwidth(s)+6,OFFSET+2*getheight()+4);
  712.     color(WHITE);
  713.     recti(OFFSET,OFFSET,
  714.         OFFSET+strwidth(s)+6,OFFSET+2*getheight()+4);
  715.     cmov2i(OFFSET+5,OFFSET+5);
  716.     charstr(s);
  717.     if (!rgbmode_avail)
  718.         sprintf(s," X   Y  IDX");
  719.     else if (widauxmode)
  720.         sprintf(s," X   Y  FNT BCK    Z   P O W");
  721.     else
  722.         sprintf(s," X   Y  FNT BCK    Z");
  723.     cmov2i(OFFSET+5,OFFSET+5+getheight());
  724.     charstr(s);
  725.     if (shademode == FLAT) {
  726.         color((readsrc==SRC_FRONT)
  727.         ? (((front&0xFFF)==7)?0:7) :(((back&0xFFF)==7)?0:7));
  728.         recti(-xll*zoom,-yll*zoom,
  729.         -xll*zoom+zoom-1,-yll*zoom+zoom-1);
  730.     }
  731.     }
  732. }
  733.