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 |
|
---|
18 | int8_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 |
|
---|
52 | int16_t et_imlt(int16_t n)
|
---|
53 | {
|
---|
54 | register struct instdef *ip;
|
---|
55 | register struct idfnhdr *fp;
|
---|
56 |
|
---|
57 | ip = &vbufs[curvce];
|
---|
58 | fp = &ip->idhfnc[curfunc];
|
---|
59 |
|
---|
60 | ebuf[0] = '0' + fp->idfsrc;
|
---|
61 | fr2dec(fp->idfmlt, &ebuf[1]);
|
---|
62 | ebuf[5] = '\0';
|
---|
63 |
|
---|
64 | ebflag = TRUE;
|
---|
65 |
|
---|
66 | #if DEBUGIT
|
---|
67 | if (debugsw)
|
---|
68 | printf("et_imlt(): ebuf=[%s]\n", ebuf);
|
---|
69 | #endif
|
---|
70 |
|
---|
71 | return(SUCCESS);
|
---|
72 | }
|
---|
73 |
|
---|
74 | /*
|
---|
75 | =============================================================================
|
---|
76 | ef_imlt() -- parse (unload) the edit buffer (called by 'E' key)
|
---|
77 | =============================================================================
|
---|
78 | */
|
---|
79 |
|
---|
80 | int16_t ef_imlt(int16_t n)
|
---|
81 | {
|
---|
82 | register int16_t i, tmpval, srctmp;
|
---|
83 | register struct instdef *ip;
|
---|
84 | register struct idfnhdr *fp;
|
---|
85 |
|
---|
86 | ip = &vbufs[curvce];
|
---|
87 | fp = &ip->idhfnc[curfunc];
|
---|
88 |
|
---|
89 | ebuf[5] = '\0'; /* terminate the string in ebuf */
|
---|
90 | ebflag = FALSE;
|
---|
91 |
|
---|
92 | #if DEBUGIT
|
---|
93 | if (debugsw)
|
---|
94 | printf("ef_imlt(): ebuf=[%s]\n", ebuf);
|
---|
95 | #endif
|
---|
96 |
|
---|
97 |
|
---|
98 | if (idsrcsw) { /* entering the source */
|
---|
99 |
|
---|
100 | idsrcsw = FALSE;
|
---|
101 | submenu = FALSE;
|
---|
102 |
|
---|
103 | if (vtcrow EQ 22) {
|
---|
104 |
|
---|
105 | /* 'PchW/HT', 'Pitch', 'Random', 'GPC/CV1' */
|
---|
106 |
|
---|
107 | if (vtccol LT 24)
|
---|
108 | srctmp = SM_HTPW;
|
---|
109 | else if ((vtccol GT 24) AND (vtccol LT 28))
|
---|
110 | srctmp = SM_PTCH;
|
---|
111 | else if ((vtccol GT 28) AND (vtccol LT 32))
|
---|
112 | srctmp = SM_FREQ;
|
---|
113 | else if ((vtccol GT 32) AND (vtccol LT 40))
|
---|
114 | srctmp = SM_RAND;
|
---|
115 | else
|
---|
116 | srctmp = SM_CTL1;
|
---|
117 |
|
---|
118 | } else if (vtcrow EQ 23) {
|
---|
119 |
|
---|
120 | /* 'ModW/VT', 'Key Vel', 'Pedal 1' */
|
---|
121 |
|
---|
122 | if (vtccol LT 24)
|
---|
123 | srctmp = SM_VTMW;
|
---|
124 | else if ((vtccol GT 24) AND (vtccol LT 32))
|
---|
125 | srctmp = SM_KVEL;
|
---|
126 | else if ((vtccol GT 32) AND (vtccol LT 40))
|
---|
127 | srctmp = SM_PED1;
|
---|
128 | else
|
---|
129 | srctmp = SM_NONE;
|
---|
130 |
|
---|
131 | } else { /* must be row 24 */
|
---|
132 |
|
---|
133 | /* 'PchW/LP', 'Key Prs' */
|
---|
134 |
|
---|
135 | if (vtccol LT 24)
|
---|
136 | srctmp = SM_LPBR;
|
---|
137 | else if ((vtccol GT 24) AND (vtccol LT 32))
|
---|
138 | srctmp = SM_KPRS;
|
---|
139 | else
|
---|
140 | srctmp = SM_NONE;
|
---|
141 | }
|
---|
142 |
|
---|
143 | fp->idfsrc = srctmp; /* set the source */
|
---|
144 | objclr(TTCPRI); /* turn off the menu cursor */
|
---|
145 | idvlblc(); /* blank the menu area */
|
---|
146 | modinst();
|
---|
147 | dswin(22); /* refresh the screen */
|
---|
148 |
|
---|
149 | } else if (stccol LT 8) { /* selecting the source */
|
---|
150 |
|
---|
151 | idsrcsw = TRUE; /* set the select switch */
|
---|
152 | submenu = TRUE;
|
---|
153 | idvlbld(); /* load the menu area */
|
---|
154 | dswin(22); /* refresh the screen */
|
---|
155 | SetPri(TTCURS, TTCPRI); /* turn on the typewriter cursor */
|
---|
156 | ttcpos(22, 17); /* position the typewriter cusor */
|
---|
157 |
|
---|
158 | } else if (stccol GT 8) { /* entering the multiplier */
|
---|
159 |
|
---|
160 | tmpval = dec2fr(&ebuf[1]);
|
---|
161 |
|
---|
162 | if (tmpval EQ 0xFFFF)
|
---|
163 | return(FAILURE);
|
---|
164 | else
|
---|
165 | fp->idfmlt = tmpval;
|
---|
166 |
|
---|
167 | modinst();
|
---|
168 |
|
---|
169 | } else
|
---|
170 | return(FAILURE);
|
---|
171 |
|
---|
172 | #if DEBUGIT
|
---|
173 | if (debugsw)
|
---|
174 | printf("ef_imlt(): SUCCESS\n");
|
---|
175 | #endif
|
---|
176 |
|
---|
177 | return(SUCCESS);
|
---|
178 | }
|
---|
179 |
|
---|
180 | /*
|
---|
181 | =============================================================================
|
---|
182 | rd_imlt() -- (re)display the field
|
---|
183 | =============================================================================
|
---|
184 | */
|
---|
185 |
|
---|
186 | int16_t rd_imlt(int16_t n)
|
---|
187 | {
|
---|
188 | register struct instdef *ip;
|
---|
189 | register struct idfnhdr *fp;
|
---|
190 |
|
---|
191 | ip = &vbufs[curvce];
|
---|
192 | fp = &ip->idhfnc[curfunc];
|
---|
193 |
|
---|
194 | dsimlt(dspbuf, fp->idfsrc, fp->idfmlt);
|
---|
195 |
|
---|
196 | vcputsv(instob, 64, idbox[n][4], idbox[n][5],
|
---|
197 | idbox[n][6] + 1, idbox[n][7], dspbuf, 14);
|
---|
198 |
|
---|
199 | return(SUCCESS);
|
---|
200 | }
|
---|
201 |
|
---|
202 | /*
|
---|
203 | =============================================================================
|
---|
204 | nd_imlt() -- handle new data entry
|
---|
205 | =============================================================================
|
---|
206 | */
|
---|
207 |
|
---|
208 | int16_t nd_imlt(int16_t n, int16_t k)
|
---|
209 | {
|
---|
210 | register int16_t ec;
|
---|
211 |
|
---|
212 | if (idsrcsw) /* not if the source menu is up */
|
---|
213 | return(FAILURE);
|
---|
214 |
|
---|
215 | if (stccol LT 9) /* only in the multiplier field */
|
---|
216 | return(FAILURE);
|
---|
217 |
|
---|
218 | ec = stccol - 9; /* calculate edit buffer column */
|
---|
219 |
|
---|
220 | switch (ec) {
|
---|
221 |
|
---|
222 | case 0: /* sign position */
|
---|
223 |
|
---|
224 | if (k EQ 8) { /* - */
|
---|
225 |
|
---|
226 | ebuf[4] = '-';
|
---|
227 | dspbuf[0] = '-'; /* setup display buffer */
|
---|
228 |
|
---|
229 | } else if (k EQ 9) { /* + */
|
---|
230 |
|
---|
231 | ebuf[4] = '+';
|
---|
232 | dspbuf[0] = '+'; /* setup display buffer */
|
---|
233 |
|
---|
234 | } else
|
---|
235 | return(FAILURE);
|
---|
236 |
|
---|
237 | break;
|
---|
238 |
|
---|
239 | case 1: /* 1st digit position (0 or 1) */
|
---|
240 |
|
---|
241 | if (k EQ 0) { /* '0' -> '.' */
|
---|
242 |
|
---|
243 | ebuf[1] = '0';
|
---|
244 | dspbuf[0] = '.'; /* setup display buffer */
|
---|
245 |
|
---|
246 | } else if (k EQ 1) { /* '1' -> '1.' */
|
---|
247 |
|
---|
248 | ebuf[1] = '1';
|
---|
249 | dspbuf[0] = SP_1P; /* setup display buffer */
|
---|
250 |
|
---|
251 | } else
|
---|
252 | return(FAILURE);
|
---|
253 |
|
---|
254 | break;
|
---|
255 |
|
---|
256 | case 2: /* 2nd digit position */
|
---|
257 | case 3: /* 3rd digit position */
|
---|
258 |
|
---|
259 | ebuf[ec] = k + '0';
|
---|
260 | dspbuf[0] = k + '0'; /* setup display buffer */
|
---|
261 | break;
|
---|
262 |
|
---|
263 | default:
|
---|
264 | return(FAILURE);
|
---|
265 | }
|
---|
266 |
|
---|
267 | ebuf[5] = '\0';
|
---|
268 | dspbuf[1] = '\0';
|
---|
269 |
|
---|
270 | #if DEBUGIT
|
---|
271 | if (debugsw)
|
---|
272 | printf("nd_imlt(): OK - k=%d, ec=%d, ebuf=[%s]\n", k, ec, ebuf);
|
---|
273 | #endif
|
---|
274 |
|
---|
275 | vbank(0);
|
---|
276 |
|
---|
277 | vcputsv(instob, 64, ID_ENTRY, idbox[n][5],
|
---|
278 | idbox[n][6] + 1, stccol, dspbuf, 14);
|
---|
279 |
|
---|
280 | if (ec EQ 4)
|
---|
281 | return(SUCCESS);
|
---|
282 |
|
---|
283 | advicur();
|
---|
284 |
|
---|
285 | return(SUCCESS);
|
---|
286 | }
|
---|
287 |
|
---|