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 / brcFillSp.c < prev    next >
C/C++ Source or Header  |  1991-09-20  |  19KB  |  694 lines

  1. /*
  2.  * $Id: brcFillSp.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. #include "X.h"
  37. #include "misc.h"
  38. #include "gcstruct.h"
  39. #include "windowstr.h"
  40. #include "window.h"
  41. #include "pixmapstr.h"
  42. #include "scrnintstr.h"
  43.  
  44. #include "OScompiler.h"
  45.  
  46. #include "ppc.h"
  47. #include "ppcSpMcro.h"
  48.  
  49. #include "x8514.h"
  50. #include "ibmTrace.h"
  51.  
  52. extern int mergexlate[] ;
  53. extern int ibm8514cursorSemaphore ;
  54. extern int mfbGCPrivateIndex;
  55.  
  56. void
  57. ibm8514SolidFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
  58.      DrawablePtr pDrawable ;
  59.      GCPtr    pGC ;
  60.      int    nInit ;            /* number of spans to fill */
  61.      DDXPointPtr pptInit ;        /* pointer to list of start points */
  62.      int    *pwidthInit ;        /* pointer to list of n widths */
  63.      int     fSorted ;
  64. {
  65.     unsigned long int pm ;
  66.     unsigned long int fg ;
  67.     int alu ;
  68.                 /* next three parameters are post-clip */
  69.     int n ;            /* number of spans to fill */
  70.     DDXPointPtr ppt ;        /* pointer to list of start points */
  71.     int *pwidth ;        /* pointer to list of n widths */
  72.     int *pwidthFree ;        /* copies of the pointers to free */
  73.     DDXPointPtr pptFree ;
  74.  
  75.     TRACE(("ibm8514SolidFS((pDrawable = x%x, pGC = x%x, nInit = x%x, pptInit = x%x, pwidthInit = x%x, fSorted = x%x)\n",
  76.        pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ;
  77.  
  78.     if ( pDrawable->depth == 1 )
  79.     {
  80.     ErrorF("ibm8514SolidFS: depth == 1\n") ;
  81.     return ;
  82.     }
  83.  
  84.     if (pDrawable->type != DRAWABLE_WINDOW)
  85.     {
  86.     ErrorF("ibm8514SolidFS: not a window\n") ;
  87.     return ;
  88.     }
  89.  
  90.     if ( ( alu = ( (ppcPrivGC *) pGC->
  91.           devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu )
  92.     == GXnoop )
  93.     return ;
  94.  
  95.     pm = ( (ppcPrivGC *) pGC->
  96.       devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
  97.     fg = ( (ppcPrivGC *) pGC->
  98.       devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ;
  99.  
  100.     SETSPANPTRS( nInit, n, pwidthInit, pwidth, pptInit, 
  101.         ppt, pwidthFree, pptFree, fSorted ) ;
  102.  
  103.     while ( n--)
  104.     {
  105.     if ( *pwidth )
  106.         ibm8514DrawRectangle( fg, alu, pm,
  107.                  ppt->x, ppt->y, *pwidth, 1 ) ;
  108.     ppt++ ;
  109.     pwidth++ ;
  110.     }
  111.     DEALLOCATE_LOCAL(pptFree) ;
  112.     DEALLOCATE_LOCAL(pwidthFree) ;
  113.     return ;
  114. }
  115.  
  116. #ifndef OLDFS
  117. void
  118. ibm8514TileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
  119.      DrawablePtr pDrawable ;
  120.      GC        *pGC ;
  121.      int    nInit ;            /* number of spans to fill */
  122.      DDXPointPtr pptInit ;        /* pointer to list of start points */
  123.      int     *pwidthInit ;        /* pointer to list of n widths */
  124.      int     fSorted ;
  125. {
  126.     unsigned long int pm ;
  127.     int alu ;
  128.     /* next three parameters are post-clip */
  129.     int n ;            /* number of spans to fill */
  130.     DDXPointPtr ppt ;        /* pointer to list of start points */
  131.     int *pwidth ;        /* pointer to list of n widths */
  132.     int *pwidthFree ;        /* copies of the pointers to free */
  133.     DDXPointPtr pptFree ;
  134.     PixmapPtr pTile ;
  135.     int xSrc, ySrc ;
  136.     int width ;
  137.     int tlx, tly, hoffset, voffset, hremaining ;
  138.     int currx ;
  139.  
  140.     TRACE(("ibm8514TileFS((pDrawable = x%x, pGC = x%x, nInit = %d, pptInit = x%x, pwidthInit = x%x, fSorted = x%x)\n",
  141.        pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
  142.  
  143.     if (pDrawable->type != DRAWABLE_WINDOW)
  144.     {
  145.     ErrorF("ibm8514TileFS: not a window\n") ;
  146.     return ;
  147.     }
  148.  
  149.     if ( ( alu = ( (ppcPrivGC *) pGC->
  150.           devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu )
  151.     == GXnoop )
  152.     return ;
  153.  
  154.     pm = ( (ppcPrivGC *) pGC->
  155.       devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
  156.  
  157.     SETSPANPTRS(nInit, n, pwidthInit, pwidth, pptInit, 
  158.         ppt, pwidthFree, pptFree, fSorted) ;
  159.  
  160.     switch(alu)
  161.     {
  162.       case GXset:
  163.       case GXclear:
  164.       case GXinvert:
  165.     while ( n--)
  166.     {
  167.         ibm8514DrawRectangle( 0xFF, alu, pm,
  168.                  ppt->x, ppt->y, *pwidth, 1) ;
  169.         ppt++ ;
  170.         pwidth++ ;
  171.     }
  172.     return ;
  173.       default:
  174.     break ;
  175.     }
  176.  
  177.  
  178.     xSrc = pGC->patOrg.x + pDrawable->x ;
  179.     ySrc = pGC->patOrg.y + pDrawable->y ;
  180.  
  181.     pTile= pGC->tile.pixmap ;
  182.  
  183.     tlx = pTile->drawable.width ;
  184.     tly = pTile->drawable.height ;
  185.  
  186.     if ( n == 1 )
  187.     {
  188.     unsigned char *data ;
  189.  
  190.     if ((hoffset = ((ppt->x-xSrc)%tlx)) < 0) hoffset += tlx ;
  191.     hremaining = tlx-hoffset ;
  192.     if ((voffset = ((ppt->y-ySrc)%tly)) < 0) voffset += tly ;
  193.  
  194.     data = pTile->devPrivate.ptr + voffset * pTile->devKind ;
  195.     width = *pwidth ;
  196.  
  197.     if ( hoffset )
  198.     {
  199.         unsigned char *tmp
  200.         = (unsigned char *) ALLOCATE_LOCAL(pTile->devKind) ;
  201.         MOVEBYTE( data + hoffset, tmp, hremaining) ;
  202.         if ( width > hremaining )
  203.         MOVEBYTE( data, tmp + hremaining, 
  204.               MIN( hoffset, width - hremaining ) ) ;
  205.         data = tmp ;
  206.     }
  207.  
  208.     if ( width <= tlx )
  209.     {
  210.         ibm8514DrawColorImage( ppt->x, ppt->y, width, 1, 
  211.                   data, width, alu, pm ) ;
  212.     }
  213.     else
  214.     {
  215.         switch ( alu )
  216.         {
  217.           case GXcopy:
  218.           case GXcopyInverted:
  219.         ibm8514DrawColorImage( ppt->x, ppt->y,
  220.                       MIN( width, tlx ), 1, 
  221.                       data,
  222.                       MIN( width, tlx ),
  223.                       alu, pm) ;
  224.         ppcReplicateArea( ppt->x, ppt->y,
  225.                  pm, width, 1,
  226.                  tlx, 1, 
  227.                  pTile->drawable.pScreen ) ;
  228.         break ;
  229.           default:
  230.         if ( tlx > MAXTILESIZE )
  231.         {
  232.             ibm8514DrawColorImage(
  233.                       ppt->x, ppt->y,
  234.                       MIN( width, tlx ), 1, 
  235.                       data,
  236.                       MIN( width, tlx ),
  237.                       alu, pm) ;
  238.             for ( width -= tlx,
  239.              currx = ppt->x + tlx ;
  240.              width > 0 ; 
  241.              currx += tlx,
  242.              width -= tlx
  243.              )
  244.             ibm8514DrawColorImage(
  245.                           currx, ppt->y,
  246.                           MIN( width, tlx ), 
  247.                           1, data, 
  248.                           MIN( width, tlx ), 
  249.                           alu, pm ) ;
  250.         }
  251.         else
  252.         { 
  253.             ibm8514DrawColorImage(
  254.                       TILE_X, TILE_Y,
  255.                       *pwidth, 1, 
  256.                       data, *pwidth,
  257.                       alu, pm ) ;
  258.             while ( tlx << 1 <= MAXTILESIZE)
  259.             {
  260.             ibm8514Bitblt(
  261.                       GXcopy, 0xFF, 
  262.                       0xFF,
  263.                       TILE_X, TILE_Y,
  264.                       TILE_X + tlx, 
  265.                       TILE_Y,
  266.                       tlx, 1 ) ;
  267.             tlx <<= 1 ;
  268.             }
  269.             for ( currx = ppt->x ;
  270.              width > 0 ;
  271.              currx += tlx,
  272.              width -= tlx )
  273.             ibm8514Bitblt(
  274.                       alu, 0xFF, pm,
  275.                       TILE_X, TILE_Y,
  276.                       currx, ppt->y,
  277.                       MIN( width, tlx ),
  278.                       1 ) ;
  279.         }
  280.         }            /* end switch on rop */
  281.     }            /* end else on width > hremaining */
  282.     }                /* end N = 1 */
  283.     else
  284.     {
  285.     if ( ( tlx <= MAXTILESIZE ) && ( tly <= MAXTILESIZE ) ) {
  286.  
  287.         ibm8514DrawColorImage(
  288.                   TILE_X, TILE_Y,
  289.                   tlx, tly,
  290.                   pTile->devPrivate.ptr,
  291.                   pTile->devKind,
  292.                   GXcopy, ibm8514ALLPLANES ) ;
  293.         /*we'll do the alu and planemask in the blits*/
  294.  
  295.         while ( tlx << 1 <= MAXTILESIZE )
  296.         {
  297.         ibm8514Bitblt(
  298.                   GXcopy, 0xff, 0xff,
  299.                   TILE_X, TILE_Y,
  300.                   TILE_X + tlx, TILE_Y,
  301.                   tlx, tly ) ;
  302.         tlx <<= 1 ;
  303.         }
  304.  
  305.         while ( n-- )
  306.         {
  307.         if ( ( hoffset = ( ( ppt->x - xSrc ) % tlx ) ) < 0 ) 
  308.             hoffset += pTile->drawable.width ;
  309.         if ( ( voffset = ( ( ppt->y - ySrc ) %tly ) ) < 0 ) 
  310.             voffset += tly ;
  311.  
  312.         width = *pwidth ;
  313.         if ( hoffset )
  314.         {
  315.             ibm8514RotateTile( tlx, tly, hoffset, 0 ) ;
  316.             while ( width > 0 )
  317.             {
  318.             ibm8514Bitblt( alu, 0xff, pm,
  319.                       ROTTILE_X, 
  320.                       ROTTILE_Y + voffset,
  321.                       ppt->x, ppt->y,
  322.                       MIN( width, tlx ), 1 ) ;
  323.             width -= tlx ;
  324.             ppt->x += tlx ;
  325.             }
  326.         }
  327.         else
  328.             while ( width > 0 )
  329.             {
  330.             ibm8514Bitblt( alu, 0xff, pm,
  331.                       TILE_X, 
  332.                       TILE_Y + voffset,
  333.                       ppt->x, ppt->y,
  334.                       MIN( width, tlx ), 1 ) ;
  335.             width -= tlx ;
  336.             ppt->x += tlx ;
  337.             }
  338.         ppt++ ;
  339.         pwidth++ ;
  340.         }
  341.     }
  342.     else
  343.     {
  344.         unsigned char *data ;
  345.         unsigned char *tmp
  346.         = (unsigned char *) ALLOCATE_LOCAL(pTile->devKind) ;
  347.  
  348.         while ( n-- )
  349.         {
  350.         if ( ( hoffset = ( ( ppt->x - xSrc ) % tlx ) ) < 0 ) 
  351.             hoffset += tlx ;
  352.         hremaining = tlx-hoffset ;
  353.         if ( ( voffset = ( ( ppt->y - ySrc ) % tly ) ) < 0 )
  354.             voffset += tly ;
  355.  
  356.         data = pTile->devPrivate.ptr + 
  357.             voffset * pTile->devKind ;
  358.                 
  359.         if ( hoffset )
  360.         {
  361.             MOVEBYTE( data + hoffset, tmp, hremaining ) ;
  362.             if ( *pwidth > hremaining )
  363.             MOVEBYTE( data, tmp + hremaining, hoffset ) ;
  364.             data = tmp ;
  365.         }
  366.  
  367.         while ( *pwidth > 0 )
  368.         {
  369.             ibm8514DrawColorImage(
  370.                       ppt->x, ppt->y,
  371.                       MIN( *pwidth, tlx ), 1,
  372.                       data,
  373.                       MIN( *pwidth, tlx ),
  374.                       alu, pm ) ;
  375.             *pwidth -= tlx ;
  376.             ppt->x += tlx ;
  377.         }
  378.         ppt++ ;
  379.         pwidth++ ;
  380.         }
  381.     }
  382.     }                /* end N > 1 */
  383.  
  384.     DEALLOCATE_LOCAL(pptFree) ;
  385.     DEALLOCATE_LOCAL(pwidthFree) ;
  386.     return ;
  387. }
  388. #endif
  389. #ifdef OLDFS
  390. void
  391. ibm8514TileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
  392.      DrawablePtr pDrawable ;
  393.      GC        *pGC ;
  394.      int    nInit ;        /* number of spans to fill */
  395.      DDXPointPtr pptInit ;    /* pointer to list of start points */
  396.      int     *pwidthInit ;    /* pointer to list of n widths */
  397.      int     fSorted ;
  398. {
  399.     unsigned long int pm ;
  400.     int alu ;
  401.                 /* next three parameters are post-clip */
  402.     int n ;            /* number of spans to fill */
  403.     DDXPointPtr ppt ;        /* pointer to list of start points */
  404.     int *pwidth ;        /* pointer to list of n widths */
  405.     int *pwidthFree ;        /* copies of the pointers to free */
  406.     DDXPointPtr pptFree ;
  407.     PixmapPtr pTile ;
  408.     int xSrc, ySrc ;
  409.  
  410.     TRACE(("ibm8514TileFS((pDrawable = x%x, pGC = x%x, nInit = x%x, pptInit = x%x, pwidthInit = x%x, fSorted = x%x)\n",
  411.        pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
  412.  
  413.     if (pDrawable->depth == 1 )
  414.     {
  415.     ErrorF("ibm8514TileFS: depth == 1\n") ;
  416.     return ;
  417.     }
  418.  
  419.     if (pDrawable->type != DRAWABLE_WINDOW)
  420.     {
  421.     ErrorF("ibm8514TileFS: not a window\n") ;
  422.     return ;
  423.     }
  424.     if ( ( alu = ( (ppcPrivGC *) pGC->
  425.           devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu )
  426.     == GXnoop )
  427.     return ;
  428.  
  429.     pm = ( (ppcPrivGC *) pGC->
  430.       devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
  431.  
  432.     SETSPANPTRS(nInit, n, pwidthInit, pwidth, pptInit, 
  433.         ppt, pwidthFree, pptFree, fSorted) ;
  434.  
  435.     xSrc = pGC->patOrg.x ;
  436.     ySrc = pGC->patOrg.y ;
  437.     pTile= pGC->tile ;
  438.  
  439.     while (n--)
  440.     {
  441.     ibm8514TileRect(pTile,alu,pm,ppt->x,ppt->y,*pwidth,1,xSrc,ySrc) ;
  442.     ppt++ ;
  443.     pwidth++ ;
  444.     }
  445.     DEALLOCATE_LOCAL(pptFree) ;
  446.     DEALLOCATE_LOCAL(pwidthFree) ;
  447.     return ;
  448. }
  449. #endif
  450.  
  451. /* Fill spans with stipples that aren't 32 bits wide */
  452. void
  453. ibm8514StippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
  454.      DrawablePtr pDrawable ;
  455.      GC        *pGC ;
  456.      int    nInit ;        /* number of spans to fill */
  457.      DDXPointPtr pptInit ;    /* pointer to list of start points */
  458.      int     *pwidthInit ;    /* pointer to list of n widths */
  459.      int     fSorted ;
  460. {
  461.     unsigned long int pm ;
  462.     unsigned long int fg ;
  463.     int alu ;
  464.                 /* next three parameters are post-clip */
  465.     int n ;            /* number of spans to fill */
  466.     DDXPointPtr ppt ;        /* pointer to list of start points */
  467.     int *pwidth ;        /* pointer to list of n widths */
  468.     int        iline ;        /* first line of stipple to use */
  469.     PixmapPtr    pStipple ;    /* pointer to stipple we want to fill with */
  470.     int        xSrc, ySrc, stippleWidth, xshift, maxwidth, totlen,
  471.     saved = FALSE ;
  472.  
  473.     pointer data ;
  474.     int *pwidthFree ;        /* copies of the pointers to free */
  475.     DDXPointPtr pptFree ;
  476.  
  477.     TRACE(("ibm8514StippleFS((pDrawable = x%x, pGC = x%x, nInit = x%x, pptInit = x%x, pwidthInit = x%x, fSorted = x%x)\n",
  478.        pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
  479.     if ( pDrawable->depth != 8 )
  480.     {
  481.     ErrorF("ibm8514StippleFS: depth != 8\n") ;
  482.     return ;
  483.     }
  484.  
  485.     if (pDrawable->type != DRAWABLE_WINDOW)
  486.     {
  487.         int dummy ;
  488.     dummy = (int) pDrawable->type ;
  489.     ErrorF("ibm8514StippleFS: x%x (=%d) not a window\n",dummy,dummy) ;
  490.     return ;
  491.     }
  492.  
  493.     if ( ( alu = ( (ppcPrivGC *) pGC->
  494.           devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu )
  495.     == GXnoop )
  496.     return ;
  497.  
  498.     SETSPANPTRS(nInit, n, pwidthInit, pwidth, pptInit, 
  499.         ppt, pwidthFree, pptFree, fSorted) ;
  500.  
  501.     pStipple = pGC->stipple ;
  502.     stippleWidth = pStipple->drawable.width ;
  503.  
  504.     /* this replaces rotating the stipple.  Instead, we just adjust the offset
  505.      * at which we start grabbing bits from the stipple */
  506.     xSrc = pGC->patOrg.x + pDrawable->x ;
  507.     ySrc = pGC->patOrg.y + pDrawable->y ;
  508.  
  509.     /* Grab From Pre-Calculated Storage */
  510.     pm = ( (ppcPrivGC *) pGC->
  511.       devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
  512.     fg = ( (ppcPrivGC *) pGC->
  513.       devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ;
  514.  
  515.     while (n--)
  516.     {
  517.     iline = (ppt->y - ySrc) % pStipple->drawable.height ;
  518.     maxwidth = _8514_SCREENWIDTH - ppt->x ;
  519.     *pwidth = MIN(*pwidth,maxwidth) ;
  520.     data = pStipple->devPrivate.ptr + iline*stippleWidth ;
  521.  
  522.         if ( !saved && !ibm8514cursorSemaphore )
  523.         saved = ibm8514CheckCursor(ppt->x%xSrc,ppt->y,
  524.                        *pwidth+stippleWidth,1) ;
  525.     /* I am only going to call replace ONCE, after the whole
  526.        stipple id done */
  527.  
  528.     /* set up stipple off screen */
  529.     xshift = (ppt->x - xSrc) % stippleWidth ;
  530.     ibm8514AlignMonoImage(WPLANE0, alu,
  531.                   STIPX, STIPY+1, stippleWidth, 1, data) ;
  532.     if (xshift) 
  533.     {            /* shift the stipple left, then tack on end
  534.                    to the right */
  535.         ibm8514Bitblt(GXcopy,RPLANE0,WPLANE0,STIPX+xshift,STIPY+1,
  536.               STIPX,STIPY,stippleWidth-xshift,1) ;
  537.         ibm8514Bitblt(GXcopy,RPLANE0,WPLANE0,STIPX,STIPY+1,
  538.               STIPX+stippleWidth-xshift,STIPY,xshift,1) ;
  539.     }
  540.     totlen = stippleWidth ;
  541.     while ( totlen<*pwidth)
  542.     {            /* widen stipple to totlen of area to be
  543.                    stippled */
  544.         ibm8514Bitblt(GXcopy,RPLANE0,WPLANE0,
  545.               STIPX,STIPY,totlen,STIPY,totlen,1) ;
  546.         totlen += totlen ;
  547.     }
  548.  
  549.  
  550.         ibm8514ClearQueue( 2 ) ;
  551.     SETXMIN(ppt->x) ;    /* use clip to draw stippled line */
  552.     SETXMAX(*pwidth + ppt->x) ;
  553.  
  554.     ibm8514BlitFG(RPLANE0,pm,fg,alu,
  555.               STIPX,STIPY,ppt->x%xSrc,ppt->y,*pwidth+stippleWidth,1) ;
  556.  
  557.         ibm8514ClearQueue(2) ;
  558.     SETXMIN(0) ;
  559.     SETXMAX(_8514_SCREENWIDTH-1) ;
  560.  
  561.     ppt++ ;
  562.     pwidth++ ;
  563.     }
  564.  
  565.     DEALLOCATE_LOCAL(pptFree) ;
  566.     DEALLOCATE_LOCAL(pwidthFree) ;
  567.     if (saved)
  568.     ibm8514ReplaceCursor() ;
  569.  
  570.     return ;
  571. }
  572.  
  573.  
  574. void
  575. ibm8514OPStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
  576.      DrawablePtr pDrawable ;
  577.      GC        *pGC ;
  578.      int    nInit ;        /* number of spans to fill */
  579.      DDXPointPtr pptInit ;    /* pointer to list of start points */
  580.      int     *pwidthInit ;    /* pointer to list of n widths */
  581.      int     fSorted ;
  582. {
  583.     unsigned long int pm ;
  584.     unsigned long int fg ;
  585.     unsigned long int bg ;
  586.     int alu ;
  587.                 /* next three parameters are post-clip */
  588.     int n ;            /* number of spans to fill */
  589.     DDXPointPtr ppt ;        /* pointer to list of start points */
  590.     int *pwidth ;        /* pointer to list of n widths */
  591.     int        iline ;        /* first line of stipple to use */
  592.     PixmapPtr    pStipple ;    /* pointer to stipple we want to fill with */
  593.     int        xSrc, ySrc, stippleWidth, xshift,
  594.     maxwidth, totlen, saved = FALSE ;
  595.     pointer data ;
  596.     int *pwidthFree ;        /* copies of the pointers to free */
  597.     DDXPointPtr pptFree ;
  598.  
  599.     TRACE(("ibm8514StippleFS((pDrawable = x%x, pGC = x%x, nInit = x%x, pptInit = x%x, pwidthInit = x%x, fSorted = x%x)\n",
  600.        pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
  601.     if ( pDrawable->depth != 8 )
  602.     {
  603.     ErrorF("ibm8514StippleFS: depth != 8\n") ;
  604.     return ;
  605.     }
  606.  
  607.     if (pDrawable->type != DRAWABLE_WINDOW)
  608.     {
  609.         int dummy ;
  610.     dummy = (int) pDrawable->type ;
  611.     ErrorF("ibm8514StippleFS: x%x (=%d) not a window\n",dummy,dummy) ;
  612.     return ;
  613.     }
  614.  
  615.     if ( ( alu = ( (ppcPrivGC *) pGC->
  616.           devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu )
  617.     == GXnoop )
  618.     return ;
  619.  
  620.     pm = ( (ppcPrivGC *) pGC->
  621.       devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
  622.     fg = ( (ppcPrivGC *) pGC->
  623.       devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ;
  624.     bg = ( (ppcPrivGC *) pGC->
  625.       devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.bgPixel ;
  626.  
  627.     SETSPANPTRS(nInit, n, pwidthInit, pwidth, pptInit, 
  628.         ppt, pwidthFree, pptFree, fSorted) ;
  629.  
  630.     pStipple = pGC->stipple ;
  631.     stippleWidth = pStipple->drawable.width ;
  632.  
  633.     /* this replaces rotating the stipple.  Instead, we just adjust the offset
  634.      * at which we start grabbing bits from the stipple */
  635.     xSrc = pGC->patOrg.x + pDrawable->x ;
  636.     ySrc = pGC->patOrg.y + pDrawable->y ;
  637.  
  638.     while (n--)
  639.     {
  640.     iline = (ppt->y - ySrc) % pStipple->drawable.height ;
  641.     maxwidth = _8514_SCREENWIDTH - ppt->x ;
  642.     *pwidth = MIN(*pwidth,maxwidth) ;
  643.     data = pStipple->devPrivate.ptr + iline*stippleWidth ;
  644.  
  645.         if ( !saved && !ibm8514cursorSemaphore )
  646.             saved = ibm8514CheckCursor(ppt->x%xSrc,ppt->y,
  647.                        *pwidth+stippleWidth,1) ;
  648.     /* I am only going to call replace ONCE, after the whole
  649.        stipple id done */
  650.  
  651.     /* set up stipple off screen */
  652.     xshift = (ppt->x - xSrc) % stippleWidth ;
  653.     ibm8514AlignMonoImage(WPLANE0,alu,STIPX,STIPY+1,stippleWidth,1,data) ;
  654.     if (xshift) 
  655.     {            /* shift the stipple left, then tack on end
  656.                    to the right */
  657.         ibm8514Bitblt(GXcopy,RPLANE0,WPLANE0,STIPX+xshift,STIPY+1,
  658.               STIPX,STIPY,stippleWidth-xshift,1) ;
  659.         ibm8514Bitblt(GXcopy,RPLANE0,WPLANE0,STIPX,STIPY+1,
  660.               STIPX+stippleWidth-xshift,STIPY,xshift,1) ;
  661.     }
  662.  
  663.     totlen = stippleWidth ;
  664.     while ( totlen<*pwidth)
  665.     {            /* widen stipple to totlen of area to be
  666.                    stippled */
  667.         ibm8514Bitblt(GXcopy,RPLANE0,WPLANE0,
  668.               STIPX,STIPY,totlen,STIPY,totlen,1) ;
  669.         totlen += totlen ;
  670.     }
  671.  
  672.         ibm8514ClearQueue( 2 ) ;
  673.     SETXMIN(ppt->x) ;    /* use clip to draw stippled line */
  674.     SETXMAX(*pwidth + ppt->x) ;
  675.  
  676.     ibm8514BlitFGBG(RPLANE0,pm,fg,bg,alu,
  677.             STIPX,STIPY,ppt->x%xSrc,ppt->y,*pwidth+stippleWidth,1);
  678.  
  679.         ibm8514ClearQueue(2) ;
  680.     SETXMIN(0) ;
  681.     SETXMAX(_8514_SCREENWIDTH-1) ;
  682.  
  683.     ppt++ ;
  684.     pwidth++ ;
  685.     }
  686.  
  687.     DEALLOCATE_LOCAL(pptFree) ;
  688.     DEALLOCATE_LOCAL(pwidthFree) ;
  689.     if (saved)
  690.     ibm8514ReplaceCursor() ;
  691.  
  692.     return ;
  693. }
  694.