source: buchla-68k/ram/ptselbx.c@ 60288f5

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

Make function pointers more consistent.

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