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

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

Added include files for global functions and variables.

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