source: buchla-68k/orig/RAM/ETIMLT.C@ ee49131

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

Imported original source code.

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