annotate ringtools/fc-e1decode.c @ 537:018488f6343b

doc/Loadtools-usage: new fc-xram -j option documented
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 19 Jun 2019 22:42:25 +0000
parents c8806a5d4a6a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
176
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This program decodes a binary Melody E1 file into the ASCII source format
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * of our own invention which fc-e1gen accepts as input.
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <ctype.h>
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <string.h>
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <strings.h>
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 char *infname;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 FILE *inf, *outf;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 static unsigned
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 get_word()
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 u_char b[2];
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 int i, c;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 for (i = 0; i < 2; i++) {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 c = getc(inf);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 if (c < 0) {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 fprintf(stderr, "error: premature EOF in %s\n",
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 infname);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 exit(1);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 b[i] = c;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 return((b[1] << 8) | b[0]);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 do_global_osc_set()
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 unsigned word, osc;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 word = get_word();
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 fprintf(outf, "osc-set (%u)", word & 0xFF);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 for (osc = 0; osc < 8; osc++)
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 if (word & (1 << (osc + 8)))
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 fprintf(outf, " %u", osc);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 putc('\n', outf);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 putc('\n', outf);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 convert_signed_14bit(u)
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 unsigned u;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 int i;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 i = u;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 if (i >= 8192)
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 i -= 16384;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 return (i);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 convert_signed_5bit(u)
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 unsigned u;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 int i;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 i = u;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 if (i >= 16)
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 i -= 32;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 return (i);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 process_oscwords(osc, warnflags)
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 unsigned osc, *warnflags;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 unsigned word0, word1, extraword;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 word0 = get_word();
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 word1 = get_word();
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 if (word1 & 0xF)
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 *warnflags |= 1;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 fprintf(outf, "osc %u (%u)", osc, word0 & 1);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 if (word0 & 2) {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 fprintf(outf, " df %d %u", convert_signed_14bit(word0 >> 2),
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 word1 >> 6);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 } else {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 if (word0 & 4)
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 fputs(" sq1", outf);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 if (word0 & 8)
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 fputs(" sq2", outf);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 fprintf(outf, " %u %u %u", (word0 >> 4) & 0x3F, word0 >> 10,
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 word1 >> 6);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 if (word1 & 0x10) {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 extraword = get_word();
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 if (extraword & 0xFF)
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 *warnflags |= 2;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 fprintf(outf, " trem %u %d", (extraword >> 8) & 7,
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 convert_signed_5bit(extraword >> 11));
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 if (word1 & 0x20) {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 extraword = get_word();
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 fprintf(outf, " env %u %u %u %u %u", extraword & 0xF,
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 extraword >> 13, (extraword >> 10) & 7,
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 (extraword >> 7) & 7, (extraword >> 4) & 7);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 }
178
c8806a5d4a6a fc-e1decode: forgot terminating newline on osc lines
Mychaela Falconia <falcon@freecalypso.org>
parents: 176
diff changeset
103 putc('\n', outf);
176
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 process_block(timeword)
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 unsigned timeword;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 unsigned osc, warnflags[8], anywarn;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 fprintf(outf, "time %u\n", timeword & 0xFF);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 for (osc = 0; osc < 8; osc++) {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 warnflags[osc] = 0;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 if (timeword & (1 << (osc + 8)))
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 process_oscwords(osc, warnflags + osc);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 putc('\n', outf);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 anywarn = 0;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 for (osc = 0; osc < 8; osc++) {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 if (warnflags[osc] & 1) {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 fprintf(outf,
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 "# warning: reserved bits set in osc %u word1 above\n",
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 osc);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 anywarn = 1;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 if (warnflags[osc] & 2) {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 fprintf(outf,
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 "# warning: reserved bits set in osc %u word2 above\n",
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 osc);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 anywarn = 1;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 if (anywarn)
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 putc('\n', outf);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 main(argc, argv)
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 char **argv;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 unsigned timeword;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 if (argc < 2 || argc > 3) {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 fprintf(stderr, "usage: %s infile [outfile]\n", argv[0]);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 exit(1);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 infname = argv[1];
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 inf = fopen(infname, "r");
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 if (!inf) {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 perror(infname);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 exit(1);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 if (argc > 2) {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 outf = fopen(argv[2], "w");
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 if (!outf) {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 perror(argv[2]);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 exit(1);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 } else
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 outf = stdout;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 do_global_osc_set();
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 for (;;) {
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 timeword = get_word();
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 if (timeword == 0)
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 break;
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 process_block(timeword);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 }
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 fputs("end\n", outf);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 exit(0);
2b38691076b9 fc-e1decode utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 }