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

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

Removed form-feed comments.

  • 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 if (NOT submenu) { /* SEQUENCE DATA ENTRY LINE */
424
425 if (inrange(stccol, 2, 4)) { /* Line */
426
427 ltemp = 0;
428
429 for (i = 2; i < 5; i++)
430 ltemp = (ltemp * 10) + (sqdebuf[i] - '0');
431
432 curslin = ltemp;
433 sqdeflg = FALSE;
434 dstw();
435 movestc(DATAROW, 2);
436 return(SUCCESS);
437
438 } else if (inrange(stccol, 6, 10)) { /* Time */
439
440 ltemp = 0;
441
442 for (i = 6; i < 8; i++)
443 ltemp = (ltemp * 10) + (sqdebuf[i] - '0');
444
445 for (i = 9; i < 11; i++)
446 ltemp = (ltemp * 10) + (sqdebuf[i] - '0');
447
448 seqtab[curslin].seqtime = ltemp;
449 seqbuf.seqtime = ltemp;
450 dsqlin(sqdebuf, curslin);
451 sqdeflg = TRUE;
452 dcursq();
453 movestc(DATAROW, 12);
454 return(SUCCESS);
455
456 } else if (inrange(stccol, 12, 22)) { /* Action 1 */
457
458 action = 0;
459
460 if (inrange(stccol, 12, 13)) {
461
462 setsqm(19, 2);
463 return(SUCCESS);
464
465 } else if ((sqopreq[seqbuf.seqact1 & SQ_MACT]) AND
466 (stccol EQ 19)) {
467
468 setsqm(19, 53);
469 return(SUCCESS);
470
471 } else {
472
473 return(sqenter());
474 }
475
476 } else if (inrange(stccol, 24, 34)) { /* Action 2 */
477
478 action = 1;
479
480 if (inrange(stccol, 24, 25)) {
481
482 setsqm(19, 2);
483 return(SUCCESS);
484
485 } else if ((sqopreq[seqbuf.seqact2 & SQ_MACT]) AND
486 (stccol EQ 31)) {
487
488 setsqm(19, 53);
489 return(SUCCESS);
490
491 } else {
492
493 return(sqenter());
494 }
495
496 } else if (inrange(stccol, 36, 46)) { /* Action 3 */
497
498 action = 2;
499
500 if (inrange(stccol, 36, 37)) {
501
502 setsqm(19, 2);
503 return(SUCCESS);
504
505 } else if ((sqopreq[seqbuf.seqact3 & SQ_MACT]) AND
506 (stccol EQ 43)) {
507
508 setsqm(19, 53);
509 return(SUCCESS);
510
511 } else {
512
513 return(sqenter());
514 }
515
516 } else
517 return(FAILURE);
518
519 } else { /* SUBMENU SELECTION */
520
521 /* determine the "box" we're pointing at */
522
523 if (inrange(vtccol, 2, 14))
524 box = vtcrow - 18;
525 else if (inrange(vtccol, 17, 27))
526 box = vtcrow - 14;
527 else if (inrange(vtccol, 30, 40))
528 box = vtcrow - 10;
529 else if (inrange(vtccol, 43, 50))
530 box = vtcrow - 6;
531 else if (inrange(vtccol, 53, 60))
532 box = vtcrow - 1;
533 else
534 return(FAILURE);
535
536 switch (sqmenu) { /* switch on submenu type */
537
538 case ST_0: /* Action 1 or Action 2 type */
539 case ST_2: /* Action 3 type */
540
541 if (inrange(box, 18, 21))
542 return(FAILURE);
543
544 switch (action) {
545
546 case 0: /* action 1 */
547
548 act = SQ_MACT & (seqbuf.seqact1 = sqatype[box]);
549 vtype = 0x000F & ((seqbuf.seqdat1 = sqidata[box]) >> 8);
550 break;
551
552 case 1: /* action 2 */
553
554 act = SQ_MACT & (seqbuf.seqact2 = sqatype[box]);
555 vtype = 0x000F & ((seqbuf.seqdat2 = sqidata[box]) >> 8);
556 break;
557
558 case 2: /* action 3 */
559
560 if ((box EQ 4) OR (box EQ 8) OR (box EQ 12) OR
561 inrange(box, 15, 17))
562 return(FAILURE);
563
564 act = SQ_MACT & (seqbuf.seqact3 = sqatype[box]);
565 vtype = 0x000F & ((seqbuf.seqdat3 = sqidata[box]) >> 8);
566 break;
567 }
568
569 memcpyw(&seqtab[curslin], &seqbuf, NSEQW);
570 dsqlin(sqdebuf, curslin);
571 sqdeflg = TRUE;
572 dcursq();
573
574 if (sqopreq[act])
575 endssm(stcrow, actlft[action] + sqvcol[vtype]);
576 else if ((act EQ SQ_ISTM) OR (act EQ SQ_STOP))
577 endssm(stcrow, nextact[action]);
578 else
579 endssm(stcrow, actlft[action] + actcol[act]);
580
581 return(SUCCESS);
582
583 case ST_1: /* operand type */
584
585 if (NOT inrange(box, 18, 21))
586 return(FAILURE);
587
588 switch (action) {
589
590 case 0: /* action 1 */
591
592 if (NOT sqopreq[act = SQ_MACT & seqbuf.seqact1])
593 return(FAILURE);
594
595 seqbuf.seqdat1 = (seqbuf.seqdat1 & SQ_MFLG) | sqndata[box - 18];
596 break;
597
598 case 1: /* action 2 */
599
600 if (NOT sqopreq[act = SQ_MACT & seqbuf.seqact2])
601 return(FAILURE);
602
603 seqbuf.seqdat2 = (seqbuf.seqdat2 & SQ_MFLG) | sqndata[box - 18];
604 break;
605
606 case 2: /* action 3 */
607
608 if (NOT sqopreq[act = SQ_MACT & seqbuf.seqact3])
609 return(FAILURE);
610
611 seqbuf.seqdat3 = (seqbuf.seqdat3 & SQ_MFLG) | sqndata[box - 18];
612 break;
613 }
614
615 break;
616
617 default: /* -BOGUS- */
618
619 endssm(stcrow, stccol);
620 return(FAILURE);
621 }
622
623 memcpyw(&seqtab[curslin], &seqbuf, NSEQW);
624 dsqlin(sqdebuf, curslin);
625 sqdeflg = TRUE;
626 dcursq();
627 endssm(stcrow, actlft[action] + seqvcol[box - 18]);
628 return(SUCCESS);
629 }
630
631 return(FAILURE);
632}
633
Note: See TracBrowser for help on using the repository browser.