source: buchla-68k/ram/ptfield.c@ f4fbee9

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

Code compiles, doesn't link.

  • Property mode set to 100644
File size: 16.3 KB
Line 
1/*
2 =============================================================================
3 ptfield.c -- MIDAS-VII patch display field functions
4 Version 35 -- 1989-11-16 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#define DEBUGXP 0
9
10#define USEVECTR 0 /* to force vector cursor control */
11
12#include "stddefs.h"
13#include "hwdefs.h"
14#include "graphdef.h"
15#include "vsdd.h"
16#include "fields.h"
17#include "curpak.h"
18#include "patch.h"
19#include "macros.h"
20
21#include "midas.h"
22#include "ptdisp.h"
23
24#if DEBUGXP
25extern short debugsw;
26
27short debugxp = 1;
28#endif
29
30#if USEVECTR
31short usevect = TRUE;
32
33extern short (*cx_key)(), (*cy_key)();
34#endif
35
36extern short (*xy_up)(), (*xy_dn)();
37extern short (*premove)(), (*pstmove)();
38extern short (*curtype)();
39
40extern unsigned short fromfpu();
41
42extern short select(), nokey(), stdctp5();
43extern short cxkstd(), cykstd(), stdmkey(), stddkey();
44extern short stopcm(), smxupd(), smyupd();
45extern short aftercm();
46extern short ptdkey();
47
48extern short astat;
49extern short chtime;
50extern short chwait;
51extern short cmfirst;
52extern short cmtype;
53extern short curhold;
54extern short cvtime;
55extern short cvwait;
56extern short ncvwait;
57extern short ptbflag;
58extern short ptecpos;
59extern short ptedef;
60extern short ptedfok;
61extern short pteset;
62extern short ptestm;
63extern short ptestok;
64extern short ss_ptsw;
65extern short ss_sqsw;
66extern short stccol;
67extern short stcrow;
68extern short syrate;
69extern short tvcwval;
70extern short vcwval;
71
72extern short crate1[];
73
74extern char ptdebuf[];
75
76extern struct selbox *csbp;
77extern struct selbox ptboxes[];
78
79extern struct patch ptebuf;
80
81short ptxkey(); /* forward reference */
82short ptmkey(); /* forward reference */
83short ptekey(); /* forward reference */
84
85/*
86
87*/
88
89char *trdata[] = { "Trans", "Stop ", "Start" };
90char *ssdata[] = { "Stop ", "Start" };
91
92char *stdata[] = { "Srce" , "Mult", "Time", "Valu", "Func" };
93
94char *smdata[] = {
95
96 " ", /* SM_NONE 0 No source - always 0 */
97 "Randm", /* SM_RAND 1 Random source */
98 "GPC/V", /* SM_CTL1 2 Control Voltage 1 / MIDI GPC 1 */
99 "??3??", /* ------- 3 -unused- */
100 "??4??", /* ------- 4 -unused- */
101 "Pitch", /* SM_PTCH 5 Key Pitch */
102 "KeyPr", /* SM_KPRS 6 Key Pressure */
103 "KeyVL", /* SM_KVEL 7 Key Velocity */
104 "Pedal", /* SM_PED1 8 Pedal 1 */
105 "??9??", /* ------- 9 -unused- */
106 "Freq ", /* SM_FREQ 10 Key Frequency */
107 "PchWh", /* SM_HTPW 11 Tablet X / MIDI Pitch Wheel */
108 "ModWh", /* SM_VTMW 12 Tablet Y / MIDI Mod Wheel */
109 "Breth", /* SM_LPBR 13 LongPot / MIDI Breath Controller */
110};
111
112struct curpak pt_flds = {
113
114 stdctp5, /* curtype */
115 nokey, /* premove */
116 aftercm, /* pstmove */
117 cxkstd, /* cx_key */
118 cykstd, /* cy_key */
119 smxupd, /* cx_upd */
120 smyupd, /* cy_upd */
121 stopcm, /* xy_up */
122 nokey, /* xy_dn */
123 ptxkey, /* x_key */
124 ptekey, /* e_key */
125 ptmkey, /* m_key */
126 ptdkey, /* d_key */
127 nokey, /* not_fld */
128 (struct fet *)NULL, /* curfet */
129 ptboxes, /* csbp */
130 crate1, /* cratex */
131 crate1, /* cratey */
132 CT_SMTH, /* cmtype */
133 CTOX(2), /* cxval */
134 RTOY(DATAROW) /* cyval */
135};
136
137/*
138
139*/
140
141/*
142 =============================================================================
143 ptmkey() -- M key processing for the patch display
144 =============================================================================
145*/
146
147short
148ptmkey()
149{
150 register short nc;
151
152 if (astat) {
153
154 if (stccol EQ 48) {
155
156 if (ss_sqsw EQ 0) {
157
158 (*xy_dn)(); /* handle KEY_DOWN functions */
159
160 (*premove)(); /* handle PRE-MOVE functions */
161
162 nc = (*curtype)(); /* get new CURSOR TYPE wanted */
163
164 cvtime = syrate;
165 ncvwait = curhold;
166
167 ss_ptsw = -1;
168 cmtype = nc;
169 cvwait = 1;
170 }
171
172 } else
173 stdmkey();
174
175 } else {
176
177 if (stccol EQ 48) {
178
179 ss_ptsw = 0;
180 cvwait = 1;
181 ncvwait = cvtime;
182 cmfirst = TRUE;
183
184 if (ss_sqsw EQ 0)
185 (*xy_up)();
186
187 (*pstmove)(); /* handle POST-MOVE functions */
188
189 } else
190 stdmkey();
191 }
192}
193
194/*
195
196*/
197
198/*
199 =============================================================================
200 ptekey() -- E key processing for the patch display
201 =============================================================================
202*/
203
204short
205ptekey()
206{
207 register short nc;
208
209 if (astat) {
210
211 if (stccol EQ 48) {
212
213 if (ss_sqsw EQ 0) {
214
215 (*xy_dn)(); /* handle KEY_DOWN functions */
216
217 (*premove)(); /* handle PRE-MOVE functions */
218
219 nc = (*curtype)(); /* get new CURSOR TYPE wanted */
220
221 cvtime = syrate;
222 ncvwait = curhold;
223
224 ss_ptsw = 1;
225 cmtype = nc;
226 cvwait = 1;
227 }
228
229 } else
230 select();
231
232 } else {
233
234 if (stccol EQ 48) {
235
236 ss_ptsw = 0;
237 cvwait = 1;
238 ncvwait = cvtime;
239 cmfirst = TRUE;
240
241 if (ss_sqsw EQ 0)
242 (*xy_up)();
243
244 (*pstmove)(); /* handle POST-MOVE functions */
245
246 } else
247 select();
248 }
249}
250
251/*
252
253*/
254
255/*
256 =============================================================================
257 ptxkey() -- X key processing for the patch display
258 =============================================================================
259*/
260
261short
262ptxkey()
263{
264 register short i, cp, pp, sp, stm;
265
266 if (NOT astat) /* only on key closures ... */
267 return;
268
269 if (inrange(stccol, 2, 13)) { /* definer -- clear definer */
270
271 if (ptecpos AND NOT ptbflag) { /* refresh data entry stuff */
272
273 memcpyw(&ptebuf.defnum, &patches[ptecpos].defnum, 6);
274 pteset = TRUE;
275 pte2buf();
276 }
277
278 ptedef = NULL_DEF;
279 ptedfok = TRUE;
280
281 memset(&ptdebuf[2], ' ', 12);
282
283 for (i = 0; i < 48; i++)
284 if (ptdebuf[i] EQ '\0')
285 ptdebuf[i] = ' ';
286
287 ptdebuf[0] = '\260';
288 ptdebuf[48] = '\0';
289
290 UpdVid(7, 0, ptdebuf, PTEATR);
291 movectc(stcrow, stccol);
292
293/*
294
295*/
296 } else if (inrange(stccol, 15, 26)) { /* stimulus -- clear stimulus */
297
298 if (ptecpos AND NOT ptbflag) { /* refresh data entry stuff */
299
300 memcpyw(&ptebuf.defnum, &patches[ptecpos].defnum, 6);
301 pteset = TRUE;
302 pte2buf();
303 }
304
305 ptestm = NULL_DEF;
306 ptestok = FALSE;
307
308 memset(&ptdebuf[15], ' ', 12);
309
310 for (i = 0; i < 48; i++)
311 if (ptdebuf[i] EQ '\0')
312 ptdebuf[i] = ' ';
313
314 ptdebuf[0] = '\260';
315 ptdebuf[48] = '\0';
316
317 UpdVid(7, 0, ptdebuf, PTEATR);
318 movectc(stcrow, stccol);
319
320 } else if (inrange(stccol, 28, 40)) { /* destination -- clear line */
321
322 voidpb(); /* void the patch buffer */
323
324 ptdebuf[0] = '\260';
325 ptdebuf[48] = '\0';
326
327 UpdVid(7, 0, ptdebuf, PTEATR);
328 movectc(stcrow, stccol);
329/*
330
331*/
332 } else if (inrange(stccol, 42, 46)) { /* datum -- delete the patch */
333
334 if (ptecpos) {
335
336 cp = ptecpos; /* setup indices */
337 pp = patches[cp].prevstm;
338 sp = patches[cp].nextstm;
339
340 stm = patches[cp].stmnum; /* get stimulus used */
341#if DEBUGXP
342 if (debugsw AND debugxp)
343 printf("ptxkey(): DELETING PATCH pp = %d cp = %d sp = %d\n",
344 pp, cp, sp);
345#endif
346
347 if (pp) /* adjust predecessor */
348 patches[pp].nextstm = sp;
349 else /* adjust stmptr */
350 stmptr[TRG_MASK & stm] = sp;
351
352 if (sp) /* adjust successor */
353 patches[sp].prevstm = pp;
354
355 if (sp = findnxt(cp)) /* adjust ptecpos */
356 ptecpos = sp;
357 else if (pp = findprv(cp))
358 ptecpos = pp;
359 else
360 ptecpos = 0;
361
362 pt_del(cp); /* delete the patch entry */
363/*
364
365*/
366 for (i = 0; i < NDEFSTMS; ++i) { /* adjust defptr list */
367
368 if (cp = defptr[i]) { /* in use ? */
369
370 pp = 0; /* initial predecessor */
371
372 while (cp) { /* check the chain */
373
374 sp = defents[cp].nextdef; /* successor */
375
376 if (defents[cp].stm EQ stm) {
377
378#if DEBUGXP
379 if (debugsw AND debugxp) {
380
381 printf("ptxkey(): DELETING DEF trg=$%04.4X stm=$%04.4X\n",
382 i, stm);
383
384 printf("ptxkey(): DELETING DEF pp=%d cp=%d sp=%d\n",
385 pp, cp, sp);
386 }
387#endif
388
389 if (pp) /* adjust predecessor */
390 defents[pp].nextdef = sp;
391 else /* adjust defptr */
392 defptr[i] = sp;
393
394 dt_del(cp); /* delete def entry */
395
396 } else {
397
398 pp = cp; /* update predecessor index */
399 }
400
401 cp = sp; /* next defent */
402 }
403 }
404 }
405
406 dptw(); /* update the display */
407 }
408 }
409}
410
411/*
412
413*/
414
415/*
416 =============================================================================
417 dspdfst() -- convert a patch DEF or STM value for display
418 =============================================================================
419*/
420
421dspdfst(buf, val)
422char *buf;
423register unsigned short val;
424{
425 register unsigned short chan, port, stim;
426
427 if (val EQ NULL_DEF) { /* handle possible blank definer */
428
429 strcpy(buf, " ");
430 return;
431 }
432
433 port = (val >> 11) & 0x0003;
434 chan = (val >> 7) & 0x000F;
435 stim = val & 0x007F;
436
437 switch (port) { /* use port to decode possible types */
438
439 case 0: /* MIDI-1 - Keys */
440 case 1: /* MIDI-2 - Keys */
441
442 sprintf(buf, "%s %03u %u %02u",
443 (val & 0x8000) ? "Rel" : "Key",
444 1 + stim, 1 + port, 1 + chan);
445
446 break;
447/*
448
449*/
450
451 case 2: /* Local Keys */
452
453 switch (chan) { /* use channel to further decode */
454
455 case 0: /* Keys - Local Keyboard */
456
457 sprintf(buf, "%s %03u L ",
458 (val & 0x8000) ? "Rel" : "Key",
459 1 + stim);
460
461 break;
462
463 case 2: /* Triggers */
464
465 sprintf(buf, "Trig %02u ", 1 + stim);
466 break;
467
468 case 3: /* Pulses */
469
470 sprintf(buf, "Pulse %u ", 1 + stim);
471 break;
472
473 default: /* spurious type -- shouldn't happen */
474
475 sprintf(buf, "%s?? %03u L %02u",
476 (val & 0x8000) ? "r" : "c",
477 1 + stim, 1 + chan);
478 break;
479
480 }
481
482 break;
483
484 default: /* spurious port -- should never happen */
485
486 sprintf(buf, "??? %03u %u %02u", 1 + stim, 1 + port, 1 + chan);
487 break;
488 }
489}
490
491/*
492
493*/
494
495/*
496 =============================================================================
497 dfpdat() -- convert FPU datum for display
498 =============================================================================
499*/
500
501char *
502dfpdat(pp)
503register struct patch *pp;
504{
505 static char buf[32];
506 unsigned short sgn, vp1, vp2;
507 short val;
508
509 val = pp->padat2;
510
511 switch (pp->padat1) {
512
513 case PSA_SRC: /* source */
514
515 strcpy(buf, smdata[val]);
516 break;
517
518 case PSA_MLT: /* multiplier */
519
520 fr2dec(val, ebuf);
521
522 buf[0] = ebuf[3];
523 buf[1] = ebuf[0];
524 buf[2] = '.';
525 buf[3] = ebuf[1];
526 buf[4] = ebuf[2];
527 buf[5] = '\0';
528 break;
529/*
530
531*/
532 case PSA_VAL: /* value */
533
534 val >>= 5;
535
536 if (val < 0) {
537
538 val = -val;
539 sgn = '-';
540
541 } else {
542
543 sgn = '+';
544 }
545
546 vp1 = val / 100;
547 vp2 = val - (vp1 * 100);
548
549 if (vp1 > 9) {
550
551 vp1 = 0;
552
553 if (sgn EQ '+')
554 sgn = '\240';
555 else
556 sgn = '\241';
557 }
558
559 sprintf(buf, "%c%u.%02u", sgn, vp1, vp2);
560 break;
561/*
562
563*/
564 case PSA_TIM: /* time */
565
566 vp1 = fromfpu(val);
567
568 sprintf(buf, "%5u", vp1);
569 break;
570
571 case PSA_FNC: /* function / control */
572
573 if ((PE_SPEC & pp->paspec) EQ PA_AUX)
574 sprintf(buf, "%s", (val & 0x0001) ? "On " : "Off ");
575 else
576 sprintf(buf, "%s", (val & 0x0001) ? "Start" : "Stop ");
577
578 break;
579
580 default:
581
582 sprintf(buf, "$%04.4X", val);
583 break;
584 }
585
586 return(buf);
587}
588
589/*
590
591*/
592
593/*
594 =============================================================================
595 pafpu1() -- convert patch for display -- aaaaa ssss tn ddddd
596
597 Level, Filtr, Fil Q, Loctn, Dynmc
598 =============================================================================
599*/
600
601pafpu1(bf, ad, gt, gn, pp)
602char *bf;
603char *ad;
604unsigned short gt, gn;
605register struct patch *pp;
606{
607 sprintf(bf, "%s %s %c%c %s", ad, stdata[pp->padat1], gt, gn, dfpdat(pp));
608}
609
610/*
611 =============================================================================
612 pafpu2() -- convert patch for display -- aaa n ssss tn ddddd
613
614 Index, Freq
615 =============================================================================
616*/
617
618pafpu2(bf, ad, os, gt, gn, pp)
619char *bf;
620char *ad;
621unsigned short os, gt, gn;
622register struct patch *pp;
623{
624 sprintf(bf, "%s %d %s %c%c %s", ad, os, stdata[pp->padat1], gt, gn, dfpdat(pp));
625}
626
627/*
628 =============================================================================
629 pafpu3() -- convert patch for display -- aaaaa ssss ddddd
630
631 Aux, Rate, Inten, Depth, Vlt
632 =============================================================================
633*/
634
635pafpu3(bf, ad, pp)
636char *bf;
637char *ad;
638register struct patch *pp;
639{
640 sprintf(bf, "%s %s %s", ad, stdata[pp->padat1], dfpdat(pp));
641}
642
643/*
644
645*/
646
647/*
648 =============================================================================
649 dspdest() -- convert patch destination and datum for display
650 =============================================================================
651*/
652
653dspdest(buf, pp)
654char *buf;
655register struct patch *pp;
656{
657 unsigned short chan, osc, port, stim, vg, vgt, vgn, vp1, vp2, sgn;
658 short val;
659 char buf2[16], *rtype;
660
661 port = (pp->pasuba >> 11) & 0x0003; /* for trg types */
662 chan = (pp->pasuba >> 7) & 0x000F;
663 stim = pp->pasuba & 0x007F;
664
665 vg = (pp->pasuba >> 8) & 0x00FF; /* for vg types */
666 osc = (pp->pasuba & 0x00FF) + 1;
667
668 if (vg > 11) {
669
670 vgt = 'G';
671 vgn = vg - 11;
672
673 } else {
674
675 vgt = 'V';
676 vgn = vg + 1;
677 }
678
679 vgn = vgn + ((vgn > 9) ? '\242' : '0');
680
681/*
682
683*/
684 switch (PE_SPEC & pp->paspec) {
685
686 case PA_KEY: /* key action */
687
688 sprintf(buf, "K %03u %u %02u %s",
689 1 + stim, 1 + port, 1 + chan,
690 trdata[pp->padat2 & 0x0003]);
691
692 break;
693
694 case PA_TRG:
695
696 sprintf(buf, "Trigger %02u %s",
697 1 + stim,
698 ssdata[pp->padat2 & 0x0001]);
699
700 break;
701
702 case PA_PLS:
703
704 sprintf(buf, "Pulse %u %s",
705 1 + stim,
706 trdata[pp->padat2 & 0x0003]);
707
708 break;
709/*
710
711*/
712 case PA_LED:
713
714 if (pp->pasuba & 0x0001) {
715
716 sprintf(buf, "LED %c %c%c%c%c",
717 'A' + pp->pasuba,
718 '0' + ((pp->padat1 >> 14) & 0x0003),
719 '0' + ((pp->padat1 >> 12) & 0x0003),
720 '0' + ((pp->padat1 >> 10) & 0x0003),
721 '0' + ((pp->padat1 >> 8) & 0x0003));
722
723 } else {
724
725 sprintf(buf, "LED %c %c%c%c",
726 'A' + pp->pasuba,
727 '0' + ((pp->padat1 >> 14) & 0x0003),
728 '0' + ((pp->padat1 >> 12) & 0x0003),
729 '0' + ((pp->padat1 >> 10) & 0x0003));
730 }
731
732 break;
733
734 case PA_SLIN:
735
736 sprintf(buf, "Seq %02u Lin %03u",
737 1 + pp->pasuba,
738 pp->padat1);
739
740 break;
741
742 case PA_SCTL:
743
744 sprintf(buf, "Seq %02u Ctl %s",
745 1 + pp->pasuba,
746 ssdata[pp->padat2 & 0x0001]);
747
748 break;
749
750 case PA_TUNE:
751
752 sprintf(buf, "Tune Table %u",
753 pp->padat1);
754
755 break;
756/*
757
758*/
759 case PA_RSET:
760
761 rtype = "Set";
762 goto doregs;
763
764 case PA_RADD:
765
766 rtype = "Add";
767
768doregs:
769
770 if (pp->padat1 & 0x0001) {
771
772 sprintf(buf, "Reg %02u %s R%02u",
773 1 + pp->pasuba, rtype,
774 1 + pp->padat2);
775
776 } else {
777
778 if ((val = pp->padat2) < 0) {
779
780 sgn = '-';
781 val = - val;
782
783 } else {
784
785 sgn = '+';
786 }
787
788 sprintf(buf, "Reg %02u %s %c%02u",
789 1 + pp->pasuba, rtype,
790 sgn, val);
791 }
792
793 break;
794
795 case PA_INST:
796
797 sprintf(buf, "Instrument %c%c %02u",
798 vgt, vgn, pp->padat1);
799
800 break;
801/*
802
803*/
804 case PA_OSC:
805
806 val = pp->padat2 >> 1;
807
808 switch (pp->padat1) {
809
810 case PSO_INT: /* interval */
811
812 if (val < 0) {
813
814 sgn = '-';
815 val = -val;
816
817 } else {
818
819 sgn = '+';
820 }
821
822 sprintf(buf, "Osc %u Int %c%c %c%04u",
823 osc, vgt, vgn, sgn, val);
824
825 break;
826
827 case PSO_RAT: /* ratio */
828
829 int2rat(val);
830
831 sprintf(buf, "Osc %u Rat %c%c %s",
832 osc, vgt, vgn, ebuf);
833
834 break;
835
836 case PSO_FRQ: /* frequency */
837
838 vp1 = val / 10;
839 vp2 = val - (vp1 * 10);
840
841 sprintf(buf, "Osc %u Frq %c%c %02u.%u",
842 osc, vgt, vgn, vp1, vp2);
843
844 break;
845/*
846
847*/
848 case PSO_PCH: /* pitch */
849
850 cnvc2p(ebuf, val);
851
852 sprintf(buf, "Osc %u Pch %c%c %s",
853 osc, vgt, vgn, ebuf);
854
855 break;
856
857 default:
858
859 break;
860 }
861
862 break;
863/*
864
865*/
866 case PA_WAVA:
867
868 sgn = 'A';
869 goto dowaves;
870
871 case PA_WAVB:
872
873 sgn = 'B';
874
875dowaves:
876
877 sprintf(buf, "Waveshape%c %c%c %02u",
878 sgn, vgt, vgn, pp->padat1);
879
880 break;
881
882 case PA_CNFG:
883
884 sprintf(buf, "Configure %c%c %02u",
885 vgt, vgn, pp->padat1);
886
887 break;
888/*
889
890*/
891 case PA_LEVL:
892
893 pafpu1(buf, "Level", vgt, vgn, pp);
894 break;
895
896 case PA_INDX:
897
898 pafpu2(buf, "Ind", osc, vgt, vgn, pp);
899 break;
900
901 case PA_FREQ:
902
903 pafpu2(buf, "Frq", osc, vgt, vgn, pp);
904 break;
905
906 case PA_FILT:
907
908 pafpu1(buf, "Filtr", vgt, vgn, pp);
909 break;
910
911 case PA_FILQ:
912
913 pafpu1(buf, "Fil Q", vgt, vgn, pp);
914 break;
915
916 case PA_LOCN:
917
918 pafpu1(buf, "Loctn", vgt, vgn, pp);
919 break;
920
921 case PA_DYNM:
922
923 pafpu1(buf, "Dynmc", vgt, vgn, pp);
924 break;
925/*
926
927*/
928 case PA_AUX:
929
930 pafpu3(buf, "Aux ", pp);
931 break;
932
933 case PA_RATE:
934
935 pafpu3(buf, "Rate ", pp);
936 break;
937
938 case PA_INTN:
939
940 pafpu3(buf, "Inten", pp);
941 break;
942
943 case PA_DPTH:
944
945 pafpu3(buf, "Depth", pp);
946 break;
947
948 case PA_VOUT:
949
950 sprintf(buf2, "Vlt %u", pp->pasuba);
951 pafpu3(buf, buf2, pp);
952 break;
953
954 default:
955
956 break;
957 }
958}
959
960/*
961
962*/
963
964/*
965 =============================================================================
966 ptfield() -- setup field routines for the patch editor
967 =============================================================================
968*/
969
970ptfield()
971{
972 curset(&pt_flds);
973
974#if USEVECTR
975 if (usevect) {
976
977 cx_key = cxkstd;
978 cy_key = cykstd;
979 }
980#endif
981
982}
Note: See TracBrowser for help on using the repository browser.