// makfast.c

#include <string.h>
#include <graphics.h>
#include <stdio.h>
#include <string.h>
#include <bios.h>
#include <dos.h>
#include <math.h>
#include <stdlib.h>

void main(void)
{
  int x,n;
  char temp[300];
  FILE *out_file;
  double StepSize,angle,pi2,sn,out,out2;

  pi2 = acos(-1.0) * 2.0;
  StepSize = pi2/16.0;

  out_file = fopen("fast_sin.h","w");
  
  fputs("unsigned char sin_table[] = {",out_file);
  
  printf("unsigned char sin_table[] = {");
  
  for(n=0,x=0; n<10; n++)
  {  
    for(angle=0.0; angle<=pi2; angle+=StepSize,x++)
    {
      if(x)
      {
        if(!(x % 10))
        {
          fputs("\n                            ,",out_file);
          printf("\n                            ,");
        }

        else
        {
          fputs(",",out_file);
          printf(",");
        }
      }
      sn = sin(angle);
      out = (sn + 1.0)/2.0;
      sprintf(temp,"%1.0f",255.0*out);
      out2 = atof(temp);
      fprintf(out_file,"%3d",(int)out2);
      printf("%3d",(int)out2);
    }
  }

  fprintf(out_file,"}; /* %d */\n",x);
  printf("}; /* %d */\n",x);
  fprintf(out_file,"\nint last = %d;\n",x);
  printf("last = %d\n",x);
  fprintf(out_file,"double StepSize = %f;\n",StepSize);
  printf("StepSize = %f\n",StepSize);
  printf("data send to fast_sin.h\n");
  fflush(out_file);
  fclose(out_file);
}

// makfast.c
