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

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

Point of no return.

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