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