source: buchla-68k/ram/sendval.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: 5.4 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 "m7ver.h"
9#include "stddefs.h"
10#include "biosdefs.h"
11#include "graphdef.h"
12#include "vsdd.h"
13#include "vsddsw.h"
14#include "vsddvars.h"
15#include "hwdefs.h"
16#include "memory.h"
17#include "fpu.h"
18#include "panel.h"
19
20#include "midas.h"
21#include "instdsp.h"
22#include "score.h"
23#include "scdsp.h"
24#include "scfns.h"
25#include "wsdsp.h"
26
27/* functions defined elsewhere */
28
29extern uint16_t tofpu(uint16_t time);
30
31extern uint16_t setipl(uint16_t arg);
32
33extern int16_t addpch(int16_t p1, int16_t p2);
34extern void clrpfl(void);
35extern void fpuclr(void);
36extern void l_init(int16_t stat, int16_t sig);
37extern void setdyn(int16_t grp, int16_t dyn);
38extern void setloc(int16_t grp, int16_t loc);
39extern void settune(void);
40
41extern int16_t amplval, ext_cv1, ext_cv2, ext_cv3, ext_cv4, ext_mod;
42extern int16_t lstbgnc, lstendc, ps_intn, ps_rate, ps_dpth, sliders;
43
44extern int16_t lastart[];
45extern int16_t dyntab[];
46extern int16_t expbit[];
47extern int16_t fnoff[];
48extern int16_t fp_resv[];
49extern int16_t grpdyn[];
50extern int16_t grploc[];
51extern int16_t lastvce[];
52extern int16_t prstab[];
53extern int16_t vce2grp[];
54extern int16_t vce2trg[];
55extern int16_t veltab[];
56
57extern int16_t sigtab[128][2];
58
59extern int8_t keystat[];
60extern int8_t mpsust[];
61extern int8_t trgtab[];
62
63extern struct n_entry *lstbgns[NLSTENTS];
64extern struct n_entry *lstends[NLSTENTS];
65
66/*
67
68*/
69
70/*
71 =============================================================================
72 sendval() -- send a value to a voice parameter
73 =============================================================================
74*/
75
76void sendval(int16_t voice, int16_t par, int16_t ival)
77{
78 register uint16_t *fpu;
79 register int16_t oldi, val;
80 register int32_t ltmp;
81 int16_t nop;
82
83 fpu = io_fpu + FPU_OFNC + (voice << 8) + (par << 4);
84
85 switch (par) {
86
87 case 1: /* freq 1 */
88 case 3: /* freq 2 */
89 case 5: /* freq 3 */
90 case 7: /* freq 4 */
91
92 val = addpch(ival, 0);
93 break;
94
95 case 4: /* location */
96
97 val = (ival << 1) ^ 0x8000;
98 break;
99
100 case 10: /* filter */
101
102 ltmp = ((int32_t)ival >> 1) + ((int32_t)ival >>2);
103
104 if (ltmp GT (int32_t)VALMAX)
105 ltmp = (int32_t)VALMAX;
106 else if (ltmp LT (int32_t)VALMIN)
107 ltmp = (int32_t)VALMIN;
108
109 val = (int16_t)ltmp;
110 break;
111/*
112
113*/
114 case 2: /* level */
115
116 val = (((int16_t)ival >> 5) - 500) << 6;
117 break;
118
119 default:
120
121 val = ival;
122 }
123
124 oldi = setipl(FPU_DI);
125
126/* ++++++++++++++++++++++++++++ FPU interrupts disabled +++++++++++++++++++++ */
127
128 *(fpu + (int32_t)FPU_TNV0) = val;
129 ++nop; ++nop; ++nop;
130 *(fpu + (int32_t)FPU_TNV1) = val;
131 ++nop; ++nop; ++nop;
132 *(fpu + (int32_t)FPU_TCTL) = 0x0015;
133
134 setipl(oldi);
135
136/* ++++++++++++++++++++++++++++ Interrupts restored +++++++++++++++++++++++++ */
137
138}
139
140/*
141
142*/
143
144/*
145 =============================================================================
146 clearer() -- clear the FPU
147 =============================================================================
148*/
149
150void clearer(int16_t stat, int16_t sig)
151{
152 register uint16_t *fpu;
153 register uint16_t fpexp, fpmant, fptime;
154 register int16_t oldi, i;
155 int16_t nop, olds;
156
157 if (stat) {
158
159 fp_resv[0] = 0x8300; /* amplitude (off) */
160 fp_resv[1] = (ps_intn * 10) << 5; /* intensity */
161 fp_resv[2] = (ps_rate * 10) << 5; /* sweep rate */
162 fp_resv[3] = (ps_dpth * 10) << 5; /* sweep depth */
163 fp_resv[4] = 0; /* - unused - */
164 fp_resv[5] = 0; /* - unused - */
165 fp_resv[6] = ext_cv3; /* CV-3 */
166 fp_resv[7] = 0; /* - unused - */
167 fp_resv[8] = ext_cv4; /* CV-4 */
168 fp_resv[9] = ext_mod; /* Aux Signal Mod */
169 fp_resv[10] = ext_cv2; /* CV-2 */
170 fp_resv[11] = ext_cv1; /* CV-1 */
171
172 fpu = io_fpu + FPU_OFNC; /* setup to set slew rate */
173 fptime = tofpu(AMP_TIME);
174 fpexp = expbit[fptime & 0x000F];
175 fpmant = fptime & 0xFFF0;
176/*
177
178*/
179 oldi = setipl(FPU_DI); /* disable FPU interrupts */
180
181/* ++++++++++++++++++++++++++++ FPU interrupts disabled +++++++++++++++++++++ */
182
183 fpuclr(); /* reset the FPU to nominal */
184
185 *(fpu + FPU_TMNT) = fpmant; /* set amplitude slew rate */
186 ++nop; ++nop;
187 *(fpu + FPU_TEXP) = fpexp;
188
189 /* reset execution control tables */
190
191 memset(trgtab, 0, NTRIGS); /* trigger table */
192 memset(keystat, 0, 24); /* local key status */
193
194 memsetw(prstab, 0, NTRIGS); /* pressure table */
195 memsetw(veltab, SM_SCALE(64), NTRIGS); /* velocity table */
196
197 clrpfl(); /* clear pendant functions */
198
199 for (i = 0; i < 48; i++) /* sustain pedal table */
200 mpsust[i] = 0;
201
202 for (i = 0; i < 12; i++) {
203
204 vce2trg[i] = -1; /* voice to trigger table */
205 lastvce[i] = 0; /* last voice used table */
206 }
207
208 olds = sliders; /* reset articulation pots */
209 sliders = LS_PRMTR;
210 l_init(1, 0);
211 sliders = LS_OTHER;
212 l_init(1, 0);
213 sliders = olds;
214
215 setipl(oldi); /* restore interrupts */
216
217/* ++++++++++++++++++++++++++++ Interrupts restored +++++++++++++++++++++++++ */
218
219/*
220
221*/
222 lstbgnc = 0; /* reset last note begin count */
223 lstendc = 0; /* reset last note end count */
224
225 memsetw(lstbgns, 0, (NLSTENTS << 1)); /* clear begin table */
226 memsetw(lstends, 0, (NLSTENTS << 1)); /* clear end table */
227
228 /* re-establish dynamics and locations */
229
230 for (i = 0; i < 12; i++) {
231
232 setdyn(i, grpdyn[i]);
233 setloc(i, grploc[i]);
234 }
235
236 settune(); /* set tuning */
237 sendval(0, 0, amplval); /* set amplitude */
238 }
239}
Note: See TracBrowser for help on using the repository browser.