1 | /*
|
---|
2 | =============================================================================
|
---|
3 | ldselbx.c -- librarian box selection functions
|
---|
4 | Version 46 -- 1988-11-18 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #define DEBUGIT 0
|
---|
9 |
|
---|
10 | #include "stdio.h"
|
---|
11 | #include "stddefs.h"
|
---|
12 | #include "fields.h"
|
---|
13 | #include "graphdef.h"
|
---|
14 | #include "glcfns.h"
|
---|
15 | #include "glcdefs.h"
|
---|
16 | #include "graphdef.h"
|
---|
17 | #include "hwdefs.h"
|
---|
18 | #include "lcdline.h"
|
---|
19 | #include "panel.h"
|
---|
20 | #include "vsdd.h"
|
---|
21 | #include "vsddvars.h"
|
---|
22 |
|
---|
23 | #include "midas.h"
|
---|
24 | #include "instdsp.h"
|
---|
25 | #include "libdsp.h"
|
---|
26 | #include "score.h"
|
---|
27 | #include "scdsp.h"
|
---|
28 | #include "scfns.h"
|
---|
29 |
|
---|
30 | extern void ldswin(short n);
|
---|
31 | extern void advlcur(void);
|
---|
32 | extern void bsplcur(void);
|
---|
33 | extern void ttcpos(short row, short col);
|
---|
34 | extern short fcindex(void);
|
---|
35 | extern short storit(void);
|
---|
36 | extern int showsiz(void);
|
---|
37 | extern short get_asg(void);
|
---|
38 | extern short get_orc(short lorh, short kind);
|
---|
39 | extern short get_tun(void);
|
---|
40 | extern short get_wav(void);
|
---|
41 | extern short nokey(void);
|
---|
42 | extern short ldline(short cy);
|
---|
43 | extern short lin2slt(short line);
|
---|
44 | extern void dslslot(short slot, unsigned fg, short row);
|
---|
45 | extern void vtdisp(unsigned *obj, unsigned fg, unsigned bg, short row, short col, char *buf);
|
---|
46 | extern void ldpoint(short x, short y, short pen);
|
---|
47 | extern short rd_ec(FILE *fp, char *to, long len);
|
---|
48 | extern void fcreset(void);
|
---|
49 | extern short ftkind(short ns);
|
---|
50 | extern void ldwmsg(char *line1, char *line2, char *line3, unsigned fgcolor, unsigned bgcolor);
|
---|
51 | extern void ldbusy(char *msg);
|
---|
52 | extern short ckstor(void);
|
---|
53 | extern short get_pat(void);
|
---|
54 | extern short get_scr(void);
|
---|
55 |
|
---|
56 | extern unsigned exp_c(unsigned c);
|
---|
57 |
|
---|
58 | extern char *slotnam(unsigned slot, unsigned kind);
|
---|
59 |
|
---|
60 | /* |
---|
61 |
|
---|
62 | */
|
---|
63 |
|
---|
64 | #if DEBUGIT
|
---|
65 | extern short debugsw;
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | extern void (*point)(short x, short y, short pen);
|
---|
69 |
|
---|
70 | extern short asmode;
|
---|
71 | extern short catin;
|
---|
72 | extern short cxrate;
|
---|
73 | extern short cxval;
|
---|
74 | extern short cyrate;
|
---|
75 | extern short cyval;
|
---|
76 | extern int errno;
|
---|
77 | extern short gomode;
|
---|
78 | extern short hitcx;
|
---|
79 | extern short hitcy;
|
---|
80 | extern short ismode;
|
---|
81 | extern short lasgsw;
|
---|
82 | extern short ldelsw;
|
---|
83 | extern short lderrsw;
|
---|
84 | extern short ldkind;
|
---|
85 | extern short ldrow;
|
---|
86 | extern short ldslot;
|
---|
87 | extern short lksel;
|
---|
88 | extern short lmwtype;
|
---|
89 | extern short lorchl;
|
---|
90 | extern short lorchsw;
|
---|
91 | extern short lorclsw;
|
---|
92 | extern short ldpass;
|
---|
93 | extern short lpatsw;
|
---|
94 | extern short lrasw;
|
---|
95 | extern short lscrsw;
|
---|
96 | extern short lselsw;
|
---|
97 | extern short lseqsw;
|
---|
98 | extern short lstrsw;
|
---|
99 | extern short ltagged;
|
---|
100 | extern short ltunsw;
|
---|
101 | extern short lwavsw;
|
---|
102 | extern short ndisp;
|
---|
103 | extern short oldpk;
|
---|
104 | extern short oldsl;
|
---|
105 | extern short pkctrl;
|
---|
106 | extern short sliders;
|
---|
107 | extern short stcrow;
|
---|
108 | extern short stccol;
|
---|
109 | extern short tagslot;
|
---|
110 |
|
---|
111 | extern unsigned *librob;
|
---|
112 |
|
---|
113 | extern short ldmap[];
|
---|
114 | extern short scsizes[][2];
|
---|
115 |
|
---|
116 | extern short ldbox[][8];
|
---|
117 |
|
---|
118 | extern struct scndx sindex[];
|
---|
119 |
|
---|
120 | extern struct selbox *csbp;
|
---|
121 | extern struct selbox *curboxp;
|
---|
122 |
|
---|
123 | extern PFS (*swpt)[];
|
---|
124 | extern PFS (*oldsw)[];
|
---|
125 | extern PFS t_libr[];
|
---|
126 |
|
---|
127 | extern char bfs[];
|
---|
128 | extern char ldfile[];
|
---|
129 | extern char ldcmnt[];
|
---|
130 |
|
---|
131 | extern char loadedf[][8];
|
---|
132 | extern char loadedc[][37];
|
---|
133 |
|
---|
134 | /* forward references */
|
---|
135 |
|
---|
136 | short bx_null(void);
|
---|
137 | short ldfnbox(short n);
|
---|
138 |
|
---|
139 | /* |
---|
140 |
|
---|
141 | */
|
---|
142 |
|
---|
143 | short ft2lt[] = { /* file type to load type map */
|
---|
144 |
|
---|
145 | LT_ASG,
|
---|
146 | LT_ORL,
|
---|
147 | LT_ORH,
|
---|
148 | LT_SCR,
|
---|
149 | LT_TUN,
|
---|
150 | LT_WAV,
|
---|
151 | LT_ORL,
|
---|
152 | LT_PAT,
|
---|
153 | LT_SEQ
|
---|
154 | };
|
---|
155 |
|
---|
156 | struct selbox ldboxes[] = {
|
---|
157 |
|
---|
158 | { 1, 1, 510, 13, 0, ldfnbox}, /* 0 - index area label */
|
---|
159 | { 1, 14, 510, 293, 1, ldfnbox}, /* 1 - index area */
|
---|
160 | { 1, 294, 78, 307, 2, ldfnbox}, /* 2 - file name label */
|
---|
161 | { 80, 294, 143, 307, 3, ldfnbox}, /* 3 - file name */
|
---|
162 | {145, 294, 214, 307, 4, ldfnbox}, /* 4 - comment label */
|
---|
163 | {216, 294, 510, 307, 5, ldfnbox}, /* 5 - comment */
|
---|
164 | { 1, 308, 70, 321, 6, ldfnbox}, /* 6 - fetch */
|
---|
165 | { 1, 322, 70, 335, 7, ldfnbox}, /* 7 - replace / append */
|
---|
166 | { 1, 336, 70, 349, 8, ldfnbox}, /* 8 - lo orch / hi orch */
|
---|
167 | { 72, 308, 255, 349, 9, ldfnbox}, /* 9 - store */
|
---|
168 | {257, 308, 510, 349, 10, ldfnbox}, /* 10 - message window */
|
---|
169 |
|
---|
170 | { 0, 0, 0, 0, 0, FN_NULL} /* end of table */
|
---|
171 | };
|
---|
172 |
|
---|
173 | /* |
---|
174 |
|
---|
175 | */
|
---|
176 |
|
---|
177 | /*
|
---|
178 | =============================================================================
|
---|
179 | skperr() -- complain about an error while skipping a score
|
---|
180 | =============================================================================
|
---|
181 | */
|
---|
182 |
|
---|
183 | void skperr(short sn)
|
---|
184 | {
|
---|
185 | char scid[32];
|
---|
186 | char erms[64];
|
---|
187 |
|
---|
188 | clrlsel();
|
---|
189 |
|
---|
190 | sprintf(scid, " score %d", sn + 1);
|
---|
191 | sprintf(erms, " errno = %d", errno);
|
---|
192 |
|
---|
193 | ldermsg("Couldn't skip", scid, erms,
|
---|
194 | LD_EMCF, LD_EMCB);
|
---|
195 | }
|
---|
196 |
|
---|
197 | /* |
---|
198 |
|
---|
199 | */
|
---|
200 |
|
---|
201 | /*
|
---|
202 | =============================================================================
|
---|
203 | skp_ec() -- skip with error checking
|
---|
204 | =============================================================================
|
---|
205 | */
|
---|
206 |
|
---|
207 | short skp_ec(FILE *fp, long len)
|
---|
208 | {
|
---|
209 | register long count;
|
---|
210 | register int c;
|
---|
211 | char errbuf[64];
|
---|
212 |
|
---|
213 | for (count = 0; count < len; count++) {
|
---|
214 |
|
---|
215 | errno = 0;
|
---|
216 |
|
---|
217 | if (EOF EQ (c = getc(fp))) {
|
---|
218 |
|
---|
219 | sprintf(errbuf, "errno = %d", errno);
|
---|
220 |
|
---|
221 | ldermsg("Unexpected EOF",
|
---|
222 | errbuf, (char *)NULL, LD_EMCF, LD_EMCB);
|
---|
223 |
|
---|
224 | #if DEBUGIT
|
---|
225 | if (debugsw)
|
---|
226 | FILEpr(fp);
|
---|
227 | #endif
|
---|
228 |
|
---|
229 | fclose(fp);
|
---|
230 | postio(); /* restore LCD backlight */
|
---|
231 | return(FAILURE);
|
---|
232 | }
|
---|
233 | }
|
---|
234 |
|
---|
235 | return(SUCCESS);
|
---|
236 | }
|
---|
237 |
|
---|
238 | /* |
---|
239 |
|
---|
240 | */
|
---|
241 |
|
---|
242 | /*
|
---|
243 | =============================================================================
|
---|
244 | scskip() -- skip a score starting with its section list
|
---|
245 | =============================================================================
|
---|
246 | */
|
---|
247 |
|
---|
248 | short scskip(FILE *fp, short ns)
|
---|
249 | {
|
---|
250 | register short ehdr, go;
|
---|
251 | char etype;
|
---|
252 | char erms[64];
|
---|
253 |
|
---|
254 | go = TRUE;
|
---|
255 |
|
---|
256 | if (skp_ec(fp, (long)(N_SECTS * 12))) { /* skip section times */
|
---|
257 |
|
---|
258 | skperr(ns);
|
---|
259 | return(FAILURE);
|
---|
260 | }
|
---|
261 |
|
---|
262 | if (rd_ec(fp, &etype, 1L)) { /* read first score header event */
|
---|
263 |
|
---|
264 | skperr(ns);
|
---|
265 | return(FAILURE);
|
---|
266 | }
|
---|
267 |
|
---|
268 | if (etype NE EV_SCORE) { /* complain if it's not a score event */
|
---|
269 |
|
---|
270 | sprintf(erms, " score %d etype = %d", ns + 1, etype);
|
---|
271 |
|
---|
272 | ldermsg("Bad score --", " 1st event is wrong",
|
---|
273 | erms, LD_EMCF, LD_EMCB);
|
---|
274 |
|
---|
275 | return(FAILURE);
|
---|
276 | }
|
---|
277 |
|
---|
278 | if (skp_ec(fp, (long)(scsizes[etype][1] - 1))) { /* skip data */
|
---|
279 |
|
---|
280 | skperr(ns);
|
---|
281 | return(FAILURE);
|
---|
282 | }
|
---|
283 |
|
---|
284 | /* |
---|
285 |
|
---|
286 | */
|
---|
287 | do { /* skip remaining score events */
|
---|
288 |
|
---|
289 | if (rd_ec(fp, &etype, 1L)) { /* get event type */
|
---|
290 |
|
---|
291 | skperr(ns);
|
---|
292 | return(FAILURE);
|
---|
293 | }
|
---|
294 |
|
---|
295 | /* skip the event's data */
|
---|
296 |
|
---|
297 | if (skp_ec(fp, (long)(scsizes[etype][1] - 1))) {
|
---|
298 |
|
---|
299 | skperr(ns);
|
---|
300 | return(FAILURE);
|
---|
301 | }
|
---|
302 |
|
---|
303 | if (etype EQ EV_FINI) /* check for score end */
|
---|
304 | go = FALSE;
|
---|
305 |
|
---|
306 | } while (go);
|
---|
307 |
|
---|
308 | return(SUCCESS);
|
---|
309 | }
|
---|
310 |
|
---|
311 | /* |
---|
312 |
|
---|
313 | */
|
---|
314 |
|
---|
315 | /*
|
---|
316 | =============================================================================
|
---|
317 | ldermsg() -- display an error message if none is up already
|
---|
318 | =============================================================================
|
---|
319 | */
|
---|
320 |
|
---|
321 | void ldermsg(char *p1, char *p2, char *p3, unsigned p4, unsigned p5)
|
---|
322 | {
|
---|
323 | char msgbuf[64];
|
---|
324 |
|
---|
325 | if (NOT lderrsw) { /* put up new messages only */
|
---|
326 |
|
---|
327 | strcpy(msgbuf, "ERROR: ");
|
---|
328 | strcat(msgbuf, p1);
|
---|
329 |
|
---|
330 | ldwmsg(p1, p2, p3, p4, p5);
|
---|
331 | }
|
---|
332 |
|
---|
333 | lderrsw = TRUE; /* set error state */
|
---|
334 | }
|
---|
335 |
|
---|
336 | /*
|
---|
337 | =============================================================================
|
---|
338 | clrerms() -- clear an error message from the message window
|
---|
339 | =============================================================================
|
---|
340 | */
|
---|
341 |
|
---|
342 | void clrerms(void)
|
---|
343 | {
|
---|
344 | if (lderrsw) {
|
---|
345 |
|
---|
346 | lderrsw = FALSE;
|
---|
347 | lmwclr();
|
---|
348 | ldswin(10);
|
---|
349 | }
|
---|
350 | }
|
---|
351 |
|
---|
352 | /* |
---|
353 |
|
---|
354 | */
|
---|
355 |
|
---|
356 | /*
|
---|
357 | =============================================================================
|
---|
358 | clrlsel() -- clear library selection
|
---|
359 | =============================================================================
|
---|
360 | */
|
---|
361 |
|
---|
362 | void clrlsel(void)
|
---|
363 | {
|
---|
364 | if (lselsw) {
|
---|
365 |
|
---|
366 | if (lrasw) {
|
---|
367 |
|
---|
368 | lksel = -1;
|
---|
369 | ldpass = 0;
|
---|
370 | pkctrl = oldpk;
|
---|
371 | sliders = oldsl;
|
---|
372 | swpt = oldsw;
|
---|
373 | lcdlbls();
|
---|
374 | setleds();
|
---|
375 | fcindex();
|
---|
376 |
|
---|
377 | } else {
|
---|
378 |
|
---|
379 | dslslot(ldslot, exp_c(ldbox[1][4]), ldrow);
|
---|
380 | }
|
---|
381 | }
|
---|
382 |
|
---|
383 | fcreset();
|
---|
384 | }
|
---|
385 |
|
---|
386 | /*
|
---|
387 | =============================================================================
|
---|
388 | endltyp() -- end function for virtual typewriter
|
---|
389 | =============================================================================
|
---|
390 | */
|
---|
391 |
|
---|
392 | void endltyp(void)
|
---|
393 | {
|
---|
394 | lmwclr();
|
---|
395 | ldswin(10);
|
---|
396 | }
|
---|
397 |
|
---|
398 | /* |
---|
399 |
|
---|
400 | */
|
---|
401 |
|
---|
402 | /*
|
---|
403 | =============================================================================
|
---|
404 | savefc() -- save name and comment from loaded or stored file
|
---|
405 | =============================================================================
|
---|
406 | */
|
---|
407 |
|
---|
408 | void savefc(short kind)
|
---|
409 | {
|
---|
410 | short fi;
|
---|
411 |
|
---|
412 | fi = ft2lt[kind - 1];
|
---|
413 |
|
---|
414 | if (kind EQ FT_ORC)
|
---|
415 | fi = lorchl ? LT_ORH : LT_ORL;
|
---|
416 |
|
---|
417 | memcpy(loadedf[fi], ldfile, 8);
|
---|
418 | memcpy(loadedc[fi], ldcmnt, 37);
|
---|
419 | }
|
---|
420 |
|
---|
421 | /* |
---|
422 |
|
---|
423 | */
|
---|
424 |
|
---|
425 | /*
|
---|
426 | =============================================================================
|
---|
427 | lcancel() -- cancel librarian selections
|
---|
428 | =============================================================================
|
---|
429 | */
|
---|
430 |
|
---|
431 | short lcancel(short lct)
|
---|
432 | {
|
---|
433 | short rc;
|
---|
434 |
|
---|
435 | rc = FALSE;
|
---|
436 |
|
---|
437 | if ((lct NE 0) AND lselsw) {
|
---|
438 |
|
---|
439 | rc = TRUE;
|
---|
440 | clrlsel();
|
---|
441 | }
|
---|
442 |
|
---|
443 | if ((lct NE 1) AND (lstrsw OR (NOT ckstor()))) {
|
---|
444 |
|
---|
445 | rc = TRUE;
|
---|
446 | streset();
|
---|
447 | }
|
---|
448 |
|
---|
449 | if ((lct NE 2) AND ldelsw) {
|
---|
450 |
|
---|
451 | rc = TRUE;
|
---|
452 | ldelsw = FALSE;
|
---|
453 | dslslot(ldslot, exp_c(ldbox[1][4]), ldrow);
|
---|
454 | }
|
---|
455 |
|
---|
456 | return(rc);
|
---|
457 | }
|
---|
458 |
|
---|
459 | /* |
---|
460 |
|
---|
461 | */
|
---|
462 |
|
---|
463 | /*
|
---|
464 | =============================================================================
|
---|
465 | dpy_scr() -- display score contents entry
|
---|
466 | =============================================================================
|
---|
467 | */
|
---|
468 |
|
---|
469 | void dpy_scr(unsigned color, short ns)
|
---|
470 | {
|
---|
471 | char buf[40];
|
---|
472 | long scl;
|
---|
473 |
|
---|
474 | if (ndisp NE 0)
|
---|
475 | return;
|
---|
476 |
|
---|
477 | if (v_regs[5] & 0x0180)
|
---|
478 | vbank(0);
|
---|
479 |
|
---|
480 | if (ldmap[ns] EQ -1)
|
---|
481 | strcpy(buf, " ");
|
---|
482 | else
|
---|
483 | sprintf(buf, "%02d", 1 + ldmap[ns]);
|
---|
484 |
|
---|
485 | vcputsv(librob, 64, ldbox[1][4], ldbox[1][5], 1 + ns, 1, buf, 14);
|
---|
486 |
|
---|
487 | if (-1L EQ (scl = sindex[ns].sclen))
|
---|
488 | strcpy(buf, "{ empty score } 0");
|
---|
489 | else
|
---|
490 | sprintf(buf, "%-16.16s %5ld", sindex[ns].scfnm, scl);
|
---|
491 |
|
---|
492 | vcputsv(librob, 64, color, ldbox[1][5], 1 + ns, 4, buf, 14);
|
---|
493 | }
|
---|
494 |
|
---|
495 | /* |
---|
496 |
|
---|
497 | */
|
---|
498 |
|
---|
499 | /*
|
---|
500 | =============================================================================
|
---|
501 | lst_scr() -- list the score contents directory
|
---|
502 | =============================================================================
|
---|
503 | */
|
---|
504 |
|
---|
505 | void lst_scr(void)
|
---|
506 | {
|
---|
507 | register short i;
|
---|
508 | unsigned cx;
|
---|
509 |
|
---|
510 | if (ndisp NE 0)
|
---|
511 | return;
|
---|
512 |
|
---|
513 | point = ldpoint;
|
---|
514 |
|
---|
515 | cx = exp_c(ldbox[0][5]);
|
---|
516 |
|
---|
517 | if (v_regs[5] & 0x0180)
|
---|
518 | vbank(0);
|
---|
519 |
|
---|
520 | vbfill4(librob, 128, ldbox[0][0], ldbox[0][1],
|
---|
521 | ldbox[0][2], ldbox[0][3], cx);
|
---|
522 |
|
---|
523 | tsplot4(librob, 64, ldbox[0][4], ldbox[0][6], ldbox[0][7],
|
---|
524 | "No Score Name Length", 14);
|
---|
525 |
|
---|
526 | lseg( 8, 13, 23, 13, LUNDRLN);
|
---|
527 | lseg( 32, 13, 159, 13, LUNDRLN);
|
---|
528 | lseg(168, 13, 215, 13, LUNDRLN);
|
---|
529 |
|
---|
530 | cx = exp_c(ldbox[1][5]);
|
---|
531 |
|
---|
532 | vbfill4(librob, 128, ldbox[1][0], ldbox[1][1],
|
---|
533 | ldbox[1][2], ldbox[1][3], cx);
|
---|
534 |
|
---|
535 | for (i = 0; i < N_SCORES; i++)
|
---|
536 | dpy_scr(ldbox[1][4], i);
|
---|
537 | }
|
---|
538 |
|
---|
539 | /* |
---|
540 |
|
---|
541 | */
|
---|
542 |
|
---|
543 | /*
|
---|
544 | =============================================================================
|
---|
545 | ndx_scr() -- display the table of contents for a score
|
---|
546 | =============================================================================
|
---|
547 | */
|
---|
548 |
|
---|
549 | short ndx_scr(short slot)
|
---|
550 | {
|
---|
551 | register FILE *fp;
|
---|
552 | register short i;
|
---|
553 | register long rlen;
|
---|
554 | long rdlen;
|
---|
555 | char msgbuf1[64];
|
---|
556 | char msgbuf2[64];
|
---|
557 |
|
---|
558 | ldpass = 0;
|
---|
559 |
|
---|
560 | for (i = 0; i < N_SCORES; i++) {
|
---|
561 |
|
---|
562 | sindex[i].sclen = -1L;
|
---|
563 | memset(sindex[i].scfnm, ' ', 16);
|
---|
564 | }
|
---|
565 |
|
---|
566 | errno = 0;
|
---|
567 |
|
---|
568 | if ((FILE *)NULL EQ (fp = fopenb(slotnam(slot, FT_SCR), "r"))) {
|
---|
569 |
|
---|
570 | sprintf(msgbuf2, " errno = %d", errno);
|
---|
571 |
|
---|
572 | ldermsg("Couldn't open the file",
|
---|
573 | " for the scores", msgbuf2,
|
---|
574 | LD_EMCF, LD_EMCB);
|
---|
575 |
|
---|
576 | clrlsel();
|
---|
577 | return(FAILURE);
|
---|
578 | }
|
---|
579 |
|
---|
580 | errno = 0;
|
---|
581 |
|
---|
582 | if (fseek(fp, 60L, 1)) { /* seek past header */
|
---|
583 |
|
---|
584 | sprintf(msgbuf2, " errno = %d", errno);
|
---|
585 |
|
---|
586 | ldermsg("Seek failure",
|
---|
587 | (char *)NULL, msgbuf2,
|
---|
588 | LD_EMCF, LD_EMCB);
|
---|
589 |
|
---|
590 |
|
---|
591 | #if DEBUGIT
|
---|
592 | if (debugsw)
|
---|
593 | FILEpr(fp);
|
---|
594 | #endif
|
---|
595 |
|
---|
596 | fclose(fp);
|
---|
597 | postio(); /* restore LCD backlight */
|
---|
598 | clrlsel();
|
---|
599 | return(FAILURE);
|
---|
600 | }
|
---|
601 |
|
---|
602 | /* |
---|
603 |
|
---|
604 | */
|
---|
605 | #if DEBUGIT
|
---|
606 | if (debugsw)
|
---|
607 | FILEpr(fp);
|
---|
608 | #endif
|
---|
609 |
|
---|
610 | for (i = 0; i < N_SCORES; i++) {
|
---|
611 |
|
---|
612 | if (rd_ec(fp, &rdlen, 4L)) {
|
---|
613 |
|
---|
614 | sprintf(msgbuf1, " of score %d", i + 1);
|
---|
615 | sprintf(msgbuf2, " errno = %d", errno);
|
---|
616 |
|
---|
617 | ldermsg("Unable to read the length",
|
---|
618 | msgbuf1, msgbuf2,
|
---|
619 | LD_EMCF, LD_EMCB);
|
---|
620 |
|
---|
621 |
|
---|
622 | #if DEBUGIT
|
---|
623 | if (debugsw)
|
---|
624 | FILEpr(fp);
|
---|
625 | #endif
|
---|
626 |
|
---|
627 | clrlsel();
|
---|
628 | return(FAILURE);
|
---|
629 | }
|
---|
630 |
|
---|
631 | sindex[i].sclen = rdlen;
|
---|
632 |
|
---|
633 | if (-1L NE rdlen) {
|
---|
634 |
|
---|
635 | if (rd_ec(fp, sindex[i].scfnm, 16L)) {
|
---|
636 |
|
---|
637 | sprintf(msgbuf1, " of score %d", i + 1);
|
---|
638 | sprintf(msgbuf2, " errno = %d", errno);
|
---|
639 |
|
---|
640 | ldermsg("Unable to read the name",
|
---|
641 | msgbuf1, msgbuf2,
|
---|
642 | LD_EMCF, LD_EMCB);
|
---|
643 |
|
---|
644 |
|
---|
645 | #if DEBUGIT
|
---|
646 | if (debugsw)
|
---|
647 | FILEpr(fp);
|
---|
648 | #endif
|
---|
649 |
|
---|
650 | clrlsel();
|
---|
651 | return(FAILURE);
|
---|
652 | }
|
---|
653 |
|
---|
654 | errno = 0;
|
---|
655 |
|
---|
656 | if (scskip(fp, i)) {
|
---|
657 |
|
---|
658 | sprintf(msgbuf1, " score %d", i + 1);
|
---|
659 | sprintf(msgbuf2, " errno=%d rlen=%ld",
|
---|
660 | errno, rlen);
|
---|
661 |
|
---|
662 | ldermsg("Unable to skip past",
|
---|
663 | msgbuf1, msgbuf2,
|
---|
664 | LD_EMCF, LD_EMCB);
|
---|
665 |
|
---|
666 |
|
---|
667 | #if DEBUGIT
|
---|
668 | if (debugsw)
|
---|
669 | FILEpr(fp);
|
---|
670 | #endif
|
---|
671 |
|
---|
672 | fclose(fp);
|
---|
673 | postio(); /* restore LCD backlight */
|
---|
674 | clrlsel();
|
---|
675 | return(FAILURE);
|
---|
676 | }
|
---|
677 | }
|
---|
678 | }
|
---|
679 |
|
---|
680 | fclose(fp);
|
---|
681 | postio(); /* restore LCD backlight */
|
---|
682 | ldpass = 1;
|
---|
683 | lst_scr();
|
---|
684 |
|
---|
685 | /* |
---|
686 |
|
---|
687 | */
|
---|
688 | point = GLCplot;
|
---|
689 | GLCcurs(G_ON);
|
---|
690 |
|
---|
691 | if (ismode NE IS_NULL) { /* cancel inst. mode */
|
---|
692 |
|
---|
693 | ismode = IS_NULL;
|
---|
694 | pkctrl = oldpk;
|
---|
695 | sliders = oldsl;
|
---|
696 | swpt = oldsw;
|
---|
697 | lcdlbls();
|
---|
698 | }
|
---|
699 |
|
---|
700 | if (gomode NE GO_NULL) { /* cancel goto mode */
|
---|
701 |
|
---|
702 | gomode = GO_NULL;
|
---|
703 | pkctrl = oldpk;
|
---|
704 | lseg(GOTO_XL, GOTO_Y, GOTO_XR, GOTO_Y, 0);
|
---|
705 | }
|
---|
706 |
|
---|
707 | if (asmode) { /* cancel assign mode */
|
---|
708 |
|
---|
709 | asmode = 0;
|
---|
710 | pkctrl = oldpk;
|
---|
711 | swpt = oldsw;
|
---|
712 | lseg(ASGN_XL, ASGN_Y, ASGN_XR, ASGN_Y, 0);
|
---|
713 | }
|
---|
714 |
|
---|
715 | if ((pkctrl EQ PK_PFRM) OR (pkctrl EQ PK_NOTE))
|
---|
716 | oldpk = pkctrl;
|
---|
717 |
|
---|
718 | if (sliders NE LS_LIBR)
|
---|
719 | oldsl = sliders;
|
---|
720 |
|
---|
721 | oldsw = swpt;
|
---|
722 | swpt = t_libr;
|
---|
723 | pkctrl = PK_LIBR;
|
---|
724 | sliders = LS_LIBR;
|
---|
725 |
|
---|
726 | lcdlbls();
|
---|
727 | setleds();
|
---|
728 |
|
---|
729 | return(SUCCESS);
|
---|
730 | }
|
---|
731 |
|
---|
732 | /* |
---|
733 |
|
---|
734 | */
|
---|
735 |
|
---|
736 | /*
|
---|
737 | =============================================================================
|
---|
738 | getit() -- read selected file
|
---|
739 | =============================================================================
|
---|
740 | */
|
---|
741 |
|
---|
742 | short getit(void)
|
---|
743 | {
|
---|
744 | ldkind = ftkind(ldslot);
|
---|
745 |
|
---|
746 | if (ldkind EQ -1) {
|
---|
747 |
|
---|
748 | ldermsg("Unknown file type",
|
---|
749 | (char *)NULL, (char *)NULL,
|
---|
750 | LD_EMCF, LD_EMCB);
|
---|
751 |
|
---|
752 | clrlsel();
|
---|
753 | return(FAILURE);
|
---|
754 | }
|
---|
755 |
|
---|
756 | ldbusy(" Reading file");
|
---|
757 | /* |
---|
758 |
|
---|
759 | */
|
---|
760 | switch (ldkind) {
|
---|
761 |
|
---|
762 | case FT_ASG:
|
---|
763 |
|
---|
764 | if (get_asg())
|
---|
765 | return(FAILURE);
|
---|
766 |
|
---|
767 | break;
|
---|
768 |
|
---|
769 | case FT_ORH:
|
---|
770 | case FT_ORL:
|
---|
771 | case FT_ORC:
|
---|
772 |
|
---|
773 | if (get_orc(lorchl, ldkind))
|
---|
774 | return(FAILURE);
|
---|
775 |
|
---|
776 | break;
|
---|
777 |
|
---|
778 | case FT_PAT:
|
---|
779 |
|
---|
780 | if (get_pat())
|
---|
781 | return(FAILURE);
|
---|
782 |
|
---|
783 | break;
|
---|
784 |
|
---|
785 | case FT_SCR:
|
---|
786 |
|
---|
787 | if (get_scr())
|
---|
788 | return(FAILURE);
|
---|
789 |
|
---|
790 | break;
|
---|
791 |
|
---|
792 | case FT_SEQ:
|
---|
793 |
|
---|
794 | if (get_seq())
|
---|
795 | return(FAILURE);
|
---|
796 |
|
---|
797 | break;
|
---|
798 |
|
---|
799 | case FT_TUN:
|
---|
800 |
|
---|
801 | if (get_tun())
|
---|
802 | return(FAILURE);
|
---|
803 |
|
---|
804 | break;
|
---|
805 |
|
---|
806 | case FT_WAV:
|
---|
807 |
|
---|
808 | if (get_wav())
|
---|
809 | return(FAILURE);
|
---|
810 |
|
---|
811 | break;
|
---|
812 |
|
---|
813 | default:
|
---|
814 |
|
---|
815 | ldermsg("ldkind bad",
|
---|
816 | (char *)NULL, (char *)NULL,
|
---|
817 | LD_EMCF, LD_EMCB);
|
---|
818 |
|
---|
819 | clrlsel();
|
---|
820 | return(FAILURE);
|
---|
821 | }
|
---|
822 | /* |
---|
823 |
|
---|
824 | */
|
---|
825 |
|
---|
826 | memcpy(ldfile, filecat[ldslot].fcname, 8);
|
---|
827 | memcpy(ldcmnt, filecat[ldslot].fccmnt, 37);
|
---|
828 | savefc(ldkind);
|
---|
829 |
|
---|
830 | clrlsel();
|
---|
831 |
|
---|
832 | if (lrasw) {
|
---|
833 |
|
---|
834 | ldswin(0);
|
---|
835 | ldswin(8);
|
---|
836 | }
|
---|
837 |
|
---|
838 | ldswin(3);
|
---|
839 | ldswin(5);
|
---|
840 | showsiz();
|
---|
841 | return(SUCCESS);
|
---|
842 | }
|
---|
843 |
|
---|
844 | /* |
---|
845 |
|
---|
846 | */
|
---|
847 |
|
---|
848 | /*
|
---|
849 | =============================================================================
|
---|
850 | ldfnbox() -- librarian display box hit processor
|
---|
851 | =============================================================================
|
---|
852 | */
|
---|
853 |
|
---|
854 | short ldfnbox(short n)
|
---|
855 | {
|
---|
856 | register short col, i, slot, sn;
|
---|
857 |
|
---|
858 | col = hitcx >> 3;
|
---|
859 |
|
---|
860 | if (lderrsw)
|
---|
861 | clrerms();
|
---|
862 |
|
---|
863 | switch (n) {
|
---|
864 |
|
---|
865 | case 1: /* index area */
|
---|
866 |
|
---|
867 | if (lcancel(0))
|
---|
868 | return(SUCCESS);
|
---|
869 |
|
---|
870 | if (lselsw) { /* something already selected ? */
|
---|
871 |
|
---|
872 | if (lrasw) { /* content mode ? */
|
---|
873 |
|
---|
874 | if (ldkind EQ FT_SCR) { /* score */
|
---|
875 |
|
---|
876 | sn = ldline(hitcy) - 1;
|
---|
877 |
|
---|
878 | if (sindex[sn].sclen NE -1L) {
|
---|
879 |
|
---|
880 | if ((1 + sn) NE ldrow) {
|
---|
881 |
|
---|
882 | dpy_scr(ldbox[1][4], ldrow - 1);
|
---|
883 | ldrow = 1 + sn;
|
---|
884 | }
|
---|
885 |
|
---|
886 | dpy_scr(LD_SELC, sn);
|
---|
887 | lksel = sn;
|
---|
888 |
|
---|
889 | } else {
|
---|
890 |
|
---|
891 | lksel = -1;
|
---|
892 | }
|
---|
893 |
|
---|
894 | return(SUCCESS);
|
---|
895 | }
|
---|
896 | }
|
---|
897 |
|
---|
898 | if (ldrow NE ldline(hitcy)) {
|
---|
899 |
|
---|
900 | clrlsel();
|
---|
901 | return(SUCCESS);
|
---|
902 | }
|
---|
903 |
|
---|
904 | return(getit());
|
---|
905 | /* |
---|
906 |
|
---|
907 | */
|
---|
908 | } else { /* nothing selected yet */
|
---|
909 |
|
---|
910 | if (0 NE (ldrow = ldline(hitcy))) {
|
---|
911 |
|
---|
912 | if (col EQ 11) {
|
---|
913 |
|
---|
914 | if (catin AND ltagged) {
|
---|
915 |
|
---|
916 | slot = lin2slt(ldrow);
|
---|
917 |
|
---|
918 | if (slot EQ tagslot) {
|
---|
919 |
|
---|
920 | putcat();
|
---|
921 | ltagged = FALSE;
|
---|
922 | showcat();
|
---|
923 | }
|
---|
924 | }
|
---|
925 |
|
---|
926 | } else {
|
---|
927 |
|
---|
928 | if (-1 NE (ldslot = lin2slt(ldrow))) {
|
---|
929 |
|
---|
930 | lselsw = TRUE;
|
---|
931 | ldswin(8);
|
---|
932 | ldkind = ftkind(ldslot);
|
---|
933 |
|
---|
934 | for (i = 0; i < N_SCORES; i++)
|
---|
935 | ldmap[i] = i;
|
---|
936 |
|
---|
937 | if (lrasw AND (ldkind EQ FT_SCR))
|
---|
938 | return(ndx_scr(ldslot));
|
---|
939 |
|
---|
940 | dslslot(ldslot, exp_c(LD_SELC), ldrow);
|
---|
941 | return(SUCCESS);
|
---|
942 | }
|
---|
943 | }
|
---|
944 | }
|
---|
945 |
|
---|
946 | clrlsel();
|
---|
947 | return(FAILURE);
|
---|
948 | }
|
---|
949 | /* |
---|
950 |
|
---|
951 | */
|
---|
952 | case 3: /* file name field */
|
---|
953 |
|
---|
954 | if (lcancel(3))
|
---|
955 | return(SUCCESS);
|
---|
956 |
|
---|
957 | if (lmwtype NE 1) {
|
---|
958 |
|
---|
959 | lmwvtyp(); /* setup for the typewriter */
|
---|
960 | ldswin(10); /* display the typewriter */
|
---|
961 |
|
---|
962 | vtsetup(librob, vtdisp, 10, ldfile, 22, 33,
|
---|
963 | advlcur, bsplcur, nokey, nokey, endltyp,
|
---|
964 | ldbox[n][4], ldbox[n][5]);
|
---|
965 |
|
---|
966 | } else {
|
---|
967 |
|
---|
968 | vtyper();
|
---|
969 | }
|
---|
970 |
|
---|
971 | return(SUCCESS);
|
---|
972 |
|
---|
973 | case 5: /* comment field */
|
---|
974 |
|
---|
975 | if (lcancel(3))
|
---|
976 | return(SUCCESS);
|
---|
977 |
|
---|
978 | if (lmwtype NE 1) {
|
---|
979 |
|
---|
980 | lmwvtyp(); /* setup for the typewriter */
|
---|
981 | ldswin(10); /* display the typewriter */
|
---|
982 |
|
---|
983 | vtsetup(librob, vtdisp, 27, ldcmnt, 22, 33,
|
---|
984 | advlcur, bsplcur, nokey, nokey, endltyp,
|
---|
985 | ldbox[n][4], ldbox[n][5]);
|
---|
986 |
|
---|
987 | } else {
|
---|
988 |
|
---|
989 | vtyper();
|
---|
990 | }
|
---|
991 |
|
---|
992 | return(SUCCESS);
|
---|
993 |
|
---|
994 | /* |
---|
995 |
|
---|
996 | */
|
---|
997 |
|
---|
998 | case 6: /* "Index" */
|
---|
999 |
|
---|
1000 | if (lcancel(0))
|
---|
1001 | return(SUCCESS);
|
---|
1002 |
|
---|
1003 | clrlsel();
|
---|
1004 | return(fcindex());
|
---|
1005 |
|
---|
1006 | case 7: /* "Content" */
|
---|
1007 |
|
---|
1008 | if (lselsw AND lrasw)
|
---|
1009 | return(getit());
|
---|
1010 |
|
---|
1011 | lrasw = NOT lrasw;
|
---|
1012 | ldswin(7);
|
---|
1013 | return(SUCCESS);
|
---|
1014 |
|
---|
1015 | case 8: /* "Hi Orch" / "Lo Orch" */
|
---|
1016 |
|
---|
1017 | lorchl = NOT lorchl;
|
---|
1018 | ldswin(8);
|
---|
1019 | return(SUCCESS);
|
---|
1020 |
|
---|
1021 | /* |
---|
1022 |
|
---|
1023 | */
|
---|
1024 | case 9: /* "Store" */
|
---|
1025 |
|
---|
1026 | if (lcancel(1))
|
---|
1027 | return(SUCCESS);
|
---|
1028 |
|
---|
1029 | if (cyval < 321) {
|
---|
1030 |
|
---|
1031 | /* row 22: "Store", "Score", or "Hi Orch" */
|
---|
1032 |
|
---|
1033 | if (cxval < 120) {
|
---|
1034 |
|
---|
1035 | /* "Store" */
|
---|
1036 |
|
---|
1037 | if (lstrsw) {
|
---|
1038 |
|
---|
1039 | storit();
|
---|
1040 |
|
---|
1041 | } else {
|
---|
1042 |
|
---|
1043 | lstrsw = TRUE;
|
---|
1044 | ldswin(9);
|
---|
1045 | }
|
---|
1046 |
|
---|
1047 | return(SUCCESS);
|
---|
1048 |
|
---|
1049 | } else if ((cxval > 135) AND (cxval < 176)) {
|
---|
1050 |
|
---|
1051 | /* "Score" */
|
---|
1052 |
|
---|
1053 | lscrsw = NOT lscrsw;
|
---|
1054 | ldswin(9);
|
---|
1055 |
|
---|
1056 | if (lstrsw)
|
---|
1057 | storit();
|
---|
1058 |
|
---|
1059 | return(SUCCESS);
|
---|
1060 |
|
---|
1061 | } else if (cxval > 191) {
|
---|
1062 |
|
---|
1063 | /* "Hi Orch" */
|
---|
1064 |
|
---|
1065 | lorchsw = NOT lorchsw;
|
---|
1066 | ldswin(9);
|
---|
1067 |
|
---|
1068 | if (lstrsw)
|
---|
1069 | storit();
|
---|
1070 |
|
---|
1071 | return(SUCCESS);
|
---|
1072 | }
|
---|
1073 | /* |
---|
1074 |
|
---|
1075 | */
|
---|
1076 | } else if ((cyval > 321) AND (cyval < 335)) {
|
---|
1077 |
|
---|
1078 | /* row 23: "Waves", "Patch", or "Lo Orch" */
|
---|
1079 |
|
---|
1080 | if (cxval < 120) { /* "Waves" */
|
---|
1081 |
|
---|
1082 | lwavsw = NOT lwavsw;
|
---|
1083 | ldswin(9);
|
---|
1084 |
|
---|
1085 | if (lstrsw)
|
---|
1086 | storit();
|
---|
1087 |
|
---|
1088 | return(SUCCESS);
|
---|
1089 |
|
---|
1090 | } else if ((cxval > 135) AND (cxval < 176)) {
|
---|
1091 |
|
---|
1092 | /* "Patch" */
|
---|
1093 |
|
---|
1094 | lpatsw = NOT lpatsw;
|
---|
1095 | ldswin(9);
|
---|
1096 |
|
---|
1097 | if (lstrsw)
|
---|
1098 | storit();
|
---|
1099 |
|
---|
1100 | return(SUCCESS);
|
---|
1101 |
|
---|
1102 | } else if (cxval > 191) { /* "Lo Orch" */
|
---|
1103 |
|
---|
1104 | lorclsw = NOT lorclsw;
|
---|
1105 | ldswin(9);
|
---|
1106 |
|
---|
1107 | if (lstrsw)
|
---|
1108 | storit();
|
---|
1109 |
|
---|
1110 | return(SUCCESS);
|
---|
1111 | }
|
---|
1112 | /* |
---|
1113 |
|
---|
1114 | */
|
---|
1115 | } else if (cyval > 335) {
|
---|
1116 |
|
---|
1117 | /* row 24: "Assgn", "Seqnc", or "Tunings" */
|
---|
1118 |
|
---|
1119 | if (cxval < 120) { /* "Assgn" */
|
---|
1120 |
|
---|
1121 | lasgsw = NOT lasgsw;
|
---|
1122 | ldswin(9);
|
---|
1123 |
|
---|
1124 | if (lstrsw)
|
---|
1125 | storit();
|
---|
1126 |
|
---|
1127 | return(SUCCESS);
|
---|
1128 |
|
---|
1129 | } else if ((cxval > 135) AND (cxval < 176)) {
|
---|
1130 |
|
---|
1131 | /* "Seqnc" */
|
---|
1132 |
|
---|
1133 | lseqsw = NOT lseqsw;
|
---|
1134 | ldswin(9);
|
---|
1135 |
|
---|
1136 | if (lstrsw)
|
---|
1137 | storit();
|
---|
1138 |
|
---|
1139 | return(SUCCESS);
|
---|
1140 |
|
---|
1141 | } else if (cxval > 191) { /* "Tunings" */
|
---|
1142 |
|
---|
1143 | ltunsw = NOT ltunsw;
|
---|
1144 | ldswin(9);
|
---|
1145 |
|
---|
1146 | if (lstrsw)
|
---|
1147 | storit();
|
---|
1148 |
|
---|
1149 | return(SUCCESS);
|
---|
1150 | }
|
---|
1151 | }
|
---|
1152 |
|
---|
1153 | return(FAILURE);
|
---|
1154 |
|
---|
1155 | default:
|
---|
1156 |
|
---|
1157 | lcancel(3);
|
---|
1158 | return(FAILURE);
|
---|
1159 | }
|
---|
1160 | }
|
---|