1 | /*
|
---|
2 | =============================================================================
|
---|
3 | tmults. -- calculate a table of time multipliers for the Buchla 700
|
---|
4 | Version 5 -- 1987-09-24 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include "stdio.h"
|
---|
9 | #include "stddefs.h"
|
---|
10 |
|
---|
11 | #define OUT_FILE "tmultab.tmp"
|
---|
12 | #define PRN_FILE "tmultab.prn"
|
---|
13 |
|
---|
14 | #define SHIFTCON 32768.0
|
---|
15 |
|
---|
16 | float j, m;
|
---|
17 | int i, k[101], n;
|
---|
18 | FILE *fp_out, *fp_prn;
|
---|
19 |
|
---|
20 | main()
|
---|
21 | {
|
---|
22 | if (NULL EQ (fp_out = fopen(OUT_FILE, "wa"))) {
|
---|
23 |
|
---|
24 | printf("Unable to open [%s] for output\n", OUT_FILE);
|
---|
25 | exit(1);
|
---|
26 | }
|
---|
27 |
|
---|
28 | if (NULL EQ (fp_prn = fopen(PRN_FILE, "wa"))) {
|
---|
29 |
|
---|
30 | printf("Unable to open [%s] for output\n", PRN_FILE);
|
---|
31 | exit(1);
|
---|
32 | }
|
---|
33 |
|
---|
34 | printf("Creating time multiplier table on [%s]\n", OUT_FILE);
|
---|
35 | printf(" and documentation on [%s]\n\n", PRN_FILE);
|
---|
36 |
|
---|
37 | fprintf(fp_prn, "Time Multipliers\n\n");
|
---|
38 | fprintf(fp_prn, "Ndx Mult 1/Mult Value\n");
|
---|
39 |
|
---|
40 | for (i = 0; i LE 100; i++) {
|
---|
41 |
|
---|
42 | j = 0.5 + (float)i * 0.01;
|
---|
43 | m = 1.0 / j;
|
---|
44 |
|
---|
45 | if (m EQ 2.0) /* limit to 'almost 2.0' to avoid overflow */
|
---|
46 | m = 1.99999;
|
---|
47 |
|
---|
48 | n = m * SHIFTCON;
|
---|
49 | k[i] = n;
|
---|
50 |
|
---|
51 | fprintf(fp_prn, "%3d %4.2f %6.4f 0x%04x\n", i, j, m, n);
|
---|
52 | }
|
---|
53 |
|
---|
54 | for (i = 0; i LE 100; i++) {
|
---|
55 |
|
---|
56 | if (0 EQ (i % 5))
|
---|
57 | fprintf(fp_out, "\n\t");
|
---|
58 |
|
---|
59 | fprintf(fp_out, "0x%04x, ", k[i]);
|
---|
60 | }
|
---|
61 |
|
---|
62 | fprintf(fp_out, "\n");
|
---|
63 | fflush(fp_out);
|
---|
64 | fclose(fp_out);
|
---|
65 | fflush(fp_prn);
|
---|
66 | fclose(fp_prn);
|
---|
67 | printf("Time multipler table output complete.\n");
|
---|
68 | exit(0);
|
---|
69 | }
|
---|