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

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

Zero redundant declarations.

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