source: buchla-68k/ram/sqdkey.c@ 3fcb810

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

Fixed sqdkey.c.

  • Property mode set to 100644
File size: 6.8 KB
Line 
1/*
2 =============================================================================
3 sqdkey.c -- MIDAS-VII sequence display data entry functions
4 Version 8 -- 1988-11-22 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "ram.h"
9
10int16_t actfmt; /* action code format */
11
12int8_t actlft[] = { 12, 24, 36 }; /* action field leftmost columns */
13
14int8_t seqdfmt[] = { /* action data entry format by action */
15
16 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0, 4, 0, 3
17};
18
19/*
20 =============================================================================
21 seq2buf() -- load the edit buffer from the current sequence line
22 =============================================================================
23*/
24
25void seq2buf(void)
26{
27 memcpyw(&seqbuf, &seqtab[curslin], NSEQW);
28 dsqlin(sqdebuf, curslin);
29 sqdeflg = TRUE;
30}
31
32/*
33 =============================================================================
34 sqactde() -- sequence action digit data entry function
35 =============================================================================
36*/
37
38void sqactde(int16_t key)
39{
40 register int16_t col;
41 int16_t defmt;
42 uint16_t act, vtype;
43 int8_t buf[8];
44
45 col = stccol - actlft[action]; /* get field data entry column */
46
47 switch (action) { /* get action code from sequence entry */
48
49 case 0: /* action 1 */
50
51 act = seqbuf.seqact1;
52 vtype = SQ_MTYP & seqbuf.seqdat1;
53 break;
54
55 case 1: /* action 2 */
56
57 act = seqbuf.seqact2;
58 vtype = SQ_MTYP & seqbuf.seqdat2;
59 break;
60
61 case 2: /* action 3 */
62
63 act = seqbuf.seqact3;
64 vtype = SQ_MTYP & seqbuf.seqdat3;
65 break;
66
67 default: /* something weird got in here */
68
69 return;
70 }
71
72 defmt = seqdfmt[SQ_MACT & act]; /* get data entry format code */
73
74 switch (defmt) { /* switch off of data entry format */
75
76 case 1: /* key, port, chan */
77
78 if (inrange(col, 3, 5)) { /* key */
79
80 if ((col EQ 3) AND (key > 1))
81 return;
82
83 buf[0] = (int8_t)(key + '0');
84
85 } else if (col EQ 7) { /* port */
86
87 if ((key EQ 1) OR (key EQ 2)) { /* MIDI */
88
89 buf[0] = (int8_t)(key + '0');
90
91 UpdVid(7, stccol + 1, " 01", PTDATR);
92 memcpy(&sqdebuf[stccol + 1], " 01", 3);
93
94 } else if (key EQ 3) { /* local */
95
96 buf[0] = 'L';
97
98 UpdVid(7, stccol + 1, " ", PTDATR);
99 memset(&sqdebuf[stccol + 1], ' ', 3);
100
101 } else {
102
103 return;
104 }
105
106 } else if (inrange(col, 9, 10)) { /* channel */
107
108 if ((col EQ 9) AND (key > 1))
109 return;
110
111 buf[0] = (int8_t)(key + '0');
112 }
113
114 buf[1] = '\0';
115 sqdebuf[stccol] = buf[0];
116
117 UpdVid(7, stccol, buf, PTDATR);
118
119 if ((col EQ 5) OR (col EQ 7)) { /* skip blanks */
120
121 ++stccol;
122 ++col;
123 }
124
125 if (col EQ 10)
126 ctcon();
127 else
128 movestc(stcrow, ++stccol);
129
130 return;
131
132 case 2: /* trigger */
133
134 if (inrange(col, 9, 10)) {
135
136 if ((col EQ 9) AND (key > 1))
137 return;
138
139 } else {
140
141 return;
142 }
143
144 buf[0] = (int8_t)(key + '0');
145 buf[1] = '\0';
146 sqdebuf[stccol] = (int8_t)(key + '0');
147
148 UpdVid(7, stccol, buf, PTDATR);
149
150 if (col EQ 10)
151 ctcon();
152 else
153 movestc(stcrow, ++stccol);
154
155 return;
156
157 case 3: /* register operations */
158
159 if ((col EQ 7) AND (act EQ SQ_AREG)) {
160
161 if (key EQ 8) /* - */
162 buf[0] = '-';
163 else if (key EQ 9) /* + */
164 buf[0] = '+';
165 else
166 return;
167
168 buf[1] = '\0';
169 sqdebuf[stccol] = buf[0];
170 UpdVid(7, stccol, buf, PTDATR);
171 movestc(stcrow, ++stccol);
172 return;
173 }
174
175 switch (vtype) {
176
177 case SQ_REG: /* register contents */
178
179 if (inrange(col, 5, 6) OR inrange(col, 9, 10)) {
180
181 if ( ((col EQ 5) OR (col EQ 9)) AND (key > 1) )
182 return;
183
184 } else {
185
186 return;
187 }
188
189 buf[0] = (int8_t)(key + '0');
190 buf[1] = '\0';
191 sqdebuf[stccol] = (int8_t)(key + '0');
192
193 UpdVid(7, stccol, buf, PTDATR);
194
195 if (col EQ 6) {
196
197 col += 2;
198 stccol += 2;
199 }
200
201 if (col EQ 10)
202 ctcon();
203 else
204 movestc(stcrow, ++stccol);
205
206 return;
207
208 case SQ_VAL: /* constant value */
209
210 if (inrange(col, 5, 6) OR inrange(col, 8, 9)) {
211
212 if ((col EQ 5) AND (key > 1))
213 return;
214
215 } else {
216
217 return;
218 }
219
220 buf[0] = (int8_t)(key + '0');
221 buf[1] = '\0';
222 sqdebuf[stccol] = (int8_t)(key + '0');
223
224 UpdVid(7, stccol, buf, PTDATR);
225
226 if (col EQ 6) {
227
228 ++col;
229 ++stccol;
230 }
231
232 if (col EQ 9)
233 ctcon();
234 else
235 movestc(stcrow, ++stccol);
236
237 return;
238
239 case SQ_VLT: /* voltage input */
240
241 if (inrange(col, 5, 6) OR (col EQ 9)) {
242
243 if ((col EQ 5) AND (key > 1))
244 return;
245 else if ( (col EQ 9) AND ((key < 1) OR (key > 4)) )
246 return;
247
248 } else {
249
250 return;
251 }
252
253 buf[0] = (int8_t)(key + '0');
254 buf[1] = '\0';
255 sqdebuf[stccol] = (int8_t)(key + '0');
256
257 UpdVid(7, stccol, buf, PTDATR);
258
259 if (col EQ 6) {
260
261 col += 2;
262 stccol += 2;
263 }
264
265 if (col EQ 9)
266 ctcon();
267 else
268 movestc(stcrow, ++stccol);
269
270 return;
271
272 case SQ_RND: /* random value */
273
274 if (inrange(col, 5, 6) OR (col EQ 9)) {
275
276 if ((col EQ 5) AND (key > 1))
277 return;
278
279 if ((col EQ 9) AND (key > 6))
280 return;
281
282 } else {
283
284 return;
285 }
286
287 buf[0] = (int8_t)(key + '0');
288 buf[1] = '\0';
289 sqdebuf[stccol] = (int8_t)(key + '0');
290
291 UpdVid(7, stccol, buf, PTDATR);
292
293 if (col EQ 6) {
294
295 col += 2;
296 stccol += 2;
297 }
298
299 if (col EQ 9)
300 ctcon();
301 else
302 movestc(stcrow, ++stccol);
303
304 return;
305 }
306
307 case 4: /* sequence line */
308
309 if (inrange(col, 0, 7))
310 return;
311
312 buf[0] = (int8_t)(key + '0');
313 buf[1] = '\0';
314 sqdebuf[stccol] = (int8_t)(key + '0');
315
316 UpdVid(7, stccol, buf, PTDATR);
317
318 if (col EQ 10)
319 ctcon();
320 else
321 movestc(stcrow, ++stccol);
322
323 return;
324
325 case 0: /* -none- */
326 default:
327
328 return;
329 }
330}
331
332/*
333 =============================================================================
334 sqdkey() -- sequence digit data entry control function
335 =============================================================================
336*/
337
338void sqdkey(int16_t k)
339{
340 register int16_t key;
341 int8_t buf[8];
342
343 (void)k;
344
345 if (NOT astat) /* only do this on key closures */
346 return;
347
348 if (NOT sqdeflg) /* load up the edit buffer */
349 seq2buf();
350
351 key = asig - 60;
352
353 if (inrange(stccol, 2, 4)) { /* line */
354
355 buf[0] = (int8_t)(key + '0');
356 buf[1] = '\0';
357
358 sqdebuf[stccol] = (int8_t)(key + '0');
359
360 UpdVid(7, stccol, buf, PTDATR);
361
362 if (stccol EQ 4)
363 ctcon();
364 else
365 movestc(stcrow, ++stccol);
366
367 return;
368
369 } else if (inrange(stccol, 6, 10)) { /* time */
370
371 if (stccol EQ 8)
372 return;
373
374 buf[0] = (int8_t)(key + '0');
375 buf[1] = '\0';
376
377 sqdebuf[stccol] = (int8_t)(key + '0');
378
379 UpdVid(7, stccol, buf, PTDATR);
380
381 if (stccol EQ 7)
382 ++stccol;
383
384 if (stccol EQ 10)
385 ctcon();
386 else
387 movestc(stcrow, ++stccol);
388
389 return;
390
391 } else if (inrange(stccol, 12, 22)) { /* action 1 */
392
393 action = 0;
394 sqactde(key);
395 return;
396
397 } else if (inrange(stccol, 24, 34)) { /* action 2 */
398
399 action = 1;
400 sqactde(key);
401 return;
402
403 } else if (inrange(stccol, 36, 46)) { /* action 3 */
404
405 action = 2;
406 sqactde(key);
407 return;
408 }
409}
410
Note: See TracBrowser for help on using the repository browser.