source: buchla-68k/ram/sendval.c@ 7258c6a

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

Use standard integer types.

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