annotate ringtools/fc-e1gen.c @ 172:c138906889f7

fc-e1gen & e1-experiments: added global oscillator set header word
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 22 Mar 2017 21:56:33 +0000
parents cefdc6623322
children b002c7cf5d03
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This program is an experimental compiler for TI's Melody E1 format
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * based on the description given in the L1M_AS001_1.pdf document
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * found in the Peek/FGW drop.
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/types.h>
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <ctype.h>
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <string.h>
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <strings.h>
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #define MAX_FIELDS 16
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 char *infname, *outfname;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 FILE *inf, *outf;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 char linebuf[512], *fields[MAX_FIELDS+1];
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 int lineno, nfields;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
172
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
21 int global_osc_set;
33
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 int start_time, osc_mask;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 u_short osc_words[8][4];
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 get_input_line()
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 char *cp;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 int n;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 if (!fgets(linebuf, sizeof linebuf, inf)) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 fprintf(stderr, "%s: unexpected EOF\n", infname);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 exit(1);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 cp = index(linebuf, '\n');
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 if (!cp) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 fprintf(stderr, "%s line %d: too long or missing newline\n",
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 infname, lineno);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 exit(1);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 *cp = '\0';
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 /* parse it into fields */
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 cp = linebuf;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 n = 0;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 for (;;) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 while (isspace(*cp))
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 cp++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 if (*cp == '\0' || *cp == '#')
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 break;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 if (n >= MAX_FIELDS) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 fprintf(stderr, "%s line %d: too many fields\n",
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 infname, lineno);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 exit(1);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 fields[n++] = cp;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 while (*cp && !isspace(*cp))
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 cp++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 if (*cp)
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 *cp++ = '\0';
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 fields[n] = 0;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 nfields = n;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 input_number(str, min, max)
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 char *str;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 char *endp;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 long val;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 val = strtol(str, &endp, 10);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 if (*endp) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 fprintf(stderr,
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 "%s line %d: \"%s\" is not a valid decimal number\n",
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 infname, lineno, str);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 exit(1);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 if (val < min || val > max) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 fprintf(stderr, "%s line %d: number %ld is out of range\n",
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 infname, lineno, val);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 exit(1);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 return val;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 handle_time_line()
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 if (nfields != 2) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 fprintf(stderr, "%s line %d: time header takes 1 argument\n",
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 infname, lineno);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 exit(1);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 start_time = input_number(fields[1], 1, 255);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 check_req_field(n)
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 if (n >= nfields) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 fprintf(stderr, "%s line %d: too few fields\n",
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 infname, lineno);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 exit(1);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 process_osc_line()
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 int p = 1;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 int oscn, osc_bit;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 u_short word0, word1, word2, word3;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 int amp, freq, length;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 int tremT0, tremFreq;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 int sustain, t1, t2, t3, t5;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 check_req_field(p);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 oscn = input_number(fields[p], 0, 7);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 osc_bit = 1 << oscn;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 if (osc_mask & osc_bit) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 fprintf(stderr, "%s line %d: osc %d defined more than once\n",
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 infname, lineno, oscn);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 exit(1);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 osc_mask |= osc_bit;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 /* basic part */
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 check_req_field(p);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 if (!strcmp(fields[p], "df")) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 check_req_field(p);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 freq = input_number(fields[p], -8192, 8191) & 0x3FFF;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 check_req_field(p);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 amp = input_number(fields[p], 0, 1023);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 word0 = freq << 2 | 2;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 word1 = amp << 6;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 } else {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 word0 = 0;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 if (!strcmp(fields[p], "sq1")) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 word0 |= 4;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 check_req_field(p);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 if (!strcmp(fields[p], "sq2")) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 word0 |= 8;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 check_req_field(p);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 amp = input_number(fields[p], 0, 63);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 check_req_field(p);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 freq = input_number(fields[p], 0, 63);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 word0 |= (freq << 10) | (amp << 4);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 check_req_field(p);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 length = input_number(fields[p], 0, 1023);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 word1 = length << 6;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 /* optional 3rd word */
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 if (p < nfields && !strcmp(fields[p], "trem")) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 word1 |= 0x10;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 check_req_field(p);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 tremT0 = input_number(fields[p], 0, 7);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 check_req_field(p);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 tremFreq = input_number(fields[p], -16, 15) & 31;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 word2 = (tremFreq << 11) | (tremT0 << 8);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 /* optional 4th word */
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 if (p < nfields && !strcmp(fields[p], "env")) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 word1 |= 0x20;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 check_req_field(p);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 sustain = input_number(fields[p], 0, 15);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 check_req_field(p);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 t1 = input_number(fields[p], 0, 7);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 check_req_field(p);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 t2 = input_number(fields[p], 0, 7);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 check_req_field(p);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 t3 = input_number(fields[p], 0, 7);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 check_req_field(p);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 t5 = input_number(fields[p], 0, 7);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 p++;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 word3 = (t1 << 13) | (t2 << 10) | (t3 << 7) | (t5 << 4) |
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 sustain;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 if (p != nfields) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 fprintf(stderr, "%s line %d: unexpected extra fields\n",
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 infname, lineno);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 osc_words[oscn][0] = word0;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 osc_words[oscn][1] = word1;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 osc_words[oscn][2] = word2;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 osc_words[oscn][3] = word3;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 read_osc_lines()
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 osc_mask = 0;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 for (;;) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 get_input_line();
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 if (!nfields)
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 break;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 if (!strcmp(fields[0], "osc")) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 process_osc_line();
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 continue;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 fprintf(stderr, "%s line %d: osc line expected\n",
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 infname, lineno);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 exit(1);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 emit_16bit_word(word)
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 u_short word;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 putc(word & 0xFF, outf);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 putc(word >> 8, outf);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 emit_record()
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231 {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 int oscn, osc_bit;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 putc(start_time, outf);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235 putc(osc_mask, outf);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 for (oscn = 0; oscn < 8; oscn++) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 osc_bit = 1 << oscn;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 if (!(osc_mask & osc_bit))
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 continue;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 emit_16bit_word(osc_words[oscn][0]);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 emit_16bit_word(osc_words[oscn][1]);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242 if (osc_words[oscn][1] & 0x10)
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243 emit_16bit_word(osc_words[oscn][2]);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
244 if (osc_words[oscn][1] & 0x20)
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
245 emit_16bit_word(osc_words[oscn][3]);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248
172
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
249 handle_global_osc_set()
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
250 {
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
251 int p;
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
252 int oscn, osc_bit;
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
253
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
254 do
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
255 get_input_line();
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
256 while (!nfields);
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
257 if (strcmp(fields[0], "osc-set")) {
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
258 fprintf(stderr, "%s line %d: osc-set line expected\n",
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
259 infname, lineno);
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
260 exit(1);
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
261 }
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
262 if (nfields < 2) {
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
263 fprintf(stderr, "%s line %d: osc-set must be non-empty\n",
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
264 infname, lineno);
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
265 exit(1);
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
266 }
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
267 for (p = 1; p < nfields; p++) {
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
268 oscn = input_number(fields[p], 0, 7);
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
269 osc_bit = 1 << oscn;
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
270 global_osc_set |= osc_bit;
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
271 }
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
272 putc(0, outf);
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
273 putc(global_osc_set, outf);
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
274 }
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
275
33
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
276 main(argc, argv)
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
277 char **argv;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
278 {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
279 if (argc != 3) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
280 fprintf(stderr, "usage: %s src-file e1-bin-file\n", argv[0]);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
281 exit(1);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
282 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
283 if (strcmp(argv[1], "-")) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
284 infname = argv[1];
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
285 inf = fopen(infname, "r");
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
286 if (!inf) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
287 perror(infname);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
288 exit(1);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
289 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
290 } else {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
291 infname = "stdin";
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
292 inf = stdin;
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
293 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
294 outfname = argv[2];
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
295 outf = fopen(outfname, "w");
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
296 if (!outf) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
297 perror(outfname);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
298 exit(1);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
299 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
300
172
c138906889f7 fc-e1gen & e1-experiments: added global oscillator set header word
Mychaela Falconia <falcon@freecalypso.org>
parents: 33
diff changeset
301 handle_global_osc_set();
33
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
302 /* main loop */
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
303 for (;;) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
304 do
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
305 get_input_line();
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
306 while (!nfields);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
307 if (!strcmp(fields[0], "time")) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
308 handle_time_line();
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
309 read_osc_lines();
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
310 emit_record();
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
311 } else if (!strcmp(fields[0], "end")) {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
312 emit_16bit_word(0);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
313 exit(0);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
314 } else {
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
315 fprintf(stderr, "%s line %d: expected time or end\n",
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
316 infname, lineno);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
317 exit(1);
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
318 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
319 }
cefdc6623322 fc-e1gen utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
320 }