home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xibm.zip / ppc / ppcCurs.c < prev    next >
C/C++ Source or Header  |  1989-11-14  |  4KB  |  155 lines

  1. /*
  2.  * Copyright IBM Corporation 1987,1988,1989
  3.  *
  4.  * All Rights Reserved
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software and its
  7.  * documentation for any purpose and without fee is hereby granted,
  8.  * provided that the above copyright notice appear in all copies and that 
  9.  * both that copyright notice and this permission notice appear in
  10.  * supporting documentation, and that the name of IBM not be
  11.  * used in advertising or publicity pertaining to distribution of the
  12.  * software without specific, written prior permission.
  13.  *
  14.  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  15.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  16.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  17.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  18.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  19.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  20.  * SOFTWARE.
  21.  *
  22. */
  23.  
  24. /* $Header: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcCurs.c,v 9.1 88/10/24 03:59:54 paul Exp $ */
  25. /* $Source: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcCurs.c,v $ */
  26.  
  27. #ifndef lint
  28. static char *rcsid = "$Header: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcCurs.c,v 9.1 88/10/24 03:59:54 paul Exp $" ;
  29. #endif
  30.  
  31. /*
  32.  * Realize and Unrealize cursor
  33.  *
  34.  * T. Paquin 8/87
  35.  *
  36.  * Takes the pCurs source and mask fields, and creates foreground and background
  37.  * fields in the devPriv.
  38.  *
  39.  */
  40. #include "X.h"
  41. #include "Xmd.h"
  42. #include "servermd.h"
  43. #include "miscstruct.h"
  44. #include "scrnintstr.h"
  45. #include "cursorstr.h"
  46. #include "pixmapstr.h"
  47.  
  48. #include "OScompiler.h"
  49. #include "ppc.h"
  50. #include "ppcBitMacs.h"
  51. #include "ibmTrace.h"
  52.  
  53. #if !defined(IMAGE_BYTE_ORDER)
  54.     ******** ERROR ********
  55. #endif
  56.  
  57. /* We want to access the cursor as a sequence of bytes.
  58.  * However, the data is defined to be a sequence of longs
  59.  * So, we convert if needed!
  60.  */
  61. #if defined(CURSOR_DEBUG)
  62. void
  63. print_ppc_cursor_data( src, width, height )
  64. unsigned long int *src ;
  65. unsigned int width ;
  66. unsigned int height ;
  67. {
  68. register unsigned char *c_ptr ;
  69. register unsigned long int *l_ptr ;
  70. register unsigned int i ;
  71.  
  72. extern int puts(), printf() ;
  73.  
  74. (void) puts( "First Array" ) ;
  75. l_ptr = src ;
  76. for ( i = height ; i-- ; l_ptr++ ) {
  77.     c_ptr = (unsigned char *) l_ptr ;
  78.     (void) printf( " %08X    %02X %02X %02X %02X\n",
  79.                *l_ptr, c_ptr[0], c_ptr[1], c_ptr[2], c_ptr[3] ) ;
  80. }
  81. (void) puts( "Second Array" ) ;
  82. l_ptr = src + 32 ;
  83. for ( i = height ; i-- ; l_ptr++ ) {
  84.     c_ptr = (unsigned char *) l_ptr ;
  85.     (void) printf( " %08X    %02X %02X %02X %02X\n",
  86.                *l_ptr, c_ptr[0], c_ptr[1], c_ptr[2], c_ptr[3] ) ;
  87. }
  88.  
  89. return ;
  90. }
  91. #endif
  92.  
  93. Bool
  94. ppcRealizeCursor( pScr, pCurs )
  95.     ScreenPtr    pScr ;
  96.     CursorPtr    pCurs ;
  97. {
  98.     register unsigned long int *pFG, *pBG ;
  99.     register int i ;
  100.     register unsigned long int tmp ;
  101.     unsigned long int endbits ;
  102.     unsigned long int *psrcImage, *psrcMask ;
  103.     int srcWidth ;
  104.     int srcHeight ;
  105.     int srcRealWidth ;
  106.  
  107.     TRACE(("ppcRealizeCursor( pScr= 0x%x, pCurs= 0x%x)\n",pScr,pCurs)) ;
  108.     if ( ! ( pCurs->devPriv[ pScr->myNum ] = (pointer) Xalloc( 256 ) ) )
  109.     {
  110.     ErrorF("ppcRealizeCursor: can't malloc\n") ;
  111.     return FALSE ;
  112.     }
  113.     pFG = (unsigned long int *) pCurs->devPriv[pScr->myNum] ;
  114.     pBG = pFG + 32 ; /* words */
  115.     bzero( (char *) pFG, 256 ) ;
  116.     psrcImage = (unsigned long int *) pCurs->bits->source ;
  117.     psrcMask = (unsigned long int *) pCurs->bits->mask ;
  118.     srcRealWidth = ( pCurs->bits->width + 0x1F ) >> 5 ;
  119.  
  120.     srcHeight = MIN( pCurs->bits->height, 32 ) ;
  121.  
  122.     endbits = ( ( srcWidth  = MIN( pCurs->bits->width, 32 ) ) == 32 )
  123.         ? 0xFFFFFFFF
  124.         : SCRLEFT( -1, ( 32 - srcWidth ) ) ;
  125.  
  126.     for ( i = srcHeight ; i-- ; ) {
  127.     tmp = *psrcMask & endbits ;
  128.     *pFG++ = ( tmp & *psrcImage ) ;
  129.     *pBG++ = ( tmp & ~ *psrcImage ) ;
  130.     psrcImage = psrcImage + srcRealWidth ;
  131.     psrcMask = psrcMask + srcRealWidth ;
  132.     }
  133.  
  134. #if defined(CURSOR_DEBUG)
  135. print_ppc_cursor_data( pCurs->devPriv[pScr->myNum],
  136.                srcRealWidth << 5, srcHeight ) ;
  137. #endif
  138.  
  139.     TRACE(("exiting ppcRealizeCursor\n")) ;
  140.     return TRUE ;
  141. }
  142.  
  143. Bool
  144. ppcUnrealizeCursor( pScr, pCurs )
  145.     register ScreenPtr     pScr ;
  146.     register CursorPtr     pCurs ;
  147. {
  148.  
  149.     TRACE(("ppcUnrealizeCursor( pScr= 0x%x, pCurs= 0x%x )\n",pScr,pCurs)) ;
  150.  
  151.     Xfree( pCurs->devPriv[ pScr->myNum ] ) ;
  152.     pCurs->devPriv[ pScr->myNum ] = 0 ;
  153.     return TRUE ;
  154. }
  155.