maketable.c
564 Bytes
/*
* maketable.c
*
* This program generates the sintable.h file used by sins.c and coss.c
*/
#include <stdio.h>
#include <math.h>
int main (void)
{
int i, val;
printf ("\n/*\n");
printf (" * Do not edit this file -- it was generated by \"maketable\".\n");
printf (" */\n\n");
printf ("static signed short sintable[0x400] = {\n");
for (i = 0; i < 0x400; i++) {
val = (int)(sin (i * (M_PI/2) / 0x3ff) * 32767);
if (val < 0) {
val = 0;
}
if (val > 32767) {
val = 32767;
}
printf ("\t0x%04x,\n", val);
}
printf ("};\n");
return 0;
}