// SCBUILD.C v1.1 -- builds SIN/COS lookup tables (c)1998 James Shaughnessy // Written for use with the Sony Net Yaroze (as there's no FPU!) // // Compiled on Turbo C++ 3.0 for DOS // // Type SCBUILD to generate SINCOS.H file, and then just // #include "sincos.h" in your programs to access the arrays // // SCBUILD n (default: 360) will generate n number of indices to the // arrays, eg SCBUILD 4096 will create SIN[4096] = {...} etc. // // The values are LONG integers and are of the * 4096 order, so to get // the required effect you MUST use ((value * SIN[angle])>>12) // where value is the number you're affecting, and angle is the integer // angle in degrees of the range 0 to n-1 // // You can easily alter and re-compile this code to generate more custom // lookup tables -- if you'd like me to do it for you no problemo, just // email below. It takes the PlayStation AGES to generate these tables // so let's never see that "Generating lookup tables, please wait..." // message EVER again! // Note the nifty way of getting maximum accuracy for pi... // // James Shaughnessy // http://www.netyaroze-europe.com/~shaughnj #include #include int main(int argc, char *argv[]) { FILE *outfile; int i, n; double value; long longvalue; double pi = 4.0 * atan(1.0); // 3.14159265358979858... char hdrstr[] = "// Sine/Cosine lookup tables (c)1998 James Shaughnessy\n// Created with SCBUILD v1.1 See http://www.netyaroze-europe.com/~shaughnj\n\n"; if (argc == 1) { n = 360; } else { n = atoi(argv[1]); // Get input number if (argv[1] == "-h" || argv[1] == "-?" || n < 1 || n > 4096) { printf("SCBUILD v1.1 Sine/Cosine Lookup-table Builder (c)1998 James Shaughnessy\n"); printf("For Sony Net Yaroze See http://www.netyaroze-europe.com/~shaughnj\n"); printf("Format: SCBUILD [n] (n = size of arrays Default: 360 Max: 4096)\n"); exit(1); } } printf("Format: SCBUILD [n] (n = size of arrays Default: 360)\n\n"); printf("Building SIN[%d] / COS[%d] lookup tables ...\n", n, n); outfile = fopen("SINCOS.H", "wt"); // [W]rite [T]ext fwrite(hdrstr, strlen(hdrstr), 1, outfile); // Write hdrstr[] // Build SIN lookup table fwrite("long SIN[", 9, 1, outfile); // Write "long SIN[" fprintf(outfile, "%d", n); // Write "n" fwrite("] = {", 5, 1, outfile); // Write "] = {" for (i=0; i