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 / brcCmap.c < prev    next >
C/C++ Source or Header  |  1991-09-20  |  3KB  |  91 lines

  1. /*
  2.  * $Id: brcCmap.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 "screenint.h"
  38. #include "scrnintstr.h"
  39.  
  40. #include "OScompiler.h"
  41.  
  42. #include "x8514.h"
  43.  
  44. #include "ibmTrace.h"
  45.  
  46. extern int ibm8514NumberOfPlanes ;
  47.  
  48. void
  49. ibm8514SetColor( number, red, green, blue, pVisual )
  50.      unsigned long int number ;
  51.      unsigned int red, green, blue ;
  52.      VisualPtr pVisual ;
  53. {
  54.     unsigned short r = red;
  55.     unsigned short g = green;
  56.     unsigned short b = blue;
  57.  
  58.     TRACE( ( "ibm8514SetColor(num=%d,r=%d,g=%d,b=%d)\n", number, r, g, b ) ) ;
  59.  
  60.     if ( number > pVisual->ColormapEntries )
  61.     return ;
  62.  
  63.     r >>= 10 ;
  64.     g >>= 10 ;            /* only top 6 bits sent to 8514 */
  65.     b >>= 10 ;
  66.  
  67.     if ( ibm8514NumberOfPlanes == 8 ) {
  68.     /* FOLLOWING OPS ARE BYTE OUTS!!! */
  69.     ibm8514ClearQueue( 5 ) ;
  70.     outb( PALWRITE_ADDR, number ) ;
  71.     outb( PALMASK, 0xFFFF ) ; /* enable all color bits */
  72.     outb( PALDATA, (unsigned char) r ) ;
  73.     outb( PALDATA, (unsigned char) g ) ;
  74.     outb( PALDATA, (unsigned char) b ) ;
  75.     }
  76.     else
  77.     {
  78.     unsigned int top ;
  79.     for ( top = 0 ; top < 16 ; top++ )
  80.     {
  81.         ibm8514ClearQueue( 5 ) ;
  82.         outb( PALWRITE_ADDR, ( top << 4 ) + number ) ;
  83.         outb( PALMASK, 0xFFFF ) ; /* enable all color bits */
  84.         outb( PALDATA, (unsigned char) r ) ;
  85.         outb( PALDATA, (unsigned char) g ) ;
  86.         outb( PALDATA, (unsigned char) b ) ;
  87.     }
  88.     }
  89.     return ;
  90. }
  91.