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

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

Removed form-feed comments.

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