source: buchla-68k/ram/sendval.c

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

Fixed no-op delays.

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/*
2 =============================================================================
3 sendval.c -- MIDAS-VII -- FPU output and clear functions
4 Version 4 -- 1988-09-27 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "ram.h"
9
10/*
11 =============================================================================
12 sendval() -- send a value to a voice parameter
13 =============================================================================
14*/
15
16void sendval(int16_t voice, int16_t par, int16_t ival)
17{
18 volatile uint16_t *fpu;
19 int16_t oldi, val;
20 int32_t ltmp;
21 volatile int16_t nop = 0;
22
23 fpu = io_fpu + FPU_OFNC + (voice << 8) + (par << 4);
24
25 switch (par) {
26
27 case 1: /* freq 1 */
28 case 3: /* freq 2 */
29 case 5: /* freq 3 */
30 case 7: /* freq 4 */
31
32 val = addpch(ival, 0);
33 break;
34
35 case 4: /* location */
36
37 val = (ival << 1) ^ (int16_t)0x8000;
38 break;
39
40 case 10: /* filter */
41
42 ltmp = ((int32_t)ival >> 1) + ((int32_t)ival >>2);
43
44 if (ltmp GT (int32_t)VALMAX)
45 ltmp = (int32_t)VALMAX;
46 else if (ltmp LT (int32_t)VALMIN)
47 ltmp = (int32_t)VALMIN;
48
49 val = (int16_t)ltmp;
50 break;
51
52 case 2: /* level */
53
54 val = (((int16_t)ival >> 5) - 500) << 6;
55 break;
56
57 default:
58
59 val = ival;
60 }
61
62 oldi = setipl(FPU_DI);
63
64/* ++++++++++++++++++++++++++++ FPU interrupts disabled +++++++++++++++++++++ */
65
66 *(fpu + (int32_t)FPU_TNV0) = (uint16_t)val;
67 ++nop; ++nop; ++nop;
68 *(fpu + (int32_t)FPU_TNV1) = (uint16_t)val;
69 ++nop; ++nop; ++nop;
70 *(fpu + (int32_t)FPU_TCTL) = 0x0015;
71
72 setipl(oldi);
73
74/* ++++++++++++++++++++++++++++ Interrupts restored +++++++++++++++++++++++++ */
75
76}
77
78/*
79 =============================================================================
80 clearer() -- clear the FPU
81 =============================================================================
82*/
83
84void clearer(int16_t stat)
85{
86 volatile uint16_t *fpu;
87 uint16_t fpexp, fpmant, fptime;
88 int16_t oldi, i;
89 volatile int16_t nop = 0;
90 int16_t olds;
91
92 if (stat) {
93
94 fp_resv[0] = -32000; /* amplitude (off) */
95 fp_resv[1] = (ps_intn * 10) << 5; /* intensity */
96 fp_resv[2] = (ps_rate * 10) << 5; /* sweep rate */
97 fp_resv[3] = (ps_dpth * 10) << 5; /* sweep depth */
98 fp_resv[4] = 0; /* - unused - */
99 fp_resv[5] = 0; /* - unused - */
100 fp_resv[6] = ext_cv3; /* CV-3 */
101 fp_resv[7] = 0; /* - unused - */
102 fp_resv[8] = ext_cv4; /* CV-4 */
103 fp_resv[9] = ext_mod; /* Aux Signal Mod */
104 fp_resv[10] = ext_cv2; /* CV-2 */
105 fp_resv[11] = ext_cv1; /* CV-1 */
106
107 fpu = io_fpu + FPU_OFNC; /* setup to set slew rate */
108 fptime = tofpu(AMP_TIME);
109 fpexp = expbit[fptime & 0x000F];
110 fpmant = fptime & 0xFFF0;
111
112 oldi = setipl(FPU_DI); /* disable FPU interrupts */
113
114/* ++++++++++++++++++++++++++++ FPU interrupts disabled +++++++++++++++++++++ */
115
116 fpuclr(); /* reset the FPU to nominal */
117
118 *(fpu + FPU_TMNT) = fpmant; /* set amplitude slew rate */
119 ++nop; ++nop;
120 *(fpu + FPU_TEXP) = fpexp;
121
122 /* reset execution control tables */
123
124 memset(trgtab, 0, NTRIGS); /* trigger table */
125 memset(keystat, 0, 24); /* local key status */
126
127 memsetw(prstab, 0, NTRIGS); /* pressure table */
128 memsetw(veltab, SM_SCALE(64), NTRIGS); /* velocity table */
129
130 clrpfl(); /* clear pendant functions */
131
132 for (i = 0; i < 48; i++) /* sustain pedal table */
133 mpsust[i] = 0;
134
135 for (i = 0; i < 12; i++) {
136
137 vce2trg[i] = -1; /* voice to trigger table */
138 lastvce[i] = 0; /* last voice used table */
139 }
140
141 olds = sliders; /* reset articulation pots */
142 sliders = LS_PRMTR;
143 l_init(1, 0);
144 sliders = LS_OTHER;
145 l_init(1, 0);
146 sliders = olds;
147
148 setipl(oldi); /* restore interrupts */
149
150/* ++++++++++++++++++++++++++++ Interrupts restored +++++++++++++++++++++++++ */
151
152
153 lstbgnc = 0; /* reset last note begin count */
154 lstendc = 0; /* reset last note end count */
155
156 memsetw(lstbgns, 0, (NLSTENTS << 1)); /* clear begin table */
157 memsetw(lstends, 0, (NLSTENTS << 1)); /* clear end table */
158
159 /* re-establish dynamics and locations */
160
161 for (i = 0; i < 12; i++) {
162
163 setdyn(i, grpdyn[i]);
164 setloc(i, grploc[i]);
165 }
166
167 settune(); /* set tuning */
168 sendval(0, 0, amplval); /* set amplitude */
169 }
170}
171
Note: See TracBrowser for help on using the repository browser.