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

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

Removed redundant declarations.

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