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