1 | /*
|
---|
2 | =============================================================================
|
---|
3 | etimlt.c -- instrument editor - global source / multiplier field
|
---|
4 | Version 14 -- 1988-09-15 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #define DEBUGIT 0
|
---|
9 |
|
---|
10 | #include "stddefs.h"
|
---|
11 | #include "fields.h"
|
---|
12 | #include "vsdd.h"
|
---|
13 | #include "vsddsw.h"
|
---|
14 | #include "vsddvars.h"
|
---|
15 | #include "graphdef.h"
|
---|
16 | #include "charset.h"
|
---|
17 | #include "smdefs.h"
|
---|
18 |
|
---|
19 | #include "midas.h"
|
---|
20 | #include "instdsp.h"
|
---|
21 |
|
---|
22 | #include "stdio.h"
|
---|
23 |
|
---|
24 | #if DEBUGIT
|
---|
25 | extern short debugsw;
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | extern void advicur(void);
|
---|
29 | extern int16_t dec2fr(int8_t *s);
|
---|
30 | extern void dswin(int16_t n);
|
---|
31 | extern void idvlbld(void);
|
---|
32 | extern void ttcpos(int16_t row, int16_t col);
|
---|
33 |
|
---|
34 | extern int8_t *fr2dec(int16_t v, int8_t *s);
|
---|
35 |
|
---|
36 | extern void idvlblc(void);
|
---|
37 | extern void modinst(void);
|
---|
38 |
|
---|
39 | extern uint16_t *instob;
|
---|
40 |
|
---|
41 | extern int16_t stcrow, stccol, curvce, curfunc, idsrcsw;
|
---|
42 | extern int16_t vtcrow, vtccol, submenu;
|
---|
43 |
|
---|
44 | extern int16_t idbox[][8];
|
---|
45 |
|
---|
46 | extern int8_t dspbuf[];
|
---|
47 |
|
---|
48 | extern int8_t *srctbl[];
|
---|
49 |
|
---|
50 | extern struct instpnt *pntptr;
|
---|
51 |
|
---|
52 | extern struct instdef vbufs[];
|
---|
53 |
|
---|
54 | /* |
---|
55 |
|
---|
56 | */
|
---|
57 |
|
---|
58 | /*
|
---|
59 | =============================================================================
|
---|
60 | dsimlt() -- decode a source / multiplier pair for display
|
---|
61 | =============================================================================
|
---|
62 | */
|
---|
63 |
|
---|
64 | int8_t *dsimlt(int8_t *buf, int16_t src, int16_t mltval)
|
---|
65 | {
|
---|
66 | int8_t mltstr[5], mlttmp[5];
|
---|
67 |
|
---|
68 | fr2dec(mltval, mlttmp); /* convert to ASCII from binary */
|
---|
69 |
|
---|
70 | mltstr[0] = mlttmp[3]; /* sign */
|
---|
71 |
|
---|
72 | if (mlttmp[0] EQ '0') /* 1st digit & decimal point */
|
---|
73 | mltstr[1] = '.';
|
---|
74 | else
|
---|
75 | mltstr[1] = SP_1P;
|
---|
76 |
|
---|
77 | mltstr[2] = mlttmp[1]; /* 2nd digit */
|
---|
78 | mltstr[3] = mlttmp[2]; /* 3rd digit */
|
---|
79 | mltstr[4] = '\0'; /* terminate the string */
|
---|
80 |
|
---|
81 | sprintf(buf, "%7.7s %s", srctbl[src], mltstr);
|
---|
82 |
|
---|
83 | #if DEBUGIT
|
---|
84 | if (debugsw)
|
---|
85 | printf("dsimlt($%08.8lX, %d, $%04.4X): [%s]\n",
|
---|
86 | buf, src, mltval, buf);
|
---|
87 | #endif
|
---|
88 |
|
---|
89 | return(buf);
|
---|
90 | }
|
---|
91 |
|
---|
92 | /* |
---|
93 |
|
---|
94 | */
|
---|
95 |
|
---|
96 | /*
|
---|
97 | =============================================================================
|
---|
98 | et_imlt() -- load the edit buffer
|
---|
99 | =============================================================================
|
---|
100 | */
|
---|
101 |
|
---|
102 | int16_t et_imlt(int16_t n)
|
---|
103 | {
|
---|
104 | register struct instdef *ip;
|
---|
105 | register struct idfnhdr *fp;
|
---|
106 |
|
---|
107 | ip = &vbufs[curvce];
|
---|
108 | fp = &ip->idhfnc[curfunc];
|
---|
109 |
|
---|
110 | ebuf[0] = '0' + fp->idfsrc;
|
---|
111 | fr2dec(fp->idfmlt, &ebuf[1]);
|
---|
112 | ebuf[5] = '\0';
|
---|
113 |
|
---|
114 | ebflag = TRUE;
|
---|
115 |
|
---|
116 | #if DEBUGIT
|
---|
117 | if (debugsw)
|
---|
118 | printf("et_imlt(): ebuf=[%s]\n", ebuf);
|
---|
119 | #endif
|
---|
120 |
|
---|
121 | return(SUCCESS);
|
---|
122 | }
|
---|
123 |
|
---|
124 | /* |
---|
125 |
|
---|
126 | */
|
---|
127 |
|
---|
128 | /*
|
---|
129 | =============================================================================
|
---|
130 | ef_imlt() -- parse (unload) the edit buffer (called by 'E' key)
|
---|
131 | =============================================================================
|
---|
132 | */
|
---|
133 |
|
---|
134 | int16_t ef_imlt(int16_t n)
|
---|
135 | {
|
---|
136 | register int16_t i, tmpval, srctmp;
|
---|
137 | register struct instdef *ip;
|
---|
138 | register struct idfnhdr *fp;
|
---|
139 |
|
---|
140 | ip = &vbufs[curvce];
|
---|
141 | fp = &ip->idhfnc[curfunc];
|
---|
142 |
|
---|
143 | ebuf[5] = '\0'; /* terminate the string in ebuf */
|
---|
144 | ebflag = FALSE;
|
---|
145 |
|
---|
146 | #if DEBUGIT
|
---|
147 | if (debugsw)
|
---|
148 | printf("ef_imlt(): ebuf=[%s]\n", ebuf);
|
---|
149 | #endif
|
---|
150 |
|
---|
151 | /* |
---|
152 |
|
---|
153 | */
|
---|
154 | if (idsrcsw) { /* entering the source */
|
---|
155 |
|
---|
156 | idsrcsw = FALSE;
|
---|
157 | submenu = FALSE;
|
---|
158 |
|
---|
159 | if (vtcrow EQ 22) {
|
---|
160 |
|
---|
161 | /* 'PchW/HT', 'Pitch', 'Random', 'GPC/CV1' */
|
---|
162 |
|
---|
163 | if (vtccol LT 24)
|
---|
164 | srctmp = SM_HTPW;
|
---|
165 | else if ((vtccol GT 24) AND (vtccol LT 28))
|
---|
166 | srctmp = SM_PTCH;
|
---|
167 | else if ((vtccol GT 28) AND (vtccol LT 32))
|
---|
168 | srctmp = SM_FREQ;
|
---|
169 | else if ((vtccol GT 32) AND (vtccol LT 40))
|
---|
170 | srctmp = SM_RAND;
|
---|
171 | else
|
---|
172 | srctmp = SM_CTL1;
|
---|
173 |
|
---|
174 | } else if (vtcrow EQ 23) {
|
---|
175 |
|
---|
176 | /* 'ModW/VT', 'Key Vel', 'Pedal 1' */
|
---|
177 |
|
---|
178 | if (vtccol LT 24)
|
---|
179 | srctmp = SM_VTMW;
|
---|
180 | else if ((vtccol GT 24) AND (vtccol LT 32))
|
---|
181 | srctmp = SM_KVEL;
|
---|
182 | else if ((vtccol GT 32) AND (vtccol LT 40))
|
---|
183 | srctmp = SM_PED1;
|
---|
184 | else
|
---|
185 | srctmp = SM_NONE;
|
---|
186 |
|
---|
187 | } else { /* must be row 24 */
|
---|
188 |
|
---|
189 | /* 'PchW/LP', 'Key Prs' */
|
---|
190 |
|
---|
191 | if (vtccol LT 24)
|
---|
192 | srctmp = SM_LPBR;
|
---|
193 | else if ((vtccol GT 24) AND (vtccol LT 32))
|
---|
194 | srctmp = SM_KPRS;
|
---|
195 | else
|
---|
196 | srctmp = SM_NONE;
|
---|
197 | }
|
---|
198 |
|
---|
199 | fp->idfsrc = srctmp; /* set the source */
|
---|
200 | objclr(TTCPRI); /* turn off the menu cursor */
|
---|
201 | idvlblc(); /* blank the menu area */
|
---|
202 | modinst();
|
---|
203 | dswin(22); /* refresh the screen */
|
---|
204 | /* |
---|
205 |
|
---|
206 | */
|
---|
207 | } else if (stccol LT 8) { /* selecting the source */
|
---|
208 |
|
---|
209 | idsrcsw = TRUE; /* set the select switch */
|
---|
210 | submenu = TRUE;
|
---|
211 | idvlbld(); /* load the menu area */
|
---|
212 | dswin(22); /* refresh the screen */
|
---|
213 | SetPri(TTCURS, TTCPRI); /* turn on the typewriter cursor */
|
---|
214 | ttcpos(22, 17); /* position the typewriter cusor */
|
---|
215 |
|
---|
216 | } else if (stccol GT 8) { /* entering the multiplier */
|
---|
217 |
|
---|
218 | tmpval = dec2fr(&ebuf[1]);
|
---|
219 |
|
---|
220 | if (tmpval EQ 0xFFFF)
|
---|
221 | return(FAILURE);
|
---|
222 | else
|
---|
223 | fp->idfmlt = tmpval;
|
---|
224 |
|
---|
225 | modinst();
|
---|
226 |
|
---|
227 | } else
|
---|
228 | return(FAILURE);
|
---|
229 |
|
---|
230 | #if DEBUGIT
|
---|
231 | if (debugsw)
|
---|
232 | printf("ef_imlt(): SUCCESS\n");
|
---|
233 | #endif
|
---|
234 |
|
---|
235 | return(SUCCESS);
|
---|
236 | }
|
---|
237 |
|
---|
238 | /* |
---|
239 |
|
---|
240 | */
|
---|
241 |
|
---|
242 | /*
|
---|
243 | =============================================================================
|
---|
244 | rd_imlt() -- (re)display the field
|
---|
245 | =============================================================================
|
---|
246 | */
|
---|
247 |
|
---|
248 | int16_t rd_imlt(int16_t n)
|
---|
249 | {
|
---|
250 | register struct instdef *ip;
|
---|
251 | register struct idfnhdr *fp;
|
---|
252 |
|
---|
253 | ip = &vbufs[curvce];
|
---|
254 | fp = &ip->idhfnc[curfunc];
|
---|
255 |
|
---|
256 | dsimlt(dspbuf, fp->idfsrc, fp->idfmlt);
|
---|
257 |
|
---|
258 | vcputsv(instob, 64, idbox[n][4], idbox[n][5],
|
---|
259 | idbox[n][6] + 1, idbox[n][7], dspbuf, 14);
|
---|
260 |
|
---|
261 | return(SUCCESS);
|
---|
262 | }
|
---|
263 |
|
---|
264 | /* |
---|
265 |
|
---|
266 | */
|
---|
267 |
|
---|
268 | /*
|
---|
269 | =============================================================================
|
---|
270 | nd_imlt() -- handle new data entry
|
---|
271 | =============================================================================
|
---|
272 | */
|
---|
273 |
|
---|
274 | int16_t nd_imlt(int16_t n, int16_t k)
|
---|
275 | {
|
---|
276 | register int16_t ec;
|
---|
277 |
|
---|
278 | if (idsrcsw) /* not if the source menu is up */
|
---|
279 | return(FAILURE);
|
---|
280 |
|
---|
281 | if (stccol LT 9) /* only in the multiplier field */
|
---|
282 | return(FAILURE);
|
---|
283 |
|
---|
284 | ec = stccol - 9; /* calculate edit buffer column */
|
---|
285 |
|
---|
286 | switch (ec) {
|
---|
287 |
|
---|
288 | case 0: /* sign position */
|
---|
289 |
|
---|
290 | if (k EQ 8) { /* - */
|
---|
291 |
|
---|
292 | ebuf[4] = '-';
|
---|
293 | dspbuf[0] = '-'; /* setup display buffer */
|
---|
294 |
|
---|
295 | } else if (k EQ 9) { /* + */
|
---|
296 |
|
---|
297 | ebuf[4] = '+';
|
---|
298 | dspbuf[0] = '+'; /* setup display buffer */
|
---|
299 |
|
---|
300 | } else
|
---|
301 | return(FAILURE);
|
---|
302 |
|
---|
303 | break;
|
---|
304 |
|
---|
305 | case 1: /* 1st digit position (0 or 1) */
|
---|
306 |
|
---|
307 | if (k EQ 0) { /* '0' -> '.' */
|
---|
308 |
|
---|
309 | ebuf[1] = '0';
|
---|
310 | dspbuf[0] = '.'; /* setup display buffer */
|
---|
311 |
|
---|
312 | } else if (k EQ 1) { /* '1' -> '1.' */
|
---|
313 |
|
---|
314 | ebuf[1] = '1';
|
---|
315 | dspbuf[0] = SP_1P; /* setup display buffer */
|
---|
316 |
|
---|
317 | } else
|
---|
318 | return(FAILURE);
|
---|
319 |
|
---|
320 | break;
|
---|
321 |
|
---|
322 | case 2: /* 2nd digit position */
|
---|
323 | case 3: /* 3rd digit position */
|
---|
324 |
|
---|
325 | ebuf[ec] = k + '0';
|
---|
326 | dspbuf[0] = k + '0'; /* setup display buffer */
|
---|
327 | break;
|
---|
328 |
|
---|
329 | default:
|
---|
330 | return(FAILURE);
|
---|
331 | }
|
---|
332 |
|
---|
333 | ebuf[5] = '\0';
|
---|
334 | dspbuf[1] = '\0';
|
---|
335 |
|
---|
336 | #if DEBUGIT
|
---|
337 | if (debugsw)
|
---|
338 | printf("nd_imlt(): OK - k=%d, ec=%d, ebuf=[%s]\n", k, ec, ebuf);
|
---|
339 | #endif
|
---|
340 |
|
---|
341 | vbank(0);
|
---|
342 |
|
---|
343 | vcputsv(instob, 64, ID_ENTRY, idbox[n][5],
|
---|
344 | idbox[n][6] + 1, stccol, dspbuf, 14);
|
---|
345 |
|
---|
346 | if (ec EQ 4)
|
---|
347 | return(SUCCESS);
|
---|
348 |
|
---|
349 | advicur();
|
---|
350 |
|
---|
351 | return(SUCCESS);
|
---|
352 | }
|
---|