FreeCalypso > hg > freecalypso-tools
comparison 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 |
comparison
equal
deleted
inserted
replaced
171:f736f3ce8310 | 172:c138906889f7 |
---|---|
16 char *infname, *outfname; | 16 char *infname, *outfname; |
17 FILE *inf, *outf; | 17 FILE *inf, *outf; |
18 char linebuf[512], *fields[MAX_FIELDS+1]; | 18 char linebuf[512], *fields[MAX_FIELDS+1]; |
19 int lineno, nfields; | 19 int lineno, nfields; |
20 | 20 |
21 int global_osc_set; | |
21 int start_time, osc_mask; | 22 int start_time, osc_mask; |
22 u_short osc_words[8][4]; | 23 u_short osc_words[8][4]; |
23 | 24 |
24 get_input_line() | 25 get_input_line() |
25 { | 26 { |
215 } | 216 } |
216 fprintf(stderr, "%s line %d: osc line expected\n", | 217 fprintf(stderr, "%s line %d: osc line expected\n", |
217 infname, lineno); | 218 infname, lineno); |
218 exit(1); | 219 exit(1); |
219 } | 220 } |
220 if (!osc_mask) { | |
221 fprintf(stderr, "%s line %d: no oscillators defined\n", | |
222 infname, lineno); | |
223 exit(1); | |
224 } | |
225 } | 221 } |
226 | 222 |
227 emit_16bit_word(word) | 223 emit_16bit_word(word) |
228 u_short word; | 224 u_short word; |
229 { | 225 { |
248 if (osc_words[oscn][1] & 0x20) | 244 if (osc_words[oscn][1] & 0x20) |
249 emit_16bit_word(osc_words[oscn][3]); | 245 emit_16bit_word(osc_words[oscn][3]); |
250 } | 246 } |
251 } | 247 } |
252 | 248 |
249 handle_global_osc_set() | |
250 { | |
251 int p; | |
252 int oscn, osc_bit; | |
253 | |
254 do | |
255 get_input_line(); | |
256 while (!nfields); | |
257 if (strcmp(fields[0], "osc-set")) { | |
258 fprintf(stderr, "%s line %d: osc-set line expected\n", | |
259 infname, lineno); | |
260 exit(1); | |
261 } | |
262 if (nfields < 2) { | |
263 fprintf(stderr, "%s line %d: osc-set must be non-empty\n", | |
264 infname, lineno); | |
265 exit(1); | |
266 } | |
267 for (p = 1; p < nfields; p++) { | |
268 oscn = input_number(fields[p], 0, 7); | |
269 osc_bit = 1 << oscn; | |
270 global_osc_set |= osc_bit; | |
271 } | |
272 putc(0, outf); | |
273 putc(global_osc_set, outf); | |
274 } | |
275 | |
253 main(argc, argv) | 276 main(argc, argv) |
254 char **argv; | 277 char **argv; |
255 { | 278 { |
256 if (argc != 3) { | 279 if (argc != 3) { |
257 fprintf(stderr, "usage: %s src-file e1-bin-file\n", argv[0]); | 280 fprintf(stderr, "usage: %s src-file e1-bin-file\n", argv[0]); |
273 if (!outf) { | 296 if (!outf) { |
274 perror(outfname); | 297 perror(outfname); |
275 exit(1); | 298 exit(1); |
276 } | 299 } |
277 | 300 |
301 handle_global_osc_set(); | |
278 /* main loop */ | 302 /* main loop */ |
279 for (;;) { | 303 for (;;) { |
280 do | 304 do |
281 get_input_line(); | 305 get_input_line(); |
282 while (!nfields); | 306 while (!nfields); |