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

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

Zero redundant declarations.

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