home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / ibm / skyway / skyImg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-16  |  3.9 KB  |  166 lines

  1. /*
  2.  * $XConsortium: skyImg.c,v 1.2 91/07/16 13:15:20 jap Exp $
  3.  *
  4.  * Copyright IBM Corporation 1987,1988,1989,1990,1991
  5.  *
  6.  * All Rights Reserved
  7.  *
  8.  * License 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, FITNESS, AND 
  18.  * NONINFRINGEMENT OF THIRD PARTY RIGHTS, IN NO EVENT SHALL
  19.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  20.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23.  * SOFTWARE.
  24.  *
  25. */
  26.  
  27. #include "X.h"
  28. #include "scrnintstr.h"
  29. #include "colormapst.h"
  30. #include "pixmapstr.h"
  31. #include "regionstr.h"
  32. #include "windowstr.h"
  33.  
  34. #include "skyHdwr.h"
  35. #include "skyReg.h"
  36. #include "ibmTrace.h"
  37.  
  38. /* DMA */
  39. /* move int by int instead of byte by byte */
  40.  
  41. void
  42. skywayDrawColorImage(x, y, w, h, data, RowIncrement, alu, mask,index)
  43.     int    x ;
  44.     int    y ;
  45.     int w ;
  46.     int h ;
  47.     register unsigned char *data ;
  48.     int        RowIncrement ;
  49.     int    alu ;
  50.     unsigned long int mask ;
  51.     int    index ;
  52. {
  53.     unsigned char *sptr;            /* the source pointer           */
  54.     unsigned char *dptr, *Dptr;     /* the destination pointer      */
  55.     int i, j;
  56.  
  57.     TRACE(("SkywayDrawColorImage\n"));
  58.  
  59.      skywayWaitFifo2(index);
  60.     sptr = (unsigned char *) data ; 
  61.     Dptr = (unsigned char *) ((SKYWAY_VRAM_START[index] | 
  62.         SKYWAY_OFFSET[index]) + (SKYWAY_WIDTH * y) + x ) ;
  63.  
  64.      for ( i=0; i<h; i++ ) {
  65.  
  66.         dptr = Dptr ;
  67.  
  68.         for( j=0; j<w; j++ )    /* copy one row into memory     */
  69.         {
  70.             switch( alu )
  71.             {
  72.                 case 0x0 : *dptr = 0;
  73.                        break;
  74.                 case 0x1 : *dptr =  ( *sptr & *dptr );
  75.                        break;
  76.                 case 0x2 : *dptr =  ( *sptr & ~*dptr );
  77.                        break;
  78.                 case 0x3 : *dptr =  *sptr;
  79.                        break;
  80.                 case 0x4 : *dptr =  ( ~*sptr & *dptr );
  81.                        break;
  82.                 case 0x5 : *dptr =  *dptr;
  83.                        break;
  84.                 case 0x6 : *dptr =  ( *sptr ^ *dptr );
  85.                        break;
  86.                 case 0x7 : *dptr =  ( *sptr | *dptr );
  87.                        break;
  88.                 case 0x8 : *dptr =  ( ~*sptr & ~*dptr );
  89.                        break;
  90.                 case 0x9 : *dptr =  ( ~*sptr ^ *dptr );
  91.                        break;
  92.                 case 0xa : *dptr =  ~*dptr;
  93.                        break;
  94.                 case 0xb : *dptr =  ( *sptr | ~*dptr );
  95.                        break;
  96.                 case 0xc : *dptr =   ~*sptr;
  97.                        break;
  98.                 case 0xd : *dptr =  ( ~*sptr | *dptr );
  99.                        break;
  100.                 case 0xe : *dptr =  ( ~*sptr | ~*dptr );
  101.                        break;
  102.                 case 0xf : *dptr =  0x1;
  103.                        break;
  104.             }
  105.  
  106.             dptr++;
  107.             sptr++;
  108.  
  109.         }
  110.  
  111.         Dptr += SKYWAY_WIDTH ;
  112.  
  113.         /* skip 32-bit boundary */
  114.  
  115.         while ( ( (int) sptr % 4 ) != 0 )
  116.             sptr++;
  117.     }
  118.  
  119.      skywayWaitFifo2(index);
  120.  
  121.         return ;
  122. }
  123.  
  124. void skywayReadColorImage(x, y, w, h, data ,RowIncrement,index)
  125.     int        x ;
  126.     int        y ;
  127.     int        w ;
  128.     register int h ;
  129.     register unsigned char *data ;
  130.     int        RowIncrement ;
  131.     int        index ;
  132. {
  133.     unsigned char *sptr, *Sptr ;
  134.     unsigned char *dptr ;
  135.     int i, j;
  136.  
  137.     TRACE(("SkywayReadColorImage\n"));
  138.  
  139.     dptr = data;    /* data is assumed to be at 32-bit boundary     */
  140.  
  141.     Sptr = (unsigned char *) ((SKYWAY_VRAM_START[index] | 
  142.            SKYWAY_OFFSET[index]) + (SKYWAY_WIDTH * y) + x ) ;
  143.  
  144.     for ( i=0; i<h; i++ )
  145.     {
  146.         sptr = Sptr;
  147.         for( j=0; j<w; j++ )    /* copy one row into memory     */
  148.         {
  149.             *dptr++ = *sptr++;
  150.         }
  151.  
  152.         /* then skip subsequent destination memory up to the
  153.            next 32-bit boundary                                 */
  154.  
  155.         while ( ( (int) dptr % 4 ) != 0 )
  156.         {
  157.             dptr++;
  158.         }
  159.  
  160.         Sptr += SKYWAY_WIDTH ;
  161.     }
  162.  
  163.     return ;
  164. }
  165.  
  166.