// makslo.c #include #include #include #include #include #include #include #include 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/255.0; out_file = fopen("slosin.h","w"); // store in slosin.h fputs("unsigned char sin_table[] = {",out_file); printf("unsigned char sin_table[] = {"); for(n=0,x=0; n<2; 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 slosin.h\n"); fflush(out_file); fclose(out_file); } // makslo.c