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

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

Cleanup.

  • Property mode set to 100644
File size: 26.0 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
36uint16_t ptedef; /* pte buffer -- definer number */
37uint16_t ptestm; /* pte buffer -- stimulus number */
38uint16_t ptespec; /* pte buffer -- address type */
39uint16_t ptesuba; /* pte buffer -- sub-address */
40uint16_t ptedat1; /* pte buffer -- data word 1 */
41uint16_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
104uint16_t omtabl[] = { PSO_FRQ, PSO_PCH, PSO_INT, PSO_RAT }; /* oscillator modes */
105uint16_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
110uint16_t fpudtab[] = { SM_HTPW, 0, 1, 0, 1 };
111int16_t fpuetab[] = { 11, 1, 2, 3, 9 };
112
113uint16_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
126uint16_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
175uint16_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
185uint16_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 = (int16_t)(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 = (int16_t)(ltemp - 1);
483 }
484
485 if (n)
486 ptestm = (ptestm & 0x8000) | ((uint16_t)port << 11) |
487 ((uint16_t)chan << 7) | (uint16_t)stim;
488 else
489 ptedef = (ptedef & 0x8000) | ((uint16_t)port << 11) |
490 ((uint16_t)chan << 7) | (uint16_t)stim;
491
492 } else if ((port EQ 2) AND (chan EQ 2)) { /* Trig */
493
494 ltemp = 0;
495 left = n ? 20 : 7;
496 right = n ? 22 : 9;
497
498 for (i = left; i < right; i++)
499 ltemp = (ltemp * 10) + ptdebuf[i] - '0';
500
501 if ((ltemp EQ 0) OR (ltemp > 16L)) {
502
503 movectc(DATAROW, left);
504 return;
505 }
506
507 stim = (int16_t)(ltemp - 1);
508
509 if (n)
510 ptestm = 0x1100 | (uint16_t)stim;
511 else
512 ptedef = 0x1100 | (uint16_t)stim;
513
514 } else if ((port EQ 2) AND (chan EQ 3)) { /* Pulse */
515
516 left = n ? 21 : 8;
517 ltemp = ptdebuf[left] - '0';
518
519 if ((ltemp EQ 0) OR (ltemp > 2L)) {
520
521 movectc(DATAROW, left);
522 return;
523 }
524
525 stim = (int16_t)(ltemp - 1);
526
527 if (n)
528 ptestm = 0x1180 | (uint16_t)stim;
529 else
530 ptedef = 0x1180 | (uint16_t)stim;
531
532 } else {
533
534 movectc(DATAROW, n ? 15 : 2);
535 return;
536 }
537
538 if (n)
539 ptestok = TRUE;
540 else
541 ptedfok = TRUE;
542
543#if SNAPDUMP
544 if (debugsw AND snapit)
545 SnapPTV("edefstm");
546#endif
547
548 if (du) { /* if display is to be updated ... */
549
550 srdspte();
551 movectc(DATAROW, n ? 28 : 15);
552 }
553}
554
555/*
556 =============================================================================
557 ptdest() -- enter patch destination field
558 =============================================================================
559*/
560
561void ptdest(int16_t du)
562{
563 register int32_t ltemp;
564 register int16_t i, left, right, stim;
565 int16_t port, chan;
566
567#if DEBUGIT
568 if (debugsw AND debug01)
569 printf("ptdest(%d): entry -- ptedest = %d\n", du, ptedest);
570#endif
571
572 switch (ptedest) {
573
574 case 0: /* key */
575
576 ltemp = 0;
577 left = 30;
578 right = 33;
579
580 for (i = left; i < right; i++)
581 ltemp = (ltemp * 10) + ptdebuf[i] - '0';
582
583 if ((ltemp EQ 0) OR (ltemp > 128L)) {
584
585 movectc(DATAROW, left);
586 return;
587 }
588
589 stim = (int16_t)(ltemp - 1);
590 ltemp = 0;
591 left = 36;
592 right = 38;
593
594 for (i = left; i < right; i++)
595 ltemp = (ltemp * 10) + ptdebuf[i] - '0';
596
597 if ((ltemp EQ 0) OR (ltemp > 16L)) {
598
599 movectc(DATAROW, left);
600 return;
601 }
602
603 chan = (int16_t)(ltemp - 1);
604
605 if (ptdebuf[34] EQ 'L') {
606
607 port = 2;
608 chan = 0;
609
610 } else {
611
612 port = ptdebuf[34] - '1';
613 }
614
615 ptesuba = ((uint16_t)port << 11) | ((uint16_t)chan << 7) | (uint16_t)stim;
616 break;
617
618 case 1: /* trigger */
619
620 ltemp = 0;
621 left = 36;
622 right = 38;
623
624 for (i = left; i < right; i++)
625 ltemp = (ltemp * 10) + ptdebuf[i] - '0';
626
627 if ((ltemp EQ 0) OR (ltemp > 16L)) {
628
629 movectc(DATAROW, left);
630 return;
631 }
632
633 stim = (int16_t)(ltemp - 1);
634 ptesuba = 0x1100 | (uint16_t)stim;
635 break;
636
637 case 2: /* pulse */
638
639 ptesuba = (uint16_t)(ptdebuf[34] - '1');
640 break;
641
642 case 3: /* led */
643
644 ptesuba = (uint16_t)(ptdebuf[32] - 'A');
645 break;
646
647 case 4: /* seq / reg */
648
649 ltemp = 0;
650 left = 32;
651 right = 34;
652
653 for (i = left; i < right; i++)
654 ltemp = (ltemp * 10) + ptdebuf[i] - '0';
655
656 if ((ltemp EQ 0) OR (ltemp > 16L)) {
657
658 movectc(DATAROW, left);
659 return;
660 }
661
662 ptesuba = (uint16_t)(ltemp - 1);
663 break;
664
665
666 case 5: /* tuning */
667 case 7: /* aux, rate, inten, depth */
668
669 break;
670
671 case 6: /* inst, wave, config */
672 case 10: /* level, filtr, fil Q, loctn, dynmc */
673
674 if (ptdebuf[39] EQ 'V')
675 stim = 0;
676 else
677 stim = 12;
678
679 i = ptdebuf[40] & 0x00FF;
680
681 if (i GE '\254')
682 stim += i - '\242';
683 else
684 stim += i - '0';
685
686 --stim;
687 ptesuba = (uint16_t)stim << 8;
688 break;
689
690 case 8: /* vlt */
691
692 ptesuba = (uint16_t)(ptdebuf[32] - '0');
693 break;
694
695 case 9: /* osc, ind, frq */
696
697 if (ptdebuf[39] EQ 'V')
698 stim = 0;
699 else
700 stim = 12;
701
702 i = ptdebuf[40] & 0x00FF;
703
704 if (i GE '\254')
705 stim += i - '\242';
706 else
707 stim += i - '0';
708
709 --stim;
710 ptesuba = ((uint16_t)stim << 8) | (uint16_t)(ptdebuf[32] - '0');
711 break;
712
713 default: /* something weird got in here ... */
714
715 movectc(DATAROW, 28);
716 return;
717 }
718
719 ptedsok = TRUE;
720
721#if SNAPDUMP
722 if (debugsw AND snapit)
723 SnapPTV("ptdest");
724#endif
725
726 if (du) {
727
728 srdspte();
729 movectc(DATAROW, 42);
730 }
731
732#if DEBUGIT
733 if (debugsw AND debug01)
734 printf("ptdest(%d): exit\n", du);
735#endif
736}
737
738/*
739 =============================================================================
740 epatch() -- enter patch and reposition cursor to the DEF field
741 =============================================================================
742*/
743
744void epatch(void)
745{
746#if DEBUGIT
747 if (debugsw AND debug01)
748 printf("epatch(): entry\n");
749#endif
750
751 ptedtok = TRUE; /* data just got parsed or we wouldn't be here */
752 edefstm(0, 0); /* parse def */
753 edefstm(0, 1); /* parse stm */
754 ptdest(0); /* parse dest */
755 entrpte(); /* enter the patch */
756 srdspte(); /* adjust the display */
757 movectc(DATAROW, 2); /* reposition the cursor */
758
759#if SNAPDUMP
760 if (debugsw AND snapit)
761 SnapPTV("epatch");
762#endif
763
764#if DEBUGIT
765 if (debugsw AND debug01)
766 printf("epatch(): exit\n");
767#endif
768}
769
770/*
771 =============================================================================
772 badpdat() -- position cursor at bad data field
773 =============================================================================
774*/
775
776void badpdat(void)
777{
778 ptedtok = FALSE;
779 movectc(DATAROW, 42);
780}
781
782/*
783 =============================================================================
784 setsubm() -- setup submenu
785 =============================================================================
786*/
787
788void setsubm(int16_t r, int16_t c)
789{
790 submenu = TRUE;
791 cmtype = CT_MENU;
792 mtcpos(r, c);
793}
794
795/*
796 =============================================================================
797 ptfnbox() -- patch display box hit processor
798 =============================================================================
799*/
800
801int16_t ptfnbox(int16_t n)
802{
803 register int16_t i, box, ptd, ptt;
804 register int32_t ltemp;
805
806 (void)n;
807
808 if (NOT submenu) { /* PATCH DATA ENTRY LINE */
809
810 if (inrange(stccol, 2, 13)) { /* DEFINER */
811
812 ptedftp = 1; /* def */
813
814 if (inrange(stccol, 2, 4)) { /* select */
815
816 setsubm(19, 2);
817
818 } else { /* enter */
819
820 edefstm(0, 1);
821 ptdest(0);
822 edefstm(1, 0);
823 }
824
825 return(SUCCESS);
826
827 } else if (inrange(stccol, 15, 26)) { /* STIMULUS */
828
829 ptedftp = 2; /* stm */
830
831 if (inrange(stccol, 15, 17)) { /* select */
832
833 setsubm(19, 2);
834
835 } else { /* enter */
836
837 edefstm(0 ,0);
838 ptdest(0);
839 edefstm(1, 1);
840 }
841
842 return(SUCCESS);
843
844 } else if (inrange(stccol, 28, 40)) { /* DESTINATION */
845
846 ptedftp = 0; /* not def/stm */
847
848 if (stccol EQ 28) { /* select */
849
850 setsubm(19, 2);
851
852 } else if (ptemenu EQ HT_3) {
853
854 setsubm(20, 22);
855
856 } else if ((ptemenu EQ HT_4) OR
857 (ptemenu EQ HT_5)) {
858
859 setsubm(19, 43);
860
861 } else { /* enter */
862
863 edefstm(0, 0);
864 edefstm(0, 1);
865 ptdest(1);
866 }
867
868 return(SUCCESS);
869
870 } else if (inrange(stccol, 42, 46)) { /* DATUM */
871
872 ptedftp = 0; /* not def/stm */
873 setptcv(); /* setup control variables */
874
875#if DEBUGIT
876 if (debugsw AND debug01)
877 SnapPTV("ptfnbox");
878#endif
879 switch (ptedata) { /* switch on Datum format */
880
881 case 0: /* -none- */
882
883 ptedtok = FALSE;
884 return(FAILURE);
885
886 case 1: /* multiplier -- +1.00 */
887
888 ebuf[0] = ptdebuf[43];
889 ebuf[1] = ptdebuf[45];
890 ebuf[2] = ptdebuf[46];
891 ebuf[3] = ptdebuf[42];
892
893 if (0xFFFF EQ (i = dec2fr(ebuf))) {
894
895 badpdat();
896 return(FAILURE);
897 }
898
899 ptedat2 = (uint16_t)i;
900 epatch(); /* enter -- multiplier */
901 return(SUCCESS);
902
903 case 2: /* time -- 32767 */
904
905 ltemp = 0;
906
907 for (i = 42; i < 47; i++)
908 ltemp = (ltemp * 10) + (ptdebuf[i] - '0');
909
910 if (ltemp > 32767L) {
911
912 badpdat();
913 return(FAILURE);
914 }
915
916 ptedat2 = tofpu((uint16_t)ltemp);
917 epatch(); /* enter -- time */
918 return(SUCCESS);
919
920 case 3: /* value -- +10.00 */
921
922 i = ptdebuf[42] & 0x00FF;
923
924 if ((i EQ '\240') OR (i EQ '\241'))
925 ltemp = 1000;
926 else
927 ltemp = 0;
928
929 ltemp += ((ptdebuf[43] - '0') * 100) +
930 ((ptdebuf[45] - '0') * 10) +
931 (ptdebuf[46] - '0');
932
933 if (ltemp > 1000L) {
934
935 badpdat();
936 return(FAILURE);
937 }
938
939 if ((i EQ '-') OR (i EQ '\241'))
940 ltemp = -ltemp;
941
942 ptedat2 = (uint16_t)(ltemp << 5);
943 epatch(); /* enter -- value */
944 return(SUCCESS);
945
946
947 case 4: /* interval -- +1200 */
948
949 ltemp = 0;
950
951 for (i = 43; i < 47; i++)
952 ltemp = (ltemp * 10) + (ptdebuf[i] - '0');
953
954 if (ltemp > 1200L) {
955
956 badpdat();
957 return(FAILURE);
958 }
959
960 if (ptdebuf[42] EQ '-')
961 ltemp = -ltemp;
962
963 ptedat2 = (uint16_t)(ltemp << 1);
964 epatch(); /* enter -- interval */
965 return(SUCCESS);
966
967 case 5: /* ratio -- 9/9 */
968
969 ptedat2 = (uint16_t)(ndvals[ptdebuf[42] - '0'] -
970 ndvals[ptdebuf[44] - '0']);
971
972 epatch(); /* enter -- ratio */
973 return(SUCCESS);
974
975 case 6: /* frequency -- 15.9 */
976
977 ltemp = ((ptdebuf[42] - '0') * 100) +
978 ((ptdebuf[43] - '0') * 10) +
979 (ptdebuf[45] - '0');
980
981 if (ltemp > 159L) {
982
983 badpdat();
984 return(FAILURE);
985 }
986
987 ptedat2 = (uint16_t)(ltemp << 1);
988 epatch(); /* enter -- frequency */
989 return(SUCCESS);
990
991 case 7: /* pitch -- 9C#99 */
992
993 memcpy(ebuf,& ptdebuf[42], 5);
994
995 if (FAILURE EQ cnvp2c()) {
996
997 badpdat();
998 return(FAILURE);
999 }
1000
1001 ptedat2 = (uint16_t)cents;
1002 epatch(); /* enter - pitch */
1003 return(SUCCESS);
1004
1005 case 8: /* trans/stop/start */
1006 case 9: /* stop/start */
1007 case 10: /* off/on */
1008
1009 epatch(); /* enter -- control */
1010 return(SUCCESS);
1011
1012 case 11: /* source */
1013
1014 if (stccol EQ 42)
1015 setsubm(19, 49); /* select */
1016 else
1017 epatch(); /* enter -- source */
1018
1019 return(SUCCESS);
1020
1021 case 12: /* register/value -- R16 | +99 */
1022
1023 ltemp = ((ptdebuf[43] - '0') * 10) +
1024 (ptdebuf[44] - '0');
1025
1026 if (ptdebuf[42] EQ 'R') {
1027
1028 if ((ltemp EQ 0) OR (ltemp > 16L)) {
1029
1030 badpdat();
1031 return(FAILURE);
1032 }
1033
1034 --ltemp;
1035 ptedat1 = 1;
1036
1037 } else {
1038
1039 ptedat1 = 0;
1040 }
1041
1042 ptedat2 = (uint16_t)ltemp;
1043 epatch(); /* enter -- register | value */
1044 return(SUCCESS);
1045
1046 case 13: /* sequence line */
1047
1048 ltemp = 0;
1049
1050 for (i = 42; i < 45; i++)
1051 ltemp = (ltemp * 10) + (ptdebuf[i] - '0');
1052
1053 ptedat1 = (uint16_t)ltemp;
1054 epatch(); /* enter -- sequence line */
1055 return(SUCCESS);
1056
1057 case 14: /* LED controls */
1058
1059 ltemp = 0;
1060
1061 if (ptesuba & 0x0001) {
1062
1063 for (i = 42; i < 46; i++)
1064 ltemp = (ltemp << 2) | (ptdebuf[i] - '0');
1065
1066 ptedat1 = (uint16_t)(ltemp << 8);
1067
1068 } else {
1069
1070 for (i = 42; i < 45; i++)
1071 ltemp = (ltemp << 2) | (ptdebuf[i] - '0');
1072
1073 ptedat1 = (uint16_t)(ltemp << 10);
1074 }
1075
1076 epatch(); /* enter -- LED controls */
1077 return(SUCCESS);
1078
1079
1080 case 15: /* instrument number */
1081
1082 ltemp = ((ptdebuf[42] - '0') * 10) +
1083 (ptdebuf[43] - '0');
1084
1085 if (ltemp > 40L) {
1086
1087 badpdat();
1088 return(FAILURE);
1089 }
1090
1091 ptedat1 = (uint16_t)ltemp;
1092 epatch(); /* enter -- instrument number */
1093 return(SUCCESS);
1094
1095 case 16: /* waveshape number */
1096
1097 ltemp = ((ptdebuf[42] - '0') * 10) +
1098 (ptdebuf[43] - '0');
1099
1100 if ((ltemp EQ 0) OR (ltemp > 20L)) {
1101
1102 badpdat();
1103 return(FAILURE);
1104 }
1105
1106 ptedat1 = (uint16_t)ltemp;
1107 epatch(); /* enter -- waveshape number */
1108 return(SUCCESS);
1109
1110 case 17: /* configuration number */
1111
1112 ltemp = ((ptdebuf[42] - '0') * 10) +
1113 (ptdebuf[43] - '0');
1114
1115 if (ltemp > 11L) {
1116
1117 badpdat();
1118 return(FAILURE);
1119 }
1120
1121 ptedat1 = (uint16_t)ltemp;
1122 epatch(); /* enter -- configuration number */
1123 return(SUCCESS);
1124
1125 case 18: /* tuning table number */
1126
1127 ptedat1 = (uint16_t)(ptdebuf[42] - '0');
1128 epatch(); /* enter -- tuning table number */
1129 return(SUCCESS);
1130
1131 default: /* something weird got in here ... */
1132
1133 ptedtok = FALSE;
1134 return(FAILURE);
1135 }
1136 }
1137
1138 return(FAILURE);
1139
1140 } else { /* SUBMENU SELECTION */
1141
1142 /* determine the "box" we're pointing at */
1143
1144 if (inrange(vtccol, 2, 4))
1145 box = vtcrow - 18;
1146 else if (inrange(vtccol, 7, 12))
1147 box = vtcrow - 13;
1148 else if (inrange(vtccol, 15, 19))
1149 box = vtcrow - 8;
1150 else if (inrange(vtccol, 22, 26))
1151 box = vtcrow - 3;
1152 else if (inrange(vtccol, 29, 33))
1153 box = vtcrow + 2;
1154 else if (inrange(vtccol, 36, 40))
1155 box = vtcrow + 7;
1156 else if (inrange(vtccol, 43, 46))
1157 box = vtcrow + 12;
1158 else if (inrange(vtccol, 49, 53))
1159 box = vtcrow + 17;
1160 else if (inrange(vtccol, 56, 60))
1161 box = vtcrow + 22;
1162 else
1163 return(FAILURE);
1164
1165
1166 switch (ptemenu) { /* switch on submenu type */
1167
1168 case HT_0: /* DEFINERS / STIMULLI */
1169
1170 if (inrange(box, 1, 4)) { /* Key, Rel, Trg, Pls */
1171
1172 i = box - 1;
1173 ptedfst = dfsttp[i];
1174
1175 if (ptedftp EQ 1) { /* def */
1176
1177 ptedfok = TRUE;
1178 ptbflag = TRUE;
1179
1180 ptedef = dfsttab[i];
1181
1182 strcpy(&ptdebuf[2], rawdfst[i]);
1183
1184 UpdVid(7, 2, rawdfst[i], PTDATR);
1185 endpsm(DATAROW, defcols[ptedfst]);
1186
1187 return(SUCCESS);
1188
1189 } else if (ptedftp EQ 2) { /* stm */
1190
1191 ptestok = TRUE;
1192 ptbflag = TRUE;
1193
1194 ptestm = dfsttab[i];
1195
1196 strcpy(&ptdebuf[15], rawdfst[i]);
1197
1198 UpdVid(7, 15, rawdfst[i], PTDATR);
1199 endpsm(DATAROW, stmcols[ptedfst]);
1200
1201 return(SUCCESS);
1202 }
1203 }
1204
1205 return(FAILURE);
1206
1207 case HT_1: /* SOURCES */
1208
1209 if (inrange(box, 36, 45)) {
1210
1211 ptedtok = TRUE;
1212 ptbflag = TRUE;
1213
1214 ptedat2 = datasrc[box - 36];
1215
1216 strcpy(&ptdebuf[42], smdata[ptedat2]);
1217
1218 UpdVid(7, 42, smdata[ptedat2], PTDATR);
1219 endpsm(DATAROW, 46);
1220
1221 return(SUCCESS);
1222 }
1223
1224 return(FAILURE);
1225
1226 case HT_2: /* DESTINATIONS */
1227
1228 i = box - 1;
1229 ptt = destype[i];
1230
1231 if (ptt NE -1) {
1232
1233 ptedsok = TRUE;
1234 ptedtok = TRUE;
1235 ptbflag = TRUE;
1236
1237 ptedest = destfmt[i];
1238 ptedata = datafmt[i];
1239 ptespec = (uint16_t)ptt;
1240 ptesuba = 0x0000;
1241 ptedat1 = 0x0000;
1242 ptedat2 = 0x0000;
1243
1244 if (ptd = desdatf[i]) {
1245
1246 if (ptd & 1)
1247 ptedat1 = desdat1[i];
1248
1249 if (ptd & 2)
1250 ptedat2 = desdat2[i];
1251 }
1252
1253 strcpy(&ptdebuf[28], rawdest[ptt]);
1254 strcpy(&ptdebuf[42], rawdata[i]);
1255
1256 UpdVid(7, 28, rawdest[ptt], PTDATR);
1257 UpdVid(7, 42, rawdata[i], PTDATR);
1258 endpsm(DATAROW, dstcols[1 + ptedest]);
1259
1260 return(SUCCESS);
1261 }
1262
1263 return(FAILURE);
1264
1265 case HT_3: /* OSCILLATOR MODES */
1266
1267 if (inrange(box, 17, 20)) {
1268
1269 i = box - 17;
1270
1271 ptedsok = TRUE;
1272 ptedtok = TRUE;
1273 ptbflag = TRUE;
1274
1275 ptedat1 = omtabl[i];
1276 ptedat2 = omdtab[i];
1277
1278 ptedata = omftab[i];
1279
1280 strcpy(&ptdebuf[34], rawmode[i]);
1281 strcpy(&ptdebuf[42], rawmdat[i]);
1282
1283 UpdVid(7, 34, rawmode[i], PTDATR);
1284 UpdVid(7, 42, rawmdat[i], PTDATR);
1285 endpsm(DATAROW, 39);
1286
1287 return(SUCCESS);
1288 }
1289
1290 return(FAILURE);
1291
1292 case HT_5: /* FPU OUTPUTS WITHOUT FUNCTIONS */
1293
1294 if (NOT inrange(box, 31, 34))
1295 return(FAILURE);
1296
1297 case HT_4: /* FPU OUTPUTS WITH FUNCTIONS */
1298
1299 if (NOT inrange(box, 31, 35))
1300 return(FAILURE);
1301
1302 i = box - 31;
1303
1304 ptedsok = TRUE;
1305 ptedtok = TRUE;
1306 ptbflag = TRUE;
1307
1308 ptedat1 = (uint16_t)i;
1309 ptedat2 = (uint16_t)fpudtab[i];
1310
1311 ptedata = fpuetab[i];
1312
1313 strcpy(&ptdebuf[34], stdata[i]);
1314 strcpy(&ptdebuf[42], rawfpud[i]);
1315
1316 UpdVid(7, 34, stdata[i], PTDATR);
1317 UpdVid(7, 42, rawfpud[i], PTDATR);
1318 endpsm(DATAROW, 42);
1319
1320 return(SUCCESS);
1321
1322 default: /* -BOGUS- */
1323
1324 endpsm(stcrow, stccol);
1325
1326 return(FAILURE);
1327 }
1328 }
1329
1330 return(FAILURE);
1331}
1332
Note: See TracBrowser for help on using the repository browser.