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