source: buchla-68k/ram/libdsp.c@ 7258c6a

Last change on this file since 7258c6a was 7258c6a, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Use standard integer types.

  • Property mode set to 100644
File size: 35.4 KB
Line 
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)
36extern short debugsw;
37#endif
38
39#if DEBUGRE
40short debugre = 1;
41#endif
42
43#if DEBUGWE
44short debugwe = 1;
45#endif
46
47extern int16_t lcancel(int16_t lct);
48
49extern int32_t ptsizer(void);
50extern int32_t scsizer(void);
51extern int32_t sqsizer(void);
52
53/*
54
55*/
56
57/* things defined elsewhere */
58
59extern void (*point)(int16_t x, int16_t y, int16_t pen);
60
61extern void vbfill4(uint16_t *obj, int16_t obwidth, int16_t xmin, int16_t ymin, int16_t xmax, int16_t ymax, uint16_t color);
62extern void tsplot4(int16_t *obase, int16_t nw, int16_t fg, int16_t row, int16_t col, int8_t *str, int16_t pitch);
63extern void lseg(int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t t);
64extern void clrlsel(void);
65extern void _clsvol(void);
66extern void setgc(int16_t xv, int16_t yv);
67
68extern int16_t errno;
69extern int16_t _bpbin;
70
71extern int16_t chtime;
72extern int16_t cmtype;
73extern int16_t cvtime;
74extern int16_t cxval;
75extern int16_t cyval;
76extern int16_t sgcsw;
77extern int16_t stccol;
78extern int16_t stcrow;
79extern int16_t submenu;
80extern int16_t thcwval;
81extern int16_t tvcwval;
82
83extern uint16_t *obj0, *obj2;
84
85extern int8_t *ldbxlb0[];
86extern int8_t vtlin1[], vtlin2[], vtlin3[];
87
88extern int16_t ldbox[][8];
89extern struct instdef idefs[];
90
91extern struct bpb *_thebpb;
92
93/*
94
95*/
96
97extern uint16_t *librob; /* display object pointer */
98
99extern int16_t catin; /* catalog read in flag */
100extern int16_t lrasw; /* append (TRUE) / replace (FALSE) score */
101extern int16_t lorchl; /* hi (TRUE) / lo (FALSE) orchestra */
102extern int16_t ldrow; /* fetch select row */
103extern int16_t ldslot; /* fetch select slot */
104extern int16_t lselsw; /* fetch select switch */
105extern int16_t ldkind; /* fetch file type */
106extern int16_t lstrsw; /* store state switch */
107extern int16_t lasgsw; /* assignments store switch */
108extern int16_t lksel; /* librarian key slot selector */
109extern int16_t lorchsw; /* hi orchestra (21 - 40) store switch */
110extern int16_t lorclsw; /* lo orchestra (01 - 20) store switch */
111extern int16_t lpatsw; /* patch store switch */
112extern int16_t lscrsw; /* score store switch */
113extern int16_t lseqsw; /* sequence store switch */
114extern int16_t ltunsw; /* tunings store switch */
115extern int16_t lwavsw; /* waveshapes store switch */
116extern int16_t ldelsw; /* delete switch */
117extern int16_t lderrsw; /* error message displayed switch */
118extern int16_t ldidsiz; /* getcat() did showsiz() switch */
119extern int16_t lmwtype; /* librarian message window type */
120extern int16_t ltagged; /* load tag update in progress flag */
121extern int16_t ndisp; /* display number currently up */
122
123extern int32_t lcsum; /* library checksum */
124extern int32_t ndbytes; /* bytes needed for storage */
125
126extern int8_t *lmln22; /* message window line 22 */
127extern int8_t *lmln23; /* message window line 23 */
128extern int8_t *lmln24; /* message window line 24 */
129
130extern int8_t ldfile[9]; /* file name field */
131extern int8_t ldcmnt[38]; /* comment field */
132extern int8_t ldmsg1[65]; /* messsage build area 1 */
133extern int8_t ldmsg2[65]; /* messsage build area 2 */
134extern int8_t ldmsg3[65]; /* messsage build area 3 */
135extern int8_t errbuf[65]; /* error message build area */
136
137extern struct octent *ldoct; /* object control table pointer */
138
139extern struct mlibhdr ldhead; /* library header */
140
141/* forward references */
142
143void ldpoint(int16_t x, int16_t y, int16_t pen);
144
145/*
146
147*/
148
149int8_t *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
162int8_t ld_em1[] = "No files stored on disk";
163int8_t ld_em2[] = " by this operation";
164
165int16_t 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
194 -1 returned on error (returns 1..NFTYPES for a good type)
195 =============================================================================
196*/
197
198int16_t ftkind(int16_t ns)
199{
200 register int16_t 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
214 just = 0: right justify string, 1: left justify string
215 =============================================================================
216*/
217
218int8_t *fctstr(int16_t ns, int16_t just)
219{
220 static int8_t fcbad[11];
221 register int16_t 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/*
236 =============================================================================
237 ocslot() -- determine if a slot is occupied
238 =============================================================================
239*/
240
241int16_t ocslot(int16_t 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/*
251 =============================================================================
252 ldline() -- determine which catalog line the cursor is on, if any
253 =============================================================================
254*/
255
256int16_t ldline(int16_t 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 =============================================================================
273 lin2slt() -- determine which slot a line corresponds to, if any
274
275 -1 returned on error (0..FCMAX-1 returned for a good slot)
276 =============================================================================
277*/
278
279int16_t lin2slt(int16_t line)
280{
281 register int16_t 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
293/*
294 =============================================================================
295 exp_c() -- expand a 4 bit color to 16 bits
296 =============================================================================
297*/
298
299uint16_t exp_c(uint16_t c)
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*/
311
312/*
313 =============================================================================
314 ldwmsg() -- display a message in the message window
315 =============================================================================
316*/
317
318void ldwmsg(int8_t *line1, int8_t *line2, int8_t *line3, uint16_t fgcolor, uint16_t 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 ((int8_t *)NULL NE line1)
339 tsplot4(librob, 64, fgcolor, ldbox[10][6], ldbox[10][7],
340 line1, 14);
341
342 if ((int8_t *)NULL NE line2)
343 tsplot4(librob, 64, fgcolor, (ldbox[10][6] + 1), ldbox[10][7],
344 line2, 14);
345
346 if ((int8_t *)NULL NE line3)
347 tsplot4(librob, 64, fgcolor, (ldbox[10][6] + 2), ldbox[10][7],
348 line3, 14);
349}
350
351/*
352
353*/
354
355/*
356 =============================================================================
357 chksum() -- checksum an area of memory
358 =============================================================================
359*/
360
361int32_t chksum(int8_t *area, int32_t len)
362{
363 register int32_t cs, i;
364
365 cs = 0L;
366
367 for (i = 0; i < len; i++)
368 cs += 0x000000FFL & *area++;
369
370 return(cs);
371}
372
373/*
374 =============================================================================
375 makelh() -- make a library header
376 =============================================================================
377*/
378
379void makelh(int16_t 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, (int32_t)(LH_LEN - 8));
387}
388
389/*
390
391*/
392
393/*
394 =============================================================================
395 ldbusy() -- put up a "Busy" message
396 =============================================================================
397*/
398
399void ldbusy(int8_t *msg)
400{
401 if (ndisp NE 0)
402 return;
403
404 ldwmsg((int8_t *)NULL, " Busy - Please stand by", msg,
405 ldbox[10][4], ldbox[10][5]);
406}
407
408/*
409 =============================================================================
410 noslot() -- complain about not finding a slot we expected
411 =============================================================================
412*/
413
414void noslot(int16_t 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
422/*
423
424*/
425
426/*
427 =============================================================================
428 wr_ec() -- write with error checking
429 =============================================================================
430*/
431
432int16_t wr_ec(FILE *fp, int8_t *from, int32_t len)
433{
434 register int32_t count;
435 register int8_t 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, (int8_t *)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}
461
462/*
463
464*/
465
466/*
467 =============================================================================
468 rd_ec() -- read with error checking
469 =============================================================================
470*/
471
472int16_t rd_ec(FILE *fp, int8_t *to, int32_t len)
473{
474 register int32_t count;
475 register int16_t 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, (int8_t *)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
506/*
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
518int16_t srchcat(int8_t extn[])
519{
520 register int16_t 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)))
527 return(fcslot);
528 }
529
530 return(-1);
531}
532
533/*
534 =============================================================================
535 clrcat() -- clear the file catalog
536 =============================================================================
537*/
538
539void clrcat(void)
540{
541 register int16_t i;
542 int8_t 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}
553
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
566int16_t clreq(int32_t bytes)
567{
568 register int16_t rclusts;
569 register int32_t clmask;
570
571 clmask = _thebpb->clsizb - 1;
572
573 rclusts = (bytes / _thebpb->clsizb)
574 + ((bytes & clmask) ? 1 : 0);
575
576 return(rclusts);
577}
578
579/*
580
581*/
582
583/*
584 =============================================================================
585 spacerq() -- return space required for storing a file
586 =============================================================================
587*/
588
589int16_t spacerq(int16_t kind)
590{
591 register int16_t howmuch;
592 register int32_t k;
593
594 k = 0L;
595
596 switch (kind) {
597
598 case FT_ASG: /* Assignment file */
599
600 k = (sizeof (struct asgent) * (int32_t)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)) * (int32_t)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 = ((int32_t)NUMWAVS * OR_LEN2) + LH_LEN;
633 break;
634
635 default:
636
637 k = 0L;
638 break;
639 }
640/*
641
642*/
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
658int16_t 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);
680
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
697int16_t 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
731 if (lwavsw)
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
749int16_t showsiz(void)
750{
751 register int16_t 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 (int8_t *)NULL, (int8_t *)NULL,
761 LD_EMCF, LD_EMCB);
762
763 return(FAILURE);
764 }
765
766 drem = dspace(1);
767 dused = dcap - drem;
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 return(SUCCESS);
775}
776
777/*
778
779*/
780
781/*
782 =============================================================================
783 getcat() -- get the file catalog from disk
784 =============================================================================
785*/
786
787int16_t getcat(int16_t msgsw)
788{
789 register FILE *fp;
790 int16_t rc, fesize;
791
792 ldidsiz = FALSE; /* we didn't show the size (yet) */
793 _bpbin = FALSE; /* guarantee we read the directory */
794 catin = FALSE; /* catalog not valid */
795
796 errno = 0;
797 preio(); /* kill LCD backlight */
798 fp = fopenb(CATNAME, "r"); /* open the catalog file */
799
800 if (NULL EQ fp) {
801
802 clrcat();
803 catin = TRUE;
804
805 if (msgsw) { /* see if we show the message */
806
807 showsiz();
808 ldidsiz = TRUE; /* showed the size */
809 }
810
811 return(SUCCESS); /* no catalog is OK, too */
812 }
813
814 fesize = sizeof(struct fcat);
815 memset(filecat, 0, sizeof (struct fcat) * FCMAX);
816
817/*
818
819*/
820 errno = 0;
821 rc = fread(filecat, fesize, FCMAX, fp);
822
823 if (rc NE FCMAX) {
824
825 if (rc) {
826
827 sprintf(ldmsg1, " fread returned %d", rc);
828 sprintf(ldmsg2, " errno = %d, fesize=%d",
829 errno, fesize);
830
831 ldermsg("Unable to read catalog",
832 ldmsg1, ldmsg2, LD_EMCF, LD_EMCB);
833
834 catin = FALSE;
835
836 } else {
837
838 ldermsg("File catalog is NULL",
839 (int8_t *)NULL, (int8_t *)NULL,
840 LD_EMCF, LD_EMCB);
841
842 clrcat();
843 catin = TRUE;
844 }
845
846 fclose(fp);
847 postio(); /* restore LCD backlight */
848 return(FAILURE);
849 }
850
851 catin = TRUE;
852 fclose(fp);
853 postio(); /* restore LCD backlight */
854 return(SUCCESS);
855}
856
857/*
858
859*/
860
861/*
862 =============================================================================
863 putcat() -- write the updated catalog on disk
864 =============================================================================
865*/
866
867int16_t putcat(void)
868{
869 register FILE *fp;
870 register int16_t i, rc, fesize;
871
872 for (i = 0; i < FCMAX; i++) { /* clean up the catalog */
873
874 filecat[i].fceol[0] = A_CR;
875 filecat[i].fceol[1] = A_LF;
876 }
877
878 errno = 0;
879 preio(); /* kill LCD backlight */
880 fp = fopenb(CATNAME, "w"); /* open the catalog file */
881
882 if (NULL EQ fp) {
883
884 sprintf(ldmsg2, " errno = %d", errno);
885
886 ldermsg("Unable to open catalog",
887 (int8_t *)NULL, ldmsg2, LD_EMCF, LD_EMCB);
888
889 return(FAILURE);
890 }
891
892 fesize = sizeof (struct fcat);
893
894/*
895
896*/
897 errno = 0;
898 rc = fwrite(filecat, fesize, FCMAX, fp);
899
900 if (rc NE FCMAX) {
901
902 if (rc) {
903
904 sprintf(ldmsg1, " fwrite returned %d", rc);
905 sprintf(ldmsg2, " errno = %d, fesize=%d",
906 errno, fesize);
907
908 ldermsg("Can't write catalog",
909 ldmsg1, ldmsg2, LD_EMCF, LD_EMCB);
910
911 } else {
912
913 sprintf(ldmsg2, " errno = %d", errno);
914
915 ldermsg("Disk may be full",
916 (int8_t *)NULL, ldmsg2,
917 LD_EMCF, LD_EMCB);
918 }
919
920 fclose(fp);
921 postio(); /* restore LCD backlight */
922 return(FAILURE);
923 }
924
925 fclose(fp);
926 postio(); /* restore LCD backlight */
927 return(SUCCESS);
928}
929
930/*
931
932*/
933
934/*
935 =============================================================================
936 dslslot() -- display a file catalog entry
937 =============================================================================
938*/
939
940void dslslot(int16_t slot, uint16_t fg, int16_t row)
941{
942 register uint16_t color, chilon, chilorc;
943 int16_t c;
944 int8_t buf[40];
945
946 if (ndisp NE 0)
947 return;
948
949 color = exp_c(fg); /* foreground color */
950 chilon = exp_c(ldbox[1][4]);
951 chilorc = exp_c(HILORC);
952
953 /* file type */
954
955 vcputsv(librob, 64, color, ldbox[1][5], row, 1, fctstr(slot, 0), 14);
956
957 /* load letter */
958
959 c = filecat[slot].fcp0;
960 buf[0] = 0x007F & c;
961 buf[1] = '\0';
962 vcputsv(librob, 64, (c & 0x0080) ? chilorc : chilon,
963 ldbox[1][5], row, 11, buf, 14);
964
965 /* file name */
966
967 memcpy(buf, filecat[slot].fcname, 8);
968 buf[8] = '\0';
969 vcputsv(librob, 64, color, ldbox[1][5], row, 13, buf, 14);
970
971 /* comment */
972
973 memcpy(buf, filecat[slot].fccmnt, 37);
974 buf[37] = '\0';
975 vcputsv(librob, 64, chilon, ldbox[1][5], row, 22, buf, 14);
976
977 /* size */
978
979 memcpy(buf, filecat[slot].fcsize, 3);
980 buf[3] = '\0';
981 vcputsv(librob, 64, chilon, ldbox[1][5], row, 60, buf, 14);
982}
983
984/*
985
986*/
987
988/*
989 =============================================================================
990 showcat() -- display the file catalog entries
991 =============================================================================
992*/
993
994int16_t showcat(void)
995{
996 register int16_t i, fcslot, fcrow, fcount;
997 register uint16_t color;
998
999 if (ndisp NE 0)
1000 return(FAILURE);
1001
1002 ldswin(0); /* fix up the title */
1003
1004 color = exp_c(ldbox[1][5]); /* background color */
1005
1006 if (v_regs[5] & 0x0180)
1007 vbank(0);
1008
1009 vbfill4(librob, 128, ldbox[1][0], ldbox[1][1],
1010 ldbox[1][2], ldbox[1][3], color);
1011
1012 color = ldbox[1][4]; /* foreground color */
1013
1014 fcrow = 1;
1015 fcount = 0;
1016
1017 for (fcslot = 0; fcslot < FCMAX; fcslot++) {
1018
1019 if (ocslot(fcslot)) {
1020
1021 dslslot(fcslot, color, fcrow);
1022 fcrow++;
1023 fcount++;
1024 }
1025 }
1026
1027 return(fcount);
1028}
1029
1030/*
1031
1032*/
1033
1034/*
1035 =============================================================================
1036 fcindex() -- display the file catalog
1037 =============================================================================
1038*/
1039
1040int16_t fcindex(void)
1041{
1042 if (NOT lderrsw)
1043 ldbusy(" Reading catalog");
1044
1045 if (getcat(1)) /* get catalog, possibly display size */
1046 return(FAILURE);
1047
1048 if (NOT lderrsw)
1049 showcat(); /* display the catalog */
1050
1051 /* show size if getcat() didn't */
1052
1053 if ((NOT ldidsiz) AND (NOT lderrsw))
1054 showsiz();
1055
1056 return(SUCCESS);
1057}
1058
1059/*
1060
1061*/
1062
1063/*
1064 =============================================================================
1065 streset() -- reset the switches after a store or an error
1066 =============================================================================
1067*/
1068
1069void streset(void)
1070{
1071 lstrsw = FALSE;
1072
1073 lasgsw = FALSE;
1074 lorchsw = FALSE;
1075 lorclsw = FALSE;
1076 lpatsw = FALSE;
1077 lscrsw = FALSE;
1078 lseqsw = FALSE;
1079 ltunsw = FALSE;
1080 lwavsw = FALSE;
1081
1082 ldswin(9);
1083}
1084
1085/*
1086 =============================================================================
1087 fcreset() -- reset the switches after a fetch or an error
1088 =============================================================================
1089*/
1090
1091void fcreset(void)
1092{
1093 lselsw = FALSE;
1094
1095 ldswin(6);
1096}
1097
1098/*
1099
1100*/
1101
1102/*
1103 =============================================================================
1104 getslot() -- find a free file catalog slot
1105
1106 returns -1 on error, slot # 0..FCMAX-1 if a slot was found
1107 =============================================================================
1108*/
1109
1110int16_t getslot(void)
1111{
1112 register int16_t i;
1113
1114 for (i = 0; i < FCMAX; i++)
1115 if (NOT ocslot(i))
1116 return(i);
1117
1118 return(-1);
1119}
1120
1121/*
1122 =============================================================================
1123 slotnam() -- return the file name for a slot
1124 =============================================================================
1125*/
1126
1127int8_t *slotnam(uint16_t slot, uint16_t kind)
1128{
1129 static int8_t thename[13];
1130
1131 sprintf(thename, "M7SLOT%02.2u.%-3.3s",
1132 slot, ftypes[kind - 1][0]);
1133
1134 return(thename);
1135}
1136
1137/*
1138
1139*/
1140
1141/*
1142 =============================================================================
1143 wrtfile() -- write a file on the disk
1144 =============================================================================
1145*/
1146
1147int16_t wrtfile(int16_t kind)
1148{
1149 register int16_t slot, flspace, tkind;
1150 int8_t sizetmp[4];
1151
1152 slot = getslot();
1153
1154 if (-1 EQ slot) {
1155
1156 noslot(kind);
1157 streset();
1158 return(FAILURE);
1159 }
1160
1161/*
1162
1163*/
1164
1165 switch (kind) {
1166
1167 case FT_ASG:
1168
1169 if (wrt_asg(slot))
1170 return(FAILURE);
1171 else
1172 break;
1173
1174 case FT_ORL: /* lo orch write */
1175
1176 if (wrt_orc(slot, 0))
1177 return(FAILURE);
1178 else
1179 break;
1180
1181 case FT_ORH: /* hi orch write */
1182
1183 if (wrt_orc(slot, 1))
1184 return(FAILURE);
1185 else
1186 break;
1187
1188 case FT_PAT:
1189
1190 if (wrt_pat(slot))
1191 return(FAILURE);
1192 else
1193 break;
1194
1195 case FT_SCR:
1196
1197 if (wrt_scr(slot))
1198 return(FAILURE);
1199 else
1200 break;
1201
1202 case FT_SEQ:
1203
1204 if (wrt_seq(slot))
1205 return(FAILURE);
1206 else
1207 break;
1208
1209/*
1210
1211*/
1212 case FT_TUN:
1213
1214 if (wrt_tun(slot))
1215 return(FAILURE);
1216 else
1217 break;
1218
1219 case FT_WAV:
1220
1221 if (wrt_wav(slot))
1222 return(FAILURE);
1223 else
1224 break;
1225
1226 default:
1227
1228 sprintf(ldmsg1, " kind=%d", kind);
1229
1230 ldermsg("bad wrtfile argument:",
1231 ldmsg1, (int8_t *)NULL, LD_EMCF, LD_EMCB);
1232
1233 return(FAILURE);
1234 }
1235
1236/*
1237
1238*/
1239
1240 /* update the file catalog */
1241
1242 if ((kind EQ FT_ORL) OR (kind EQ FT_ORH))
1243 tkind = FT_ORC;
1244 else
1245 tkind = kind;
1246
1247 flspace = spacerq(kind);
1248
1249 sprintf(sizetmp, "%03.3d", flspace); /* size */
1250 memcpy(filecat[slot].fcsize, sizetmp, 3);
1251
1252 memcpy(filecat[slot].fcname, ldfile, 8); /* name */
1253 memcpy(filecat[slot].fcextn, ftypes[tkind - 1][0], 3); /* type */
1254 memcpy(filecat[slot].fccmnt, ldcmnt, 37); /* comment */
1255
1256 savefc(kind);
1257
1258 filecat[slot].fceol[0] = A_CR;
1259 filecat[slot].fceol[1] = A_LF;
1260
1261 return(SUCCESS);
1262}
1263
1264/*
1265
1266*/
1267
1268/*
1269 =============================================================================
1270 writem() -- write selected files
1271 =============================================================================
1272*/
1273
1274int16_t writem(void)
1275{
1276 if (lasgsw) /* Assignments */
1277 if (wrtfile(FT_ASG))
1278 return(FAILURE);
1279
1280 if (lorchsw) /* Hi Orch */
1281 if (wrtfile(FT_ORH))
1282 return(FAILURE);
1283
1284 if (lorclsw) /* Lo Orch */
1285 if (wrtfile(FT_ORL))
1286 return(FAILURE);
1287
1288 if (lpatsw) /* Patches */
1289 if (wrtfile(FT_PAT))
1290 return(FAILURE);
1291
1292 if (lscrsw) /* Score */
1293 if (wrtfile(FT_SCR))
1294 return(FAILURE);
1295
1296 if (lseqsw) /* Sequences */
1297 if (wrtfile(FT_SEQ))
1298 return(FAILURE);
1299
1300 if (ltunsw) /* Tunings */
1301 if (wrtfile(FT_TUN))
1302 return(FAILURE);
1303
1304 if (lwavsw) /* Waveshapes */
1305 if (wrtfile(FT_WAV))
1306 return(FAILURE);
1307
1308 return(SUCCESS);
1309}
1310
1311/*
1312
1313*/
1314
1315/*
1316 =============================================================================
1317 storit() -- store selected files on disk
1318 =============================================================================
1319*/
1320
1321int16_t storit(void)
1322{
1323 register int16_t weneed, i, slotnd, slothv;
1324 int16_t rc, drem;
1325
1326 /* make sure the file is named */
1327
1328 if (0 EQ memcmp(ldfile, " ", 8)) {
1329
1330 ldermsg("File must be named",
1331 ld_em1, ld_em2, LD_EMCF, LD_EMCB);
1332
1333 streset();
1334 return(FAILURE);
1335 }
1336
1337 /* make sure something was selected */
1338
1339 if (ckstor()) {
1340
1341 ldermsg("No file type selected",
1342 ld_em1, ld_em2, LD_EMCF, LD_EMCB);
1343
1344 streset();
1345 return(FAILURE);
1346 }
1347
1348 if (NOT lderrsw)
1349 ldbusy(" Storing files");
1350
1351 if (getcat(0)) { /* get the catalog */
1352
1353 streset();
1354 return(FAILURE);
1355 }
1356
1357 /* find out how much space we need to store everything */
1358
1359 drem = dspace(1);
1360 slotnd = 0;
1361 weneed = 0;
1362
1363/*
1364
1365*/
1366 if (lasgsw) {
1367
1368 weneed += spacerq(FT_ASG);
1369 ++slotnd;
1370 }
1371
1372 if (lorchsw) {
1373
1374 weneed += spacerq(FT_ORH);
1375 ++slotnd;
1376 }
1377
1378 if (lorclsw) {
1379
1380 weneed += spacerq(FT_ORL);
1381 ++slotnd;
1382 }
1383
1384 if (lpatsw) {
1385
1386 weneed += spacerq(FT_PAT);
1387 ++slotnd;
1388 }
1389
1390 if (lscrsw) {
1391
1392 weneed += spacerq(FT_SCR);
1393 ++slotnd;
1394 }
1395
1396 if (lseqsw) {
1397
1398 weneed += spacerq(FT_SEQ);
1399 ++slotnd;
1400 }
1401
1402 if (ltunsw) {
1403
1404 weneed += spacerq(FT_TUN);
1405 ++slotnd;
1406 }
1407
1408 if (lwavsw) {
1409
1410 weneed += spacerq(FT_WAV);
1411 ++slotnd;
1412 }
1413
1414 if (drem < weneed) {
1415
1416 nospace(0, weneed, drem);
1417 streset();
1418 return(FAILURE);
1419 }
1420
1421/*
1422
1423*/
1424
1425 /* see if we have enough catalog space */
1426
1427 slothv = 0;
1428
1429 for (i = 0; i < FCMAX; i++)
1430 if (NOT ocslot(i))
1431 ++slothv;
1432
1433 if (slothv < slotnd) {
1434
1435 nospace(1, slothv, slotnd);
1436 streset();
1437 return(FAILURE);
1438 }
1439
1440 /* make sure the name is unique */
1441
1442 if (rc = ckdups()) {
1443
1444 sprintf(ldmsg1, "Duplicate %s", ftypes[rc - 1][2]);
1445 ldermsg(ldmsg1, ld_em1, ld_em2, LD_EMCF, LD_EMCB);
1446
1447 streset();
1448 return(FAILURE);
1449 }
1450
1451/*
1452
1453*/
1454
1455 /* write the files */
1456
1457 rc = writem();
1458
1459 if (NOT rc)
1460 ldbusy(" Writing catalog");
1461
1462 if (putcat()) {
1463
1464 _clsvol();
1465 streset();
1466 showcat();
1467 return(FAILURE);
1468 }
1469
1470 _clsvol();
1471 streset();
1472 showcat();
1473
1474 if (rc)
1475 return(FAILURE);
1476
1477 showsiz();
1478 return(SUCCESS);
1479}
1480
1481/*
1482
1483*/
1484
1485/*
1486 =============================================================================
1487 advlcur() -- advance the librarian display text cursor
1488 =============================================================================
1489*/
1490
1491void advlcur(void)
1492{
1493 register int16_t newcol;
1494
1495 if (infield(stcrow, stccol, curfet))
1496 cfetp = infetp;
1497 else
1498 return;
1499
1500 newcol = stccol + 1;
1501
1502 if (newcol LE cfetp->frcol)
1503 itcpos(stcrow, newcol);
1504
1505 cxval = stccol * 8;
1506 cyval = stcrow * 14;
1507}
1508
1509/*
1510 =============================================================================
1511 bsplcur() -- backspace the librarian display text cursor
1512 =============================================================================
1513*/
1514
1515void bsplcur(void)
1516{
1517 register int16_t newcol;
1518
1519 if (infield(stcrow, stccol, curfet))
1520 cfetp = infetp;
1521 else
1522 return;
1523
1524 newcol = stccol - 1;
1525
1526 if (newcol GE cfetp->flcol)
1527 itcpos(stcrow, newcol);
1528
1529 cxval = stccol * 8;
1530 cyval = stcrow * 14;
1531}
1532
1533/*
1534
1535*/
1536
1537/*
1538 =============================================================================
1539 ldswin() -- display a window
1540 =============================================================================
1541*/
1542
1543void ldswin(int16_t n)
1544{
1545 register int16_t cx, cy;
1546
1547 if (ndisp NE 0)
1548 return;
1549
1550 if ((n EQ 10) AND (lmwtype EQ 1))
1551 cx = exp_c(TTBACK); /* use black for the typewriter */
1552 else
1553 cx = exp_c(ldbox[n][5]); /* expand the background color */
1554
1555 /* first, fill the box with the background color */
1556
1557 if (v_regs[5] & 0x0180)
1558 vbank(0);
1559
1560 vbfill4(librob, 128, ldbox[n][0], ldbox[n][1], ldbox[n][2],
1561 ldbox[n][3], cx);
1562
1563 /* put in the box label */
1564
1565 tsplot4(librob, 64, ldbox[n][4], ldbox[n][6], ldbox[n][7],
1566 ldbxlb0[n], 14);
1567
1568/*
1569
1570*/
1571 switch (n) { /* final text - overlays above stuff */
1572
1573 case 0: /* titles */
1574
1575 point = ldpoint;
1576
1577 lseg( 8, 13, 79, 13, LUNDRLN);
1578 lseg( 88, 13, 95, 13, LUNDRLN);
1579 lseg(104, 13, 167, 13, LUNDRLN);
1580 lseg(176, 13, 471, 13, LUNDRLN);
1581 lseg(480, 13, 504, 13, LUNDRLN);
1582
1583 return;
1584
1585 case 1: /* index area */
1586
1587 return;
1588
1589 case 3: /* current file name */
1590
1591 tsplot4(librob, 64, ldbox[n][4], ldbox[n][6], ldbox[n][7],
1592 ldfile, 14);
1593 return;
1594
1595 case 5: /* current comment field */
1596
1597 tsplot4(librob, 64, ldbox[n][4], ldbox[n][6], ldbox[n][7],
1598 ldcmnt, 14);
1599 return;
1600
1601/*
1602
1603*/
1604
1605 case 7: /* "Replace" / "Append" */
1606
1607 if (lrasw)
1608 cy = exp_c(LD_SELC);
1609 else
1610 cy = ldbox[n][4];
1611
1612 tsplot4(librob, 64, cy, ldbox[n][6], ldbox[n][7],
1613 "Content", 14);
1614
1615 return;
1616
1617 case 8: /* "Hi Orch" / "Lo Orch" */
1618
1619 if (lselsw) {
1620
1621 ldkind = ftkind(ldslot);
1622
1623 if ((ldkind EQ FT_ORC) OR
1624 (ldkind EQ FT_ORL) OR
1625 (ldkind EQ FT_ORH))
1626 cy = exp_c(LD_SELC);
1627 else
1628 cy = ldbox[n][4];
1629
1630 } else {
1631
1632 cy = ldbox[n][4];
1633 }
1634
1635 tsplot4(librob, 64, cy, ldbox[n][6], ldbox[n][7],
1636 (lorchl ? "Hi Orch" : "Lo Orch"), 14);
1637
1638 return;
1639/*
1640
1641*/
1642 case 9: /* "Store" status */
1643
1644 cy = exp_c(lstrsw ? LD_SELC : ldbox[n][4]);
1645 tsplot4(librob, 64, cy, 22, 10, "Store", 14);
1646
1647 cy = exp_c(lscrsw ? LD_SELC : ldbox[n][4]);
1648 tsplot4(librob, 64, cy, 22, 17, "Score", 14);
1649
1650 cy = exp_c(lorchsw ? LD_SELC : ldbox[n][4]);
1651 tsplot4(librob, 64, cy, 22, 24, "Hi Orch", 14);
1652
1653
1654 cy = exp_c(lwavsw ? LD_SELC : ldbox[n][4]);
1655 tsplot4(librob, 64, cy, 23, 10, "Waves", 14);
1656
1657 cy = exp_c(lpatsw ? LD_SELC : ldbox[n][4]);
1658 tsplot4(librob, 64, cy, 23, 17, "Patch", 14);
1659
1660 cy = exp_c(lorclsw ? LD_SELC : ldbox[n][4]);
1661 tsplot4(librob, 64, cy, 23, 24, "Lo Orch", 14);
1662
1663
1664 cy = exp_c(lasgsw ? LD_SELC : ldbox[n][4]);
1665 tsplot4(librob, 64, cy, 24, 10, "Assgn", 14);
1666
1667 cy = exp_c(lseqsw ? LD_SELC : ldbox[n][4]);
1668 tsplot4(librob, 64, cy, 24, 17, "Seqnc", 14);
1669
1670 cy = exp_c(ltunsw ? LD_SELC : ldbox[n][4]);
1671 tsplot4(librob, 64, cy, 24, 24, "Tunings", 14);
1672
1673 return;
1674
1675 case 10: /* typewriter / error messages */
1676
1677 tsplot4(librob, 64, ldbox[n][4], 22, ldbox[n][7], lmln22, 14);
1678 tsplot4(librob, 64, ldbox[n][4], 23, ldbox[n][7], lmln23, 14);
1679 tsplot4(librob, 64, ldbox[n][4], 24, ldbox[n][7], lmln24, 14);
1680
1681 return;
1682 }
1683}
1684
1685/*
1686
1687*/
1688
1689/*
1690 =============================================================================
1691 lwins() -- display all librarian windows
1692 =============================================================================
1693*/
1694
1695void lwins(void)
1696{
1697 register int16_t i;
1698
1699 for (i = 0; i < 11; i++)
1700 ldswin(i);
1701}
1702
1703/*
1704 =============================================================================
1705 ldpoint() -- plot a point for the lseg function
1706 =============================================================================
1707*/
1708
1709void ldpoint(int16_t x, int16_t y, int16_t pen)
1710{
1711 if (v_regs[5] & 0x0180)
1712 vbank(0);
1713
1714 vputp(ldoct, x, y, exp_c(pen));
1715}
1716
1717/*
1718
1719*/
1720
1721/*
1722 =============================================================================
1723 ldbord() -- draw the border for the librarian display
1724 =============================================================================
1725*/
1726
1727void ldbord(void)
1728{
1729 point = ldpoint;
1730
1731 lseg( 0, 0, 511, 0, LBORD); /* outer border */
1732 lseg(511, 0, 511, 349, LBORD);
1733 lseg(511, 349, 0, 349, LBORD);
1734 lseg( 0, 349, 0, 0, LBORD);
1735
1736 lseg( 0, 293, 511, 293, LBORD); /* windows - H lines */
1737 lseg(511, 308, 0, 308, LBORD);
1738
1739 lseg( 79, 293, 79, 308, LBORD); /* windows - V lines */
1740 lseg(144, 293, 144, 308, LBORD);
1741 lseg(215, 293, 215, 308, LBORD);
1742 lseg( 71, 308, 71, 349, LBORD);
1743 lseg(256, 308, 256, 349, LBORD);
1744}
1745
1746/*
1747
1748*/
1749
1750/*
1751 =============================================================================
1752 lwclr() -- clear the message window text strings
1753 =============================================================================
1754*/
1755
1756void lmwclr(void)
1757{
1758 lmwtype = 0;
1759 submenu = FALSE;
1760
1761 lmln22 = "";
1762 lmln23 = "";
1763 lmln24 = "";
1764}
1765
1766/*
1767 =============================================================================
1768 lmwvtyp() -- load the typewriter into the message window text strings
1769 =============================================================================
1770*/
1771
1772void lmwvtyp(void)
1773{
1774 lmwtype = 1;
1775 submenu = TRUE;
1776
1777 lmln22 = vtlin1;
1778 lmln23 = vtlin2;
1779 lmln24 = vtlin3;
1780}
1781
1782/*
1783
1784*/
1785
1786/*
1787 =============================================================================
1788 libdsp() -- put up the librarian display
1789 =============================================================================
1790*/
1791
1792void libdsp(void)
1793{
1794 librob = &v_score[0]; /* setup display object pointer */
1795 obj0 = &v_curs0[0]; /* setup cursor object pointer */
1796 obj2 = &v_tcur[0]; /* setup typewriter cursor pointer */
1797 ldoct = &v_obtab[LIBROBJ]; /* setup object control table pointer */
1798
1799 lselsw = FALSE;
1800 ldelsw = FALSE;
1801 lstrsw = FALSE;
1802
1803 lasgsw = FALSE;
1804 lorchsw = FALSE;
1805 lorclsw = FALSE;
1806 lpatsw = FALSE;
1807 lscrsw = FALSE;
1808 lseqsw = FALSE;
1809 ltunsw = FALSE;
1810 lwavsw = FALSE;
1811
1812 lderrsw = FALSE;
1813 ltagged = FALSE;
1814 lksel = -1;
1815/*
1816
1817*/
1818 clrcat(); /* void the catalog */
1819 catin = FALSE;
1820
1821 lmwclr(); /* clear the message window text strings */
1822
1823 dswap(); /* initialize display */
1824
1825 if (v_regs[5] & 0x0180)
1826 vbank(0);
1827
1828 memsetw(librob, 0, 32767);
1829 memsetw(librob+32767L, 0, 12033);
1830
1831 SetObj(LIBROBJ, 0, 0, librob, 512, 350, 0, 0, LIBRFL, -1);
1832 SetObj( 0, 0, 1, obj0, 16, 16, LCURX, LCURY, OBFL_00, -1);
1833 SetObj( TTCURS, 0, 1, obj2, 16, 16, 0, 0, TTCCFL, -1);
1834
1835 arcurs(TTCURC); /* setup arrow cursor object */
1836 itcini(TTCURC); /* setup text cursor object */
1837 ttcini(TTCURC); /* setup typewriter cursor object */
1838
1839 ldbord(); /* draw the border */
1840 lwins();
1841
1842 vsndpal(lbrpal); /* setup the palette */
1843
1844 SetPri(LIBROBJ, LIBRPRI);
1845 SetPri(0, GCPRI); /* display the graphic cursor */
1846
1847 setgc(LCURX, LCURY);
1848
1849 chtime = thcwval; /* turn it into a text cursor */
1850 cvtime = tvcwval;
1851 cmtype = CT_TEXT;
1852 itcpos(cyval / 14, cxval >> 3);
1853}
Note: See TracBrowser for help on using the repository browser.