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