1 | /*
|
---|
2 | =============================================================================
|
---|
3 | libdsp.c -- MIDAS librarian display
|
---|
4 | Version 64 -- 1988-11-17 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #define DEBUGRE 0
|
---|
9 | #define DEBUGWE 0
|
---|
10 |
|
---|
11 | #include "ram.h"
|
---|
12 |
|
---|
13 | #if DEBUGRE
|
---|
14 | short debugre = 1;
|
---|
15 | #endif
|
---|
16 |
|
---|
17 | #if DEBUGWE
|
---|
18 | short debugwe = 1;
|
---|
19 | #endif
|
---|
20 |
|
---|
21 | int8_t *ftypes[][3] = { /* file types (must match libdsp.h) */
|
---|
22 |
|
---|
23 | {"ASG", "Assignmnt", "Assignmnt"}, /* FT_ASG */
|
---|
24 | {"ORL", "Orchestra", "Orchestra"}, /* FT_ORL */
|
---|
25 | {"ORH", "Orchestra", "Orchestra"}, /* FT_ORH */
|
---|
26 | {"SCR", " Score", "Score"}, /* FT_SCR */
|
---|
27 | {"TUN", " Tuning", "Tuning"}, /* FT_TUN */
|
---|
28 | {"WAV", "Waveshape", "Waveshape"}, /* FT_WAV */
|
---|
29 | {"ORC", "Orchestra", "Orchestra"}, /* FT_ORC */
|
---|
30 | {"PAT", " Patch", "Patch"}, /* FT_PAT */
|
---|
31 | {"SEQ", " Sequence", "Sequence"} /* FT_SEQ */
|
---|
32 | };
|
---|
33 |
|
---|
34 | int8_t ld_em1[] = "No files stored on disk";
|
---|
35 | int8_t ld_em2[] = " by this operation";
|
---|
36 |
|
---|
37 | int16_t lbrpal[16][3] = { /* librarian color palette */
|
---|
38 |
|
---|
39 | {0, 0, 0}, /* 0 */
|
---|
40 | {3, 3, 3}, /* 1 */
|
---|
41 | {1, 0, 0}, /* 2 */
|
---|
42 | {1, 1, 0}, /* 3 */
|
---|
43 | {2, 1, 0}, /* 4 (was 2, 2, 0) */
|
---|
44 | {1, 1, 0}, /* 5 */
|
---|
45 | {2, 1, 0}, /* 6 (was 2, 2, 0) */
|
---|
46 | {1, 0, 0}, /* 7 */
|
---|
47 | {0, 1, 1}, /* 8 (was 0, 1, 0) */
|
---|
48 | {1, 0, 0}, /* 9 */
|
---|
49 | {1, 1, 0}, /* 10 */
|
---|
50 | {2, 2, 2}, /* 11 */
|
---|
51 | {2, 3, 3}, /* 12 */
|
---|
52 | {3, 3, 0}, /* 13 */
|
---|
53 | {3, 0, 0}, /* 14 */
|
---|
54 | {0, 0, 0} /* 15 */
|
---|
55 | };
|
---|
56 |
|
---|
57 | /*
|
---|
58 | =============================================================================
|
---|
59 | ftkind() -- return the file type for a given file catalog slot
|
---|
60 |
|
---|
61 | ns = catalog slot index
|
---|
62 | -1 returned on error (returns 1..NFTYPES for a good type)
|
---|
63 | =============================================================================
|
---|
64 | */
|
---|
65 |
|
---|
66 | int16_t ftkind(int16_t ns)
|
---|
67 | {
|
---|
68 | register int16_t i;
|
---|
69 |
|
---|
70 | for (i = 0; i < NFTYPES; i++)
|
---|
71 | if (0 EQ memcmpu(filecat[ns].fcextn, ftypes[i][0], 3))
|
---|
72 | return(++i);
|
---|
73 |
|
---|
74 | return(-1);
|
---|
75 | }
|
---|
76 |
|
---|
77 | /*
|
---|
78 | =============================================================================
|
---|
79 | fctstr() -- return a string showing the file catalog entry type
|
---|
80 |
|
---|
81 | ns = catalog slot index
|
---|
82 | just = 0: right justify string, 1: left justify string
|
---|
83 | =============================================================================
|
---|
84 | */
|
---|
85 |
|
---|
86 | int8_t *fctstr(int16_t ns, int16_t just)
|
---|
87 | {
|
---|
88 | static int8_t fcbad[11];
|
---|
89 | register int16_t i;
|
---|
90 |
|
---|
91 | for (i = 0; i < NFTYPES; i++)
|
---|
92 | if (0 EQ memcmpu(filecat[ns].fcextn, ftypes[i][0], 3))
|
---|
93 | return(ftypes[i][just ? 2 : 1]);
|
---|
94 |
|
---|
95 | sprintf(fcbad, "?? %3.3s ??", filecat[ns].fcextn);
|
---|
96 | return(fcbad);
|
---|
97 | }
|
---|
98 |
|
---|
99 | /*
|
---|
100 | =============================================================================
|
---|
101 | ocslot() -- determine if a slot is occupied
|
---|
102 | =============================================================================
|
---|
103 | */
|
---|
104 |
|
---|
105 | int16_t ocslot(int16_t slot)
|
---|
106 | {
|
---|
107 | if (memcmp(filecat[slot].fcsize, "000", 3)
|
---|
108 | AND (0 NE filecat[slot].fcsize[0]))
|
---|
109 | return(TRUE);
|
---|
110 | else
|
---|
111 | return(FALSE);
|
---|
112 | }
|
---|
113 |
|
---|
114 | /*
|
---|
115 | =============================================================================
|
---|
116 | ldline() -- determine which catalog line the cursor is on, if any
|
---|
117 | =============================================================================
|
---|
118 | */
|
---|
119 |
|
---|
120 | int16_t ldline(int16_t cy)
|
---|
121 | {
|
---|
122 | if (cy > 292)
|
---|
123 | return(0);
|
---|
124 |
|
---|
125 | if (cy < 14)
|
---|
126 | return(0);
|
---|
127 |
|
---|
128 | return(cy / 14);
|
---|
129 | }
|
---|
130 |
|
---|
131 | /*
|
---|
132 | =============================================================================
|
---|
133 | lin2slt() -- determine which slot a line corresponds to, if any
|
---|
134 |
|
---|
135 | -1 returned on error (0..FCMAX-1 returned for a good slot)
|
---|
136 | =============================================================================
|
---|
137 | */
|
---|
138 |
|
---|
139 | int16_t lin2slt(int16_t line)
|
---|
140 | {
|
---|
141 | register int16_t slot, row;
|
---|
142 |
|
---|
143 | row = 0;
|
---|
144 |
|
---|
145 | for (slot = 0; slot < FCMAX; slot++)
|
---|
146 | if (ocslot(slot))
|
---|
147 | if (++row EQ line)
|
---|
148 | return(slot);
|
---|
149 |
|
---|
150 | return(-1);
|
---|
151 | }
|
---|
152 |
|
---|
153 | /*
|
---|
154 | =============================================================================
|
---|
155 | exp_c() -- expand a 4 bit color to 16 bits
|
---|
156 | =============================================================================
|
---|
157 | */
|
---|
158 |
|
---|
159 | uint16_t exp_c(int16_t c)
|
---|
160 | {
|
---|
161 | uint16_t r;
|
---|
162 |
|
---|
163 | r = (uint16_t)c & 0x000F; /* use low 4 bits as the basis */
|
---|
164 | r |= r << 4; /* turn them into 8 bits */
|
---|
165 | r |= r << 8; /* make it a full 16 bits */
|
---|
166 |
|
---|
167 | return(r);
|
---|
168 | }
|
---|
169 |
|
---|
170 | /*
|
---|
171 | =============================================================================
|
---|
172 | ldwmsg() -- display a message in the message window
|
---|
173 | =============================================================================
|
---|
174 | */
|
---|
175 |
|
---|
176 | void ldwmsg(int8_t *line1, int8_t *line2, int8_t *line3, uint16_t fgcolor, uint16_t bgcolor)
|
---|
177 | {
|
---|
178 | lderrsw = FALSE; /* clear error switch */
|
---|
179 | lmwtype = 2; /* message type */
|
---|
180 | submenu = FALSE;
|
---|
181 |
|
---|
182 | if (ndisp NE 0)
|
---|
183 | return;
|
---|
184 |
|
---|
185 | bgcolor = exp_c(bgcolor); /* expand background color */
|
---|
186 | fgcolor = exp_c(fgcolor); /* expand foreground color */
|
---|
187 |
|
---|
188 | if (v_regs[5] & 0x0180)
|
---|
189 | vbank(0);
|
---|
190 |
|
---|
191 | /* clear the window */
|
---|
192 |
|
---|
193 | vbfill4(librob, 128, ldbox[10][0], ldbox[10][1],
|
---|
194 | ldbox[10][2], ldbox[10][3], bgcolor);
|
---|
195 |
|
---|
196 | if ((int8_t *)NULL NE line1)
|
---|
197 | tsplot4(librob, 64, fgcolor, ldbox[10][6], ldbox[10][7],
|
---|
198 | line1, 14);
|
---|
199 |
|
---|
200 | if ((int8_t *)NULL NE line2)
|
---|
201 | tsplot4(librob, 64, fgcolor, (ldbox[10][6] + 1), ldbox[10][7],
|
---|
202 | line2, 14);
|
---|
203 |
|
---|
204 | if ((int8_t *)NULL NE line3)
|
---|
205 | tsplot4(librob, 64, fgcolor, (ldbox[10][6] + 2), ldbox[10][7],
|
---|
206 | line3, 14);
|
---|
207 | }
|
---|
208 |
|
---|
209 | /*
|
---|
210 | =============================================================================
|
---|
211 | chksum() -- checksum an area of memory
|
---|
212 | =============================================================================
|
---|
213 | */
|
---|
214 |
|
---|
215 | int32_t chksum(void *area, int32_t len)
|
---|
216 | {
|
---|
217 | uint8_t *area8;
|
---|
218 | int32_t cs, i;
|
---|
219 |
|
---|
220 | area8 = area;
|
---|
221 | cs = 0L;
|
---|
222 |
|
---|
223 | for (i = 0; i < len; i++)
|
---|
224 | cs += 0x000000FFL & *area8++;
|
---|
225 |
|
---|
226 | return(cs);
|
---|
227 | }
|
---|
228 |
|
---|
229 | /*
|
---|
230 | =============================================================================
|
---|
231 | makelh() -- make a library header
|
---|
232 | =============================================================================
|
---|
233 | */
|
---|
234 |
|
---|
235 | void makelh(int16_t kind)
|
---|
236 | {
|
---|
237 | memset(ldhead.l_csum, '?', 8); /* checksum */
|
---|
238 | memcpy(ldhead.l_name, ldfile, 8); /* file name */
|
---|
239 | memcpy(ldhead.l_type, ftypes[kind - 1][0], 3); /* file type */
|
---|
240 | memcpy(ldhead.l_cmnt, ldcmnt, 37); /* comment */
|
---|
241 |
|
---|
242 | lcsum = chksum(ldhead.l_name, (int32_t)(LH_LEN - 8));
|
---|
243 | }
|
---|
244 |
|
---|
245 | /*
|
---|
246 | =============================================================================
|
---|
247 | ldbusy() -- put up a "Busy" message
|
---|
248 | =============================================================================
|
---|
249 | */
|
---|
250 |
|
---|
251 | void ldbusy(int8_t *msg)
|
---|
252 | {
|
---|
253 | if (ndisp NE 0)
|
---|
254 | return;
|
---|
255 |
|
---|
256 | ldwmsg((int8_t *)NULL, " Busy - Please stand by", msg,
|
---|
257 | ldbox[10][4], ldbox[10][5]);
|
---|
258 | }
|
---|
259 |
|
---|
260 | /*
|
---|
261 | =============================================================================
|
---|
262 | noslot() -- complain about not finding a slot we expected
|
---|
263 | =============================================================================
|
---|
264 | */
|
---|
265 |
|
---|
266 | void noslot(int16_t fctype)
|
---|
267 | {
|
---|
268 | sprintf(ldmsg1, " the %s file,", ftypes[fctype - 1][2]);
|
---|
269 |
|
---|
270 | ldermsg("Can't find a slot for",
|
---|
271 | ldmsg1, " and one was expected", LD_EMCF, LD_EMCB);
|
---|
272 | }
|
---|
273 |
|
---|
274 | /*
|
---|
275 | =============================================================================
|
---|
276 | wr_ec() -- write with error checking
|
---|
277 | =============================================================================
|
---|
278 | */
|
---|
279 |
|
---|
280 | int16_t wr_ec(FILE *fp, void *from, int32_t len)
|
---|
281 | {
|
---|
282 | uint8_t *from8, c;
|
---|
283 | int32_t count;
|
---|
284 |
|
---|
285 | from8 = from;
|
---|
286 |
|
---|
287 | for (count = 0; count < len; count++) {
|
---|
288 |
|
---|
289 | errno = 0;
|
---|
290 | c = *from8++;
|
---|
291 |
|
---|
292 | if (EOF EQ putc(c, fp)) {
|
---|
293 |
|
---|
294 | sprintf(errbuf, "errno = %d", errno);
|
---|
295 |
|
---|
296 | ldermsg("Disk may be full",
|
---|
297 | errbuf, (int8_t *)NULL, LD_EMCF, LD_EMCB);
|
---|
298 |
|
---|
299 | fclose(fp);
|
---|
300 | postio(); /* restore LCD backlight */
|
---|
301 | return(FAILURE);
|
---|
302 | }
|
---|
303 |
|
---|
304 | #if DEBUGWE
|
---|
305 | if (debugsw AND debugwe)
|
---|
306 | printf(" %02.2X", 0x00FF & c);
|
---|
307 | #endif
|
---|
308 | }
|
---|
309 |
|
---|
310 | return(SUCCESS);
|
---|
311 | }
|
---|
312 |
|
---|
313 | /*
|
---|
314 | =============================================================================
|
---|
315 | rd_ec() -- read with error checking
|
---|
316 | =============================================================================
|
---|
317 | */
|
---|
318 |
|
---|
319 | int16_t rd_ec(FILE *fp, void *to, int32_t len)
|
---|
320 | {
|
---|
321 | uint8_t *to8;
|
---|
322 | int32_t count;
|
---|
323 | int16_t c;
|
---|
324 |
|
---|
325 | to8 = to;
|
---|
326 |
|
---|
327 | for (count = 0; count < len; count++) {
|
---|
328 |
|
---|
329 | errno = 0;
|
---|
330 |
|
---|
331 | if (EOF EQ (c = getc(fp))) {
|
---|
332 |
|
---|
333 | sprintf(errbuf, "errno = %d", errno);
|
---|
334 |
|
---|
335 | ldermsg("Unexpected EOF",
|
---|
336 | errbuf, (int8_t *)NULL, LD_EMCF, LD_EMCB);
|
---|
337 |
|
---|
338 | fclose(fp);
|
---|
339 | postio(); /* restore LCD backlight */
|
---|
340 | return(FAILURE);
|
---|
341 |
|
---|
342 | } else {
|
---|
343 |
|
---|
344 | *to8++ = (uint8_t)c;
|
---|
345 |
|
---|
346 | #if DEBUGRE
|
---|
347 | if (debugsw AND debugre)
|
---|
348 | printf(" %02.2X", 0x00FF & c);
|
---|
349 | #endif
|
---|
350 | }
|
---|
351 | }
|
---|
352 |
|
---|
353 | return(SUCCESS);
|
---|
354 | }
|
---|
355 |
|
---|
356 | /*
|
---|
357 | =============================================================================
|
---|
358 | srchcat() -- search the file catalog
|
---|
359 |
|
---|
360 | returns -1 on 'not found', slot 0..FCMAX-1 if found
|
---|
361 | =============================================================================
|
---|
362 | */
|
---|
363 |
|
---|
364 | int16_t srchcat(int8_t extn[])
|
---|
365 | {
|
---|
366 | register int16_t fcslot;
|
---|
367 |
|
---|
368 | for (fcslot = 0; fcslot < FCMAX; fcslot++) {
|
---|
369 |
|
---|
370 | if (ocslot(fcslot))
|
---|
371 | if (0 EQ (memcmp(filecat[fcslot].fcname, ldfile, 8))
|
---|
372 | AND (0 EQ memcmpu(filecat[fcslot].fcextn, extn, 3)))
|
---|
373 | return(fcslot);
|
---|
374 | }
|
---|
375 |
|
---|
376 | return(-1);
|
---|
377 | }
|
---|
378 |
|
---|
379 | /*
|
---|
380 | =============================================================================
|
---|
381 | clrcat() -- clear the file catalog
|
---|
382 | =============================================================================
|
---|
383 | */
|
---|
384 |
|
---|
385 | void clrcat(void)
|
---|
386 | {
|
---|
387 | register int16_t i;
|
---|
388 | int8_t fcebuf[1 + sizeof (struct fcat)];
|
---|
389 |
|
---|
390 | for (i = 0; i < FCMAX; i++) {
|
---|
391 |
|
---|
392 | sprintf(fcebuf, "000 Empty-%02.2d ??? %-37.37s%c%c",
|
---|
393 | i, "1234567890123456789012345678901234567",
|
---|
394 | A_CR, A_LF);
|
---|
395 |
|
---|
396 | memcpy(&filecat[i], fcebuf, sizeof (struct fcat));
|
---|
397 | }
|
---|
398 | }
|
---|
399 |
|
---|
400 | /*
|
---|
401 | =============================================================================
|
---|
402 | clreq() -- return number of clusters needed for a file
|
---|
403 |
|
---|
404 | Assumes the BPB pointer is valid.
|
---|
405 | =============================================================================
|
---|
406 | */
|
---|
407 |
|
---|
408 | int16_t clreq(int32_t bytes)
|
---|
409 | {
|
---|
410 | register int16_t rclusts;
|
---|
411 | register int32_t clmask;
|
---|
412 |
|
---|
413 | clmask = _thebpb->clsizb - 1;
|
---|
414 |
|
---|
415 | rclusts = (bytes / _thebpb->clsizb)
|
---|
416 | + ((bytes & clmask) ? 1 : 0);
|
---|
417 |
|
---|
418 | return(rclusts);
|
---|
419 | }
|
---|
420 |
|
---|
421 | /*
|
---|
422 | =============================================================================
|
---|
423 | spacerq() -- return space required for storing a file
|
---|
424 | =============================================================================
|
---|
425 | */
|
---|
426 |
|
---|
427 | int16_t spacerq(int16_t kind)
|
---|
428 | {
|
---|
429 | register int16_t howmuch;
|
---|
430 | register int32_t k;
|
---|
431 |
|
---|
432 | k = 0L;
|
---|
433 |
|
---|
434 | switch (kind) {
|
---|
435 |
|
---|
436 | case FT_ASG: /* Assignment file */
|
---|
437 |
|
---|
438 | k = (sizeof (struct asgent) * (int32_t)NASGLIB) + LH_LEN;
|
---|
439 | break;
|
---|
440 |
|
---|
441 | case FT_ORL:
|
---|
442 | case FT_ORH:
|
---|
443 | case FT_ORC:
|
---|
444 |
|
---|
445 | k = ((OR_LEN1 + (2 * OR_LEN2)) * (int32_t)NINORC) + LH_LEN;
|
---|
446 | break;
|
---|
447 |
|
---|
448 | case FT_PAT: /* Patch file */
|
---|
449 |
|
---|
450 | k = ptsizer() + LH_LEN;
|
---|
451 | break;
|
---|
452 |
|
---|
453 | case FT_SCR: /* Score file */
|
---|
454 |
|
---|
455 | k = scsizer() + LH_LEN;
|
---|
456 | break;
|
---|
457 |
|
---|
458 | case FT_SEQ: /* Sequence file */
|
---|
459 |
|
---|
460 | k = sqsizer() + LH_LEN;
|
---|
461 | break;
|
---|
462 |
|
---|
463 | case FT_TUN: /* Tuning file */
|
---|
464 |
|
---|
465 | k = (NTUNSLIB * 256L) + (NTUNSLIB * 32L) + LH_LEN;
|
---|
466 | break;
|
---|
467 |
|
---|
468 | case FT_WAV: /* Waveshape file */
|
---|
469 |
|
---|
470 | k = ((int32_t)NUMWAVS * OR_LEN2) + LH_LEN;
|
---|
471 | break;
|
---|
472 |
|
---|
473 | default:
|
---|
474 |
|
---|
475 | k = 0L;
|
---|
476 | break;
|
---|
477 | }
|
---|
478 |
|
---|
479 | howmuch = k ? clreq(k) : -1;
|
---|
480 | ndbytes = k;
|
---|
481 | return(howmuch);
|
---|
482 | }
|
---|
483 |
|
---|
484 | /*
|
---|
485 | =============================================================================
|
---|
486 | ckstor() -- check for storage type selection
|
---|
487 | =============================================================================
|
---|
488 | */
|
---|
489 |
|
---|
490 | int16_t ckstor(void)
|
---|
491 | {
|
---|
492 | if (lasgsw) /* assignments */
|
---|
493 | return(SUCCESS);
|
---|
494 |
|
---|
495 | if (lorchsw) /* hi orch */
|
---|
496 | return(SUCCESS);
|
---|
497 |
|
---|
498 | if (lorclsw) /* lo orch */
|
---|
499 | return(SUCCESS);
|
---|
500 |
|
---|
501 | if (lpatsw) /* patches */
|
---|
502 | return(SUCCESS);
|
---|
503 |
|
---|
504 | if (lscrsw) /* score */
|
---|
505 | return(SUCCESS);
|
---|
506 |
|
---|
507 | if (lseqsw) /* sequences */
|
---|
508 | return(SUCCESS);
|
---|
509 |
|
---|
510 | if (ltunsw) /* tunings */
|
---|
511 | return(SUCCESS);
|
---|
512 |
|
---|
513 | if (lwavsw) /* waveshapes */
|
---|
514 | return(SUCCESS);
|
---|
515 |
|
---|
516 | return(FAILURE);
|
---|
517 | }
|
---|
518 |
|
---|
519 | /*
|
---|
520 | =============================================================================
|
---|
521 | ckdups() -- check for duplicate file type entries in the file catalog
|
---|
522 | =============================================================================
|
---|
523 | */
|
---|
524 |
|
---|
525 | int16_t ckdups(void)
|
---|
526 | {
|
---|
527 | if (lasgsw)
|
---|
528 | if (-1 NE srchcat("asg"))
|
---|
529 | return(FT_ASG);
|
---|
530 |
|
---|
531 | if (lorchsw)
|
---|
532 | if (-1 NE srchcat("orh"))
|
---|
533 | return(FT_ORH);
|
---|
534 |
|
---|
535 | if (lorclsw)
|
---|
536 | if (-1 NE srchcat("orl"))
|
---|
537 | return(FT_ORL);
|
---|
538 |
|
---|
539 | if (lorchsw OR lorclsw)
|
---|
540 | if (-1 NE srchcat("orc"))
|
---|
541 | return(FT_ORC);
|
---|
542 |
|
---|
543 | if (lpatsw)
|
---|
544 | if (-1 NE srchcat("pat"))
|
---|
545 | return(FT_PAT);
|
---|
546 |
|
---|
547 | if (lscrsw)
|
---|
548 | if (-1 NE srchcat("scr"))
|
---|
549 | return(FT_SCR);
|
---|
550 |
|
---|
551 | if (lseqsw)
|
---|
552 | if (-1 NE srchcat("seq"))
|
---|
553 | return(FT_SEQ);
|
---|
554 |
|
---|
555 | if (ltunsw)
|
---|
556 | if (-1 NE srchcat("tun"))
|
---|
557 | return(FT_TUN);
|
---|
558 |
|
---|
559 | if (lwavsw)
|
---|
560 | if (-1 NE srchcat("wav"))
|
---|
561 | return(FT_WAV);
|
---|
562 | return(0);
|
---|
563 | }
|
---|
564 |
|
---|
565 | /*
|
---|
566 | =============================================================================
|
---|
567 | showsiz() -- display disk capacity and usage
|
---|
568 |
|
---|
569 | Forces the disk to be read to get the BPB and FAT.
|
---|
570 | =============================================================================
|
---|
571 | */
|
---|
572 |
|
---|
573 | int16_t showsiz(void)
|
---|
574 | {
|
---|
575 | register int16_t dcap, drem, dused;
|
---|
576 |
|
---|
577 | _bpbin = FALSE; /* force disk to be read */
|
---|
578 |
|
---|
579 | dcap = dspace(0);
|
---|
580 |
|
---|
581 | if (dcap EQ -1) {
|
---|
582 |
|
---|
583 | ldermsg("Disk not ready ?",
|
---|
584 | (int8_t *)NULL, (int8_t *)NULL,
|
---|
585 | LD_EMCF, LD_EMCB);
|
---|
586 |
|
---|
587 | return(FAILURE);
|
---|
588 | }
|
---|
589 |
|
---|
590 | drem = dspace(1);
|
---|
591 | dused = dcap - drem;
|
---|
592 |
|
---|
593 | sprintf(ldmsg1, "Microdisk capacity %4u blocks", dcap);
|
---|
594 | sprintf(ldmsg2, "This disk consumes %4u blocks", dused);
|
---|
595 | sprintf(ldmsg3, "Available space is %4u blocks", drem);
|
---|
596 |
|
---|
597 | ldwmsg(ldmsg1, ldmsg2, ldmsg3, ldbox[10][4], ldbox[10][5]);
|
---|
598 | return(SUCCESS);
|
---|
599 | }
|
---|
600 |
|
---|
601 | /*
|
---|
602 | =============================================================================
|
---|
603 | getcat() -- get the file catalog from disk
|
---|
604 | =============================================================================
|
---|
605 | */
|
---|
606 |
|
---|
607 | int16_t getcat(int16_t msgsw)
|
---|
608 | {
|
---|
609 | register FILE *fp;
|
---|
610 | int16_t rc, fesize;
|
---|
611 |
|
---|
612 | ldidsiz = FALSE; /* we didn't show the size (yet) */
|
---|
613 | _bpbin = FALSE; /* guarantee we read the directory */
|
---|
614 | catin = FALSE; /* catalog not valid */
|
---|
615 |
|
---|
616 | errno = 0;
|
---|
617 | preio(); /* kill LCD backlight */
|
---|
618 | fp = fopenb(CATNAME, "r"); /* open the catalog file */
|
---|
619 |
|
---|
620 | if (NULL EQ fp) {
|
---|
621 |
|
---|
622 | clrcat();
|
---|
623 | catin = TRUE;
|
---|
624 |
|
---|
625 | if (msgsw) { /* see if we show the message */
|
---|
626 |
|
---|
627 | showsiz();
|
---|
628 | ldidsiz = TRUE; /* showed the size */
|
---|
629 | }
|
---|
630 |
|
---|
631 | return(SUCCESS); /* no catalog is OK, too */
|
---|
632 | }
|
---|
633 |
|
---|
634 | fesize = sizeof(struct fcat);
|
---|
635 | memset(filecat, 0, sizeof (struct fcat) * FCMAX);
|
---|
636 |
|
---|
637 |
|
---|
638 | errno = 0;
|
---|
639 | rc = fread(filecat, fesize, FCMAX, fp);
|
---|
640 |
|
---|
641 | if (rc NE FCMAX) {
|
---|
642 |
|
---|
643 | if (rc) {
|
---|
644 |
|
---|
645 | sprintf(ldmsg1, " fread returned %d", rc);
|
---|
646 | sprintf(ldmsg2, " errno = %d, fesize=%d",
|
---|
647 | errno, fesize);
|
---|
648 |
|
---|
649 | ldermsg("Unable to read catalog",
|
---|
650 | ldmsg1, ldmsg2, LD_EMCF, LD_EMCB);
|
---|
651 |
|
---|
652 | catin = FALSE;
|
---|
653 |
|
---|
654 | } else {
|
---|
655 |
|
---|
656 | ldermsg("File catalog is NULL",
|
---|
657 | (int8_t *)NULL, (int8_t *)NULL,
|
---|
658 | LD_EMCF, LD_EMCB);
|
---|
659 |
|
---|
660 | clrcat();
|
---|
661 | catin = TRUE;
|
---|
662 | }
|
---|
663 |
|
---|
664 | fclose(fp);
|
---|
665 | postio(); /* restore LCD backlight */
|
---|
666 | return(FAILURE);
|
---|
667 | }
|
---|
668 |
|
---|
669 | catin = TRUE;
|
---|
670 | fclose(fp);
|
---|
671 | postio(); /* restore LCD backlight */
|
---|
672 | return(SUCCESS);
|
---|
673 | }
|
---|
674 |
|
---|
675 | /*
|
---|
676 | =============================================================================
|
---|
677 | putcat() -- write the updated catalog on disk
|
---|
678 | =============================================================================
|
---|
679 | */
|
---|
680 |
|
---|
681 | int16_t putcat(void)
|
---|
682 | {
|
---|
683 | register FILE *fp;
|
---|
684 | register int16_t i, rc, fesize;
|
---|
685 |
|
---|
686 | for (i = 0; i < FCMAX; i++) { /* clean up the catalog */
|
---|
687 |
|
---|
688 | filecat[i].fceol[0] = A_CR;
|
---|
689 | filecat[i].fceol[1] = A_LF;
|
---|
690 | }
|
---|
691 |
|
---|
692 | errno = 0;
|
---|
693 | preio(); /* kill LCD backlight */
|
---|
694 | fp = fopenb(CATNAME, "w"); /* open the catalog file */
|
---|
695 |
|
---|
696 | if (NULL EQ fp) {
|
---|
697 |
|
---|
698 | sprintf(ldmsg2, " errno = %d", errno);
|
---|
699 |
|
---|
700 | ldermsg("Unable to open catalog",
|
---|
701 | (int8_t *)NULL, ldmsg2, LD_EMCF, LD_EMCB);
|
---|
702 |
|
---|
703 | return(FAILURE);
|
---|
704 | }
|
---|
705 |
|
---|
706 | fesize = sizeof (struct fcat);
|
---|
707 |
|
---|
708 |
|
---|
709 | errno = 0;
|
---|
710 | rc = fwrite(filecat, fesize, FCMAX, fp);
|
---|
711 |
|
---|
712 | if (rc NE FCMAX) {
|
---|
713 |
|
---|
714 | if (rc) {
|
---|
715 |
|
---|
716 | sprintf(ldmsg1, " fwrite returned %d", rc);
|
---|
717 | sprintf(ldmsg2, " errno = %d, fesize=%d",
|
---|
718 | errno, fesize);
|
---|
719 |
|
---|
720 | ldermsg("Can't write catalog",
|
---|
721 | ldmsg1, ldmsg2, LD_EMCF, LD_EMCB);
|
---|
722 |
|
---|
723 | } else {
|
---|
724 |
|
---|
725 | sprintf(ldmsg2, " errno = %d", errno);
|
---|
726 |
|
---|
727 | ldermsg("Disk may be full",
|
---|
728 | (int8_t *)NULL, ldmsg2,
|
---|
729 | LD_EMCF, LD_EMCB);
|
---|
730 | }
|
---|
731 |
|
---|
732 | fclose(fp);
|
---|
733 | postio(); /* restore LCD backlight */
|
---|
734 | return(FAILURE);
|
---|
735 | }
|
---|
736 |
|
---|
737 | fclose(fp);
|
---|
738 | postio(); /* restore LCD backlight */
|
---|
739 | return(SUCCESS);
|
---|
740 | }
|
---|
741 |
|
---|
742 | /*
|
---|
743 | =============================================================================
|
---|
744 | dslslot() -- display a file catalog entry
|
---|
745 | =============================================================================
|
---|
746 | */
|
---|
747 |
|
---|
748 | void dslslot(int16_t slot, uint16_t fg, int16_t row)
|
---|
749 | {
|
---|
750 | register uint16_t color, chilon, chilorc;
|
---|
751 | int16_t c;
|
---|
752 | int8_t buf[40];
|
---|
753 |
|
---|
754 | if (ndisp NE 0)
|
---|
755 | return;
|
---|
756 |
|
---|
757 | color = exp_c(fg); /* foreground color */
|
---|
758 | chilon = exp_c(ldbox[1][4]);
|
---|
759 | chilorc = exp_c(HILORC);
|
---|
760 |
|
---|
761 | /* file type */
|
---|
762 |
|
---|
763 | vcputsv(librob, 64, color, ldbox[1][5], row, 1, fctstr(slot, 0), 14);
|
---|
764 |
|
---|
765 | /* load letter */
|
---|
766 |
|
---|
767 | c = filecat[slot].fcp0;
|
---|
768 | buf[0] = 0x007F & c;
|
---|
769 | buf[1] = '\0';
|
---|
770 | vcputsv(librob, 64, (c & 0x0080) ? chilorc : chilon,
|
---|
771 | ldbox[1][5], row, 11, buf, 14);
|
---|
772 |
|
---|
773 | /* file name */
|
---|
774 |
|
---|
775 | memcpy(buf, filecat[slot].fcname, 8);
|
---|
776 | buf[8] = '\0';
|
---|
777 | vcputsv(librob, 64, color, ldbox[1][5], row, 13, buf, 14);
|
---|
778 |
|
---|
779 | /* comment */
|
---|
780 |
|
---|
781 | memcpy(buf, filecat[slot].fccmnt, 37);
|
---|
782 | buf[37] = '\0';
|
---|
783 | vcputsv(librob, 64, chilon, ldbox[1][5], row, 22, buf, 14);
|
---|
784 |
|
---|
785 | /* size */
|
---|
786 |
|
---|
787 | memcpy(buf, filecat[slot].fcsize, 3);
|
---|
788 | buf[3] = '\0';
|
---|
789 | vcputsv(librob, 64, chilon, ldbox[1][5], row, 60, buf, 14);
|
---|
790 | }
|
---|
791 |
|
---|
792 | /*
|
---|
793 | =============================================================================
|
---|
794 | showcat() -- display the file catalog entries
|
---|
795 | =============================================================================
|
---|
796 | */
|
---|
797 |
|
---|
798 | int16_t showcat(void)
|
---|
799 | {
|
---|
800 | register int16_t fcslot, fcrow, fcount;
|
---|
801 | register uint16_t color;
|
---|
802 |
|
---|
803 | if (ndisp NE 0)
|
---|
804 | return(FAILURE);
|
---|
805 |
|
---|
806 | ldswin(0); /* fix up the title */
|
---|
807 |
|
---|
808 | color = exp_c(ldbox[1][5]); /* background color */
|
---|
809 |
|
---|
810 | if (v_regs[5] & 0x0180)
|
---|
811 | vbank(0);
|
---|
812 |
|
---|
813 | vbfill4(librob, 128, ldbox[1][0], ldbox[1][1],
|
---|
814 | ldbox[1][2], ldbox[1][3], color);
|
---|
815 |
|
---|
816 | color = ldbox[1][4]; /* foreground color */
|
---|
817 |
|
---|
818 | fcrow = 1;
|
---|
819 | fcount = 0;
|
---|
820 |
|
---|
821 | for (fcslot = 0; fcslot < FCMAX; fcslot++) {
|
---|
822 |
|
---|
823 | if (ocslot(fcslot)) {
|
---|
824 |
|
---|
825 | dslslot(fcslot, color, fcrow);
|
---|
826 | fcrow++;
|
---|
827 | fcount++;
|
---|
828 | }
|
---|
829 | }
|
---|
830 |
|
---|
831 | return(fcount);
|
---|
832 | }
|
---|
833 |
|
---|
834 | /*
|
---|
835 | =============================================================================
|
---|
836 | fcindex() -- display the file catalog
|
---|
837 | =============================================================================
|
---|
838 | */
|
---|
839 |
|
---|
840 | int16_t fcindex(void)
|
---|
841 | {
|
---|
842 | if (NOT lderrsw)
|
---|
843 | ldbusy(" Reading catalog");
|
---|
844 |
|
---|
845 | if (getcat(1)) /* get catalog, possibly display size */
|
---|
846 | return(FAILURE);
|
---|
847 |
|
---|
848 | if (NOT lderrsw)
|
---|
849 | showcat(); /* display the catalog */
|
---|
850 |
|
---|
851 | /* show size if getcat() didn't */
|
---|
852 |
|
---|
853 | if ((NOT ldidsiz) AND (NOT lderrsw))
|
---|
854 | showsiz();
|
---|
855 |
|
---|
856 | return(SUCCESS);
|
---|
857 | }
|
---|
858 |
|
---|
859 | /*
|
---|
860 | =============================================================================
|
---|
861 | streset() -- reset the switches after a store or an error
|
---|
862 | =============================================================================
|
---|
863 | */
|
---|
864 |
|
---|
865 | void streset(void)
|
---|
866 | {
|
---|
867 | lstrsw = FALSE;
|
---|
868 |
|
---|
869 | lasgsw = FALSE;
|
---|
870 | lorchsw = FALSE;
|
---|
871 | lorclsw = FALSE;
|
---|
872 | lpatsw = FALSE;
|
---|
873 | lscrsw = FALSE;
|
---|
874 | lseqsw = FALSE;
|
---|
875 | ltunsw = FALSE;
|
---|
876 | lwavsw = FALSE;
|
---|
877 |
|
---|
878 | ldswin(9);
|
---|
879 | }
|
---|
880 |
|
---|
881 | /*
|
---|
882 | =============================================================================
|
---|
883 | fcreset() -- reset the switches after a fetch or an error
|
---|
884 | =============================================================================
|
---|
885 | */
|
---|
886 |
|
---|
887 | void fcreset(void)
|
---|
888 | {
|
---|
889 | lselsw = FALSE;
|
---|
890 |
|
---|
891 | ldswin(6);
|
---|
892 | }
|
---|
893 |
|
---|
894 | /*
|
---|
895 | =============================================================================
|
---|
896 | getslot() -- find a free file catalog slot
|
---|
897 |
|
---|
898 | returns -1 on error, slot # 0..FCMAX-1 if a slot was found
|
---|
899 | =============================================================================
|
---|
900 | */
|
---|
901 |
|
---|
902 | int16_t getslot(void)
|
---|
903 | {
|
---|
904 | register int16_t i;
|
---|
905 |
|
---|
906 | for (i = 0; i < FCMAX; i++)
|
---|
907 | if (NOT ocslot(i))
|
---|
908 | return(i);
|
---|
909 |
|
---|
910 | return(-1);
|
---|
911 | }
|
---|
912 |
|
---|
913 | /*
|
---|
914 | =============================================================================
|
---|
915 | slotnam() -- return the file name for a slot
|
---|
916 | =============================================================================
|
---|
917 | */
|
---|
918 |
|
---|
919 | int8_t *slotnam(uint16_t slot, uint16_t kind)
|
---|
920 | {
|
---|
921 | static int8_t thename[13];
|
---|
922 |
|
---|
923 | sprintf(thename, "M7SLOT%02.2u.%-3.3s",
|
---|
924 | slot, ftypes[kind - 1][0]);
|
---|
925 |
|
---|
926 | return(thename);
|
---|
927 | }
|
---|
928 |
|
---|
929 | /*
|
---|
930 | =============================================================================
|
---|
931 | wrtfile() -- write a file on the disk
|
---|
932 | =============================================================================
|
---|
933 | */
|
---|
934 |
|
---|
935 | int16_t wrtfile(int16_t kind)
|
---|
936 | {
|
---|
937 | register int16_t slot, flspace, tkind;
|
---|
938 | int8_t sizetmp[4];
|
---|
939 |
|
---|
940 | slot = getslot();
|
---|
941 |
|
---|
942 | if (-1 EQ slot) {
|
---|
943 |
|
---|
944 | noslot(kind);
|
---|
945 | streset();
|
---|
946 | return(FAILURE);
|
---|
947 | }
|
---|
948 |
|
---|
949 | switch (kind) {
|
---|
950 |
|
---|
951 | case FT_ASG:
|
---|
952 |
|
---|
953 | if (wrt_asg(slot))
|
---|
954 | return(FAILURE);
|
---|
955 | else
|
---|
956 | break;
|
---|
957 |
|
---|
958 | case FT_ORL: /* lo orch write */
|
---|
959 |
|
---|
960 | if (wrt_orc(slot, 0))
|
---|
961 | return(FAILURE);
|
---|
962 | else
|
---|
963 | break;
|
---|
964 |
|
---|
965 | case FT_ORH: /* hi orch write */
|
---|
966 |
|
---|
967 | if (wrt_orc(slot, 1))
|
---|
968 | return(FAILURE);
|
---|
969 | else
|
---|
970 | break;
|
---|
971 |
|
---|
972 | case FT_PAT:
|
---|
973 |
|
---|
974 | if (wrt_pat(slot))
|
---|
975 | return(FAILURE);
|
---|
976 | else
|
---|
977 | break;
|
---|
978 |
|
---|
979 | case FT_SCR:
|
---|
980 |
|
---|
981 | if (wrt_scr(slot))
|
---|
982 | return(FAILURE);
|
---|
983 | else
|
---|
984 | break;
|
---|
985 |
|
---|
986 | case FT_SEQ:
|
---|
987 |
|
---|
988 | if (wrt_seq(slot))
|
---|
989 | return(FAILURE);
|
---|
990 | else
|
---|
991 | break;
|
---|
992 |
|
---|
993 |
|
---|
994 | case FT_TUN:
|
---|
995 |
|
---|
996 | if (wrt_tun(slot))
|
---|
997 | return(FAILURE);
|
---|
998 | else
|
---|
999 | break;
|
---|
1000 |
|
---|
1001 | case FT_WAV:
|
---|
1002 |
|
---|
1003 | if (wrt_wav(slot))
|
---|
1004 | return(FAILURE);
|
---|
1005 | else
|
---|
1006 | break;
|
---|
1007 |
|
---|
1008 | default:
|
---|
1009 |
|
---|
1010 | sprintf(ldmsg1, " kind=%d", kind);
|
---|
1011 |
|
---|
1012 | ldermsg("bad wrtfile argument:",
|
---|
1013 | ldmsg1, (int8_t *)NULL, LD_EMCF, LD_EMCB);
|
---|
1014 |
|
---|
1015 | return(FAILURE);
|
---|
1016 | }
|
---|
1017 |
|
---|
1018 | /* update the file catalog */
|
---|
1019 |
|
---|
1020 | if ((kind EQ FT_ORL) OR (kind EQ FT_ORH))
|
---|
1021 | tkind = FT_ORC;
|
---|
1022 | else
|
---|
1023 | tkind = kind;
|
---|
1024 |
|
---|
1025 | flspace = spacerq(kind);
|
---|
1026 |
|
---|
1027 | sprintf(sizetmp, "%03.3d", flspace); /* size */
|
---|
1028 | memcpy(filecat[slot].fcsize, sizetmp, 3);
|
---|
1029 |
|
---|
1030 | memcpy(filecat[slot].fcname, ldfile, 8); /* name */
|
---|
1031 | memcpy(filecat[slot].fcextn, ftypes[tkind - 1][0], 3); /* type */
|
---|
1032 | memcpy(filecat[slot].fccmnt, ldcmnt, 37); /* comment */
|
---|
1033 |
|
---|
1034 | savefc(kind);
|
---|
1035 |
|
---|
1036 | filecat[slot].fceol[0] = A_CR;
|
---|
1037 | filecat[slot].fceol[1] = A_LF;
|
---|
1038 |
|
---|
1039 | return(SUCCESS);
|
---|
1040 | }
|
---|
1041 |
|
---|
1042 | /*
|
---|
1043 | =============================================================================
|
---|
1044 | writem() -- write selected files
|
---|
1045 | =============================================================================
|
---|
1046 | */
|
---|
1047 |
|
---|
1048 | int16_t writem(void)
|
---|
1049 | {
|
---|
1050 | if (lasgsw) /* Assignments */
|
---|
1051 | if (wrtfile(FT_ASG))
|
---|
1052 | return(FAILURE);
|
---|
1053 |
|
---|
1054 | if (lorchsw) /* Hi Orch */
|
---|
1055 | if (wrtfile(FT_ORH))
|
---|
1056 | return(FAILURE);
|
---|
1057 |
|
---|
1058 | if (lorclsw) /* Lo Orch */
|
---|
1059 | if (wrtfile(FT_ORL))
|
---|
1060 | return(FAILURE);
|
---|
1061 |
|
---|
1062 | if (lpatsw) /* Patches */
|
---|
1063 | if (wrtfile(FT_PAT))
|
---|
1064 | return(FAILURE);
|
---|
1065 |
|
---|
1066 | if (lscrsw) /* Score */
|
---|
1067 | if (wrtfile(FT_SCR))
|
---|
1068 | return(FAILURE);
|
---|
1069 |
|
---|
1070 | if (lseqsw) /* Sequences */
|
---|
1071 | if (wrtfile(FT_SEQ))
|
---|
1072 | return(FAILURE);
|
---|
1073 |
|
---|
1074 | if (ltunsw) /* Tunings */
|
---|
1075 | if (wrtfile(FT_TUN))
|
---|
1076 | return(FAILURE);
|
---|
1077 |
|
---|
1078 | if (lwavsw) /* Waveshapes */
|
---|
1079 | if (wrtfile(FT_WAV))
|
---|
1080 | return(FAILURE);
|
---|
1081 |
|
---|
1082 | return(SUCCESS);
|
---|
1083 | }
|
---|
1084 |
|
---|
1085 | /*
|
---|
1086 | =============================================================================
|
---|
1087 | storit() -- store selected files on disk
|
---|
1088 | =============================================================================
|
---|
1089 | */
|
---|
1090 |
|
---|
1091 | int16_t storit(void)
|
---|
1092 | {
|
---|
1093 | register int16_t weneed, i, slotnd, slothv;
|
---|
1094 | int16_t rc, drem;
|
---|
1095 |
|
---|
1096 | /* make sure the file is named */
|
---|
1097 |
|
---|
1098 | if (0 EQ memcmp(ldfile, " ", 8)) {
|
---|
1099 |
|
---|
1100 | ldermsg("File must be named",
|
---|
1101 | ld_em1, ld_em2, LD_EMCF, LD_EMCB);
|
---|
1102 |
|
---|
1103 | streset();
|
---|
1104 | return(FAILURE);
|
---|
1105 | }
|
---|
1106 |
|
---|
1107 | /* make sure something was selected */
|
---|
1108 |
|
---|
1109 | if (ckstor()) {
|
---|
1110 |
|
---|
1111 | ldermsg("No file type selected",
|
---|
1112 | ld_em1, ld_em2, LD_EMCF, LD_EMCB);
|
---|
1113 |
|
---|
1114 | streset();
|
---|
1115 | return(FAILURE);
|
---|
1116 | }
|
---|
1117 |
|
---|
1118 | if (NOT lderrsw)
|
---|
1119 | ldbusy(" Storing files");
|
---|
1120 |
|
---|
1121 | if (getcat(0)) { /* get the catalog */
|
---|
1122 |
|
---|
1123 | streset();
|
---|
1124 | return(FAILURE);
|
---|
1125 | }
|
---|
1126 |
|
---|
1127 | /* find out how much space we need to store everything */
|
---|
1128 |
|
---|
1129 | drem = dspace(1);
|
---|
1130 | slotnd = 0;
|
---|
1131 | weneed = 0;
|
---|
1132 |
|
---|
1133 |
|
---|
1134 | if (lasgsw) {
|
---|
1135 |
|
---|
1136 | weneed += spacerq(FT_ASG);
|
---|
1137 | ++slotnd;
|
---|
1138 | }
|
---|
1139 |
|
---|
1140 | if (lorchsw) {
|
---|
1141 |
|
---|
1142 | weneed += spacerq(FT_ORH);
|
---|
1143 | ++slotnd;
|
---|
1144 | }
|
---|
1145 |
|
---|
1146 | if (lorclsw) {
|
---|
1147 |
|
---|
1148 | weneed += spacerq(FT_ORL);
|
---|
1149 | ++slotnd;
|
---|
1150 | }
|
---|
1151 |
|
---|
1152 | if (lpatsw) {
|
---|
1153 |
|
---|
1154 | weneed += spacerq(FT_PAT);
|
---|
1155 | ++slotnd;
|
---|
1156 | }
|
---|
1157 |
|
---|
1158 | if (lscrsw) {
|
---|
1159 |
|
---|
1160 | weneed += spacerq(FT_SCR);
|
---|
1161 | ++slotnd;
|
---|
1162 | }
|
---|
1163 |
|
---|
1164 | if (lseqsw) {
|
---|
1165 |
|
---|
1166 | weneed += spacerq(FT_SEQ);
|
---|
1167 | ++slotnd;
|
---|
1168 | }
|
---|
1169 |
|
---|
1170 | if (ltunsw) {
|
---|
1171 |
|
---|
1172 | weneed += spacerq(FT_TUN);
|
---|
1173 | ++slotnd;
|
---|
1174 | }
|
---|
1175 |
|
---|
1176 | if (lwavsw) {
|
---|
1177 |
|
---|
1178 | weneed += spacerq(FT_WAV);
|
---|
1179 | ++slotnd;
|
---|
1180 | }
|
---|
1181 |
|
---|
1182 | if (drem < weneed) {
|
---|
1183 |
|
---|
1184 | nospace("file");
|
---|
1185 | streset();
|
---|
1186 | return(FAILURE);
|
---|
1187 | }
|
---|
1188 |
|
---|
1189 | /* see if we have enough catalog space */
|
---|
1190 |
|
---|
1191 | slothv = 0;
|
---|
1192 |
|
---|
1193 | for (i = 0; i < FCMAX; i++)
|
---|
1194 | if (NOT ocslot(i))
|
---|
1195 | ++slothv;
|
---|
1196 |
|
---|
1197 | if (slothv < slotnd) {
|
---|
1198 |
|
---|
1199 | nospace("file");
|
---|
1200 | streset();
|
---|
1201 | return(FAILURE);
|
---|
1202 | }
|
---|
1203 |
|
---|
1204 | /* make sure the name is unique */
|
---|
1205 |
|
---|
1206 | if (rc = ckdups()) {
|
---|
1207 |
|
---|
1208 | sprintf(ldmsg1, "Duplicate %s", ftypes[rc - 1][2]);
|
---|
1209 | ldermsg(ldmsg1, ld_em1, ld_em2, LD_EMCF, LD_EMCB);
|
---|
1210 |
|
---|
1211 | streset();
|
---|
1212 | return(FAILURE);
|
---|
1213 | }
|
---|
1214 |
|
---|
1215 | /* write the files */
|
---|
1216 |
|
---|
1217 | rc = writem();
|
---|
1218 |
|
---|
1219 | if (NOT rc)
|
---|
1220 | ldbusy(" Writing catalog");
|
---|
1221 |
|
---|
1222 | if (putcat()) {
|
---|
1223 |
|
---|
1224 | _clsvol();
|
---|
1225 | streset();
|
---|
1226 | showcat();
|
---|
1227 | return(FAILURE);
|
---|
1228 | }
|
---|
1229 |
|
---|
1230 | _clsvol();
|
---|
1231 | streset();
|
---|
1232 | showcat();
|
---|
1233 |
|
---|
1234 | if (rc)
|
---|
1235 | return(FAILURE);
|
---|
1236 |
|
---|
1237 | showsiz();
|
---|
1238 | return(SUCCESS);
|
---|
1239 | }
|
---|
1240 |
|
---|
1241 | /*
|
---|
1242 | =============================================================================
|
---|
1243 | advlcur() -- advance the librarian display text cursor
|
---|
1244 | =============================================================================
|
---|
1245 | */
|
---|
1246 |
|
---|
1247 | void advlcur(void)
|
---|
1248 | {
|
---|
1249 | register int16_t newcol;
|
---|
1250 |
|
---|
1251 | if (infield(stcrow, stccol, curfet))
|
---|
1252 | cfetp = infetp;
|
---|
1253 | else
|
---|
1254 | return;
|
---|
1255 |
|
---|
1256 | newcol = stccol + 1;
|
---|
1257 |
|
---|
1258 | if (newcol LE cfetp->frcol)
|
---|
1259 | itcpos(stcrow, newcol);
|
---|
1260 |
|
---|
1261 | cxval = stccol * 8;
|
---|
1262 | cyval = stcrow * 14;
|
---|
1263 | }
|
---|
1264 |
|
---|
1265 | /*
|
---|
1266 | =============================================================================
|
---|
1267 | bsplcur() -- backspace the librarian display text cursor
|
---|
1268 | =============================================================================
|
---|
1269 | */
|
---|
1270 |
|
---|
1271 | void bsplcur(void)
|
---|
1272 | {
|
---|
1273 | register int16_t newcol;
|
---|
1274 |
|
---|
1275 | if (infield(stcrow, stccol, curfet))
|
---|
1276 | cfetp = infetp;
|
---|
1277 | else
|
---|
1278 | return;
|
---|
1279 |
|
---|
1280 | newcol = stccol - 1;
|
---|
1281 |
|
---|
1282 | if (newcol GE cfetp->flcol)
|
---|
1283 | itcpos(stcrow, newcol);
|
---|
1284 |
|
---|
1285 | cxval = stccol * 8;
|
---|
1286 | cyval = stcrow * 14;
|
---|
1287 | }
|
---|
1288 |
|
---|
1289 | /*
|
---|
1290 | =============================================================================
|
---|
1291 | ldswin() -- display a window
|
---|
1292 | =============================================================================
|
---|
1293 | */
|
---|
1294 |
|
---|
1295 | void ldswin(int16_t n)
|
---|
1296 | {
|
---|
1297 | register int16_t cx, cy;
|
---|
1298 |
|
---|
1299 | if (ndisp NE 0)
|
---|
1300 | return;
|
---|
1301 |
|
---|
1302 | if ((n EQ 10) AND (lmwtype EQ 1))
|
---|
1303 | cx = exp_c(TTBACK); /* use black for the typewriter */
|
---|
1304 | else
|
---|
1305 | cx = exp_c(ldbox[n][5]); /* expand the background color */
|
---|
1306 |
|
---|
1307 | /* first, fill the box with the background color */
|
---|
1308 |
|
---|
1309 | if (v_regs[5] & 0x0180)
|
---|
1310 | vbank(0);
|
---|
1311 |
|
---|
1312 | vbfill4(librob, 128, ldbox[n][0], ldbox[n][1], ldbox[n][2],
|
---|
1313 | ldbox[n][3], cx);
|
---|
1314 |
|
---|
1315 | /* put in the box label */
|
---|
1316 |
|
---|
1317 | tsplot4(librob, 64, ldbox[n][4], ldbox[n][6], ldbox[n][7],
|
---|
1318 | ldbxlb0[n], 14);
|
---|
1319 |
|
---|
1320 |
|
---|
1321 | switch (n) { /* final text - overlays above stuff */
|
---|
1322 |
|
---|
1323 | case 0: /* titles */
|
---|
1324 |
|
---|
1325 | point = ldpoint;
|
---|
1326 |
|
---|
1327 | lseg( 8, 13, 79, 13, LUNDRLN);
|
---|
1328 | lseg( 88, 13, 95, 13, LUNDRLN);
|
---|
1329 | lseg(104, 13, 167, 13, LUNDRLN);
|
---|
1330 | lseg(176, 13, 471, 13, LUNDRLN);
|
---|
1331 | lseg(480, 13, 504, 13, LUNDRLN);
|
---|
1332 |
|
---|
1333 | return;
|
---|
1334 |
|
---|
1335 | case 1: /* index area */
|
---|
1336 |
|
---|
1337 | return;
|
---|
1338 |
|
---|
1339 | case 3: /* current file name */
|
---|
1340 |
|
---|
1341 | tsplot4(librob, 64, ldbox[n][4], ldbox[n][6], ldbox[n][7],
|
---|
1342 | ldfile, 14);
|
---|
1343 | return;
|
---|
1344 |
|
---|
1345 | case 5: /* current comment field */
|
---|
1346 |
|
---|
1347 | tsplot4(librob, 64, ldbox[n][4], ldbox[n][6], ldbox[n][7],
|
---|
1348 | ldcmnt, 14);
|
---|
1349 | return;
|
---|
1350 |
|
---|
1351 | case 7: /* "Replace" / "Append" */
|
---|
1352 |
|
---|
1353 | if (lrasw)
|
---|
1354 | cy = exp_c(LD_SELC);
|
---|
1355 | else
|
---|
1356 | cy = ldbox[n][4];
|
---|
1357 |
|
---|
1358 | tsplot4(librob, 64, cy, ldbox[n][6], ldbox[n][7],
|
---|
1359 | "Content", 14);
|
---|
1360 |
|
---|
1361 | return;
|
---|
1362 |
|
---|
1363 | case 8: /* "Hi Orch" / "Lo Orch" */
|
---|
1364 |
|
---|
1365 | if (lselsw) {
|
---|
1366 |
|
---|
1367 | ldkind = ftkind(ldslot);
|
---|
1368 |
|
---|
1369 | if ((ldkind EQ FT_ORC) OR
|
---|
1370 | (ldkind EQ FT_ORL) OR
|
---|
1371 | (ldkind EQ FT_ORH))
|
---|
1372 | cy = exp_c(LD_SELC);
|
---|
1373 | else
|
---|
1374 | cy = ldbox[n][4];
|
---|
1375 |
|
---|
1376 | } else {
|
---|
1377 |
|
---|
1378 | cy = ldbox[n][4];
|
---|
1379 | }
|
---|
1380 |
|
---|
1381 | tsplot4(librob, 64, cy, ldbox[n][6], ldbox[n][7],
|
---|
1382 | (lorchl ? "Hi Orch" : "Lo Orch"), 14);
|
---|
1383 |
|
---|
1384 | return;
|
---|
1385 |
|
---|
1386 | case 9: /* "Store" status */
|
---|
1387 |
|
---|
1388 | cy = exp_c(lstrsw ? LD_SELC : ldbox[n][4]);
|
---|
1389 | tsplot4(librob, 64, cy, 22, 10, "Store", 14);
|
---|
1390 |
|
---|
1391 | cy = exp_c(lscrsw ? LD_SELC : ldbox[n][4]);
|
---|
1392 | tsplot4(librob, 64, cy, 22, 17, "Score", 14);
|
---|
1393 |
|
---|
1394 | cy = exp_c(lorchsw ? LD_SELC : ldbox[n][4]);
|
---|
1395 | tsplot4(librob, 64, cy, 22, 24, "Hi Orch", 14);
|
---|
1396 |
|
---|
1397 |
|
---|
1398 | cy = exp_c(lwavsw ? LD_SELC : ldbox[n][4]);
|
---|
1399 | tsplot4(librob, 64, cy, 23, 10, "Waves", 14);
|
---|
1400 |
|
---|
1401 | cy = exp_c(lpatsw ? LD_SELC : ldbox[n][4]);
|
---|
1402 | tsplot4(librob, 64, cy, 23, 17, "Patch", 14);
|
---|
1403 |
|
---|
1404 | cy = exp_c(lorclsw ? LD_SELC : ldbox[n][4]);
|
---|
1405 | tsplot4(librob, 64, cy, 23, 24, "Lo Orch", 14);
|
---|
1406 |
|
---|
1407 |
|
---|
1408 | cy = exp_c(lasgsw ? LD_SELC : ldbox[n][4]);
|
---|
1409 | tsplot4(librob, 64, cy, 24, 10, "Assgn", 14);
|
---|
1410 |
|
---|
1411 | cy = exp_c(lseqsw ? LD_SELC : ldbox[n][4]);
|
---|
1412 | tsplot4(librob, 64, cy, 24, 17, "Seqnc", 14);
|
---|
1413 |
|
---|
1414 | cy = exp_c(ltunsw ? LD_SELC : ldbox[n][4]);
|
---|
1415 | tsplot4(librob, 64, cy, 24, 24, "Tunings", 14);
|
---|
1416 |
|
---|
1417 | return;
|
---|
1418 |
|
---|
1419 | case 10: /* typewriter / error messages */
|
---|
1420 |
|
---|
1421 | tsplot4(librob, 64, ldbox[n][4], 22, ldbox[n][7], lmln22, 14);
|
---|
1422 | tsplot4(librob, 64, ldbox[n][4], 23, ldbox[n][7], lmln23, 14);
|
---|
1423 | tsplot4(librob, 64, ldbox[n][4], 24, ldbox[n][7], lmln24, 14);
|
---|
1424 |
|
---|
1425 | return;
|
---|
1426 | }
|
---|
1427 | }
|
---|
1428 |
|
---|
1429 | /*
|
---|
1430 | =============================================================================
|
---|
1431 | lwins() -- display all librarian windows
|
---|
1432 | =============================================================================
|
---|
1433 | */
|
---|
1434 |
|
---|
1435 | void lwins(void)
|
---|
1436 | {
|
---|
1437 | register int16_t i;
|
---|
1438 |
|
---|
1439 | for (i = 0; i < 11; i++)
|
---|
1440 | ldswin(i);
|
---|
1441 | }
|
---|
1442 |
|
---|
1443 | /*
|
---|
1444 | =============================================================================
|
---|
1445 | ldpoint() -- plot a point for the lseg function
|
---|
1446 | =============================================================================
|
---|
1447 | */
|
---|
1448 |
|
---|
1449 | void ldpoint(int16_t x, int16_t y, int16_t pen)
|
---|
1450 | {
|
---|
1451 | if (v_regs[5] & 0x0180)
|
---|
1452 | vbank(0);
|
---|
1453 |
|
---|
1454 | vputp(ldoct, x, y, exp_c(pen));
|
---|
1455 | }
|
---|
1456 |
|
---|
1457 | /*
|
---|
1458 | =============================================================================
|
---|
1459 | ldbord() -- draw the border for the librarian display
|
---|
1460 | =============================================================================
|
---|
1461 | */
|
---|
1462 |
|
---|
1463 | void ldbord(void)
|
---|
1464 | {
|
---|
1465 | point = ldpoint;
|
---|
1466 |
|
---|
1467 | lseg( 0, 0, 511, 0, LBORD); /* outer border */
|
---|
1468 | lseg(511, 0, 511, 349, LBORD);
|
---|
1469 | lseg(511, 349, 0, 349, LBORD);
|
---|
1470 | lseg( 0, 349, 0, 0, LBORD);
|
---|
1471 |
|
---|
1472 | lseg( 0, 293, 511, 293, LBORD); /* windows - H lines */
|
---|
1473 | lseg(511, 308, 0, 308, LBORD);
|
---|
1474 |
|
---|
1475 | lseg( 79, 293, 79, 308, LBORD); /* windows - V lines */
|
---|
1476 | lseg(144, 293, 144, 308, LBORD);
|
---|
1477 | lseg(215, 293, 215, 308, LBORD);
|
---|
1478 | lseg( 71, 308, 71, 349, LBORD);
|
---|
1479 | lseg(256, 308, 256, 349, LBORD);
|
---|
1480 | }
|
---|
1481 |
|
---|
1482 | /*
|
---|
1483 | =============================================================================
|
---|
1484 | lwclr() -- clear the message window text strings
|
---|
1485 | =============================================================================
|
---|
1486 | */
|
---|
1487 |
|
---|
1488 | void lmwclr(void)
|
---|
1489 | {
|
---|
1490 | lmwtype = 0;
|
---|
1491 | submenu = FALSE;
|
---|
1492 |
|
---|
1493 | lmln22 = "";
|
---|
1494 | lmln23 = "";
|
---|
1495 | lmln24 = "";
|
---|
1496 | }
|
---|
1497 |
|
---|
1498 | /*
|
---|
1499 | =============================================================================
|
---|
1500 | lmwvtyp() -- load the typewriter into the message window text strings
|
---|
1501 | =============================================================================
|
---|
1502 | */
|
---|
1503 |
|
---|
1504 | void lmwvtyp(void)
|
---|
1505 | {
|
---|
1506 | lmwtype = 1;
|
---|
1507 | submenu = TRUE;
|
---|
1508 |
|
---|
1509 | lmln22 = vtlin1;
|
---|
1510 | lmln23 = vtlin2;
|
---|
1511 | lmln24 = vtlin3;
|
---|
1512 | }
|
---|
1513 |
|
---|
1514 | /*
|
---|
1515 | =============================================================================
|
---|
1516 | libdsp() -- put up the librarian display
|
---|
1517 | =============================================================================
|
---|
1518 | */
|
---|
1519 |
|
---|
1520 | void libdsp(void)
|
---|
1521 | {
|
---|
1522 | librob = &v_score[0]; /* setup display object pointer */
|
---|
1523 | obj0 = &v_curs0[0]; /* setup cursor object pointer */
|
---|
1524 | obj2 = &v_tcur[0]; /* setup typewriter cursor pointer */
|
---|
1525 | ldoct = &v_obtab[LIBROBJ]; /* setup object control table pointer */
|
---|
1526 |
|
---|
1527 | lselsw = FALSE;
|
---|
1528 | ldelsw = FALSE;
|
---|
1529 | lstrsw = FALSE;
|
---|
1530 |
|
---|
1531 | lasgsw = FALSE;
|
---|
1532 | lorchsw = FALSE;
|
---|
1533 | lorclsw = FALSE;
|
---|
1534 | lpatsw = FALSE;
|
---|
1535 | lscrsw = FALSE;
|
---|
1536 | lseqsw = FALSE;
|
---|
1537 | ltunsw = FALSE;
|
---|
1538 | lwavsw = FALSE;
|
---|
1539 |
|
---|
1540 | lderrsw = FALSE;
|
---|
1541 | ltagged = FALSE;
|
---|
1542 | lksel = -1;
|
---|
1543 |
|
---|
1544 | clrcat(); /* void the catalog */
|
---|
1545 | catin = FALSE;
|
---|
1546 |
|
---|
1547 | lmwclr(); /* clear the message window text strings */
|
---|
1548 |
|
---|
1549 | dswap(); /* initialize display */
|
---|
1550 |
|
---|
1551 | if (v_regs[5] & 0x0180)
|
---|
1552 | vbank(0);
|
---|
1553 |
|
---|
1554 | memsetw(librob, 0, 32767);
|
---|
1555 | memsetw(librob+32767L, 0, 12033);
|
---|
1556 |
|
---|
1557 | SetObj(LIBROBJ, 0, 0, librob, 512, 350, 0, 0, LIBRFL, -1);
|
---|
1558 | SetObj( 0, 0, 1, obj0, 16, 16, LCURX, LCURY, OBFL_00, -1);
|
---|
1559 | SetObj( TTCURS, 0, 1, obj2, 16, 16, 0, 0, TTCCFL, -1);
|
---|
1560 |
|
---|
1561 | arcurs(TTCURC); /* setup arrow cursor object */
|
---|
1562 | itcini(TTCURC); /* setup text cursor object */
|
---|
1563 | ttcini(TTCURC); /* setup typewriter cursor object */
|
---|
1564 |
|
---|
1565 | ldbord(); /* draw the border */
|
---|
1566 | lwins();
|
---|
1567 |
|
---|
1568 | vsndpal(lbrpal); /* setup the palette */
|
---|
1569 |
|
---|
1570 | SetPri(LIBROBJ, LIBRPRI);
|
---|
1571 | SetPri(0, GCPRI); /* display the graphic cursor */
|
---|
1572 |
|
---|
1573 | setgc(LCURX, LCURY);
|
---|
1574 |
|
---|
1575 | chtime = thcwval; /* turn it into a text cursor */
|
---|
1576 | cvtime = tvcwval;
|
---|
1577 | cmtype = CT_TEXT;
|
---|
1578 | itcpos(cyval / 14, cxval >> 3);
|
---|
1579 | }
|
---|
1580 |
|
---|