#include <stdio.h>

#define		unshort		unsigned short
#define		unchar		unsigned char

FILE		*fpr,*fpw;

unchar		chr_data_0[32768];
unchar		chr_data_1[16384];

int		i,NO;

void main( int argc,char **argv )

{

	if( argc != 2 ){
		printf( "Usage: colcnv (table_file) (label_file) (convert data_file)\n" );
		exit(1);

	}


	if( !( fpr = fopen( argv[1],"r" ) ) ){
		printf( "can't open (%s) !!\n",argv[1] );
		exit(1);
	}


	while(( NO = fread( chr_data_0,sizeof(unchar),32768,fpr )) == 0 ){
		printf( "read error\n" );
		exit(1);
	}


	fclose( fpr );


	for( i=0;i<NO;i=i+2 ){
		chr_data_1[i/2] = ( chr_data_0[i+1] << 4 ) | ( chr_data_0[i] & 0x0f );
	}


	if( !( fpw = fopen( argv[1],"w" ) ) ){
		printf( "can't open (%s) !!\n",argv[1] );
		exit(1);
	}


	NO = NO / 2;


	while(( fwrite( chr_data_1,sizeof(unchar),NO,fpw )) == NULL ){
		printf( "write error\n" );
		exit(1);
	}


	fclose( fpw );


}
