source: buchla-68k/orig/RAM/PTWRITE.C@ a838f5b

Last change on this file since a838f5b was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 7.0 KB
Line 
1/*
2 =============================================================================
3 ptwrite.c -- librarian - write patch functions
4 Version 7 -- 1988-11-18 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#define DEBUGWE 0
9#define DEBUGPW 0
10
11#include "stddefs.h"
12#include "stdio.h"
13#include "hwdefs.h"
14#include "graphdef.h"
15#include "vsdd.h"
16#include "patch.h"
17
18#include "midas.h"
19#include "libdsp.h"
20
21#if (DEBUGPW|DEBUGWE)
22extern short debugsw;
23#endif
24
25#if DEBUGPW
26short debugpw = 1;
27#endif
28
29#if DEBUGWE
30extern short debugwe;
31#endif
32
33extern long chksum();
34
35/*
36
37*/
38
39char ptsizes[] = {
40
41 0, /* NULL - end of list */
42 4, /* PA_KEY */
43 4, /* PA_TRG */
44 3, /* PA_PLS */
45 3, /* PA_LED */
46 4, /* PA_SLIN */
47 3, /* PA_SCTL */
48 2, /* PA_TUNE */
49 4, /* PA_RSET */
50 4, /* PA_RADD */
51 3, /* PA_INST */
52 6, /* PA_OSC */
53 3, /* PA_WAVA */
54 3, /* PA_WAVB */
55 3, /* PA_CNFG */
56 5, /* PA_LEVL */
57 6, /* PA_INDX */
58 6, /* PA_FREQ */
59 5, /* PA_FILT */
60 5, /* PA_FILQ */
61 5, /* PA_LOCN */
62 5, /* PA_DYNM */
63 4, /* PA_AUX */
64 4, /* PA_RATE */
65 4, /* PA_INTN */
66 4, /* PA_DPTH */
67 5 /* PA_VOUT */
68};
69
70/*
71
72*/
73
74/*
75 =============================================================================
76 ptsizer() -- return number of bytes necessary for storing active patches
77 =============================================================================
78*/
79
80long
81ptsizer()
82{
83 register short pp;
84 register long nb;
85
86 nb = 0L;
87
88 if (pp = find1st()) {
89
90 while (pp) {
91
92 nb += (ptsizes[PE_SPEC & patches[pp].paspec] + 4);
93 pp = findnxt(pp);
94 }
95 }
96
97 if (nb)
98 ++nb; /* ... and one for the terminator */
99
100#if DEBUGPW
101 if (debugsw AND debugpw)
102 printf("ptsizer(): %ld bytes required\n", nb);
103#endif
104
105 return(nb);
106}
107
108/*
109
110*/
111
112/*
113 =============================================================================
114 ptwrite() -- store a patch table
115 =============================================================================
116*/
117
118short
119ptwrite(fp)
120register FILE *fp;
121{
122 register short pp;
123 char cb, zero;
124
125#if DEBUGPW
126 if (debugsw AND debugpw)
127 printf("ptwrite($%08lX): entered\n", fp);
128#endif
129
130 zero = '\0';
131
132 ldwmsg("Busy -- Please stand by", (char *)0L, " writing patches",
133 LCFBX10, LCBBX10);
134
135 if (pp = find1st()) {
136
137 while (pp) {
138
139#if DEBUGWE
140 if (debugsw AND debugwe) {
141
142 printf("ptwrite(): %3d %04.4X %04.4X %04.4X %04.4X %04.4X %04.4X\n ",
143 pp, patches[pp].defnum, patches[pp].stmnum,
144 patches[pp].paspec, patches[pp].pasuba,
145 patches[pp].padat1, patches[pp].padat2);
146 }
147#endif
148
149 switch (cb = (PE_SPEC & patches[pp].paspec)) {
150
151 case PA_KEY:
152 case PA_TRG:
153
154 if (wr_ec(fp, &cb, 1L))
155 return(FAILURE);
156
157 if (wr_ec(fp, &patches[pp].defnum, 4L))
158 return(FAILURE);
159
160 if (wr_ec(fp, &patches[pp].pasuba, 2L))
161 return(FAILURE);
162
163 if (wr_ec(fp, (char *)&patches[pp].padat2 + 1, 1L))
164 return(FAILURE);
165
166 break;
167/*
168
169*/
170 case PA_PLS:
171 case PA_SCTL:
172
173 if (wr_ec(fp, &cb, 1L))
174 return(FAILURE);
175
176 if (wr_ec(fp, &patches[pp].defnum, 4L))
177 return(FAILURE);
178
179 if (wr_ec(fp, (char *)&patches[pp].pasuba + 1, 1L))
180 return(FAILURE);
181
182 if (wr_ec(fp, (char *)&patches[pp].padat2 + 1, 1L))
183 return(FAILURE);
184
185 break;
186
187 case PA_LED:
188
189 if (wr_ec(fp, &cb, 1L))
190 return(FAILURE);
191
192 if (wr_ec(fp, &patches[pp].defnum, 4L))
193 return(FAILURE);
194
195 if (wr_ec(fp, (char *)&patches[pp].pasuba + 1, 1L))
196 return(FAILURE);
197
198 if (wr_ec(fp, &patches[pp].padat1, 1L))
199 return(FAILURE);
200
201 break;
202
203 case PA_SLIN:
204
205 if (wr_ec(fp, &cb, 1L))
206 return(FAILURE);
207
208 if (wr_ec(fp, &patches[pp].defnum, 4L))
209 return(FAILURE);
210
211 if (wr_ec(fp, (char *)&patches[pp].pasuba + 1, 1L))
212 return(FAILURE);
213
214 if (wr_ec(fp, &patches[pp].padat1, 2L))
215 return(FAILURE);
216
217 break;
218
219 case PA_TUNE:
220
221 if (wr_ec(fp, &cb, 1L))
222 return(FAILURE);
223
224 if (wr_ec(fp, &patches[pp].defnum, 4L))
225 return(FAILURE);
226
227 if (wr_ec(fp, (char *)&patches[pp].padat1 + 1, 1L))
228 return(FAILURE);
229
230 break;
231/*
232
233*/
234 case PA_RSET:
235 case PA_RADD:
236
237 if (wr_ec(fp, &cb, 1L))
238 return(FAILURE);
239
240 if (wr_ec(fp, &patches[pp].defnum, 4L))
241 return(FAILURE);
242
243 if (wr_ec(fp, (char *)&patches[pp].pasuba + 1, 1L))
244 return(FAILURE);
245
246 if (wr_ec(fp, (char *)&patches[pp].padat1 + 1, 1L))
247 return(FAILURE);
248
249 if (wr_ec(fp, (char *)&patches[pp].padat2 + 1, 1L))
250 return(FAILURE);
251
252 break;
253
254 case PA_INST:
255 case PA_WAVA:
256 case PA_WAVB:
257 case PA_CNFG:
258
259 if (wr_ec(fp, &cb, 1L))
260 return(FAILURE);
261
262 if (wr_ec(fp, &patches[pp].defnum, 4L))
263 return(FAILURE);
264
265 if (wr_ec(fp, &patches[pp].pasuba, 1L))
266 return(FAILURE);
267
268 if (wr_ec(fp, (char *)&patches[pp].padat1 + 1, 1L))
269 return(FAILURE);
270
271 break;
272
273 case PA_OSC:
274 case PA_INDX:
275 case PA_FREQ:
276
277 if (wr_ec(fp, &cb, 1L))
278 return(FAILURE);
279
280 if (wr_ec(fp, &patches[pp].defnum, 4L))
281 return(FAILURE);
282
283 if (wr_ec(fp, &patches[pp].pasuba, 2L))
284 return(FAILURE);
285
286 if (wr_ec(fp, (char *)&patches[pp].padat1 + 1, 1L))
287 return(FAILURE);
288
289 if (wr_ec(fp, &patches[pp].padat2, 2L))
290 return(FAILURE);
291
292 break;
293/*
294
295*/
296 case PA_LEVL:
297 case PA_FILT:
298 case PA_FILQ:
299 case PA_LOCN:
300 case PA_DYNM:
301
302 if (wr_ec(fp, &cb, 1L))
303 return(FAILURE);
304
305 if (wr_ec(fp, &patches[pp].defnum, 4L))
306 return(FAILURE);
307
308 if (wr_ec(fp, &patches[pp].pasuba, 1L))
309 return(FAILURE);
310
311 if (wr_ec(fp, (char *)&patches[pp].padat1 + 1, 1L))
312 return(FAILURE);
313
314 if (wr_ec(fp, &patches[pp].padat2, 2L))
315 return(FAILURE);
316
317 break;
318
319 case PA_AUX:
320 case PA_RATE:
321 case PA_INTN:
322 case PA_DPTH:
323
324 if (wr_ec(fp, &cb, 1L))
325 return(FAILURE);
326
327 if (wr_ec(fp, &patches[pp].defnum, 4L))
328 return(FAILURE);
329
330 if (wr_ec(fp, (char *)&patches[pp].padat1 + 1, 1L))
331 return(FAILURE);
332
333 if (wr_ec(fp, &patches[pp].padat2, 2L))
334 return(FAILURE);
335
336 break;
337
338 case PA_VOUT:
339
340 if (wr_ec(fp, &cb, 1L))
341 return(FAILURE);
342
343 if (wr_ec(fp, &patches[pp].defnum, 4L))
344 return(FAILURE);
345
346 if (wr_ec(fp, (char *)&patches[pp].pasuba + 1, 1L))
347 return(FAILURE);
348
349 if (wr_ec(fp, (char *)&patches[pp].padat1 + 1, 1L))
350 return(FAILURE);
351
352 if (wr_ec(fp, &patches[pp].padat2, 2L))
353 return(FAILURE);
354
355 break;
356/*
357
358*/
359 default:
360
361 return(FAILURE);
362 }
363
364#if DEBUGWE
365 if (debugsw AND debugwe)
366 printf("\n\n");
367#endif
368
369 pp = findnxt(pp); /* find the next patch */
370 }
371
372 if (wr_ec(fp, &zero, 1L)) /* write the terminator */
373 return(FAILURE);
374
375 } else {
376
377 return(FAILURE); /* no patches to write */
378 }
379
380#if DEBUGPW
381 if (debugsw AND debugpw)
382 printf("ptwrite(): SUCCESS\n");
383#endif
384
385 return(SUCCESS);
386}
Note: See TracBrowser for help on using the repository browser.