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

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

Added missing includes and declarations.

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