source: buchla-68k/ram/sqselbx.c@ 7ecfb7b

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

Unused variables and parameters.

  • Property mode set to 100644
File size: 12.8 KB
Line 
1/*
2 =============================================================================
3 sqselbx.c -- MIDAS-VII sequence editor box selection functions
4 Version 19 -- 1988-11-18 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "ram.h"
9
10#define ST_0 0x01 /* initial Action 1 or Action 2*/
11#define ST_1 0x02 /* operand type */
12#define ST_2 0x04 /* initial Action 3*/
13
14#define ST_OFF 0x00 /* cancel highlighting */
15
16int16_t action; /* current action column */
17int16_t sqdeflg; /* sequence data entry buffer filled */
18int16_t sqmenu; /* sqeuence submenu state */
19
20int8_t sqdebuf[50]; /* sequence data entry buffer */
21
22struct seqent seqbuf; /* sequence line buffer */
23
24int8_t sqhilit[][8] = { /* submenu highlight table */
25
26 /* start, width, row1, row2, row3, row4, row5, pad */
27
28 { 2, 13, ST_0|ST_2, ST_0|ST_2, ST_0|ST_2, ST_0, 0, 0},
29 { 17, 11, ST_0|ST_2, ST_0|ST_2, ST_0|ST_2, ST_0, 0, 0},
30 { 30, 11, ST_0|ST_2, ST_0|ST_2, 0, ST_0, 0, 0},
31 { 43, 8, ST_0|ST_2, ST_0|ST_2, ST_0, ST_0, ST_0, 0},
32 { 53, 8, ST_1, ST_1, ST_1, ST_1, 0, 0},
33};
34
35struct selbox sqboxes[] = { /* selection boxes */
36
37 {CTOX(1), RTOY(DATAROW), CTOX(48)-1, RTOY(1+DATAROW)-1, 0, sqfnbox}, /* current patch */
38
39 { 0, 0, 0, 0, 0, FN_NULL}
40};
41
42int8_t sqopreq[] = { /* action needs operand type flag table */
43
44 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1
45};
46
47int8_t nextact[] = { 24, 36, 6 }; /* next column after action entry */
48
49int16_t sqidata[] = { /* intial data by box */
50
51 0x0000, /* " " 0 */
52 0x0000, /* "Kt 001 1 01" 1 */
53 0x0000, /* "Kc 001 1 01" 2 */
54 0x0000, /* "Kr 001 1 01" 3 */
55 0x0000, /* "If 001 1 01" 4 */
56 0x0000, /* "Trig on 01" 5 */
57 0x0000, /* "Trig off 01" 6 */
58 0x0000, /* "Trig tgl 01" 7 */
59 0x0000, /* "If trig 01" 8 */
60 0x0000, /* "Stop " 9 */
61 0x0000, /* "Jump to 000" 10 */
62 0x0000, /* "???????????" 11 */
63 0x0000, /* "If stim act" 12 */
64 SQ_VAL, /* "Set R01=00 " 13 */
65 SQ_VAL, /* "Inc R01+00 " 14 */
66 SQ_VAL, /* "If R01=00 " 15 */
67 SQ_VAL, /* "If R01<00 " 16 */
68 SQ_VAL /* "If R01>00 " 17 */
69};
70
71int8_t actcol[] = { /* action data entry column by action */
72
73 0, 3, 3, 3, 3, 9, 9, 9, 9, 5, 5, 5, 5, 10, 8, 3, 5
74};
75
76int8_t sqvcol[] = { 9, 8, 9, 9 }; /* value entry column - type order */
77
78int8_t seqvcol[] = { 8, 8, 9, 9, 9 }; /* value entry column - box order */
79
80int16_t sqndata[] = { /* data types in box order */
81
82 SQ_VAL, SQ_REG, SQ_VLT, SQ_RND
83};
84
85/*
86 =============================================================================
87 hilitsq() -- highlight sequence submenu
88 =============================================================================
89*/
90
91void hilitsq(int8_t n)
92{
93 register int16_t chr, h, v, w;
94
95 sqmenu = n; /* set current submenu type */
96
97 for (h = 0; h < 5; h++) { /* scan the columns */
98
99 for (v = 0; v < 5; v++) { /* scan the rows */
100
101 chr = sqhilit[h][0]; /* starting character */
102
103 for (w = sqhilit[h][1]; w-- > 0; )
104 vsetcv(obj11, v + 1, chr++,
105 (sqhilit[h][v + 2] & n) ?
106 PTIATR : PTMATR, 64);
107 }
108 }
109}
110
111/*
112 =============================================================================
113 postcm() -- determine state after cursor motion
114 =============================================================================
115*/
116
117void postcm(void)
118{
119 if (inrange(stccol, 12, 22)) {
120
121 if (inrange(stccol, 12, 13))
122 hilitsq(ST_0);
123 else if ((sqopreq[seqbuf.seqact1 & SQ_MACT]) AND (stccol EQ 19))
124 hilitsq(ST_1);
125 else
126 hilitsq(ST_OFF);
127
128 return;
129
130 } else if (inrange(stccol, 24, 34)) {
131
132 if (inrange(stccol, 24, 25))
133 hilitsq(ST_0);
134 else if ((sqopreq[seqbuf.seqact2 & SQ_MACT]) AND (stccol EQ 31))
135 hilitsq(ST_1);
136 else
137 hilitsq(ST_OFF);
138
139 return;
140
141 } else if (inrange(stccol, 36, 46)) {
142
143 if (inrange(stccol, 36, 37))
144 hilitsq(ST_2);
145 else if ((sqopreq[seqbuf.seqact3 & SQ_MACT]) AND (stccol EQ 43))
146 hilitsq(ST_1);
147 else
148 hilitsq(ST_OFF);
149
150 return;
151
152 } else {
153
154 hilitsq(ST_OFF);
155 return;
156 }
157}
158
159/*
160 =============================================================================
161 movestc() -- move cursor and reset highlighting
162 =============================================================================
163*/
164
165void movestc(int16_t r, int16_t c)
166{
167 ctcpos(r, c);
168 postcm();
169}
170
171/*
172 =============================================================================
173 endssm() -- end patch submenu data entry
174 =============================================================================
175*/
176
177void endssm(int16_t row, int16_t col)
178{
179 submenu = FALSE;
180 cmtype = CT_SMTH;
181
182 mtcoff();
183 ctcon();
184 movestc(row, col);
185}
186
187/*
188 =============================================================================
189 setsqm() -- setup submenu
190 =============================================================================
191*/
192
193void setsqm(int16_t r, int16_t c)
194{
195 submenu = TRUE;
196 cmtype = CT_MENU;
197 mtcpos(r, c);
198}
199
200/*
201 =============================================================================
202 sqenter() -- enter an action
203 =============================================================================
204*/
205
206int16_t sqenter(void)
207{
208 register int16_t i, lcol;
209 register int32_t ltemp;
210 register uint16_t *ap, *dp;
211 uint16_t theact, port, chan, key, val, obj, dtype;
212
213 switch (action) {
214
215 case 0:
216
217 ap = &seqbuf.seqact1;
218 dp = &seqbuf.seqdat1;
219 break;
220
221 case 1:
222
223 ap = &seqbuf.seqact2;
224 dp = &seqbuf.seqdat2;
225 break;
226
227 case 2:
228
229 ap = &seqbuf.seqact3;
230 dp = &seqbuf.seqdat3;
231 break;
232
233 default:
234
235 action = 0;
236 movestc(DATAROW, actlft[action]);
237 return(FAILURE);
238 }
239
240
241 lcol = actlft[action];
242 theact = SQ_MACT & *ap;
243
244 switch (theact) {
245
246 case SQ_TKEY: /* "Kt 001 1 01" */
247 case SQ_CKEY: /* "Kc 001 1 01" */
248 case SQ_RKEY: /* "Kr 001 1 01" */
249 case SQ_IKEY: /* "If 001 1 01" */
250
251 ltemp = 0;
252
253 for (i = lcol + 3; i < lcol + 6; i++)
254 ltemp = (ltemp * 10) + (sqdebuf[i] - '0');
255
256 if ((ltemp < 1L) OR (ltemp > 128L)) {
257
258 movestc(DATAROW, actlft[action] + 3);
259 return(FAILURE);
260 }
261
262 key = ltemp - 1;
263
264 i = sqdebuf[lcol + 7];
265
266 if ((i EQ '1') OR (i EQ '2')) {
267
268 port = i - '1';
269
270 } else if (i EQ 'L') {
271
272 port = 2;
273
274 } else {
275
276 movestc(DATAROW, actlft[action] + 7);
277 return(FAILURE);
278 }
279
280 ltemp = ((sqdebuf[lcol + 9] - '0') * 10) +
281 (sqdebuf[lcol + 10] - '0');
282
283 if ((ltemp < 1L) OR (ltemp > 16L)) {
284
285 movestc(DATAROW, actlft[action] + 9);
286 return(FAILURE);
287 }
288
289 chan = ltemp - 1;
290 *dp = (port << 11) | (chan << 7) | key;
291
292 break;
293
294 case SQ_STRG: /* "Trig on 01" */
295 case SQ_CTRG: /* "Trig off 01" */
296 case SQ_TTRG: /* "Trig tgl 01" */
297
298 ltemp = ((sqdebuf[lcol + 9] - '0') * 10)+
299 (sqdebuf[lcol + 10] - '0');
300
301 if ((ltemp < 1L) OR (ltemp > 16)) {
302
303 movestc(DATAROW, actlft[action] + 9);
304 return(FAILURE);
305 }
306
307 *dp = ltemp - 1;
308
309 break;
310
311 case SQ_NULL: /* " " */
312 case SQ_ITRG: /* "If trig act" */
313 case SQ_STOP: /* "Stop " */
314 case SQ_ISTM: /* "If stim act" */
315
316 break;
317
318 case SQ_JUMP: /* "Jump to 000" */
319
320 ltemp = 0;
321
322 for (i = lcol + 8; i < lcol + 11; i++)
323 ltemp = (ltemp * 10) + (sqdebuf[i] - '0');
324
325 *dp = ltemp;
326
327 break;
328
329 case SQ_SREG: /* "Set R01=00 " */
330 case SQ_AREG: /* "Inc R01+00 " */
331 case SQ_IREQ: /* "If R01=00 " */
332 case SQ_IRLT: /* "If R01<00 " */
333 case SQ_IRGT: /* "If R01>00 " */
334
335 dtype = *dp & SQ_MTYP;
336
337 ltemp = ((sqdebuf[lcol + 5] - '0') * 10) +
338 (sqdebuf[lcol + 6] - '0');
339
340 if ((ltemp < 1) OR (ltemp > 16)) {
341
342 movestc(DATAROW, actlft[action] + 5);
343 return(FAILURE);
344 }
345
346 obj = ltemp - 1;
347
348 switch (dtype) {
349
350 case SQ_REG: /* register */
351
352 ltemp = ((sqdebuf[lcol + 9] - '0') * 10) +
353 (sqdebuf[lcol + 10] - '0');
354
355 if ((ltemp < 1) OR (ltemp > 16)) {
356
357 movestc(DATAROW, actlft[action] + 9);
358 return(FAILURE);
359 }
360
361 val = ltemp - 1;
362 break;
363
364 case SQ_VAL: /* constant value */
365
366 val = ((sqdebuf[lcol + 8] - '0') * 10) +
367 (sqdebuf[lcol + 9] - '0');
368
369 break;
370
371 case SQ_VLT: /* control voltage */
372
373 val = (sqdebuf[lcol + 9] - '0') - 1;
374 break;
375
376 case SQ_RND: /* random value */
377
378 val = sqdebuf[lcol + 9] - '0';
379 break;
380
381 default:
382
383 movestc(DATAROW, actlft[action] + 8);
384 return(FAILURE);
385 }
386
387 if (((*ap & SQ_MACT) EQ SQ_AREG) AND
388 (sqdebuf[lcol + 7] EQ '-'))
389 val |= 0x1000;
390
391 *ap = (*ap & SQ_MACT) | (obj << 8);
392 *dp = (*dp & SQ_MTYP) | val;
393
394 break;
395
396 default:
397
398 movestc(DATAROW, actlft[action]);
399 return(FAILURE);
400 }
401
402 memcpyw(&seqtab[curslin], &seqbuf, NSEQW);
403 dsqlin(sqdebuf, curslin);
404 sqdeflg = TRUE;
405 dcursq();
406 movestc(DATAROW, nextact[action]);
407 return(SUCCESS);
408}
409
410/*
411 =============================================================================
412 sqfnbox() -- sequence display box hit processor
413 =============================================================================
414*/
415
416int16_t sqfnbox(int16_t n)
417{
418 int16_t act, vtype;
419 register int16_t box;
420 register int16_t i;
421 register int32_t ltemp;
422
423 (void)n;
424
425 if (NOT submenu) { /* SEQUENCE DATA ENTRY LINE */
426
427 if (inrange(stccol, 2, 4)) { /* Line */
428
429 ltemp = 0;
430
431 for (i = 2; i < 5; i++)
432 ltemp = (ltemp * 10) + (sqdebuf[i] - '0');
433
434 curslin = ltemp;
435 sqdeflg = FALSE;
436 dstw();
437 movestc(DATAROW, 2);
438 return(SUCCESS);
439
440 } else if (inrange(stccol, 6, 10)) { /* Time */
441
442 ltemp = 0;
443
444 for (i = 6; i < 8; i++)
445 ltemp = (ltemp * 10) + (sqdebuf[i] - '0');
446
447 for (i = 9; i < 11; i++)
448 ltemp = (ltemp * 10) + (sqdebuf[i] - '0');
449
450 seqtab[curslin].seqtime = ltemp;
451 seqbuf.seqtime = ltemp;
452 dsqlin(sqdebuf, curslin);
453 sqdeflg = TRUE;
454 dcursq();
455 movestc(DATAROW, 12);
456 return(SUCCESS);
457
458 } else if (inrange(stccol, 12, 22)) { /* Action 1 */
459
460 action = 0;
461
462 if (inrange(stccol, 12, 13)) {
463
464 setsqm(19, 2);
465 return(SUCCESS);
466
467 } else if ((sqopreq[seqbuf.seqact1 & SQ_MACT]) AND
468 (stccol EQ 19)) {
469
470 setsqm(19, 53);
471 return(SUCCESS);
472
473 } else {
474
475 return(sqenter());
476 }
477
478 } else if (inrange(stccol, 24, 34)) { /* Action 2 */
479
480 action = 1;
481
482 if (inrange(stccol, 24, 25)) {
483
484 setsqm(19, 2);
485 return(SUCCESS);
486
487 } else if ((sqopreq[seqbuf.seqact2 & SQ_MACT]) AND
488 (stccol EQ 31)) {
489
490 setsqm(19, 53);
491 return(SUCCESS);
492
493 } else {
494
495 return(sqenter());
496 }
497
498 } else if (inrange(stccol, 36, 46)) { /* Action 3 */
499
500 action = 2;
501
502 if (inrange(stccol, 36, 37)) {
503
504 setsqm(19, 2);
505 return(SUCCESS);
506
507 } else if ((sqopreq[seqbuf.seqact3 & SQ_MACT]) AND
508 (stccol EQ 43)) {
509
510 setsqm(19, 53);
511 return(SUCCESS);
512
513 } else {
514
515 return(sqenter());
516 }
517
518 } else
519 return(FAILURE);
520
521 } else { /* SUBMENU SELECTION */
522
523 /* determine the "box" we're pointing at */
524
525 if (inrange(vtccol, 2, 14))
526 box = vtcrow - 18;
527 else if (inrange(vtccol, 17, 27))
528 box = vtcrow - 14;
529 else if (inrange(vtccol, 30, 40))
530 box = vtcrow - 10;
531 else if (inrange(vtccol, 43, 50))
532 box = vtcrow - 6;
533 else if (inrange(vtccol, 53, 60))
534 box = vtcrow - 1;
535 else
536 return(FAILURE);
537
538 switch (sqmenu) { /* switch on submenu type */
539
540 case ST_0: /* Action 1 or Action 2 type */
541 case ST_2: /* Action 3 type */
542
543 if (inrange(box, 18, 21))
544 return(FAILURE);
545
546 switch (action) {
547
548 case 0: /* action 1 */
549
550 act = SQ_MACT & (seqbuf.seqact1 = sqatype[box]);
551 vtype = 0x000F & ((seqbuf.seqdat1 = sqidata[box]) >> 8);
552 break;
553
554 case 1: /* action 2 */
555
556 act = SQ_MACT & (seqbuf.seqact2 = sqatype[box]);
557 vtype = 0x000F & ((seqbuf.seqdat2 = sqidata[box]) >> 8);
558 break;
559
560 case 2: /* action 3 */
561
562 if ((box EQ 4) OR (box EQ 8) OR (box EQ 12) OR
563 inrange(box, 15, 17))
564 return(FAILURE);
565
566 act = SQ_MACT & (seqbuf.seqact3 = sqatype[box]);
567 vtype = 0x000F & ((seqbuf.seqdat3 = sqidata[box]) >> 8);
568 break;
569 }
570
571 memcpyw(&seqtab[curslin], &seqbuf, NSEQW);
572 dsqlin(sqdebuf, curslin);
573 sqdeflg = TRUE;
574 dcursq();
575
576 if (sqopreq[act])
577 endssm(stcrow, actlft[action] + sqvcol[vtype]);
578 else if ((act EQ SQ_ISTM) OR (act EQ SQ_STOP))
579 endssm(stcrow, nextact[action]);
580 else
581 endssm(stcrow, actlft[action] + actcol[act]);
582
583 return(SUCCESS);
584
585 case ST_1: /* operand type */
586
587 if (NOT inrange(box, 18, 21))
588 return(FAILURE);
589
590 switch (action) {
591
592 case 0: /* action 1 */
593
594 if (NOT sqopreq[act = SQ_MACT & seqbuf.seqact1])
595 return(FAILURE);
596
597 seqbuf.seqdat1 = (seqbuf.seqdat1 & SQ_MFLG) | sqndata[box - 18];
598 break;
599
600 case 1: /* action 2 */
601
602 if (NOT sqopreq[act = SQ_MACT & seqbuf.seqact2])
603 return(FAILURE);
604
605 seqbuf.seqdat2 = (seqbuf.seqdat2 & SQ_MFLG) | sqndata[box - 18];
606 break;
607
608 case 2: /* action 3 */
609
610 if (NOT sqopreq[act = SQ_MACT & seqbuf.seqact3])
611 return(FAILURE);
612
613 seqbuf.seqdat3 = (seqbuf.seqdat3 & SQ_MFLG) | sqndata[box - 18];
614 break;
615 }
616
617 break;
618
619 default: /* -BOGUS- */
620
621 endssm(stcrow, stccol);
622 return(FAILURE);
623 }
624
625 memcpyw(&seqtab[curslin], &seqbuf, NSEQW);
626 dsqlin(sqdebuf, curslin);
627 sqdeflg = TRUE;
628 dcursq();
629 endssm(stcrow, actlft[action] + seqvcol[box - 18]);
630 return(SUCCESS);
631 }
632
633 return(FAILURE);
634}
635
Note: See TracBrowser for help on using the repository browser.