#include	<stdio.h>
/*
#include	<memory.h>
*/
#include	<strings.h>
#include	<math.h>

FILE	*fpw;

#define PAI	3.14159265358979323844
#define RAG	PAI/180.0

main()
{
	static char	filename[] = {"cos-sin.DAT"};
	static char	cpcom1[] = {"mv "};
	static char	cpcom2[] = {" ../asm_yam/"};
	char	c[125];

	printf("\n\n\n<<<<< COS & SIN DATA START !! >>>>>\t\n\n\n");

	if(( fpw = fopen(filename,"wb")) == NULL){
		fprintf(stderr,"Write file open error !!\n");
		exit(1);
	}

	sin_cos();

	fclose(fpw);

	printf("\n\n<<<<< COS & SIN DATA END !! >>>>>\n\n\n");
/**************************/
	strcpy(c,cpcom1);
	strcat(c,filename);
	strcat(c, cpcom2);
	strcat(c,filename);
	printf("\n%s\n",c);
	system(c);
/**************************/
}

sin_cos()
{
	double	i,a;
	int	j;

	i=0;
	j=0;
	fprintf(fpw,"SIN_SML\tEQU\t$");
	while(j<0x40){
/*	  while(j<0x100){*/
		if(j-j/8*8==0){
			fprintf(fpw,"\n\tWORD\t");
		}
		else{
			fprintf(fpw,",");
		}
		a=sin(RAG*i);
		a=a*0x4000;
		fprintf(fpw,"%05XH",(unsigned short)(a*1.0));
		i+=360.0/0x100;
		j++;
	}

	printf("\n");
	fprintf(fpw,"\n;\nCOS_SML\tEQU\t$");

	i=0;
	j=0;
	while(j<0x100){
		if(j-j/8*8==0){
			fprintf(fpw,"\n\tWORD\t");
		}
		else{
			fprintf(fpw,",");
		}
		a=cos(RAG*i);
		printf("%X ",(short)a);
		a=a*0x4000;
		fprintf(fpw,"%05XH",(unsigned short)(a*1.0));
		i+=360.0/0x100;
		j++;
	}
	fprintf(fpw,"\n;\n;\n;\n");
}

