/*
	fixpal.c

	fp.bat = cl /AL fixpal.c getfile

	reads an old red right 3d pal and reverses it


*/
#include <stdio.h>
#include <string.h>
#include "nomouse.h"

int Lut[256][3];

main()
{
	int i,j,k;
	char string[100];
	FILE *fp;

	if(get_file_name("*.pal",string,0)<0)
		exit(0);
	fp=fopen(string,"r+t");
	if(!fp)
	{
		printf("Could not open '%s' to read/write.\n\n",string);
		exit(0);
	}
	for(i=0;i<256;i++)
		fscanf(fp,"%d%d%d%d",&j,&Lut[i][0],&Lut[i][1],&Lut[i][2]);
	for(i=0;i<256;i++)
	{
		printf("%3d %3d %3d\n",Lut[i][0],Lut[i][1],Lut[i][2]);
		if(Lut[i][1]>0)
		{
			printf("Not a red/blue file.\n\n");
			exit(0);
		}
	}
	rewind(fp);
	for(i=0;i<256;i++)
		fprintf(fp,"%3d  %3d   0 %3d\n",i,Lut[i][2],Lut[i][0]*2);
	fclose(fp);
}





                                                                                                   