/*
 * $Id: $
 */

/*
 * Mesa 3-D graphics library
 * Copyright (C) 1995  Brian Paul  (brianp@ssec.wisc.edu)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/* Palette-Index */
#define PL_RGBA(r,g,b)  ((trueColor > 0) ? pal332[(((((unsigned char)(r)) >> 0) & 0xE0) | 			\
						   ((((unsigned char)(g)) >> 3) & 0x1C) |			\
						   ((((unsigned char)(b)) >> 6) & 0x03))].PenNo : GetPen(r, g, b))
#define	GetIndex(idx)	RGBAColorMap[idx]
/* TrueColor-RGBA */
#define TC_RGBA(r,g,b)	((((((r << 8) | g) << 8) | b) << 8) | 0)
/* TrueColor-ARGB */
#define TC_ARGB(r,g,b)	((((((0 << 8) | r) << 8) | g) << 8) | b)

#define c8toc32(x)	(((((((x) << 8) | (x)) << 8) | (x)) << 8) | (x))

#define htc_NumCols332	256
#define htc_NumCols	189

/* TODO: pad to 8 or 16 bytes */
struct ColorEntry {
  struct {
    unsigned char r, g, b, a;
  } orgEntry;
  struct {
    unsigned char r, g, b, a;
  } mapEntry;
  ULONG PenNo;
};

ULONG GetPen(register unsigned char R __asm__ ("d0"),
	     register unsigned char G __asm__ ("d1"),
	     register unsigned char B __asm__ ("d2"));
void AllocCMap(struct Screen *);
void FreeCMap(struct Screen *);

extern ULONG RGBAColorMap[256];
extern struct ColorEntry pal[];
extern struct ColorEntry pal332[];
