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