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