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

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

Fixed etires.c, fixed etimlt.c.

  • Property mode set to 100644
File size: 5.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 "ram.h"
11
12/*
13 =============================================================================
14 dsimlt() -- decode a source / multiplier pair for display
15 =============================================================================
16*/
17
18int8_t *dsimlt(int8_t *buf, int16_t src, int16_t mltval)
19{
20 int8_t mltstr[5], mlttmp[5];
21
22 fr2dec(mltval, mlttmp); /* convert to ASCII from binary */
23
24 mltstr[0] = mlttmp[3]; /* sign */
25
26 if (mlttmp[0] EQ '0') /* 1st digit & decimal point */
27 mltstr[1] = '.';
28 else
29 mltstr[1] = SP_1P;
30
31 mltstr[2] = mlttmp[1]; /* 2nd digit */
32 mltstr[3] = mlttmp[2]; /* 3rd digit */
33 mltstr[4] = '\0'; /* terminate the string */
34
35 sprintf(buf, "%7.7s %s", srctbl[src], mltstr);
36
37#if DEBUGIT
38 if (debugsw)
39 printf("dsimlt($%08.8lX, %d, $%04.4X): [%s]\n",
40 buf, src, mltval, buf);
41#endif
42
43 return(buf);
44}
45
46/*
47 =============================================================================
48 et_imlt() -- load the edit buffer
49 =============================================================================
50*/
51
52int16_t et_imlt(int16_t n)
53{
54 register struct instdef *ip;
55 register struct idfnhdr *fp;
56
57 (void)n;
58
59 ip = &vbufs[curvce];
60 fp = &ip->idhfnc[curfunc];
61
62 ebuf[0] = (int8_t)('0' + fp->idfsrc);
63 fr2dec(fp->idfmlt, &ebuf[1]);
64 ebuf[5] = '\0';
65
66 ebflag = TRUE;
67
68#if DEBUGIT
69 if (debugsw)
70 printf("et_imlt(): ebuf=[%s]\n", ebuf);
71#endif
72
73 return(SUCCESS);
74}
75
76/*
77 =============================================================================
78 ef_imlt() -- parse (unload) the edit buffer (called by 'E' key)
79 =============================================================================
80*/
81
82int16_t ef_imlt(int16_t n)
83{
84 register int16_t tmpval, srctmp;
85 register struct instdef *ip;
86 register struct idfnhdr *fp;
87
88 (void)n;
89
90 ip = &vbufs[curvce];
91 fp = &ip->idhfnc[curfunc];
92
93 ebuf[5] = '\0'; /* terminate the string in ebuf */
94 ebflag = FALSE;
95
96#if DEBUGIT
97 if (debugsw)
98 printf("ef_imlt(): ebuf=[%s]\n", ebuf);
99#endif
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', 'Pitch', 'Random', 'GPC/CV1' */
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 /* 'PchW/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 fp->idfsrc = (int8_t)srctmp; /* set the source */
148 objclr(TTCPRI); /* turn off the menu cursor */
149 idvlblc(); /* blank the menu area */
150 modinst();
151 dswin(22); /* refresh the screen */
152
153 } else if (stccol LT 8) { /* selecting the source */
154
155 idsrcsw = TRUE; /* set the select switch */
156 submenu = TRUE;
157 idvlbld(); /* load the menu area */
158 dswin(22); /* refresh the screen */
159 SetPri(TTCURS, TTCPRI); /* turn on the typewriter cursor */
160 ttcpos(22, 17); /* position the typewriter cusor */
161
162 } else if (stccol GT 8) { /* entering the multiplier */
163
164 tmpval = dec2fr(&ebuf[1]);
165
166 if (tmpval EQ 0xFFFF)
167 return(FAILURE);
168 else
169 fp->idfmlt = tmpval;
170
171 modinst();
172
173 } else
174 return(FAILURE);
175
176#if DEBUGIT
177 if (debugsw)
178 printf("ef_imlt(): SUCCESS\n");
179#endif
180
181 return(SUCCESS);
182}
183
184/*
185 =============================================================================
186 rd_imlt() -- (re)display the field
187 =============================================================================
188*/
189
190int16_t rd_imlt(int16_t n)
191{
192 register struct instdef *ip;
193 register struct idfnhdr *fp;
194
195 ip = &vbufs[curvce];
196 fp = &ip->idhfnc[curfunc];
197
198 dsimlt(dspbuf, fp->idfsrc, fp->idfmlt);
199
200 vcputsv(instob, 64, idbox[n][4], idbox[n][5],
201 idbox[n][6] + 1, idbox[n][7], dspbuf, 14);
202
203 return(SUCCESS);
204}
205
206/*
207 =============================================================================
208 nd_imlt() -- handle new data entry
209 =============================================================================
210*/
211
212int16_t nd_imlt(int16_t n, int16_t k)
213{
214 register int16_t ec;
215
216 if (idsrcsw) /* not if the source menu is up */
217 return(FAILURE);
218
219 if (stccol LT 9) /* only in the multiplier field */
220 return(FAILURE);
221
222 ec = stccol - 9; /* calculate edit buffer column */
223
224 switch (ec) {
225
226 case 0: /* sign position */
227
228 if (k EQ 8) { /* - */
229
230 ebuf[4] = '-';
231 dspbuf[0] = '-'; /* setup display buffer */
232
233 } else if (k EQ 9) { /* + */
234
235 ebuf[4] = '+';
236 dspbuf[0] = '+'; /* setup display buffer */
237
238 } else
239 return(FAILURE);
240
241 break;
242
243 case 1: /* 1st digit position (0 or 1) */
244
245 if (k EQ 0) { /* '0' -> '.' */
246
247 ebuf[1] = '0';
248 dspbuf[0] = '.'; /* setup display buffer */
249
250 } else if (k EQ 1) { /* '1' -> '1.' */
251
252 ebuf[1] = '1';
253 dspbuf[0] = SP_1P; /* setup display buffer */
254
255 } else
256 return(FAILURE);
257
258 break;
259
260 case 2: /* 2nd digit position */
261 case 3: /* 3rd digit position */
262
263 ebuf[ec] = (int8_t)(k + '0');
264 dspbuf[0] = (int8_t)(k + '0'); /* setup display buffer */
265 break;
266
267 default:
268 return(FAILURE);
269 }
270
271 ebuf[5] = '\0';
272 dspbuf[1] = '\0';
273
274#if DEBUGIT
275 if (debugsw)
276 printf("nd_imlt(): OK - k=%d, ec=%d, ebuf=[%s]\n", k, ec, ebuf);
277#endif
278
279 vbank(0);
280
281 vcputsv(instob, 64, ID_ENTRY, idbox[n][5],
282 idbox[n][6] + 1, stccol, dspbuf, 14);
283
284 if (ec EQ 4)
285 return(SUCCESS);
286
287 advicur();
288
289 return(SUCCESS);
290}
291
Note: See TracBrowser for help on using the repository browser.