source: buchla-68k/orig/RAM/SQDKEY.C@ 66b48e7

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

Imported original source code.

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