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

FILE	*fpw;

#define		PAI	3.141592654
#define		RAG	PAI/180.0

unsigned char	xx[0x40];
unsigned char	xx2[0x40];
unsigned char	yy[0x40];
unsigned char	yy2[0x40];
unsigned char	c[0x40][0x40];

main()
{
	static char	filename[] = {"ohgi0.DAT"};
	static char	cpcom1[] = {"cp "};
	static char	cpcom2[] = {" ../asm/"};
	char	c[125];

	printf("\n\n\n<<<<< CIRCLE X DATA START !! >>>>>\t\n\n\n");

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

	endata();

	fclose(fpw);

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

endata()
{
	int		j,r;
	double		i,xx,yy;
	unsigned char	c[360],x[360],y[360];
	unsigned short	xxx,yyy;

	i=225;
	j=0;
	while(j<360){
		xx=cos(i*RAG);
		yy=sin(i*RAG);
		r=rand()&0x007f;
		i++;
		if(i>315){
			i=225;
		}
		if(r>0x18){
			c[j]=rand()&0x08;
			x[j]=xx*r;
			y[j]=yy*r;
			printf("c=%02X x=%02X y=%02X\t",c[j],x[j],y[j]);
			j++;
		}
	}

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

	j=0;
	while(j<360){
		if(j-j/6*6==0){
			fprintf(fpw,"\n\tHEX\t");
		}
		fprintf(fpw,"%02X,%02X,%02X",c[j],x[j],y[j]);
		j++;
		if(j-j/6*6!=0){
			fprintf(fpw,",");
		}
	}

	fprintf(fpw,"\n\tHEX\tFF\n");
	fprintf(fpw,";\n;\n;\n;\n");
}

