source: buchla-68k/orig/RAM/ETIVAL.C@ 66b48e7

Last change on this file since 66b48e7 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Imported original source code.

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