/*
*   Program to set one color map entry in the hardware lookup table of
*   a Sun.  
*   Tim Krauskopf    August, 1987
*   National Center for Supercomputing Applications
*   University of Illinois
*   This program is in the public domain
*
*/
#include "pixrect/pixrect_hs.h"
#include "stdio.h"
#define FORMAT printf ("\nUSAGE:\n\tpalset entry_no red green blue\nOR\n\t\
palset\n")

char rmap[256],bmap[256],gmap[256];
int test,entryNo,red,green,blue;


struct pixrect *screen;

fixColor(entryNo,red,green,blue)
	int entryNo,red,green,blue;
{
	rmap[0] = red;
	gmap[0] = green;
	bmap[0] = blue;
	pr_putcolormap(screen,entryNo,1,rmap,gmap,bmap);
}

main(argc,argv)
	int argc;
	char *argv[];
{
register i;

screen = pr_open("/dev/fb");

if (argc == 5) 
	fixColor(atoi(argv[1]),atoi(argv[2]),atoi(argv[3]),atoi(argv[4]));
else 
   if (argc != 1) FORMAT;
   else
	while ((test=scanf("%d %d %d %d",&entryNo,&red,&green,&blue)) == 4)
		fixColor(entryNo,red,green,blue);

pr_close(screen);

}
