1 | /*
|
---|
2 | =============================================================================
|
---|
3 | librw.c -- MIDAS librarian read / write functions
|
---|
4 | Version 22 -- 1988-11-18 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #define DEBUGIT 0
|
---|
9 |
|
---|
10 | #include "stddefs.h"
|
---|
11 | #include "biosdefs.h"
|
---|
12 | #include "memory.h"
|
---|
13 | #include "stdio.h"
|
---|
14 | #include "errno.h"
|
---|
15 |
|
---|
16 | #include "ascii.h"
|
---|
17 | #include "charset.h"
|
---|
18 | #include "fpu.h"
|
---|
19 | #include "hwdefs.h"
|
---|
20 | #include "vsdd.h"
|
---|
21 | #include "vsddsw.h"
|
---|
22 | #include "vsddvars.h"
|
---|
23 | #include "graphdef.h"
|
---|
24 | #include "charset.h"
|
---|
25 | #include "fields.h"
|
---|
26 | #include "patch.h"
|
---|
27 | #include "score.h"
|
---|
28 | #include "scfns.h"
|
---|
29 |
|
---|
30 | #include "midas.h"
|
---|
31 | #include "asgdsp.h"
|
---|
32 | #include "instdsp.h"
|
---|
33 | #include "libdsp.h"
|
---|
34 | #include "wsdsp.h"
|
---|
35 |
|
---|
36 | /* |
---|
37 |
|
---|
38 | */
|
---|
39 |
|
---|
40 | #if DEBUGIT
|
---|
41 | extern short debugsw;
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | extern char *slotnam();
|
---|
45 |
|
---|
46 | extern long chksum();
|
---|
47 |
|
---|
48 | extern short ldslot, lderrsw, lrasw;
|
---|
49 | extern short tunlib[][128];
|
---|
50 |
|
---|
51 | extern long lcsum, schksum, sntlreq;
|
---|
52 |
|
---|
53 | extern char tunname[][32];
|
---|
54 | extern char ldfile[9];
|
---|
55 | extern char ldcmnt[38];
|
---|
56 |
|
---|
57 | extern struct mlibhdr ldhead;
|
---|
58 | extern struct asgent asgtab[];
|
---|
59 | extern struct wstbl wslib[];
|
---|
60 | extern struct instdef idefs[];
|
---|
61 | extern struct s_time stimes[N_SCORES][N_SECTS];
|
---|
62 |
|
---|
63 | /* |
---|
64 |
|
---|
65 | */
|
---|
66 |
|
---|
67 | /*
|
---|
68 | =============================================================================
|
---|
69 | wrt_asg() -- write an assignment on the disk
|
---|
70 | =============================================================================
|
---|
71 | */
|
---|
72 |
|
---|
73 | short
|
---|
74 | wrt_asg(slot)
|
---|
75 | short slot;
|
---|
76 | {
|
---|
77 | register FILE *fp;
|
---|
78 | register int i;
|
---|
79 | char cstemp[8];
|
---|
80 |
|
---|
81 | preio(); /* kill LCD backlight */
|
---|
82 |
|
---|
83 | fp = fopenb(slotnam(slot, FT_ASG), "w");
|
---|
84 |
|
---|
85 | if ((FILE *)NULL EQ fp) {
|
---|
86 |
|
---|
87 | ldermsg("Couldn't create a file",
|
---|
88 | " for the assignments", (char *)NULL,
|
---|
89 | LD_EMCF, LD_EMCB);
|
---|
90 |
|
---|
91 | postio(); /* restore LCD backlight */
|
---|
92 | streset();
|
---|
93 | return(FAILURE);
|
---|
94 | }
|
---|
95 |
|
---|
96 | makelh(FT_ASG); /* make header */
|
---|
97 |
|
---|
98 | for (i = 0; i < NASGLIB; i++)
|
---|
99 | lcsum += chksum(&asgtab[i + 1], (long)(sizeof (struct asgent)));
|
---|
100 |
|
---|
101 | sprintf(cstemp, "%08.8lX", lcsum);
|
---|
102 | memcpy(ldhead.l_csum, cstemp, 8);
|
---|
103 |
|
---|
104 | #if DEBUGIT
|
---|
105 | if (debugsw)
|
---|
106 | printf("wrt_asg(): hdr=[%-.56s]\n", &ldhead);
|
---|
107 | #endif
|
---|
108 |
|
---|
109 | /* |
---|
110 |
|
---|
111 | */
|
---|
112 | if (wr_ec(fp, &ldhead, (long)LH_LEN)) { /* header */
|
---|
113 |
|
---|
114 | streset();
|
---|
115 | return(FAILURE);
|
---|
116 | }
|
---|
117 |
|
---|
118 | for (i = 0; i < NASGLIB; i++) {
|
---|
119 |
|
---|
120 | if (wr_ec(fp, &asgtab[i + 1], (long)(sizeof (struct asgent)))) {
|
---|
121 |
|
---|
122 | streset();
|
---|
123 | return(FAILURE);
|
---|
124 | }
|
---|
125 | }
|
---|
126 |
|
---|
127 | fclose(fp);
|
---|
128 | postio(); /* restore LCD backlight */
|
---|
129 | return(SUCCESS);
|
---|
130 | }
|
---|
131 |
|
---|
132 | /* |
---|
133 |
|
---|
134 | */
|
---|
135 |
|
---|
136 | /*
|
---|
137 | =============================================================================
|
---|
138 | get_asg() -- read an assignment library from the disk
|
---|
139 | =============================================================================
|
---|
140 | */
|
---|
141 |
|
---|
142 | short
|
---|
143 | get_asg()
|
---|
144 | {
|
---|
145 | register FILE *fp;
|
---|
146 | register int i;
|
---|
147 |
|
---|
148 | preio(); /* kill LCD backlight */
|
---|
149 |
|
---|
150 | fp = fopenb(slotnam(ldslot, FT_ASG), "r");
|
---|
151 |
|
---|
152 | if ((FILE *)NULL EQ fp) {
|
---|
153 |
|
---|
154 | ldermsg("Couldn't open the file",
|
---|
155 | " for the assignments", (char *)NULL,
|
---|
156 | LD_EMCF, LD_EMCB);
|
---|
157 |
|
---|
158 | postio(); /* restore LCD backlight */
|
---|
159 | clrlsel();
|
---|
160 | return(FAILURE);
|
---|
161 | }
|
---|
162 |
|
---|
163 | memcpy(ldfile, " ", 8);
|
---|
164 | memcpy(ldcmnt, " ", 37);
|
---|
165 | ldswin(3);
|
---|
166 | ldswin(5);
|
---|
167 |
|
---|
168 | /* |
---|
169 |
|
---|
170 | */
|
---|
171 | if (rd_ec(fp, &ldhead, (long)LH_LEN)) { /* header */
|
---|
172 |
|
---|
173 | clrlsel();
|
---|
174 | return(FAILURE);
|
---|
175 | }
|
---|
176 |
|
---|
177 | #if DEBUGIT
|
---|
178 | if (debugsw)
|
---|
179 | printf("get_asg(): hdr=[%-.56s]\n", &ldhead);
|
---|
180 | #endif
|
---|
181 |
|
---|
182 |
|
---|
183 | for (i = 0; i < NASGLIB; i++) {
|
---|
184 |
|
---|
185 | if (rd_ec(fp, &asgtab[i + 1], (long)(sizeof (struct asgent)))) {
|
---|
186 |
|
---|
187 | clrlsel();
|
---|
188 | return(FAILURE);
|
---|
189 | }
|
---|
190 | }
|
---|
191 |
|
---|
192 | clrlsel();
|
---|
193 | fclose(fp);
|
---|
194 | postio(); /* restore LCD backlight */
|
---|
195 | return(SUCCESS);
|
---|
196 | }
|
---|
197 |
|
---|
198 | /* |
---|
199 |
|
---|
200 | */
|
---|
201 |
|
---|
202 | /*
|
---|
203 | =============================================================================
|
---|
204 | wrt_orc() -- write an orchestra on the disk
|
---|
205 | =============================================================================
|
---|
206 | */
|
---|
207 |
|
---|
208 | short
|
---|
209 | wrt_orc(slot, lorh)
|
---|
210 | short slot, lorh;
|
---|
211 | {
|
---|
212 | register FILE *fp;
|
---|
213 | register int i;
|
---|
214 | register struct instdef *ip;
|
---|
215 | char cstemp[8];
|
---|
216 |
|
---|
217 | if (lorh)
|
---|
218 | ldbusy(" Writing Hi Orch");
|
---|
219 | else
|
---|
220 | ldbusy(" Writing Lo Orch");
|
---|
221 |
|
---|
222 | preio(); /* kill LCD backlight */
|
---|
223 |
|
---|
224 | fp = fopenb(slotnam(slot, FT_ORC), "w");
|
---|
225 |
|
---|
226 | if ((FILE *)NULL EQ fp) {
|
---|
227 |
|
---|
228 | ldermsg("Couldn't create a file",
|
---|
229 | " for the orchestra", (char *)NULL,
|
---|
230 | LD_EMCF, LD_EMCB);
|
---|
231 |
|
---|
232 | postio(); /* restore LCD backlight */
|
---|
233 | streset();
|
---|
234 | return(FAILURE);
|
---|
235 | }
|
---|
236 |
|
---|
237 | makelh(FT_ORC); /* make header */
|
---|
238 |
|
---|
239 | for (i = 0; i < NINORC; i++) {
|
---|
240 |
|
---|
241 | ip = &idefs[i + 1 + (lorh ? NINORC : 0)];
|
---|
242 |
|
---|
243 | lcsum += chksum(ip, (long)OR_LEN1);
|
---|
244 | lcsum += chksum(ip->idhwvao, (long)OR_LEN2);
|
---|
245 | lcsum += chksum(ip->idhwvbo, (long)OR_LEN2);
|
---|
246 | }
|
---|
247 |
|
---|
248 | sprintf(cstemp, "%08.8lX", lcsum);
|
---|
249 | memcpy(ldhead.l_csum, cstemp, 8);
|
---|
250 |
|
---|
251 | #if DEBUGIT
|
---|
252 | if (debugsw)
|
---|
253 | printf("wrt_orc(): hdr=[%-.56s]\n", &ldhead);
|
---|
254 | #endif
|
---|
255 |
|
---|
256 | /* |
---|
257 |
|
---|
258 | */
|
---|
259 | if (wr_ec(fp, &ldhead, (long)LH_LEN)) { /* header */
|
---|
260 |
|
---|
261 | streset();
|
---|
262 | return(FAILURE);
|
---|
263 | }
|
---|
264 |
|
---|
265 | for (i = 0; i < NINORC; i++) {
|
---|
266 |
|
---|
267 | ip = &idefs[i + 1 + (lorh ? NINORC : 0)];
|
---|
268 |
|
---|
269 | if (wr_ec(fp, ip, (long)OR_LEN1)) { /* functions */
|
---|
270 |
|
---|
271 | streset();
|
---|
272 | return(FAILURE);
|
---|
273 | }
|
---|
274 |
|
---|
275 | if (wr_ec(fp, ip->idhwvao, (long)OR_LEN2)) { /* WS A */
|
---|
276 |
|
---|
277 | streset();
|
---|
278 | return(FAILURE);
|
---|
279 | }
|
---|
280 |
|
---|
281 | if (wr_ec(fp, ip->idhwvbo, (long)OR_LEN2)) { /* WS B */
|
---|
282 |
|
---|
283 | streset();
|
---|
284 | return(FAILURE);
|
---|
285 | }
|
---|
286 | }
|
---|
287 |
|
---|
288 | fclose(fp);
|
---|
289 | postio(); /* restore LCD backlight */
|
---|
290 | return(SUCCESS);
|
---|
291 | }
|
---|
292 |
|
---|
293 | /* |
---|
294 |
|
---|
295 | */
|
---|
296 |
|
---|
297 | /*
|
---|
298 | =============================================================================
|
---|
299 | get_orc() -- read an orchestra from the disk
|
---|
300 | =============================================================================
|
---|
301 | */
|
---|
302 |
|
---|
303 | short
|
---|
304 | get_orc(lorh, kind)
|
---|
305 | short lorh, kind;
|
---|
306 | {
|
---|
307 | register FILE *fp;
|
---|
308 | register int i;
|
---|
309 | register struct instdef *ip;
|
---|
310 |
|
---|
311 | if (lorh)
|
---|
312 | ldbusy(" Reading Hi Orch");
|
---|
313 | else
|
---|
314 | ldbusy(" Reading Lo Orch");
|
---|
315 |
|
---|
316 | preio(); /* kill LCD backlight */
|
---|
317 |
|
---|
318 | fp = fopenb(slotnam(ldslot, kind), "r");
|
---|
319 |
|
---|
320 | if ((FILE *)NULL EQ fp) {
|
---|
321 |
|
---|
322 | ldermsg("Couldn't open the file",
|
---|
323 | " for the orchestra", (char *)NULL,
|
---|
324 | LD_EMCF, LD_EMCB);
|
---|
325 |
|
---|
326 | postio(); /* restore LCD backlight */
|
---|
327 | clrlsel();
|
---|
328 | return(FAILURE);
|
---|
329 | }
|
---|
330 |
|
---|
331 | memcpy(ldfile, " ", 8);
|
---|
332 | memcpy(ldcmnt, " ", 37);
|
---|
333 | ldswin(3);
|
---|
334 | ldswin(5);
|
---|
335 |
|
---|
336 | /* |
---|
337 |
|
---|
338 | */
|
---|
339 | if (rd_ec(fp, &ldhead, (long)LH_LEN)) { /* header */
|
---|
340 |
|
---|
341 | clrlsel();
|
---|
342 | return(FAILURE);
|
---|
343 | }
|
---|
344 |
|
---|
345 | #if DEBUGIT
|
---|
346 | if (debugsw)
|
---|
347 | printf("get_orc(): hdr=[%-.56s]\n", &ldhead);
|
---|
348 | #endif
|
---|
349 |
|
---|
350 |
|
---|
351 | for (i = 0; i < NINORC; i++) {
|
---|
352 |
|
---|
353 | ip = &idefs[i + 1 + (lorh ? NINORC : 0)];
|
---|
354 |
|
---|
355 | if (rd_ec(fp, ip, (long)OR_LEN1)) { /* functions */
|
---|
356 |
|
---|
357 | clrlsel();
|
---|
358 | return(FAILURE);
|
---|
359 | }
|
---|
360 |
|
---|
361 | if (rd_ec(fp, ip->idhwvao, (long)OR_LEN2)) { /* WS A */
|
---|
362 |
|
---|
363 | clrlsel();
|
---|
364 | return(FAILURE);
|
---|
365 | }
|
---|
366 |
|
---|
367 | if (rd_ec(fp, ip->idhwvbo, (long)OR_LEN2)) { /* WS B */
|
---|
368 |
|
---|
369 | clrlsel();
|
---|
370 | return(FAILURE);
|
---|
371 | }
|
---|
372 |
|
---|
373 | /* unpack offsets (and eventually harmonics) into finals */
|
---|
374 |
|
---|
375 | memcpyw(ip->idhwvaf, ip->idhwvao, NUMWPNT);
|
---|
376 | memcpyw(ip->idhwvbf, ip->idhwvbo, NUMWPNT);
|
---|
377 | }
|
---|
378 |
|
---|
379 | clrlsel();
|
---|
380 | fclose(fp);
|
---|
381 | postio(); /* restore LCD backlight */
|
---|
382 | return(SUCCESS);
|
---|
383 | }
|
---|
384 |
|
---|
385 | /* |
---|
386 |
|
---|
387 | */
|
---|
388 |
|
---|
389 | /*
|
---|
390 | =============================================================================
|
---|
391 | wrt_tun() -- write a tuning library on the disk
|
---|
392 | =============================================================================
|
---|
393 | */
|
---|
394 |
|
---|
395 | short
|
---|
396 | wrt_tun(slot)
|
---|
397 | short slot;
|
---|
398 | {
|
---|
399 | register FILE *fp;
|
---|
400 | register int i;
|
---|
401 | char cstemp[8];
|
---|
402 |
|
---|
403 | preio(); /* kill LCD backlight */
|
---|
404 |
|
---|
405 | fp = fopenb(slotnam(slot, FT_TUN), "w");
|
---|
406 |
|
---|
407 | if ((FILE *)NULL EQ fp) {
|
---|
408 |
|
---|
409 | ldermsg("Couldn't create a file",
|
---|
410 | " for the tunings", (char *)NULL,
|
---|
411 | LD_EMCF, LD_EMCB);
|
---|
412 |
|
---|
413 | postio(); /* restore LCD backlight */
|
---|
414 | streset();
|
---|
415 | return(FAILURE);
|
---|
416 | }
|
---|
417 |
|
---|
418 | makelh(FT_TUN); /* make header */
|
---|
419 |
|
---|
420 | for (i = 0; i < NTUNSLIB; i++) {
|
---|
421 |
|
---|
422 | lcsum += chksum(&tunlib[i + 1], 256L);
|
---|
423 | lcsum += chksum(&tunname[i + 1], 32L);
|
---|
424 | }
|
---|
425 |
|
---|
426 | sprintf(cstemp, "%08.8lX", lcsum);
|
---|
427 | memcpy(ldhead.l_csum, cstemp, 8);
|
---|
428 |
|
---|
429 | #if DEBUGIT
|
---|
430 | if (debugsw)
|
---|
431 | printf("wrt_tun(): hdr=[%-.56s]\n", &ldhead);
|
---|
432 | #endif
|
---|
433 |
|
---|
434 | /* |
---|
435 |
|
---|
436 | */
|
---|
437 | if (wr_ec(fp, &ldhead, (long)LH_LEN)) { /* header */
|
---|
438 |
|
---|
439 | streset();
|
---|
440 | return(FAILURE);
|
---|
441 | }
|
---|
442 |
|
---|
443 | for (i = 0; i < NTUNSLIB; i++) {
|
---|
444 |
|
---|
445 | if (wr_ec(fp, &tunlib[i + 1], 256L)) {
|
---|
446 |
|
---|
447 | streset();
|
---|
448 | return(FAILURE);
|
---|
449 | }
|
---|
450 |
|
---|
451 | if (wr_ec(fp, &tunname[i + 1], 32L)) {
|
---|
452 |
|
---|
453 | streset();
|
---|
454 | return(FAILURE);
|
---|
455 | }
|
---|
456 | }
|
---|
457 |
|
---|
458 | fclose(fp);
|
---|
459 | postio(); /* restore LCD backlight */
|
---|
460 | return(SUCCESS);
|
---|
461 | }
|
---|
462 |
|
---|
463 | /* |
---|
464 |
|
---|
465 | */
|
---|
466 |
|
---|
467 | /*
|
---|
468 | =============================================================================
|
---|
469 | get_tun() -- read a tuning library from the disk
|
---|
470 | =============================================================================
|
---|
471 | */
|
---|
472 |
|
---|
473 | short
|
---|
474 | get_tun()
|
---|
475 | {
|
---|
476 | register FILE *fp;
|
---|
477 | register int i;
|
---|
478 |
|
---|
479 | preio(); /* kill LCD backlight */
|
---|
480 |
|
---|
481 | fp = fopenb(slotnam(ldslot, FT_TUN), "r");
|
---|
482 |
|
---|
483 | if ((FILE *)NULL EQ fp) {
|
---|
484 |
|
---|
485 | ldermsg("Couldn't open the file",
|
---|
486 | " for the tunings", (char *)NULL,
|
---|
487 | LD_EMCF, LD_EMCB);
|
---|
488 |
|
---|
489 | postio(); /* restore LCD backlight */
|
---|
490 | clrlsel();
|
---|
491 | return(FAILURE);
|
---|
492 | }
|
---|
493 |
|
---|
494 | memcpy(ldfile, " ", 8);
|
---|
495 | memcpy(ldcmnt, " ", 37);
|
---|
496 | ldswin(3);
|
---|
497 | ldswin(5);
|
---|
498 |
|
---|
499 | /* |
---|
500 |
|
---|
501 | */
|
---|
502 | if (rd_ec(fp, &ldhead, (long)LH_LEN)) { /* header */
|
---|
503 |
|
---|
504 | clrlsel();
|
---|
505 | return(FAILURE);
|
---|
506 | }
|
---|
507 |
|
---|
508 | #if DEBUGIT
|
---|
509 | if (debugsw)
|
---|
510 | printf("get_tun(): hdr=[%-.56s]\n", &ldhead);
|
---|
511 | #endif
|
---|
512 |
|
---|
513 |
|
---|
514 | for (i = 0; i < NTUNSLIB; i++) {
|
---|
515 |
|
---|
516 | if (rd_ec(fp, &tunlib[i + 1], 256L)) {
|
---|
517 |
|
---|
518 | clrlsel();
|
---|
519 | return(FAILURE);
|
---|
520 | }
|
---|
521 |
|
---|
522 | if (rd_ec(fp, &tunname[i + 1], 32L)) {
|
---|
523 |
|
---|
524 | clrlsel();
|
---|
525 | return(FAILURE);
|
---|
526 | }
|
---|
527 | }
|
---|
528 |
|
---|
529 | clrlsel();
|
---|
530 | fclose(fp);
|
---|
531 | postio(); /* restore LCD backlight */
|
---|
532 | return(SUCCESS);
|
---|
533 | }
|
---|
534 |
|
---|
535 | /* |
---|
536 |
|
---|
537 | */
|
---|
538 |
|
---|
539 | /*
|
---|
540 | =============================================================================
|
---|
541 | wrt_pat() -- write a patch file on the disk
|
---|
542 | =============================================================================
|
---|
543 | */
|
---|
544 |
|
---|
545 | short
|
---|
546 | wrt_pat(slot)
|
---|
547 | short slot;
|
---|
548 | {
|
---|
549 | register FILE *fp;
|
---|
550 | char cstemp[8];
|
---|
551 |
|
---|
552 | preio(); /* kill LCD backlight */
|
---|
553 |
|
---|
554 | fp = fopenb(slotnam(slot, FT_PAT), "w");
|
---|
555 |
|
---|
556 | if ((FILE *)NULL EQ fp) {
|
---|
557 |
|
---|
558 | ldermsg("Couldn't create a file",
|
---|
559 | " for the patches", (char *)NULL,
|
---|
560 | LD_EMCF, LD_EMCB);
|
---|
561 |
|
---|
562 | postio(); /* restore LCD backlight */
|
---|
563 | streset();
|
---|
564 | return(FAILURE);
|
---|
565 | }
|
---|
566 |
|
---|
567 | makelh(FT_PAT); /* make header */
|
---|
568 |
|
---|
569 | sprintf(cstemp, "%08.8lX", lcsum);
|
---|
570 | memcpy(ldhead.l_csum, cstemp, 8);
|
---|
571 |
|
---|
572 | #if DEBUGIT
|
---|
573 | if (debugsw)
|
---|
574 | printf("wrt_pat(): hdr=[%-.56s]\n", &ldhead);
|
---|
575 | #endif
|
---|
576 |
|
---|
577 | /* |
---|
578 |
|
---|
579 | */
|
---|
580 | if (wr_ec(fp, &ldhead, (long)LH_LEN)) { /* header */
|
---|
581 |
|
---|
582 | streset();
|
---|
583 | return(FAILURE);
|
---|
584 | }
|
---|
585 |
|
---|
586 | if (ptwrite(fp)) { /* patches */
|
---|
587 |
|
---|
588 | streset();
|
---|
589 | return(FAILURE);
|
---|
590 | }
|
---|
591 |
|
---|
592 | fclose(fp);
|
---|
593 | postio(); /* restore LCD backlight */
|
---|
594 | return(SUCCESS);
|
---|
595 | }
|
---|
596 |
|
---|
597 | /* |
---|
598 |
|
---|
599 | */
|
---|
600 |
|
---|
601 | /*
|
---|
602 | =============================================================================
|
---|
603 | get_pat() -- read a patch file from the disk
|
---|
604 | =============================================================================
|
---|
605 | */
|
---|
606 |
|
---|
607 | short
|
---|
608 | get_pat()
|
---|
609 | {
|
---|
610 | register FILE *fp;
|
---|
611 |
|
---|
612 | preio(); /* kill LCD backlight */
|
---|
613 |
|
---|
614 | fp = fopenb(slotnam(ldslot, FT_PAT), "r");
|
---|
615 |
|
---|
616 | if ((FILE *)NULL EQ fp) {
|
---|
617 |
|
---|
618 | ldermsg("Couldn't open the file",
|
---|
619 | " for the patches", (char *)NULL,
|
---|
620 | LD_EMCF, LD_EMCB);
|
---|
621 |
|
---|
622 | postio(); /* restore LCD backlight */
|
---|
623 | clrlsel();
|
---|
624 | return(FAILURE);
|
---|
625 | }
|
---|
626 |
|
---|
627 | memcpy(ldfile, " ", 8);
|
---|
628 | memcpy(ldcmnt, " ", 37);
|
---|
629 | ldswin(3);
|
---|
630 | ldswin(5);
|
---|
631 |
|
---|
632 | /* |
---|
633 |
|
---|
634 | */
|
---|
635 | if (rd_ec(fp, &ldhead, (long)LH_LEN)) { /* header */
|
---|
636 |
|
---|
637 | clrlsel();
|
---|
638 | return(FAILURE);
|
---|
639 | }
|
---|
640 |
|
---|
641 | #if DEBUGIT
|
---|
642 | if (debugsw)
|
---|
643 | printf("get_pat(): hdr=[%-.56s]\n", &ldhead);
|
---|
644 | #endif
|
---|
645 |
|
---|
646 | if (lrasw EQ 0) /* clear all patches if in replace mode */
|
---|
647 | initpt();
|
---|
648 |
|
---|
649 | if (ptread(fp)) {
|
---|
650 |
|
---|
651 | clrlsel();
|
---|
652 | return(FAILURE);
|
---|
653 | }
|
---|
654 |
|
---|
655 | fclose(fp);
|
---|
656 | postio(); /* restore LCD backlight */
|
---|
657 | clrlsel();
|
---|
658 | return(SUCCESS);
|
---|
659 | }
|
---|
660 |
|
---|
661 | /* |
---|
662 |
|
---|
663 | */
|
---|
664 |
|
---|
665 | /*
|
---|
666 | =============================================================================
|
---|
667 | wrt_scr() -- write a score file on the disk
|
---|
668 | =============================================================================
|
---|
669 | */
|
---|
670 |
|
---|
671 | short
|
---|
672 | wrt_scr(slot)
|
---|
673 | short slot;
|
---|
674 | {
|
---|
675 | register FILE *fp;
|
---|
676 | register int i;
|
---|
677 | long tnb;
|
---|
678 | char cstemp[8];
|
---|
679 |
|
---|
680 | preio(); /* kill LCD backlight */
|
---|
681 |
|
---|
682 | fp = fopenb(slotnam(slot, FT_SCR), "w");
|
---|
683 |
|
---|
684 | if ((FILE *)NULL EQ fp) {
|
---|
685 |
|
---|
686 | ldermsg("Couldn't create a file",
|
---|
687 | " for the scores", (char *)NULL,
|
---|
688 | LD_EMCF, LD_EMCB);
|
---|
689 |
|
---|
690 | postio(); /* restore LCD backlight */
|
---|
691 | streset();
|
---|
692 | return(FAILURE);
|
---|
693 | }
|
---|
694 |
|
---|
695 | makelh(FT_SCR); /* make header */
|
---|
696 |
|
---|
697 | lcsum += sntlreq;
|
---|
698 |
|
---|
699 | sprintf(cstemp, "%08.8lX", lcsum);
|
---|
700 | memcpy(ldhead.l_csum, cstemp, 8);
|
---|
701 |
|
---|
702 | #if DEBUGIT
|
---|
703 | if (debugsw)
|
---|
704 | printf("wrt_scr(): hdr=[%-.56s]\n", &ldhead);
|
---|
705 | #endif
|
---|
706 |
|
---|
707 | /* |
---|
708 |
|
---|
709 | */
|
---|
710 | if (wr_ec(fp, &ldhead, (long)LH_LEN)) { /* header */
|
---|
711 |
|
---|
712 | streset();
|
---|
713 | return(FAILURE);
|
---|
714 | }
|
---|
715 |
|
---|
716 | if (wr_ec(fp, &sntlreq, 4L)) { /* total longs required */
|
---|
717 |
|
---|
718 | streset();
|
---|
719 | return(FAILURE);
|
---|
720 | }
|
---|
721 |
|
---|
722 | for (i = 0; i < N_SCORES; i++) { /* scores */
|
---|
723 |
|
---|
724 | if (scwrite(i, fp)) {
|
---|
725 |
|
---|
726 | streset();
|
---|
727 | return(FAILURE);
|
---|
728 | }
|
---|
729 | }
|
---|
730 |
|
---|
731 | fclose(fp);
|
---|
732 | postio(); /* restore LCD backlight */
|
---|
733 | return(SUCCESS);
|
---|
734 | }
|
---|
735 |
|
---|
736 | /* |
---|
737 |
|
---|
738 | */
|
---|
739 |
|
---|
740 | /*
|
---|
741 | =============================================================================
|
---|
742 | get_scr() -- read a score file from the disk
|
---|
743 | =============================================================================
|
---|
744 | */
|
---|
745 |
|
---|
746 | short
|
---|
747 | get_scr()
|
---|
748 | {
|
---|
749 | register FILE *fp;
|
---|
750 | register int i;
|
---|
751 | long tnl;
|
---|
752 |
|
---|
753 | preio(); /* kill LCD backlight */
|
---|
754 |
|
---|
755 | fp = fopenb(slotnam(ldslot, FT_SCR), "r");
|
---|
756 |
|
---|
757 | if ((FILE *)NULL EQ fp) {
|
---|
758 |
|
---|
759 | ldermsg("Couldn't open the file",
|
---|
760 | " for the scores", (char *)NULL,
|
---|
761 | LD_EMCF, LD_EMCB);
|
---|
762 |
|
---|
763 | postio(); /* restore LCD backlight */
|
---|
764 | clrlsel();
|
---|
765 | return(FAILURE);
|
---|
766 | }
|
---|
767 |
|
---|
768 | memcpy(ldfile, " ", 8);
|
---|
769 | memcpy(ldcmnt, " ", 37);
|
---|
770 | ldswin(3);
|
---|
771 | ldswin(5);
|
---|
772 |
|
---|
773 | /* |
---|
774 |
|
---|
775 | */
|
---|
776 | if (rd_ec(fp, &ldhead, (long)LH_LEN)) { /* header */
|
---|
777 |
|
---|
778 | clrlsel();
|
---|
779 | return(FAILURE);
|
---|
780 | }
|
---|
781 |
|
---|
782 | #if DEBUGIT
|
---|
783 | if (debugsw)
|
---|
784 | printf("get_scr(): hdr=[%-.56s]\n", &ldhead);
|
---|
785 | #endif
|
---|
786 |
|
---|
787 |
|
---|
788 | if (rd_ec(fp, &tnl, 4L)) { /* longs required */
|
---|
789 |
|
---|
790 | clrlsel();
|
---|
791 | return(FAILURE);
|
---|
792 | }
|
---|
793 |
|
---|
794 | if (lrasw EQ 0) /* clear all scores if in replace mode */
|
---|
795 | scinit();
|
---|
796 |
|
---|
797 | for (i = 0; i < N_SCORES; i++) { /* read scores */
|
---|
798 |
|
---|
799 | if (scread(i, fp)) {
|
---|
800 |
|
---|
801 | clrlsel();
|
---|
802 | return(FAILURE);
|
---|
803 | }
|
---|
804 | }
|
---|
805 |
|
---|
806 | fclose(fp);
|
---|
807 | postio(); /* restore LCD backlight */
|
---|
808 |
|
---|
809 | p_bak = p_cur = p_ctr = p_fwd = scp = E_NULL;
|
---|
810 | t_cur = t_ctr = 0L;
|
---|
811 | t_bak = t_cur - TO_BAK;
|
---|
812 | t_fwd = t_cur + TO_FWD;
|
---|
813 |
|
---|
814 | selscor(0);
|
---|
815 |
|
---|
816 | clrlsel();
|
---|
817 | return(SUCCESS);
|
---|
818 | }
|
---|
819 |
|
---|
820 | /* |
---|
821 |
|
---|
822 | */
|
---|
823 |
|
---|
824 | /*
|
---|
825 | =============================================================================
|
---|
826 | wrt_seq() -- write a sequence file on the disk
|
---|
827 | =============================================================================
|
---|
828 | */
|
---|
829 |
|
---|
830 | short
|
---|
831 | wrt_seq(slot)
|
---|
832 | short slot;
|
---|
833 | {
|
---|
834 | register FILE *fp;
|
---|
835 | char cstemp[8];
|
---|
836 |
|
---|
837 | preio(); /* kill LCD backlight */
|
---|
838 |
|
---|
839 | fp = fopenb(slotnam(slot, FT_SEQ), "w");
|
---|
840 |
|
---|
841 | if ((FILE *)NULL EQ fp) {
|
---|
842 |
|
---|
843 | ldermsg("Couldn't create a file",
|
---|
844 | " for the sequences", (char *)NULL,
|
---|
845 | LD_EMCF, LD_EMCB);
|
---|
846 |
|
---|
847 | postio(); /* restore LCD backlight */
|
---|
848 | streset();
|
---|
849 | return(FAILURE);
|
---|
850 | }
|
---|
851 |
|
---|
852 | makelh(FT_SEQ); /* make header */
|
---|
853 |
|
---|
854 | sprintf(cstemp, "%08.8lX", lcsum);
|
---|
855 | memcpy(ldhead.l_csum, cstemp, 8);
|
---|
856 |
|
---|
857 | #if DEBUGIT
|
---|
858 | if (debugsw)
|
---|
859 | printf("wrt_seq(): hdr=[%-.56s]\n", &ldhead);
|
---|
860 | #endif
|
---|
861 |
|
---|
862 | /* |
---|
863 |
|
---|
864 | */
|
---|
865 | if (wr_ec(fp, &ldhead, (long)LH_LEN)) { /* header */
|
---|
866 |
|
---|
867 | streset();
|
---|
868 | return(FAILURE);
|
---|
869 | }
|
---|
870 |
|
---|
871 | if (sqwrite(fp)) { /* sequences */
|
---|
872 |
|
---|
873 | streset();
|
---|
874 | return(FAILURE);
|
---|
875 | }
|
---|
876 |
|
---|
877 | fclose(fp);
|
---|
878 | postio(); /* restore LCD backlight */
|
---|
879 | return(SUCCESS);
|
---|
880 | }
|
---|
881 |
|
---|
882 | /* |
---|
883 |
|
---|
884 | */
|
---|
885 |
|
---|
886 | /*
|
---|
887 | =============================================================================
|
---|
888 | get_seq() -- read a sequence file from the disk
|
---|
889 | =============================================================================
|
---|
890 | */
|
---|
891 |
|
---|
892 | short
|
---|
893 | get_seq()
|
---|
894 | {
|
---|
895 | register FILE *fp;
|
---|
896 |
|
---|
897 | preio(); /* kill LCD backlight */
|
---|
898 |
|
---|
899 | fp = fopenb(slotnam(ldslot, FT_SEQ), "r");
|
---|
900 |
|
---|
901 | if ((FILE *)NULL EQ fp) {
|
---|
902 |
|
---|
903 | ldermsg("Couldn't open the file",
|
---|
904 | " for the sequences", (char *)NULL,
|
---|
905 | LD_EMCF, LD_EMCB);
|
---|
906 |
|
---|
907 | postio(); /* restore LCD backlight */
|
---|
908 | clrlsel();
|
---|
909 | return(FAILURE);
|
---|
910 | }
|
---|
911 |
|
---|
912 | memcpy(ldfile, " ", 8);
|
---|
913 | memcpy(ldcmnt, " ", 37);
|
---|
914 | ldswin(3);
|
---|
915 | ldswin(5);
|
---|
916 |
|
---|
917 | /* |
---|
918 |
|
---|
919 | */
|
---|
920 | if (rd_ec(fp, &ldhead, (long)LH_LEN)) { /* header */
|
---|
921 |
|
---|
922 | clrlsel();
|
---|
923 | return(FAILURE);
|
---|
924 | }
|
---|
925 |
|
---|
926 | #if DEBUGIT
|
---|
927 | if (debugsw)
|
---|
928 | printf("get_seq(): hdr=[%-.56s]\n", &ldhead);
|
---|
929 | #endif
|
---|
930 |
|
---|
931 | initsq();
|
---|
932 |
|
---|
933 | if (sqread(fp)) {
|
---|
934 |
|
---|
935 | clrlsel();
|
---|
936 | return(FAILURE);
|
---|
937 | }
|
---|
938 |
|
---|
939 | fclose(fp);
|
---|
940 | postio(); /* restore LCD backlight */
|
---|
941 | clrlsel();
|
---|
942 | return(SUCCESS);
|
---|
943 | }
|
---|
944 |
|
---|
945 | /* |
---|
946 |
|
---|
947 | */
|
---|
948 |
|
---|
949 | /*
|
---|
950 | =============================================================================
|
---|
951 | wrt_wav() -- write a waveshape library on the disk
|
---|
952 | =============================================================================
|
---|
953 | */
|
---|
954 |
|
---|
955 | short
|
---|
956 | wrt_wav(slot)
|
---|
957 | short slot;
|
---|
958 | {
|
---|
959 | register FILE *fp;
|
---|
960 | register int i;
|
---|
961 | char cstemp[8];
|
---|
962 | register struct wstbl *wp;
|
---|
963 |
|
---|
964 | preio(); /* kill LCD backlight */
|
---|
965 |
|
---|
966 | fp = fopenb(slotnam(slot, FT_WAV), "w");
|
---|
967 |
|
---|
968 | if ((FILE *)NULL EQ fp) {
|
---|
969 |
|
---|
970 | ldermsg("Couldn't create a file",
|
---|
971 | " for the waveshapes", (char *)NULL,
|
---|
972 | LD_EMCF, LD_EMCB);
|
---|
973 |
|
---|
974 | postio(); /* restore LCD backlight */
|
---|
975 | streset();
|
---|
976 | return(FAILURE);
|
---|
977 | }
|
---|
978 |
|
---|
979 | makelh(FT_WAV); /* make header */
|
---|
980 |
|
---|
981 | for (i = 0; i < NUMWAVS; i++) {
|
---|
982 |
|
---|
983 | wp = &wslib[i];
|
---|
984 |
|
---|
985 | lcsum += chksum(wp->offset, (long)(NUMWPNT * 2));
|
---|
986 | lcsum += chksum(wp->harmon, (long)(NUMHARM * 2));
|
---|
987 | }
|
---|
988 |
|
---|
989 | sprintf(cstemp, "%08.8lX", lcsum);
|
---|
990 | memcpy(ldhead.l_csum, cstemp, 8);
|
---|
991 |
|
---|
992 | #if DEBUGIT
|
---|
993 | if (debugsw)
|
---|
994 | printf("wrt_wav(): hdr=[%-.56s]\n", &ldhead);
|
---|
995 | #endif
|
---|
996 |
|
---|
997 | /* |
---|
998 |
|
---|
999 | */
|
---|
1000 | if (wr_ec(fp, &ldhead, (long)LH_LEN)) { /* header */
|
---|
1001 |
|
---|
1002 | streset();
|
---|
1003 | return(FAILURE);
|
---|
1004 | }
|
---|
1005 |
|
---|
1006 | for (i = 0; i < NUMWAVS; i++) {
|
---|
1007 |
|
---|
1008 | wp = &wslib[i];
|
---|
1009 |
|
---|
1010 | if (wr_ec(fp, wp->offset, (long)(NUMWPNT * 2))) {
|
---|
1011 |
|
---|
1012 | streset();
|
---|
1013 | return(FAILURE);
|
---|
1014 | }
|
---|
1015 |
|
---|
1016 | if (wr_ec(fp, wp->harmon, (long)(NUMHARM * 2))) {
|
---|
1017 |
|
---|
1018 | streset();
|
---|
1019 | return(FAILURE);
|
---|
1020 | }
|
---|
1021 | }
|
---|
1022 |
|
---|
1023 | fclose(fp);
|
---|
1024 | postio(); /* restore LCD backlight */
|
---|
1025 | return(SUCCESS);
|
---|
1026 | }
|
---|
1027 |
|
---|
1028 | /* |
---|
1029 |
|
---|
1030 | */
|
---|
1031 |
|
---|
1032 | /*
|
---|
1033 | =============================================================================
|
---|
1034 | get_wav() -- read a waveshape library from the disk
|
---|
1035 | =============================================================================
|
---|
1036 | */
|
---|
1037 |
|
---|
1038 | short
|
---|
1039 | get_wav()
|
---|
1040 | {
|
---|
1041 | register FILE *fp;
|
---|
1042 | register int i;
|
---|
1043 | register struct wstbl *wp;
|
---|
1044 |
|
---|
1045 | preio(); /* kill LCD backlight */
|
---|
1046 |
|
---|
1047 | fp = fopenb(slotnam(ldslot, FT_WAV), "r");
|
---|
1048 |
|
---|
1049 | if ((FILE *)NULL EQ fp) {
|
---|
1050 |
|
---|
1051 | ldermsg("Couldn't open the file",
|
---|
1052 | " for the waveshapes", (char *)NULL,
|
---|
1053 | LD_EMCF, LD_EMCB);
|
---|
1054 |
|
---|
1055 | postio(); /* restore LCD backlight */
|
---|
1056 | clrlsel();
|
---|
1057 | return(FAILURE);
|
---|
1058 | }
|
---|
1059 |
|
---|
1060 | memcpy(ldfile, " ", 8);
|
---|
1061 | memcpy(ldcmnt, " ", 37);
|
---|
1062 | ldswin(3);
|
---|
1063 | ldswin(5);
|
---|
1064 |
|
---|
1065 | /* |
---|
1066 |
|
---|
1067 | */
|
---|
1068 | if (rd_ec(fp, &ldhead, (long)LH_LEN)) { /* header */
|
---|
1069 |
|
---|
1070 | clrlsel();
|
---|
1071 | return(FAILURE);
|
---|
1072 | }
|
---|
1073 |
|
---|
1074 | #if DEBUGIT
|
---|
1075 | if (debugsw)
|
---|
1076 | printf("get_wav(): hdr=[%-.56s]\n", &ldhead);
|
---|
1077 | #endif
|
---|
1078 |
|
---|
1079 |
|
---|
1080 | for (i = 0; i < NUMWAVS; i++) {
|
---|
1081 |
|
---|
1082 | wp = &wslib[i];
|
---|
1083 |
|
---|
1084 | if (rd_ec(fp, wp->offset, (long)(NUMWPNT * 2))) {
|
---|
1085 |
|
---|
1086 | clrlsel();
|
---|
1087 | return(FAILURE);
|
---|
1088 | }
|
---|
1089 |
|
---|
1090 | if (rd_ec(fp, wp->harmon, (long)(NUMHARM * 2))) {
|
---|
1091 |
|
---|
1092 | clrlsel();
|
---|
1093 | return(FAILURE);
|
---|
1094 | }
|
---|
1095 |
|
---|
1096 | /* unpack offsets (and eventually harmonics) into finals */
|
---|
1097 |
|
---|
1098 | memcpyw(wp->final, wp->offset, NUMWPNT);
|
---|
1099 | }
|
---|
1100 |
|
---|
1101 | clrlsel();
|
---|
1102 | fclose(fp);
|
---|
1103 | postio(); /* restore LCD backlight */
|
---|
1104 | return(SUCCESS);
|
---|
1105 | }
|
---|
1106 |
|
---|