ic.h
9.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
/*====================================================================
* ic.h
*
* Synopsis:
*
* Copyright 1993, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
#include <stdio.h>
#include <strings.h>
#include <stdlib.h>
#include <libaudio.h>
#define FALSE 0
#define TRUE 1
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#define ICBANK 1
#define ICINST 2
#define ICSOUND 3
#define ICKEYMAP 4
#define ICWAVE 5
#define ICLOOP 6
#define ICBANKFILE 7
#define ICENVELOPE 8
#define ICBOOK 9
typedef struct id {
char *name;
int lextype;
} Id;
typedef struct decl {
int declclass;
int id; /* object id */
int size; /* size of object in bytes */
void *offset; /* offset in the file image */
int value;
} Decl;
typedef struct ste {
struct id *name;
struct decl *decl;
struct ste *prev;
} STE;
/*
* symtab.c
*/
extern struct ste **stacktop; /* top of scope stack */
extern struct ste **globalscope;/* stacktop in global scope */
extern int *offsettop; /* pointer to stack of offsets. */
int inglobalscope(void);
void pushscope(void);
struct ste *popscope(void);
void declare(struct id *idptr, struct decl *declptr);
void declareglobal(struct id *idptr, struct decl *declptr);
struct decl *finddecl(struct id *idptr, struct ste *steptr);
struct decl *findcurrentdecl(struct id *idptr);
struct decl *testglobaldecl(struct id *idptr);
void checkredecl(struct id *idptr);
void initsymtab(void);
struct id *findname(struct decl *decl);
/*
* hash.c
*/
struct id *enter(int lextype, char *str, int len);
/*
* declreps.c
*/
extern int objectID;
void declInit(void);
int declSize(Decl *d);
void declPrint(Decl *d);
extern struct decl *makeenumconstdecl(int value);
extern struct decl *makerealconstdecl();
extern struct decl *makevardecl();
extern struct decl *maketypedecl(void);
extern struct decl *makebankfiledecl(void);
extern struct decl *makebankdecl(void);
extern struct decl *makeinstdecl(void);
extern struct decl *makesounddecl(void);
extern struct decl *makeenvdecl(void);
extern struct decl *makekeydecl(void);
extern struct decl *makefiledecl(char *s);
/* typecheck.c */
extern struct decl *getbasetype();
extern void checkiscompareabletype();
extern struct decl *checkfunctioncall();
extern struct decl *lesstype();
extern struct decl *plustype();
extern struct decl *divtype();
extern struct decl *andtype();
extern struct decl *slashtype();
extern struct decl *minustype();
extern struct decl *nottype();
extern void checkassignment();
extern struct decl *arrayindextype();
extern struct decl *recordaccesstype();
extern void matchforward();
/*
* main.c
*/
void initLex(void);
extern FILE *tblFile;
extern struct decl *insttype;
extern struct decl *banktype;
extern struct decl *sndtype;
extern struct decl *inttype;
extern struct decl *realtype;
extern struct decl *booltype;
extern struct decl *voidtype;
extern struct decl *errortype;
extern struct decl *errorvar;
extern struct id *returnid;
extern int verbose;
extern int boundcheck;
/*
* output.c
*/
void doPrint(void);
void doLayOut(void);
void doWrite(FILE *file);
/*
* list.c
*/
typedef struct Node_s {
struct Node_s *next;
void *data;
int flags;
} Node;
typedef struct {
Node *head;
Node *tail;
} List;
void listNew(List *l);
void listAppend(List *l, void *data);
void listPrepend(List *l, void *data);
/*
* wavetable.c
*/
typedef struct {
Decl decl; /* object declaration params */
ALWaveTable *wave;
char *base;
int len;
int rate;
char channels;
char size;
char format;
struct ICLoop_s *loop;
struct ICBook_s *book;
} ICWave;
void waveNew(ICWave *w);
void waveSetTable(ICWave *w, char *base, int len);
void waveSetRate(ICWave *w, int rate);
void waveSetChannels(ICWave *w, char channels);
void waveSetSize(ICWave *w, char size);
void waveSetFormat(ICWave *w, char format);
void waveLayOut(ICWave *w);
void wavePrint(ICWave *w);
void waveWrite(ICWave *w, FILE *file);
/*
* loop.c
*/
typedef short ICLoopState[ADPCMFSIZE];
typedef struct {
ICLoopState state;
u_long start;
u_long end;
u_long count;
u_long pad1;
} Aloop;
typedef struct ICLoop_s {
Decl decl;
Aloop *loop;
u_long start;
u_long end;
u_long count;
ICLoopState state;
} ICLoop;
void loopNew(ICLoop *l);
void loopSetPoints(ICLoop *l, u_long start, u_long end, u_long count,
ICLoopState state);
void loopLayOut(ICLoop *l);
void loopPrint(ICLoop *l);
void loopWrite(ICLoop *l, FILE *file);
char *ReadPString(FILE *ifile);
/*
* book.c
*/
typedef struct ICBook_s{
Decl decl;
ALADPCMBook *bookp;
u_long order;
u_long npredictors;
short book[1]; /* ** Wrong! Actually variable size */
} ICBook;
void bookNew(ICBook *b, int order, int npredictors);
void bookLayOut(ICBook *icb);
void bookPrint(ICBook *icb);
void bookWrite(ICBook *b, FILE *file);
/*
* envelope.c
*/
typedef struct {
Decl decl;
ALEnvelope *envelope;
int attackTime;
short attackVol;
int decayTime;
short decayVol;
int releaseTime;
short releaseVol;
} ICEnvelope;
extern ICEnvelope *curEnvelope;
void envNew(ICEnvelope *env);
void envSetAttackTime(ICEnvelope *e, int t);
void envSetAttackVol(ICEnvelope *e, short v);
void envSetDecayTime(ICEnvelope *e, int t);
void envSetDecayVol(ICEnvelope *e, short v);
void envSetReleaseTime(ICEnvelope *e, int t);
void envSetReleaseVol(ICEnvelope *e, short v);
void envLayOut(ICEnvelope *env);
void envPrint(ICEnvelope *env);
void envWrite(ICEnvelope *env, FILE *file);
/*
* keymap.c
*/
typedef struct {
Decl decl; /* object declaration params */
ALKeyMap *map; /* file representation */
char velocityMin;
char velocityMax;
char keyMin;
char keyMax;
char keyBase;
char detune;
} ICKeyMap;
extern ICKeyMap *curKeyMap;
void keyNew(ICKeyMap *k);
void keySetKeyMin(ICKeyMap *k, int min);
void keySetKeyMax(ICKeyMap *k, int max);
void keySetKeyBase(ICKeyMap *k, int base);
void keySetVelMin(ICKeyMap *k, int value);
void keySetVelMax(ICKeyMap *k, int value);
void keySetDetune(ICKeyMap *k, int value);
void keyLayOut(ICKeyMap *k);
void keyPrint(ICKeyMap *k);
void keyWrite(ICKeyMap *k, FILE *file);
/*
* sound.c
*/
typedef struct {
Decl decl;
ALSound *sound;
char samplePan;
char sampleVolume;
ICEnvelope *envelope;
ICKeyMap *keymap;
int waveCount;
ICWave *wave;
} ICSound;
extern ICSound *curSound;
void soundNew(ICSound *s);
void soundSetPan(ICSound *s, int pan);
void soundSetVol(ICSound *s, int vol);
void soundFromFile(ICSound *s, char *file);
void soundAddKeyMap(ICSound *s, ICKeyMap *map);
void soundAddEnvelope(ICSound *s, ICEnvelope *env);
void soundLayOut(ICSound *s);
void soundPrint(ICSound *s);
void soundWrite(ICSound *s, FILE *file);
/*
* instrument.c
*/
typedef struct {
Decl decl;
ALInstrument *inst;
List soundList;
char volume;
char pan;
int soundCount;
} ICInst;
extern ICInst *curInstrument;
void instNew(ICInst *i);
void instAddSound(ICInst *i, ICSound *s, int number);
void instSetPan(ICInst *i, int pan);
void instSetVol(ICInst *i, int vol);
void instLayOut(ICInst *i);
void instPrint(ICInst *i);
void instWrite(ICInst *i, FILE *file);
/*
* bank.c
*/
typedef struct {
Decl decl; /* object declaration */
ALBank *bank; /* file representation */
List progList; /* list of assigned instruments */
int maxPrograms; /* maximum number of programs */
} ICBank;
extern ICBank *curBank;
void bankNew(ICBank *b);
void bankAddProgram(ICBank *b, ICInst *i, int number);
void bankLayOut(ICBank *b);
void bankPrint(ICBank *b);
void bankWrite(ICBank *b, FILE *file);
/*
* bankfile.c
*/
typedef struct {
Decl decl;
ALBankFile *bankfile;
List bankList;
int bankCount;
int version;
} ICBankFile;
extern ICBankFile *curBankFile;
void bankfNew(ICBankFile *b);
void bankfAddBank(ICBankFile *icb, ICBank *b, int number);
void bankfLayOut(ICBankFile *b);
void bankfPrint(ICBankFile *b);
void bankfWrite(ICBankFile *b, FILE *file);
/* LEX, YACC interface */
extern int yylineno;
extern char yytext[];
extern void yyerror(char *msg);
extern int yyparse(void);
extern int yylex(void);
extern List *objectList;