source: buchla-68k/orig/RAM/SENDVAL.C@ abd4109

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

Imported original source code.

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