source: buchla-68k/ram/sqselbx.c@ 0c834c5

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

Prototypes for global function pointers. Consistent global types.

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