source: buchla-68k/ram/etival.c@ 7c05959

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

Unused variables and parameters.

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