source: buchla-68k/ram/etimlt.c@ 6262b5c

Last change on this file since 6262b5c was 6262b5c, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Added include files for global functions and variables.

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