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

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

Unused variables and parameters.

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