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