source: buchla-68k/ram/sendval.c@ 6262b5c

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

Added include files for global functions and variables.

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