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