source: buchla-68k/orig/RAM/PTSELBX.C@ ee49131

Last change on this file since ee49131 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 27.8 KB
Line 
1/*
2 =============================================================================
3 ptselbx.c -- MIDAS-VII Patch editor box selection functions
4 Version 45 -- 1988-12-08 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#define DEBUGIT 0
9#define SNAPDUMP 0
10
11#include "stddefs.h"
12#include "fields.h"
13#include "vsdd.h"
14#include "graphdef.h"
15#include "patch.h"
16#include "macros.h"
17#include "smdefs.h"
18#include "curpak.h"
19
20#include "midas.h"
21#include "ptdisp.h"
22
23#if SNAPDUMP
24short snapit = 0;
25#endif
26
27#if (SNAPDUMP|DEBUGIT)
28extern short debugsw;
29
30short debug01 = 1;
31#endif
32
33#define HT_0 0x01 /* definer, stimulus */
34#define HT_1 0x02 /* source */
35#define HT_2 0x04 /* destination */
36#define HT_3 0x08 /* oscillator */
37#define HT_4 0x10 /* level, index, freq, location, filter */
38#define HT_5 0x20 /* filq, dynamc, vout, depth, rate, inten, aux */
39#define HT_OFF 0x00 /* no submenu highlighted */
40
41/*
42
43*/
44
45extern short enterit(), nokey(), cnvp2c(), dec2fr();
46
47extern unsigned short exp_c();
48
49extern short CurLine;
50
51extern short cents;
52extern short cmtype;
53extern short cxval;
54extern short cyval;
55extern short hitcx;
56extern short hitcy;
57extern short stccol;
58extern short stcrow;
59extern short submenu;
60extern short vtccol;
61extern short vtcrow;
62
63extern short ndvals[];
64
65extern unsigned short *obj11;
66
67extern struct selbox *csbp;
68extern struct selbox *curboxp;
69
70extern char *smdata[];
71extern char *ssdata[];
72extern char *stdata[];
73extern char *trdata[];
74
75short ptfnbox();
76
77/*
78
79*/
80
81short ptegood; /* pte buffer -- entire entry valid flag */
82
83short ptedfok; /* pte buffer -- def valid flag */
84short ptestok; /* pte buffer -- stm valid flag */
85short ptedsok; /* pte buffer -- destination valid flag */
86short ptedtok; /* pte buffer -- datum valid flag */
87
88short ptedef; /* pte buffer -- definer number */
89short ptestm; /* pte buffer -- stimulus number */
90short ptespec; /* pte buffer -- address type */
91short ptesuba; /* pte buffer -- sub-address */
92short ptedat1; /* pte buffer -- data word 1 */
93short ptedat2; /* pte buffer -- data word 2 */
94
95short ptedftp; /* definer / stimulus entry flag */
96
97short ptedfst; /* current definer/stimulus data entry format */
98short ptedest; /* current destination data entry format */
99short ptedata; /* current datum data entry format */
100
101short ptemenu; /* current submenu highlighting */
102
103short pteset; /* pte buffer setup flag */
104short ptbflag; /* pdbuf setup flag */
105
106short ptecpos; /* current patch entry index */
107short ptepred; /* predecessor entry index */
108short ptesucc; /* successor entry index */
109
110struct patch ptebuf; /* pte buffer -- patch table format */
111
112char ptdebuf[50]; /* patch edit buffer */
113
114/*
115
116*/
117
118char *rawdfst[] = { /* def/stm field initial contents */
119
120 "Key 001 1 01",
121 "Rel 001 1 01",
122 "Trig 01 ",
123 "Pulse 1 "
124};
125
126char *rawdest[] = { /* destination field initial contents */
127
128 "??????? 00 ??", /* ?????? 00 */
129 "K 001 1 01 ", /* PA_KEY 01 */
130 "Trigger 01 ", /* PA_TRG 02 */
131 "Pulse 1 ", /* PA_PLS 03 */
132 "LED A ", /* PA_LED 04 */
133 "Seq 01 Lin ", /* PA_SLIN 05 */
134 "Seq 01 Ctl ", /* PA_SCTL 06 */
135 "Tune Table ", /* PA_TUNE 07 */
136 "Reg 01 Set ", /* PA_RSET 08 */
137 "Reg 01 Add ", /* PA_RADD 09 */
138 "Instrument V1", /* PA_INST 10 */
139 "Osc 1 Int V1", /* PA_OSC 11 */
140 "WaveshapeA V1", /* PA_WAVA 12 */
141 "WaveshapeB V1", /* PA_WAVB 13 */
142 "Configure V1", /* PA_CNFG 14 */
143 "Level Srce V1", /* PA_LEVL 15 */
144 "Ind 1 Srce V1", /* PA_INDX 16 */
145 "Frq 1 Srce V1", /* PA_FREQ 17 */
146 "Filtr Srce V1", /* PA_FILT 18 */
147 "Fil Q Srce V1", /* PA_FILQ 19 */
148 "Loctn Srce V1", /* PA_LOCN 20 */
149 "Dynmc Srce V1", /* PA_DYNM 21 */
150 "Aux Srce ", /* PA_AUX 22 */
151 "Rate Srce ", /* PA_RATE 23 */
152 "Inten Srce ", /* PA_INTN 24 */
153 "Depth Srce ", /* PA_DPTH 25 */
154 "Vlt 1 Srce " /* PA_VOUT 26 */
155};
156
157/*
158
159*/
160
161char *rawmode[] = { "Frq ", "Pch ", "Int ", "Rat " }; /* oscillator modes */
162char *rawmdat[] = { "00.1 ", "0C 00", "+0000", "1/1 " }; /* oscillator data */
163
164short omtabl[] = { PSO_FRQ, PSO_PCH, PSO_INT, PSO_RAT }; /* oscillator modes */
165short omdtab[] = { 2, 320, 0, 0 }; /* oscillator data */
166short omftab[] = { 6, 7, 4, 5 }; /* mode data format */
167
168char *rawfpud[] = { "PchWh", "+0.00", "00001", "\2400.00", "Start" };
169
170short fpudtab[] = { SM_HTPW, 0, 1, 0, 1 };
171short fpuetab[] = { 11, 1, 2, 3, 9 };
172
173short dfsttab[] = { 0x0000, 0x8000, 0x1100, 0x1180 };
174
175short defcols[] = { 2, 6, 7, 8}; /* def data entry columns */
176short stmcols[] = { 15, 19, 20, 21}; /* stm data entry columns */
177
178short dstcols[] = { /* destination data entry columns */
179
180/* -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 */
181 28, 30, 36, 34, 32, 32, 42, 39, 34, 32, 32, 34
182};
183
184short dfsttp[] = { 1, 1, 2, 3 }; /* def/stm formats */
185
186short datasrc[] = {
187
188 SM_HTPW, SM_VTMW, SM_LPBR, SM_PED1, SM_CTL1,
189 SM_PTCH, SM_FREQ, SM_KVEL, SM_KPRS, SM_RAND
190};
191
192/*
193
194*/
195
196short destype[] = { /* destination type table */
197
198 PA_KEY, -1, PA_TRG, PA_PLS, PA_LED,
199 PA_SLIN, PA_SCTL, PA_TUNE, PA_RSET, PA_RADD,
200 PA_INST, PA_OSC, PA_WAVA, PA_WAVB, PA_CNFG,
201 PA_INDX, PA_FREQ, -1, -1, -1,
202 PA_LEVL, PA_LOCN, PA_FILT, PA_FILQ, PA_DYNM,
203 PA_VOUT, PA_DPTH, PA_RATE, PA_INTN, PA_AUX,
204 -1, -1, -1, -1, -1,
205 -1, -1, -1, -1, -1,
206 -1, -1, -1, -1, -1
207};
208
209char destfmt[] = { /* destination data entry format table */
210
211 0, -1, 1, 2, 3, /* 1 .. 5 */
212 4, 4, 5, 4, 4, /* 6 .. 10 */
213 6, 9, 6, 6, 6, /* 11 .. 15 */
214 9, 9, -1, -1, -1, /* 16 .. 20 */
215 10, 10, 10, 10, 10, /* 21 .. 25 */
216 8, 7, 7, 7, 7 /* 26 .. 30 */
217};
218
219char datafmt[] = { /* datum data entry format table */
220
221 8, -1, 9, 8, 14,
222 13, 9, 18, 12, 12,
223 15, 4, 16, 16, 17,
224 11, 11, -1, -1, -1,
225 11, 11, 11, 11, 11,
226 11, 11, 11, 11, 11
227};
228
229/*
230
231*/
232
233char desdatf[] = { /* data entry default flags */
234
235 2, 0, 2, 2, 1,
236 1, 2, 1, 3, 3,
237 1, 0, 1, 1, 1,
238 2, 2, 0, 0, 0,
239 2, 2, 2, 2, 2,
240 2, 2, 2, 2, 2
241};
242
243short desdat1[] = { /* data word 1 defaults */
244
245 0, 0, 0, 0, 0,
246 0, 0, 0, 0, 0,
247 0, 0, 0, 0, 0,
248 0, 0, 0, 0, 0,
249 0, 0, 0, 0, 0,
250 0, 0, 0, 0, 0
251};
252
253short desdat2[] = { /* data word 2 defaults */
254
255 0, 0, 1, 0, 0,
256 0, 1, 0, 0, 1,
257 0, 0, 0, 0, 0,
258 SM_HTPW, SM_HTPW, 0, 0, 0,
259 SM_HTPW, SM_HTPW, SM_HTPW, SM_HTPW, SM_HTPW,
260 SM_HTPW, SM_HTPW, SM_HTPW, SM_HTPW, SM_HTPW
261};
262
263/*
264
265*/
266
267char *rawdata[] = {
268
269 "Trans", " ", "Start", "Trans", "000 ",
270 "000 ", "Start", "0 ", "+00 ", "+01 ",
271 "00 ", "+0000", "01 ", "01 ", "00 ",
272 "PchWh", "PchWh", " ", " ", " ",
273 "PchWh", "PchWh", "PchWh", "PchWh", "PchWh",
274 "PchWh", "PchWh", "PchWh", "PchWh", "PchWh"
275};
276
277char hilitab[][8] = { /* submenu highlight table */
278
279 /* start, width, row1, row2, row3, row4, row5, pad */
280
281 { 2, 3, HT_0|HT_2, HT_0, HT_0|HT_2, HT_0|HT_2, HT_2, 0},
282 { 7, 6, HT_2, HT_2, HT_2, HT_2, HT_2, 0},
283 { 15, 5, HT_2, HT_2, HT_2, HT_2, HT_2, 0},
284 { 22, 5, HT_2, HT_2|HT_3, HT_3, HT_3, HT_3, 0},
285 { 29, 5, HT_2, HT_2, HT_2, HT_2, HT_2, 0},
286 { 36, 5, HT_2, HT_2, HT_2, HT_2, HT_2, 0},
287 { 43, 4, HT_4|HT_5, HT_4|HT_5, HT_4|HT_5, HT_4|HT_5, 0, 0},
288 { 49, 5, HT_1, HT_1, HT_1, HT_1, HT_1, 0},
289 { 56, 5, HT_1, HT_1, HT_1, HT_1, HT_1, 0}
290};
291
292struct selbox ptboxes[] = { /* selection boxes */
293
294 {CTOX(1), RTOY(DATAROW), CTOX(48)-1, RTOY(1+DATAROW)-1, 0, ptfnbox}, /* current patch */
295
296 { 0, 0, 0, 0, 0, FN_NULL}
297};
298
299/*
300
301*/
302
303/*
304 =============================================================================
305 hilitpm() -- highlight patch submenu
306 =============================================================================
307*/
308
309hilitpm(n)
310register char n;
311{
312 register short chr, h, v, w;
313
314 ptemenu = n; /* set current submenu type */
315
316 for (h = 0; h < 9; h++) { /* scan the columns */
317
318 for (v = 0; v < 5; v++) { /* scan the rows */
319
320 chr = hilitab[h][0]; /* starting character */
321
322 for (w = hilitab[h][1]; w-- > 0; )
323 vsetcv(obj11, v + 1, chr++,
324 (hilitab[h][v + 2] & n) ?
325 PTIATR : PTMATR, 64);
326 }
327 }
328}
329
330/*
331
332*/
333
334/*
335 =============================================================================
336 aftercm() -- determine state after cursor motion
337 =============================================================================
338*/
339
340aftercm()
341{
342 switch (stccol) { /* switch based on current cursor column */
343
344 case 2: /* definer */
345 case 3:
346 case 4:
347 hilitpm(HT_0);
348 break;
349
350 case 15: /* stimulus */
351 case 16:
352 case 17:
353
354 hilitpm(HT_0);
355 break;
356
357 case 28: /* destination */
358
359 hilitpm(HT_2);
360 break;
361
362/*
363
364*/
365 case 34: /* may be a destination sub-address */
366 case 35:
367 case 36:
368 case 37:
369
370 if (ptedsok) { /* if destination is good ... */
371
372 switch (PE_SPEC & ptespec) {
373
374 case PA_OSC:
375
376 hilitpm(HT_3);
377 break;
378
379 case PA_LEVL:
380 case PA_INDX:
381 case PA_FREQ:
382 case PA_LOCN:
383 case PA_FILT:
384
385 hilitpm(HT_4);
386 break;
387
388 case PA_FILQ:
389 case PA_DYNM:
390 case PA_VOUT:
391 case PA_DPTH:
392 case PA_RATE:
393 case PA_INTN:
394 case PA_AUX:
395
396 hilitpm(HT_5);
397 break;
398
399 default:
400
401 hilitpm(HT_OFF);
402 break;
403 }
404
405 } else {
406
407 hilitpm(HT_OFF);
408 }
409
410 break;
411/*
412
413*/
414 case 42: /* datum */
415
416 if (ptedtok) { /* if datum is valid ... */
417
418 switch (PE_SPEC & ptespec) {
419
420 case PA_LEVL:
421 case PA_INDX:
422 case PA_FREQ:
423 case PA_LOCN:
424 case PA_FILT:
425 case PA_FILQ:
426 case PA_DYNM:
427 case PA_VOUT:
428 case PA_DPTH:
429 case PA_RATE:
430 case PA_INTN:
431 case PA_AUX:
432
433 if (ptedat1 EQ PSA_SRC)
434 hilitpm(HT_1);
435 else
436 hilitpm(HT_OFF);
437
438 break;
439
440 default:
441
442 hilitpm(HT_OFF);
443 break;
444 }
445
446 } else {
447
448 hilitpm(HT_OFF);
449 }
450
451 break;
452
453 default: /* not in a starting place */
454
455 hilitpm(HT_OFF);
456 break;
457 }
458}
459
460/*
461
462*/
463
464/*
465 =============================================================================
466 movectc() -- move cursor and reset highlighting
467 =============================================================================
468*/
469
470movectc(r, c)
471short r, c;
472{
473 ctcpos(r, c);
474 aftercm();
475}
476
477/*
478 =============================================================================
479 endpsm() -- end patch submenu data entry
480 =============================================================================
481*/
482
483endpsm(row, col)
484short row, col;
485{
486 submenu = FALSE;
487 cmtype = CT_SMTH;
488
489 ptegood = ptedfok AND ptestok AND ptedsok AND ptedtok;
490
491 mtcoff();
492 movectc(row, col);
493
494 srdspte();
495}
496
497/*
498
499*/
500
501/*
502 =============================================================================
503 edefstm() -- enter a def or a stm field
504 =============================================================================
505*/
506
507edefstm(du, n)
508short du, n;
509{
510 short chan, port, stim;
511 register short i, left, right;
512 register long ltemp;
513
514#if DEBUGIT
515 if (debugsw AND snapit)
516 printf("edefstm(%d): pte stok=%d dfok=%d\n",
517 n, ptestok, ptedfok);
518#endif
519
520 if (n) {
521
522 if (NOT ptestok) {
523
524 movectc(DATAROW, 15);
525 return;
526 }
527
528 } else {
529
530 if (NOT ptedfok) {
531
532 movectc(DATAROW, 2);
533 return;
534 }
535 }
536
537 port = ((n ? ptestm : ptedef) >> 11) & 0x0003;
538 chan = ((n ? ptestm : ptedef) >> 7) & 0x000F;
539 stim = (n ? ptestm : ptedef) & 0x007F;
540
541/*
542
543*/
544
545 if ( (port EQ 0) OR (port EQ 1) OR
546 ((port EQ 2) AND (chan < 2)) ) { /* key / rel */
547
548 ltemp = 0; /* stimulus number */
549 left = n ? 19 : 6;
550 right = n ? 22 : 9;
551
552 for (i = left; i < right; i++)
553 ltemp = (ltemp * 10) + ptdebuf[i] - '0';
554
555 if ((ltemp EQ 0) OR (ltemp > 128L)) {
556
557 movectc(DATAROW, left);
558 return;
559 }
560
561 stim = ltemp - 1;
562
563 if (port EQ 2) {
564
565 chan = 0;
566
567 } else {
568
569 ltemp = 0; /* channel */
570 left = n ? 25 : 12;
571 right = n ? 27 : 14;
572
573 for (i = left; i < right; i++)
574 ltemp = (ltemp * 10) + ptdebuf[i] - '0';
575
576 if ((ltemp EQ 0) OR (ltemp > 16L)) {
577
578 movectc(DATAROW, left);
579 return;
580 }
581
582 chan = ltemp - 1;
583 }
584
585 if (n)
586 ptestm = (ptestm & 0x8000) | (port << 11) | (chan << 7) | stim;
587 else
588 ptedef = (ptedef & 0x8000) | (port << 11) | (chan << 7) | stim;
589/*
590
591*/
592 } else if ((port EQ 2) AND (chan EQ 2)) { /* Trig */
593
594 ltemp = 0;
595 left = n ? 20 : 7;
596 right = n ? 22 : 9;
597
598 for (i = left; i < right; i++)
599 ltemp = (ltemp * 10) + ptdebuf[i] - '0';
600
601 if ((ltemp EQ 0) OR (ltemp > 16L)) {
602
603 movectc(DATAROW, left);
604 return;
605 }
606
607 stim = ltemp - 1;
608
609 if (n)
610 ptestm = 0x1100 | stim;
611 else
612 ptedef = 0x1100 | stim;
613/*
614
615*/
616 } else if ((port EQ 2) AND (chan EQ 3)) { /* Pulse */
617
618 left = n ? 21 : 8;
619 ltemp = ptdebuf[left] - '0';
620
621 if ((ltemp EQ 0) OR (ltemp > 2L)) {
622
623 movectc(DATAROW, left);
624 return;
625 }
626
627 stim = ltemp - 1;
628
629 if (n)
630 ptestm = 0x1180 | stim;
631 else
632 ptedef = 0x1180 | stim;
633
634 } else {
635
636 movectc(DATAROW, n ? 15 : 2);
637 return;
638 }
639
640 if (n)
641 ptestok = TRUE;
642 else
643 ptedfok = TRUE;
644
645#if SNAPDUMP
646 if (debugsw AND snapit)
647 SnapPTV("edefstm");
648#endif
649
650 if (du) { /* if display is to be updated ... */
651
652 srdspte();
653 movectc(DATAROW, n ? 28 : 15);
654 }
655}
656
657/*
658
659*/
660
661/*
662 =============================================================================
663 ptdest() -- enter patch destination field
664 =============================================================================
665*/
666
667ptdest(du)
668short du;
669{
670 register long ltemp;
671 register short i, left, right, stim;
672 short port, chan;
673
674#if DEBUGIT
675 if (debugsw AND debug01)
676 printf("ptdest(%d): entry -- ptedest = %d\n", du, ptedest);
677#endif
678
679 switch (ptedest) {
680
681 case 0: /* key */
682
683 ltemp = 0;
684 left = 30;
685 right = 33;
686
687 for (i = left; i < right; i++)
688 ltemp = (ltemp * 10) + ptdebuf[i] - '0';
689
690 if ((ltemp EQ 0) OR (ltemp > 128L)) {
691
692 movectc(DATAROW, left);
693 return;
694 }
695
696 stim = ltemp - 1;
697 ltemp = 0;
698 left = 36;
699 right = 38;
700
701 for (i = left; i < right; i++)
702 ltemp = (ltemp * 10) + ptdebuf[i] - '0';
703
704 if ((ltemp EQ 0) OR (ltemp > 16L)) {
705
706 movectc(DATAROW, left);
707 return;
708 }
709
710 chan = ltemp - 1;
711/*
712
713*/
714 if (ptdebuf[34] EQ 'L') {
715
716 port = 2;
717 chan = 0;
718
719 } else {
720
721 port = ptdebuf[34] - '1';
722 }
723
724 ptesuba = (port << 11) | (chan << 7) | stim;
725 break;
726/*
727
728*/
729 case 1: /* trigger */
730
731 ltemp = 0;
732 left = 36;
733 right = 38;
734
735 for (i = left; i < right; i++)
736 ltemp = (ltemp * 10) + ptdebuf[i] - '0';
737
738 if ((ltemp EQ 0) OR (ltemp > 16L)) {
739
740 movectc(DATAROW, left);
741 return;
742 }
743
744 stim = ltemp - 1;
745 ptesuba = 0x1100 | stim;
746 break;
747
748 case 2: /* pulse */
749
750 ptesuba = ptdebuf[34] - '1';
751 break;
752
753 case 3: /* led */
754
755 ptesuba = ptdebuf[32] - 'A';
756 break;
757
758 case 4: /* seq / reg */
759
760 ltemp = 0;
761 left = 32;
762 right = 34;
763
764 for (i = left; i < right; i++)
765 ltemp = (ltemp * 10) + ptdebuf[i] - '0';
766
767 if ((ltemp EQ 0) OR (ltemp > 16L)) {
768
769 movectc(DATAROW, left);
770 return;
771 }
772
773 ptesuba = ltemp - 1;
774 break;
775
776/*
777
778*/
779 case 5: /* tuning */
780 case 7: /* aux, rate, inten, depth */
781
782 break;
783
784 case 6: /* inst, wave, config */
785 case 10: /* level, filtr, fil Q, loctn, dynmc */
786
787 if (ptdebuf[39] EQ 'V')
788 stim = 0;
789 else
790 stim = 12;
791
792 i = ptdebuf[40] & 0x00FF;
793
794 if (i GE '\254')
795 stim += i - '\242';
796 else
797 stim += i - '0';
798
799 --stim;
800 ptesuba = stim << 8;
801 break;
802
803 case 8: /* vlt */
804
805 ptesuba = ptdebuf[32] - '0';
806 break;
807/*
808
809*/
810 case 9: /* osc, ind, frq */
811
812 if (ptdebuf[39] EQ 'V')
813 stim = 0;
814 else
815 stim = 12;
816
817 i = ptdebuf[40] & 0x00FF;
818
819 if (i GE '\254')
820 stim += i - '\242';
821 else
822 stim += i - '0';
823
824 --stim;
825 ptesuba = (stim << 8) | (ptdebuf[32] - '0');
826 break;
827
828 default: /* something weird got in here ... */
829
830 movectc(DATAROW, 28);
831 return;
832 }
833
834 ptedsok = TRUE;
835
836#if SNAPDUMP
837 if (debugsw AND snapit)
838 SnapPTV("ptdest");
839#endif
840
841 if (du) {
842
843 srdspte();
844 movectc(DATAROW, 42);
845 }
846
847#if DEBUGIT
848 if (debugsw AND debug01)
849 printf("ptdest(%d): exit\n", du);
850#endif
851}
852
853/*
854
855*/
856
857/*
858 =============================================================================
859 epatch() -- enter patch and reposition cursor to the DEF field
860 =============================================================================
861*/
862
863epatch()
864{
865#if DEBUGIT
866 if (debugsw AND debug01)
867 printf("epatch(): entry\n");
868#endif
869
870 ptedtok = TRUE; /* data just got parsed or we wouldn't be here */
871 edefstm(0, 0); /* parse def */
872 edefstm(0, 1); /* parse stm */
873 ptdest(0); /* parse dest */
874 entrpte(); /* enter the patch */
875 srdspte(); /* adjust the display */
876 movectc(DATAROW, 2); /* reposition the cursor */
877
878#if SNAPDUMP
879 if (debugsw AND snapit)
880 SnapPTV("epatch");
881#endif
882
883#if DEBUGIT
884 if (debugsw AND debug01)
885 printf("epatch(): exit\n");
886#endif
887}
888
889/*
890
891*/
892
893/*
894 =============================================================================
895 badpdat() -- position cursor at bad data field
896 =============================================================================
897*/
898
899badpdat()
900{
901 ptedtok = FALSE;
902 movectc(DATAROW, 42);
903}
904
905/*
906 =============================================================================
907 setsubm() -- setup submenu
908 =============================================================================
909*/
910
911setsubm(r, c)
912short r, c;
913{
914 submenu = TRUE;
915 cmtype = CT_MENU;
916 mtcpos(r, c);
917}
918
919/*
920
921*/
922
923/*
924 =============================================================================
925 ptfnbox() -- patch display box hit processor
926 =============================================================================
927*/
928
929short
930ptfnbox(n)
931short n;
932{
933 register short i, box, ptd, ptt;
934 register long ltemp;
935
936 if (NOT submenu) { /* PATCH DATA ENTRY LINE */
937
938 if (inrange(stccol, 2, 13)) { /* DEFINER */
939
940 ptedftp = 1; /* def */
941
942 if (inrange(stccol, 2, 4)) { /* select */
943
944 setsubm(19, 2);
945
946 } else { /* enter */
947
948 edefstm(0, 1);
949 ptdest(0);
950 edefstm(1, 0);
951 }
952
953 return(SUCCESS);
954
955 } else if (inrange(stccol, 15, 26)) { /* STIMULUS */
956
957 ptedftp = 2; /* stm */
958
959 if (inrange(stccol, 15, 17)) { /* select */
960
961 setsubm(19, 2);
962
963 } else { /* enter */
964
965 edefstm(0 ,0);
966 ptdest(0);
967 edefstm(1, 1);
968 }
969
970 return(SUCCESS);
971/*
972
973*/
974 } else if (inrange(stccol, 28, 40)) { /* DESTINATION */
975
976 ptedftp = 0; /* not def/stm */
977
978 if (stccol EQ 28) { /* select */
979
980 setsubm(19, 2);
981
982 } else if (ptemenu EQ HT_3) {
983
984 setsubm(20, 22);
985
986 } else if ((ptemenu EQ HT_4) OR
987 (ptemenu EQ HT_5)) {
988
989 setsubm(19, 43);
990
991 } else { /* enter */
992
993 edefstm(0, 0);
994 edefstm(0, 1);
995 ptdest(1);
996 }
997
998 return(SUCCESS);
999/*
1000
1001*/
1002 } else if (inrange(stccol, 42, 46)) { /* DATUM */
1003
1004 ptedftp = 0; /* not def/stm */
1005 setptcv(); /* setup control variables */
1006
1007#if DEBUGIT
1008 if (debugsw AND debug01)
1009 SnapPTV("ptfnbox");
1010#endif
1011 switch (ptedata) { /* switch on Datum format */
1012
1013 case 0: /* -none- */
1014
1015 ptedtok = FALSE;
1016 return(FAILURE);
1017
1018 case 1: /* multiplier -- +1.00 */
1019
1020 ebuf[0] = ptdebuf[43];
1021 ebuf[1] = ptdebuf[45];
1022 ebuf[2] = ptdebuf[46];
1023 ebuf[3] = ptdebuf[42];
1024
1025 if (0xFFFF EQ (i = dec2fr(ebuf))) {
1026
1027 badpdat();
1028 return(FAILURE);
1029 }
1030
1031 ptedat2 = i;
1032 epatch(); /* enter -- multiplier */
1033 return(SUCCESS);
1034/*
1035
1036*/
1037 case 2: /* time -- 32767 */
1038
1039 ltemp = 0;
1040
1041 for (i = 42; i < 47; i++)
1042 ltemp = (ltemp * 10) + (ptdebuf[i] - '0');
1043
1044 if (ltemp > 32767L) {
1045
1046 badpdat();
1047 return(FAILURE);
1048 }
1049
1050 ptedat2 = tofpu((unsigned short)ltemp);
1051 epatch(); /* enter -- time */
1052 return(SUCCESS);
1053
1054 case 3: /* value -- +10.00 */
1055
1056 i = ptdebuf[42] & 0x00FF;
1057
1058 if ((i EQ '\240') OR (i EQ '\241'))
1059 ltemp = 1000;
1060 else
1061 ltemp = 0;
1062
1063 ltemp += ((ptdebuf[43] - '0') * 100) +
1064 ((ptdebuf[45] - '0') * 10) +
1065 (ptdebuf[46] - '0');
1066
1067 if (ltemp > 1000L) {
1068
1069 badpdat();
1070 return(FAILURE);
1071 }
1072
1073 if ((i EQ '-') OR (i EQ '\241'))
1074 ltemp = -ltemp;
1075
1076 ptedat2 = ltemp << 5;
1077 epatch(); /* enter -- value */
1078 return(SUCCESS);
1079
1080/*
1081
1082*/
1083 case 4: /* interval -- +1200 */
1084
1085 ltemp = 0;
1086
1087 for (i = 43; i < 47; i++)
1088 ltemp = (ltemp * 10) + (ptdebuf[i] - '0');
1089
1090 if (ltemp > 1200L) {
1091
1092 badpdat();
1093 return(FAILURE);
1094 }
1095
1096 if (ptdebuf[42] EQ '-')
1097 ltemp = -ltemp;
1098
1099 ptedat2 = ltemp << 1;
1100 epatch(); /* enter -- interval */
1101 return(SUCCESS);
1102/*
1103
1104*/
1105 case 5: /* ratio -- 9/9 */
1106
1107 ptedat2 = ndvals[ptdebuf[42] - '0'] -
1108 ndvals[ptdebuf[44] - '0'];
1109
1110 epatch(); /* enter -- ratio */
1111 return(SUCCESS);
1112
1113 case 6: /* frequency -- 15.9 */
1114
1115 ltemp = ((ptdebuf[42] - '0') * 100) +
1116 ((ptdebuf[43] - '0') * 10) +
1117 (ptdebuf[45] - '0');
1118
1119 if (ltemp > 159L) {
1120
1121 badpdat();
1122 return(FAILURE);
1123 }
1124
1125 ptedat2 = ltemp << 1;
1126 epatch(); /* enter -- frequency */
1127 return(SUCCESS);
1128
1129 case 7: /* pitch -- 9C#99 */
1130
1131 memcpy(ebuf,& ptdebuf[42], 5);
1132
1133 if (FAILURE EQ cnvp2c()) {
1134
1135 badpdat();
1136 return(FAILURE);
1137 }
1138
1139 ptedat2 = cents;
1140 epatch(); /* enter - pitch */
1141 return(SUCCESS);
1142/*
1143
1144*/
1145 case 8: /* trans/stop/start */
1146 case 9: /* stop/start */
1147 case 10: /* off/on */
1148
1149 epatch(); /* enter -- control */
1150 return(SUCCESS);
1151
1152 case 11: /* source */
1153
1154 if (stccol EQ 42)
1155 setsubm(19, 49); /* select */
1156 else
1157 epatch(); /* enter -- source */
1158
1159 return(SUCCESS);
1160
1161 case 12: /* register/value -- R16 | +99 */
1162
1163 ltemp = ((ptdebuf[43] - '0') * 10) +
1164 (ptdebuf[44] - '0');
1165
1166 if (ptdebuf[42] EQ 'R') {
1167
1168 if ((ltemp EQ 0) OR (ltemp > 16L)) {
1169
1170 badpdat();
1171 return(FAILURE);
1172 }
1173
1174 --ltemp;
1175 ptedat1 = 1;
1176
1177 } else {
1178
1179 ptedat1 = 0;
1180 }
1181
1182 ptedat2 = ltemp;
1183 epatch(); /* enter -- register | value */
1184 return(SUCCESS);
1185/*
1186
1187*/
1188 case 13: /* sequence line */
1189
1190 ltemp = 0;
1191
1192 for (i = 42; i < 45; i++)
1193 ltemp = (ltemp * 10) + (ptdebuf[i] - '0');
1194
1195 ptedat1 = ltemp;
1196 epatch(); /* enter -- sequence line */
1197 return(SUCCESS);
1198
1199 case 14: /* LED controls */
1200
1201 ltemp = 0;
1202
1203 if (ptesuba & 0x0001) {
1204
1205 for (i = 42; i < 46; i++)
1206 ltemp = (ltemp << 2) | (ptdebuf[i] - '0');
1207
1208 ptedat1 = ltemp << 8;
1209
1210 } else {
1211
1212 for (i = 42; i < 45; i++)
1213 ltemp = (ltemp << 2) | (ptdebuf[i] - '0');
1214
1215 ptedat1 = ltemp << 10;
1216 }
1217
1218 epatch(); /* enter -- LED controls */
1219 return(SUCCESS);
1220
1221/*
1222
1223*/
1224 case 15: /* instrument number */
1225
1226 ltemp = ((ptdebuf[42] - '0') * 10) +
1227 (ptdebuf[43] - '0');
1228
1229 if (ltemp > 40L) {
1230
1231 badpdat();
1232 return(FAILURE);
1233 }
1234
1235 ptedat1 = ltemp;
1236 epatch(); /* enter -- instrument number */
1237 return(SUCCESS);
1238
1239 case 16: /* waveshape number */
1240
1241 ltemp = ((ptdebuf[42] - '0') * 10) +
1242 (ptdebuf[43] - '0');
1243
1244 if ((ltemp EQ 0) OR (ltemp > 20L)) {
1245
1246 badpdat();
1247 return(FAILURE);
1248 }
1249
1250 ptedat1 = ltemp;
1251 epatch(); /* enter -- waveshape number */
1252 return(SUCCESS);
1253/*
1254
1255*/
1256 case 17: /* configuration number */
1257
1258 ltemp = ((ptdebuf[42] - '0') * 10) +
1259 (ptdebuf[43] - '0');
1260
1261 if (ltemp > 11L) {
1262
1263 badpdat();
1264 return(FAILURE);
1265 }
1266
1267 ptedat1 = ltemp;
1268 epatch(); /* enter -- configuration number */
1269 return(SUCCESS);
1270
1271 case 18: /* tuning table number */
1272
1273 ptedat1 = ptdebuf[42] - '0';
1274 epatch(); /* enter -- tuning table number */
1275 return(SUCCESS);
1276
1277 default: /* something weird got in here ... */
1278
1279 ptedtok = FALSE;
1280 return(FAILURE);
1281 }
1282 }
1283
1284 return(FAILURE);
1285/*
1286
1287*/
1288 } else { /* SUBMENU SELECTION */
1289
1290 /* determine the "box" we're pointing at */
1291
1292 if (inrange(vtccol, 2, 4))
1293 box = vtcrow - 18;
1294 else if (inrange(vtccol, 7, 12))
1295 box = vtcrow - 13;
1296 else if (inrange(vtccol, 15, 19))
1297 box = vtcrow - 8;
1298 else if (inrange(vtccol, 22, 26))
1299 box = vtcrow - 3;
1300 else if (inrange(vtccol, 29, 33))
1301 box = vtcrow + 2;
1302 else if (inrange(vtccol, 36, 40))
1303 box = vtcrow + 7;
1304 else if (inrange(vtccol, 43, 46))
1305 box = vtcrow + 12;
1306 else if (inrange(vtccol, 49, 53))
1307 box = vtcrow + 17;
1308 else if (inrange(vtccol, 56, 60))
1309 box = vtcrow + 22;
1310 else
1311 return(FAILURE);
1312
1313/*
1314
1315*/
1316 switch (ptemenu) { /* switch on submenu type */
1317
1318 case HT_0: /* DEFINERS / STIMULLI */
1319
1320 if (inrange(box, 1, 4)) { /* Key, Rel, Trg, Pls */
1321
1322 i = box - 1;
1323 ptedfst = dfsttp[i];
1324
1325 if (ptedftp EQ 1) { /* def */
1326
1327 ptedfok = TRUE;
1328 ptbflag = TRUE;
1329
1330 ptedef = dfsttab[i];
1331
1332 strcpy(&ptdebuf[2], rawdfst[i]);
1333
1334 UpdVid(7, 2, rawdfst[i], PTDATR);
1335 endpsm(DATAROW, defcols[ptedfst]);
1336
1337 return(SUCCESS);
1338
1339 } else if (ptedftp EQ 2) { /* stm */
1340
1341 ptestok = TRUE;
1342 ptbflag = TRUE;
1343
1344 ptestm = dfsttab[i];
1345
1346 strcpy(&ptdebuf[15], rawdfst[i]);
1347
1348 UpdVid(7, 15, rawdfst[i], PTDATR);
1349 endpsm(DATAROW, stmcols[ptedfst]);
1350
1351 return(SUCCESS);
1352 }
1353 }
1354
1355 return(FAILURE);
1356/*
1357
1358*/
1359 case HT_1: /* SOURCES */
1360
1361 if (inrange(box, 36, 45)) {
1362
1363 ptedtok = TRUE;
1364 ptbflag = TRUE;
1365
1366 ptedat2 = datasrc[box - 36];
1367
1368 strcpy(&ptdebuf[42], smdata[ptedat2]);
1369
1370 UpdVid(7, 42, smdata[ptedat2], PTDATR);
1371 endpsm(DATAROW, 46);
1372
1373 return(SUCCESS);
1374 }
1375
1376 return(FAILURE);
1377/*
1378
1379*/
1380 case HT_2: /* DESTINATIONS */
1381
1382 i = box - 1;
1383 ptt = destype[i];
1384
1385 if (ptt NE -1) {
1386
1387 ptedsok = TRUE;
1388 ptedtok = TRUE;
1389 ptbflag = TRUE;
1390
1391 ptedest = destfmt[i];
1392 ptedata = datafmt[i];
1393 ptespec = ptt;
1394 ptesuba = 0x0000;
1395 ptedat1 = 0x0000;
1396 ptedat2 = 0x0000;
1397
1398 if (ptd = desdatf[i]) {
1399
1400 if (ptd & 1)
1401 ptedat1 = desdat1[i];
1402
1403 if (ptd & 2)
1404 ptedat2 = desdat2[i];
1405 }
1406
1407 strcpy(&ptdebuf[28], rawdest[ptt]);
1408 strcpy(&ptdebuf[42], rawdata[i]);
1409
1410 UpdVid(7, 28, rawdest[ptt], PTDATR);
1411 UpdVid(7, 42, rawdata[i], PTDATR);
1412 endpsm(DATAROW, dstcols[1 + ptedest]);
1413
1414 return(SUCCESS);
1415 }
1416
1417 return(FAILURE);
1418/*
1419
1420*/
1421 case HT_3: /* OSCILLATOR MODES */
1422
1423 if (inrange(box, 17, 20)) {
1424
1425 i = box - 17;
1426
1427 ptedsok = TRUE;
1428 ptedtok = TRUE;
1429 ptbflag = TRUE;
1430
1431 ptedat1 = omtabl[i];
1432 ptedat2 = omdtab[i];
1433
1434 ptedata = omftab[i];
1435
1436 strcpy(&ptdebuf[34], rawmode[i]);
1437 strcpy(&ptdebuf[42], rawmdat[i]);
1438
1439 UpdVid(7, 34, rawmode[i], PTDATR);
1440 UpdVid(7, 42, rawmdat[i], PTDATR);
1441 endpsm(DATAROW, 39);
1442
1443 return(SUCCESS);
1444 }
1445
1446 return(FAILURE);
1447/*
1448
1449*/
1450 case HT_5: /* FPU OUTPUTS WITHOUT FUNCTIONS */
1451
1452 if (NOT inrange(box, 31, 34))
1453 return(FAILURE);
1454
1455 case HT_4: /* FPU OUTPUTS WITH FUNCTIONS */
1456
1457 if (NOT inrange(box, 31, 35))
1458 return(FAILURE);
1459
1460 i = box - 31;
1461
1462 ptedsok = TRUE;
1463 ptedtok = TRUE;
1464 ptbflag = TRUE;
1465
1466 ptedat1 = i;
1467 ptedat2 = fpudtab[i];
1468
1469 ptedata = fpuetab[i];
1470
1471 strcpy(&ptdebuf[34], stdata[i]);
1472 strcpy(&ptdebuf[42], rawfpud[i]);
1473
1474 UpdVid(7, 34, stdata[i], PTDATR);
1475 UpdVid(7, 42, rawfpud[i], PTDATR);
1476 endpsm(DATAROW, 42);
1477
1478 return(SUCCESS);
1479
1480 default: /* -BOGUS- */
1481
1482 endpsm(stcrow, stccol);
1483
1484 return(FAILURE);
1485 }
1486 }
1487
1488 return(FAILURE);
1489}
Note: See TracBrowser for help on using the repository browser.