source: buchla-68k/ram/sqselbx.c@ 411371e

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

Removed redundant declarations.

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