home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xibm.zip / ibm8514 / brcDLine.c < prev    next >
C/C++ Source or Header  |  1991-09-20  |  19KB  |  882 lines

  1. /*
  2.  * $Id: brcDLine.c,v 1.1 1991/09/20 19:10:24 mtranle Exp $
  3.  *
  4.  * Copyright IBM Corporation 1987,1990
  5.  *
  6.  * All Rights Reserved
  7.  *
  8.  * Permission to use, copy, modify, and distribute this software and its
  9.  * documentation for any purpose and without fee is hereby granted,
  10.  * provided that the above copyright notice appear in all copies and that 
  11.  * both that copyright notice and this permission notice appear in
  12.  * supporting documentation, and that the name of IBM not be
  13.  * used in advertising or publicity pertaining to distribution of the
  14.  * software without specific, written prior permission.
  15.  *
  16.  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  17.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
  18.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  19.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  20.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  21.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  22.  * SOFTWARE.
  23.  *
  24. */
  25. /*
  26.  * PRPQ 5799-PFF (C) COPYRIGHT IBM CORPORATION 1987,1990
  27.  * LICENSED MATERIALS - PROPERTY OF IBM
  28.  * REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
  29.  */
  30. /*
  31.  *  Hardware interface routines for IBM 8514/A adapter for
  32.  *  X.11 server(s) on IBM equipment.
  33.  *
  34.  */
  35.  
  36. /***********************************************************
  37. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  38. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  39.  
  40.                         All Rights Reserved
  41.  
  42. Permission to use, copy, modify, and distribute this software and its 
  43. documentation for any purpose and without fee is hereby granted, 
  44. provided that the above copyright notice appear in all copies and that
  45. both that copyright notice and this permission notice appear in 
  46. supporting documentation, and that the names of Digital or MIT not be
  47. used in advertising or publicity pertaining to distribution of the
  48. software without specific, written prior permission.  
  49.  
  50. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  51. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  52. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  53. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  54. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  55. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  56. SOFTWARE.
  57.  
  58. ******************************************************************/
  59.  
  60. #include "X.h"
  61.  
  62. #include "misc.h"
  63. #include "gcstruct.h"
  64. #include "gc.h"
  65. #include "pixmap.h"
  66. #include "window.h"
  67. #include "windowstr.h"
  68. #include "pixmapstr.h"
  69. #include "regionstr.h"
  70. #include "scrnintstr.h"
  71. #include "mistruct.h"
  72.  
  73. #include "mfb.h"
  74. #include "ppc.h"
  75. /* #include "ppcUtils.h" */
  76.  
  77. #include "x8514.h"
  78.  
  79. /* ibm8514 dashed line
  80.  *
  81.  */
  82.  
  83. extern void ibm8514BresDash();
  84. extern void ibm8514HorzDash();
  85. extern void ibm8514VertDash();
  86. extern void ibm8514BresLineStart();
  87. extern void ibm8514BresLineCont();
  88. extern void ibm8514BresLineStop();
  89.  
  90. extern void ibm8514HorzDashPat();
  91. extern void ibm8514BresDashPat();
  92.  
  93. #define X_AXIS 0
  94.  
  95. extern int mergexlate[];
  96. extern int ibm8514cursorSemaphore ;
  97.  
  98. /* NOTE
  99.    maybe OUTCODES should take box (the one that includes all
  100. edges) instead of pbox (the standard no-right-or-lower-edge one)?
  101. */
  102. #define OUTCODES(result, x, y, pbox) \
  103.     if (x < pbox->x1) \
  104.     result |= OUT_LEFT; \
  105.     else if (x >= pbox->x2) \
  106.     result |= OUT_RIGHT; \
  107.     if (y < pbox->y1) \
  108.     result |= OUT_ABOVE; \
  109.     else if (y >= pbox->y2) \
  110.     result |= OUT_BELOW;
  111.  
  112. void
  113. ibm8514ZeroDash(pDrawable, pGC, mode, npt, pptInit)
  114.     DrawablePtr pDrawable;
  115.     GCPtr pGC;
  116.     int mode;        /* Origin or Previous */
  117.     int npt;        /* number of points */
  118.     DDXPointPtr pptInit;
  119. {
  120.     int nboxInit;
  121.     register int nbox;
  122.     BoxPtr pboxInit;
  123.     register BoxPtr pbox;
  124.     int nptTmp;
  125.     DDXPointPtr ppt;        /* pointer to list of translated points */
  126.  
  127.     DDXPointRec pt1;
  128.     DDXPointRec pt2;
  129.  
  130.     unsigned int oc1;        /* outcode of point 1 */
  131.     unsigned int oc2;        /* outcode of point 2 */
  132.  
  133.     int xorg, yorg;        /* origin of window */
  134.  
  135.     int adx;        /* abs values of dx and dy */
  136.     int ady;
  137.     int signdx;        /* sign of dx and dy */
  138.     int signdy;
  139.     int e, e1, e2;        /* bresenham error and increments */
  140.     int len;            /* length of segment */
  141.  
  142.     int clipDone;        /* flag for clipping loop */
  143.     DDXPointRec pt1Orig;    /* unclipped start point */
  144.     DDXPointRec pt2Orig;    /* unclipped end point */
  145.     int err;            /* modified bresenham error term */
  146.     int clip1, clip2;        /* clippedness of the endpoints */
  147.  
  148.     int alu ;            /* Screen Raster-Op value */
  149.     long fg ;            /* foreground Pixel value */
  150.     long bg ;            /* background Pixel value */
  151.     unsigned long pm ;            /* plane mask */
  152.     register int tmp;
  153.     int x1, x2, y1, y2;
  154.                 /* a bunch of temporaries */
  155.     void (* scrnFunc)();
  156. #ifdef notyet
  157.     int hardware_pat =
  158.     ((ibm8514GCPrivPtr)(pGC->devPrivates))->flags & HARDWARE_PAT;
  159. #endif
  160.  
  161.     if ( pDrawable->type != DRAWABLE_WINDOW )
  162.     {
  163.     ErrorF("ibm8514ZeroDash: not a window\n");
  164.     return;
  165.     }
  166.  
  167.     switch ( ( (ppcPrivGC *) pGC->devPrivates )->colorRrop.fillStyle ) {
  168.     case FillStippled :
  169.     case FillSolid : /* Can Use Optimized Color Raster-Op */
  170.         alu = ( (ppcPrivGC *) pGC->devPrivates )->colorRrop.alu ;
  171.         pm = ( (ppcPrivGC *) pGC->devPrivates )->colorRrop.planemask ;
  172.         if(pGC->lineStyle == LineOnOffDash){
  173.         ibm8514ClearQueue(1);
  174.         SETCOL1( ( (ppcPrivGC *) pGC->devPrivates )->colorRrop.fgPixel) ;
  175.         } else {
  176.             fg = ( (ppcPrivGC *) pGC->devPrivates )->colorRrop.fgPixel ;
  177.             bg = ( (ppcPrivGC *) pGC->devPrivates )->colorRrop.bgPixel ;
  178.         }
  179.         break ;
  180.     case FillOpaqueStippled :
  181.     case FillTiled : /* Can't Use Optimized Color Raster-Op */
  182.         alu = pGC->alu ;
  183.         pm = pGC->planemask ;
  184.         if(pGC->lineStyle == LineOnOffDash){
  185.         ibm8514ClearQueue(1);
  186.         SETCOL1(pGC->fgPixel);
  187.         } else {
  188.             fg = pGC->fgPixel ;
  189.             bg = pGC->bgPixel ;
  190.         }
  191.         break ;
  192.     }
  193.     if ( alu == GXnoop )
  194.     return ;
  195.  
  196.     pboxInit = REGION_RECTS(((mfbPrivGC *)(pGC->devPrivates))->pCompositeClip);
  197.     nboxInit = REGION_NUMRECTS(((mfbPrivGC *)(pGC->devPrivates))->pCompositeClip);
  198.  
  199.     xorg = pDrawable->x;
  200.     yorg = pDrawable->y;
  201.  
  202.     /* translate the point list */
  203.     ppt = pptInit;
  204.     nptTmp = npt;
  205.     if (mode == CoordModeOrigin)
  206.     {
  207.     while(nptTmp--)
  208.     {
  209.         ppt->x += xorg;
  210.         ppt++->y += yorg;
  211.     }
  212.     }
  213.     else
  214.     {
  215.     ppt->x += xorg;
  216.     ppt->y += yorg;
  217.     nptTmp--;
  218.     while ( nptTmp-- )
  219.     {
  220.         ppt++;
  221.         ppt->x += (ppt-1)->x;
  222.         ppt->y += (ppt-1)->y;
  223.     }
  224.     }
  225.  
  226.     ppt = pptInit;
  227.     while ( --npt )
  228.     {
  229.     nbox = nboxInit;
  230.     pbox = pboxInit;
  231.  
  232.     pt1 = *ppt++;
  233.     pt2 = *ppt;
  234.  
  235.     if ( !( adx = ( pt2.x - pt1.x ) ) )
  236.     {
  237.         /* make the line go top to bottom of screen, keeping
  238.            endpoint semantics
  239.         */
  240.         if ( pt1.y > pt2.y )
  241.         {
  242.         tmp = pt2.y;
  243.         pt2.y = pt1.y + 1;
  244.         pt1.y = tmp + 1;
  245.         }
  246.  
  247.         /* get to first band that might contain part of line */
  248.         while ((nbox) && (pbox->y2 <= pt1.y))
  249.         {
  250.         pbox++;
  251.         nbox--;
  252.         }
  253.  
  254.         if ( nbox )
  255.         {
  256.         /* stop when lower edge of box is beyond end of line */
  257.         while ( ( nbox ) && ( pt2.y >= pbox->y1 ) ) {
  258.             if ( ( pt1.x >= pbox->x1 ) && ( pt1.x < pbox->x2 ) ) {
  259.             /* this box has part of the line in it */
  260.             if ( ( y1 = MAX( pt1.y, pbox->y1 ) )
  261.               != ( y2 = MIN( pt2.y, pbox->y2 ) ) ) {
  262.                 ibm8514VertDash( pGC, fg, bg,
  263.                 alu, pm, pt1.x, y1, y2 - y1 ) ;
  264.             }
  265.             }
  266.             nbox--;
  267.             pbox++;
  268.         }
  269.         }
  270.  
  271.     }
  272.     else if ( !( ady = ( pt2.y - pt1.y ) ) )
  273.     {
  274.         /* force line from left to right, keeping
  275.            endpoint semantics
  276.         */
  277.         if (pt1.x > pt2.x)
  278.         {
  279.         tmp = pt2.x;
  280.         pt2.x = pt1.x + 1;
  281.         pt1.x = tmp + 1;
  282.         }
  283.  
  284.         /* find the correct band */
  285.         while( nbox && (pbox->y2 <= pt1.y))
  286.         {
  287.         pbox++;
  288.         nbox--;
  289.         }
  290.  
  291.         /* try to draw the line, if we haven't gone beyond it */
  292.         if ((nbox) && (pbox->y1 <= pt1.y))
  293.         {
  294.         /* when we leave this band, we're done */
  295.         tmp = pbox->y1;
  296.         while((nbox) && (pbox->y1 == tmp))
  297.         {
  298.             if (pbox->x2 <= pt1.x)
  299.             {
  300.             /* skip boxes until one might contain start point */
  301.             nbox--;
  302.             pbox++;
  303.             continue;
  304.             }
  305.  
  306.             /* stop if left of box is beyond right of line */
  307.             if (pbox->x1 >= pt2.x)
  308.             {
  309.             nbox = 0;
  310.             continue;
  311.             }
  312.             if ( ( x1 = MAX( pt1.x, pbox->x1 ) )
  313.               != ( x2 = MIN( pt2.x, pbox->x2 ) ) ) {
  314. #ifdef notyet
  315.                 if(hardware_pat)
  316.                     ibm8514HorzDashPat( pGC, fg, bg,
  317.                     alu, pm, x1, pt1.y, x2 - x1 ) ;
  318.                 else
  319. #endif
  320.                     ibm8514HorzDash( pGC, fg, bg,
  321.                     alu, pm, x1, pt1.y, x2 - x1 ) ;
  322.             }
  323.             nbox--;
  324.             pbox++;
  325.         }
  326.         }
  327.     }
  328.     else    /* sloped line */
  329.     {
  330.         signdx = sign(adx);
  331.         signdy = sign(ady);
  332.         adx = ABS(adx);
  333.         ady = ABS(ady);
  334.  
  335.         if (adx > ady)
  336.         {
  337.         e1 = ady*2;
  338.         e2 = e1 - 2*adx;
  339.         e = e1 - adx;
  340.  
  341.         }
  342.         else
  343.         {
  344.         e1 = adx*2;
  345.         e2 = e1 - 2*ady;
  346.         e = e1 - ady;
  347.         }
  348.  
  349.         /* we have bresenham parameters and two points.
  350.            all we have to do now is clip and draw.
  351.         */
  352.  
  353.         pt1Orig = pt1;
  354.         pt2Orig = pt2;
  355.  
  356.         while(nbox--)
  357.         {
  358.  
  359.         BoxRec box;
  360.  
  361.         pt1 = pt1Orig;
  362.         pt2 = pt2Orig;
  363.         clipDone = 0;
  364.         box.x1 = pbox->x1;
  365.         box.y1 = pbox->y1;
  366.         box.x2 = pbox->x2-1;
  367.         box.y2 = pbox->y2-1;
  368.         clip1 = 0;
  369.         clip2 = 0;
  370.  
  371.         oc1 = 0;
  372.         oc2 = 0;
  373.         OUTCODES(oc1, pt1.x, pt1.y, pbox);
  374.         OUTCODES(oc2, pt2.x, pt2.y, pbox);
  375.  
  376.         if (oc1 & oc2)
  377.             clipDone = -1;
  378.         else if ((oc1 | oc2) == 0)
  379.             clipDone = 1;
  380.         else /* have to clip */
  381.             clipDone = mfbClipLine(pbox, box,
  382.                        &pt1Orig, &pt1, &pt2, 
  383.                        adx, ady, signdx, signdy,
  384.                        ( ( adx > ady ) ? X_AXIS : Y_AXIS ),
  385.                        &clip1, &clip2);
  386.  
  387.         if (clipDone == -1)
  388.         {
  389.             pbox++;
  390.         }
  391.         else
  392.         {
  393.             if ( adx > ady )
  394.             len = ABS(pt2.x - pt1.x);
  395.             else
  396.             len = ABS(pt2.y - pt1.y);
  397.  
  398.             len += (clip2 != 0);
  399.             if (len)
  400.             {
  401.             /* unwind bresenham error term to first point */
  402.             if (clip1)
  403.             {
  404.                 if ( adx > ady )
  405.                     err = e
  406.                     + ( ABS( pt1.y - pt1Orig.y ) * ( e2 - e1 ) )
  407.                     + ( ABS( pt1.x - pt1Orig.x ) * e1 ) ;
  408.                 else
  409.                     err = e
  410.                     + ( ABS( pt1.x - pt1Orig.x ) * ( e2 - e1 ) )
  411.                     + ( ABS( pt1.y - pt1Orig.y ) * e1 ) ;
  412.             }
  413.             else
  414.                 err = e;
  415.             ibm8514BresDash( pGC, fg, bg, alu, pm,
  416.                       signdx, signdy,
  417.                       ( ( adx > ady ) ? X_AXIS : Y_AXIS ),
  418.                       pt1.x, pt1.y, err, e1, e2, len ) ;
  419.             }
  420.  
  421.             /* if segment is unclipped, skip remaining rectangles */
  422.             if (!(clip1 || clip2))
  423.             break;
  424.             else
  425.             pbox++;
  426.         }
  427.         } /* while (nbox--) */
  428.     } /* sloped line */
  429.     } /* while (nline--) */
  430.  
  431.     /* paint the last point if the end style isn't CapNotLast.
  432.        (Assume that a projecting, butt, or round cap that is one
  433.         pixel wide is the same as the single pixel of the endpoint.)
  434.     */
  435.  
  436.     if ((pGC->capStyle != CapNotLast) &&
  437.     ((ppt->x != pptInit->x) ||
  438.      (ppt->y != pptInit->y)))
  439.     {
  440.     nbox = nboxInit;
  441.     pbox = pboxInit;
  442.     scrnFunc =
  443.      ( (ppcScrnPriv *)(pDrawable->pScreen->devPrivate))->solidFill ;
  444.     while (nbox--)
  445.     {
  446.         if ((ppt->x >= pbox->x1) &&
  447.         (ppt->y >= pbox->y1) &&
  448.         (ppt->x <  pbox->x2) &&
  449.         (ppt->y <  pbox->y2))
  450.         {
  451.         (* scrnFunc)( fg, alu, pm, ppt->x, ppt->y, 1, 1 ) ;
  452.         break;
  453.         }
  454.         else
  455.         pbox++;
  456.     }
  457.     }
  458.     return ;
  459. }
  460.  
  461. void
  462. ibm8514VertDash(pGC, fg, bg, alu, pm, x, y, len)
  463. GCPtr pGC;
  464. long fg;
  465. long bg;
  466. int alu;
  467. int pm;
  468. int x;
  469. int y;
  470. int len;
  471. {
  472.     int talu = alu;
  473.     long color = fg;
  474.     int nseg;            /* number of dashed segments */
  475.     miDashPtr pdash;        /* list of dashes */
  476.     miDashPtr pdashInit;
  477.     DDXPointRec pt[2];
  478.     DDXPointRec pt1, pt2;
  479.     int lx;
  480.  
  481.     pt[0].x = x;
  482.     pt[0].y = y;
  483.     pt[1].x = x;    
  484.     pt[1].y = y + len;
  485.  
  486.     pdashInit = pdash = miDashLine( 2, pt, pGC->numInDashList,
  487.         pGC->dash, pGC->dashOffset, &nseg ) ;
  488.  
  489.     ibm8514ClearQueue(1);
  490.     PLNWENBL(pm);
  491.  
  492.     for(; nseg--; pdash++){
  493.         ibm8514ClearQueue(2);
  494.         if(pGC->lineStyle == LineOnOffDash){
  495.             if(pdash->which == ODD_DASH)
  496.                 SETFN1(FNCOLOR1,mergexlate[alu]);
  497.             else 
  498.                 SETFN1(FNCOLOR1,mergexlate[GXnoop]);
  499.         } else {
  500.             if(pdash->which == EVEN_DASH)
  501.                 SETCOL1(fg);
  502.             else
  503.                 SETCOL1(bg);
  504.         }
  505.  
  506.         pt1 = pdash->pt;
  507.         pt2 = (pdash+1)->pt;
  508.  
  509.         if (lx = (pt2.y - pt1.y))  /* SIC */
  510.             {
  511.             ibm8514ClearQueue(4);
  512.             SETLX(lx);
  513.             SETX0(pt1.x);
  514.             SETY0(pt1.y);
  515.             COMMAND(0x20df);
  516.             }
  517.     }
  518.     Xfree(pdashInit);
  519. }
  520.  
  521. #ifdef notyet
  522. void
  523. ibm8514HorzDashPat(pGC, fg, bg, alu, pm, x, y, len)
  524. GCPtr pGC;
  525. long fg;
  526. long bg;
  527. int alu;
  528. unsigned long pm;
  529. int x;
  530. int y;
  531. int len;
  532. {
  533.     short pattern = ;
  534.  
  535.     barrel_shift8(pattern, x % 8);
  536.     ibm8514ATRNotBusy();
  537.  
  538.     ibm8514CheckQueue(4);
  539.     SETMODE(M_PATTS);
  540.     SETPAT0(pattern >> 3);
  541.     SETPAT1(pattern << 1);
  542.     PLNWENBL(pm);
  543.  
  544.     ibm8514CheckQueue(4);
  545.     if(pGC->lineStyle == LineOnOffDash){
  546.         SETCOL1(fg);
  547.         SETFN0(FNCOLOR0,mergexlate[GXnoop]);
  548.         SETFN1(FNCOLOR1,mergexlate[alu]);
  549.     } else {
  550.         SETCOL0(bg);
  551.         SETCOL1(fg);
  552.         SETFN0(FNCOLOR0,mergexlate[alu]);
  553.         SETFN1(FNCOLOR1,mergexlate[alu]);
  554.     }
  555.     ibm8514HorzLine(color, alu, pm,
  556.         x, y, len);
  557. }
  558. #endif
  559.  
  560. void
  561. ibm8514HorzDash(pGC, fg, bg, alu, pm, x, y, len)
  562. GCPtr pGC;
  563. long fg;
  564. long bg;
  565. int alu;
  566. unsigned long pm;
  567. int x;
  568. int y;
  569. int len;
  570. {
  571.     int xalu = mergexlate[alu];
  572.     long color = fg;
  573.     int nseg;            /* number of dashed segments */
  574.     miDashPtr pdash;        /* list of dashes */
  575.     miDashPtr pdashInit;
  576.     DDXPointRec pt[2];
  577.  
  578.     pt[0].x = x;
  579.     pt[0].y = y;
  580.     pt[1].x = x + len;    
  581.     pt[1].y = y;
  582.  
  583.     pdashInit = pdash = miDashLine( 2, pt, pGC->numInDashList,
  584.                    pGC->dash, pGC->dashOffset, &nseg ) ;
  585.  
  586.     ibm8514ClearQueue(1);
  587.     PLNWENBL(pm);
  588.  
  589.     if (pGC->lineStyle == LineOnOffDash)
  590.     {
  591.     int  i = 0;
  592.  
  593.     while (i < nseg)
  594.     {
  595.         if (pdash[i].which == ODD_DASH)
  596.         {
  597.         int lx;
  598.         int x1   = pdash[i].pt.x;
  599.         int y1   = pdash[i].pt.y;
  600.  
  601.         if ((lx = (pdash[++i].pt.x - x1))) /* SIC */
  602.         {
  603.             ibm8514ATRNotBusy;
  604.             ibm8514CheckQueue(6);
  605.             SETFN1(FNCOLOR1,xalu);
  606.             SETCOL1(fg);
  607.             SETLX(lx);
  608.             SETX0(x1);
  609.             SETY0(y1);
  610.             COMMAND(0x201f);
  611.         }
  612.         }
  613.         else
  614.         i++;
  615.     }
  616.     }
  617.     else
  618.     {
  619.     int i = 0;
  620.  
  621.     while (i < nseg)
  622.     {
  623.         int  lx;
  624.         long color = (pdash[i].which == EVEN_DASH) ? fg : bg;
  625.         int  x1    = pdash[i].pt.x;
  626.         int  y1    = pdash[i].pt.y;
  627.  
  628.         if (lx = (pdash[++i].pt.x - x1)) /* SIC */
  629.         {
  630.         ibm8514ATRNotBusy;
  631.         ibm8514CheckQueue(6);
  632.         SETFN1(FNCOLOR1,xalu);
  633.         SETCOL1(color);
  634.         SETLX(lx);
  635.         SETX0(x1);
  636.         SETY0(y1);
  637.         COMMAND(0x201f);
  638.         }
  639.     }
  640.     }
  641.  
  642.     Xfree(pdashInit);
  643. }
  644.  
  645. void
  646. ibm8514BresDash( pGC, fg, bg, alu, pm, sdx, sdy, axis, x, y, et, e1, e2, len )
  647. GCPtr pGC;
  648. unsigned long int fg, bg;
  649. int alu ;
  650. unsigned long int pm ;
  651. int sdx, sdy, axis, x, y, et, e1, e2, len;
  652. {
  653.     int        nseg;        /* number of dashed segments */
  654.     miDashPtr    pdash;        /* list of dashes */
  655.     miDashPtr    pdashInit;
  656.     DDXPointRec    pt[2];
  657.     unsigned short command;
  658.     int         xalu = mergexlate[xalu];
  659.  
  660.     pt[0].x = x;
  661.     pt[0].y = y;
  662.     pt[1].x = x + len;    
  663.     pt[1].y = y + len;
  664.  
  665.     pdashInit = pdash = miDashLine( 2, pt, pGC->numInDashList,
  666.                    pGC->dash, pGC->dashOffset, &nseg ) ;
  667.  
  668.     ibm8514ClearQueue(1);
  669.     PLNWENBL(pm);
  670.  
  671.     if (axis==X_AXIS)
  672.     command = 0x2017;    /* draw bres. line on X, W, LPN, */
  673.     else
  674.     command = 0x2057;    /* same, on Y */
  675.     if (sdx > 0)
  676.     command |= 0x0020;
  677.     if (sdy > 0)
  678.     command |= 0x0080;
  679.  
  680.     if (pGC->lineStyle == LineOnOffDash)
  681.     {
  682.     if (axis == X_AXIS)
  683.     {
  684.         int  i=0;
  685.         while(i < nseg)
  686.         {
  687.         if (pdash[i].which == ODD_DASH)
  688.         {
  689.             int x1   = pdash[i].pt.x;
  690.             int x2, xlen;
  691.  
  692.             if (pdash[i].newLine)
  693.             ibm8514BresLineStart (fg, alu, pm,
  694.                           sdx, sdy, axis,
  695.                           x1, pdash[i].pt.y,
  696.                           et, e1, e2, len);
  697.             x2  = pdash[++i].pt.x;
  698.             if ((xlen = ABS(x2 - x1)) > 0)
  699.             {
  700.             ibm8514ATRNotBusy;
  701.             ibm8514CheckQueue(4);
  702.             SETCOL1(fg);
  703.             SETFN1(FNCOLOR1,xalu);
  704.             SETLX(xlen);
  705.             COMMAND(command);
  706.             }
  707.         }
  708.         else
  709.             i++;
  710.         }
  711.     }
  712.     else
  713.     {
  714.         int  i=0;
  715.         while (i < nseg)
  716.         {
  717.         if (pdash[i].which == ODD_DASH)
  718.         {
  719.             int y1   = pdash[i].pt.y;
  720.             int y2, xlen;
  721.  
  722.             if (pdash[i].newLine)
  723.             ibm8514BresLineStart (fg, alu, pm,
  724.                           sdx, sdy, axis,
  725.                           pdash[i].pt.x, y1,
  726.                           et, e1, e2, len);
  727.             y2  = pdash[++i].pt.y;
  728.             if ((xlen = ABS(y2 - y1)) > 0)
  729.             {
  730.             ibm8514ATRNotBusy;
  731.             ibm8514CheckQueue(4);
  732.             SETCOL1(fg);
  733.             SETFN1(FNCOLOR1,xalu);
  734.             SETLX(xlen);
  735.             COMMAND(command);
  736.             }
  737.         }
  738.         else
  739.             i++;
  740.         }
  741.     }
  742.     }
  743.     else
  744.     {
  745.     if (axis == X_AXIS)
  746.     {
  747.         int i=0;
  748.         while (i<nseg)
  749.         {
  750.         long color = (pdash[i].which == EVEN_DASH) ? fg : bg;
  751.         int x1   = pdash[i].pt.x;
  752.         int x2, xlen;
  753.  
  754.         if (pdash[i].newLine)
  755.             ibm8514BresLineStart (color, alu, pm,
  756.                       sdx, sdy, axis,
  757.                       x1, pdash[i].pt.y,
  758.                       et, e1, e2, len);
  759.         x2  = pdash[++i].pt.x;
  760.         if ((xlen = ABS(x2 - x1)) > 0)
  761.         {
  762.             ibm8514ATRNotBusy;
  763.             ibm8514CheckQueue(4);
  764.             SETCOL1(color);
  765.             SETFN1(FNCOLOR1,xalu);
  766.             SETLX(xlen);
  767.             COMMAND(command);
  768.         }
  769.         }
  770.     }
  771.     else
  772.     {
  773.         int i=0;
  774.         while (i<nseg)
  775.         {
  776.         long color = (pdash[i].which == EVEN_DASH) ? fg : bg;
  777.         int y1   = pdash[i].pt.y;
  778.         int y2, xlen;
  779.  
  780.         if (pdash[i].newLine)
  781.             ibm8514BresLineStart (color, alu, pm,
  782.                       sdx, sdy, axis,
  783.                       pdash[i].pt.x, y1,
  784.                       et, e1, e2, len);
  785.         y2  = pdash[++i].pt.y;
  786.         if ((xlen = ABS(y2 - y1))> 0)
  787.         {
  788.             ibm8514ATRNotBusy;
  789.             ibm8514CheckQueue(4);
  790.             SETCOL1(color);
  791.             SETFN1(FNCOLOR1,xalu);
  792.             SETLX(xlen);
  793.             COMMAND(command);
  794.         }
  795.         }
  796.     }
  797.     }
  798.     ibm8514BresLineStop();
  799.     Xfree(pdashInit);
  800. }
  801.  
  802. static int bres_saved;
  803.  
  804. void
  805. ibm8514BresLineStart( color, alu, pm, sdx, sdy, axis, x, y, et, e1, e2, len)
  806. unsigned long int color ;
  807. int alu ;
  808. unsigned long int pm ;
  809. int sdx, sdy, axis, x, y, et, e1, e2, len;
  810. {
  811.     int cx, cy;
  812.  
  813.     if ( len <= 0 )
  814.         return;
  815.     if (sdx == -1)
  816.             cx = x - len;
  817.     else
  818.             cx = x;
  819.     if (sdy == -1)
  820.             cy = y - len;
  821.     else
  822.             cy = y;
  823.     bres_saved =
  824.         !ibm8514cursorSemaphore && ibm8514CheckCursor( cx,cy,len,len ) ;
  825.  
  826.     ibm8514ATRNotBusy;
  827.     ibm8514CheckQueue(6);
  828.     PLNWENBL(pm);
  829.     SETET(et); 
  830.     SETK1(e1); 
  831.     SETK2(e2); 
  832.     SETX0(x);
  833.     SETY0(y);
  834.  
  835.     return;
  836. }
  837.  
  838. void
  839. ibm8514BresLineCont( color, alu, pm, sdx, sdy, axis, len)
  840. unsigned long int color ;
  841. int alu ;
  842. unsigned long int pm ;
  843. int sdx, sdy, axis, len;
  844. {
  845.     unsigned short command;
  846.  
  847.     if ( len <= 0 )
  848.         return;
  849.  
  850.     ibm8514ATRNotBusy;
  851.     ibm8514CheckQueue(4);
  852.     SETCOL1(color);
  853.     SETFN1(FNCOLOR1,mergexlate[alu]);
  854.  
  855.     SETLX(len); /* going to use LAST PEL NULL in Line command to brecon */
  856.  
  857.     if (axis==X_AXIS)
  858.         command = 0x2017; /* draw bres. line on X, W, LPN, */
  859.     else
  860.         command = 0x2057; /* same, on Y */
  861.     if (sdx > 0)
  862.         command |= 0x0020;
  863.     if (sdy > 0)
  864.         command |= 0x0080;
  865.     COMMAND(command);
  866.  
  867.     return;
  868. }
  869.  
  870. void
  871. ibm8514BresLineStop()
  872. {
  873.     ibm8514ATRNotBusy;
  874.     ibm8514CheckQueue(2);
  875.     SETFN1(FNCOLOR1,FNREPLACE);
  876.     PLNWENBL(ibm8514ALLPLANES);
  877.  
  878.     if (bres_saved)
  879.             ibm8514ReplaceCursor();
  880.     return;
  881. }
  882.