source: buchla-68k/orig/RAM/SQDISP.C@ 73dd55f

Last change on this file since 73dd55f was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 14.1 KB
RevLine 
[3ae31e9]1/*
2 =============================================================================
3 sqdisp.c -- MIDAS-VII sequence editor display functions
4 Version 24 -- 1989-11-16 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#define DEBUGSQ 0
9
10#include "stddefs.h"
11#include "hwdefs.h"
12#include "graphdef.h"
13#include "vsdd.h"
14#include "patch.h"
15
16#include "midas.h"
17#include "ptdisp.h"
18
19#if DEBUGSQ
20extern short debugsw;
21
22short debugsq = 1;
23#endif
24
25extern short nokey();
26
27extern char *(*BakLine)(), *(*FwdLine)();
28
29extern unsigned short *obj8, *obj9, *obj10, *obj11;
30extern unsigned short *LineBuf, *ScObAdr, *OldLine;
31extern unsigned short LineAtr;
32
33extern short CurLine, CurScan;
34extern short ScrlObj, SmScNsl;
35extern short PdScDnF, PdScUpF;
36extern short ctcsw, submenu;
37extern short stccol, stcrow;
38extern short cxval;
39
40extern unsigned short cg3[];
41
42extern char TheBuf[]; /* display build buffer */
43
44short curslin; /* current sequence line */
45
46/*
47
48*/
49
50char sqhead[] =
51
52 "\260 Lin Time Action 1 Action 2 Action 3 \260 No Seq Rg T \260";
53
54char *sqmcon[] = {
55
56 "\260 Key transient Trigger on Stop Set reg Value \260",
57 "\260 Key closure Trigger off Jump to lin Inc Reg Register \260",
58 "\260 Key release Trig toggle If reg = Voltage \260",
59 "\260 If key active If trig act If stim act If reg < Random \260",
60 "\260 If reg > \260"
61};
62
63short seqpal[16][3] = { /* sequence display palette */
64
65 {0, 0, 0}, /* 0 - black */
66 {2, 3, 3}, /* 1 - white */
67 {0, 0, 1}, /* 2 - dark blue #1 */
68 {2, 0, 2}, /* 3 - dark violet */
69 {0, 0, 3}, /* 4 - dark blue #2 */
70 {3, 0, 0}, /* 5 - red */
71 {3, 3, 0}, /* 6 - yellow */
72 {1, 2, 0}, /* 7 - dark green */
73 {0, 3, 3}, /* 8 - light blue */
74 {2, 2, 2}, /* 9 - gray */
75 {0, 3, 0}, /* 10 - light green */
76 {3, 1, 2}, /* 11 - light violet */
77 {0, 2, 3}, /* 12 - medium blue */
78 {2, 0, 0}, /* 13 - dark red */
79 {1, 1, 2}, /* 14 - electric purple */
80 {3, 3, 3} /* 15 - bright white */
81};
82
83/*
84
85*/
86
87short sqatype[] = { /* sequence action types by box number */
88
89 SQ_NULL, /* " " 0 */
90 SQ_TKEY, /* "Kt 001 1 01" 1 */
91 SQ_CKEY, /* "Kc 001 1 01" 2 */
92 SQ_RKEY, /* "Kr 001 1 01" 3 */
93 SQ_IKEY, /* "If 001 1 01" 4 */
94 SQ_STRG, /* "Trig on 01" 5 */
95 SQ_CTRG, /* "Trig off 01" 6 */
96 SQ_TTRG, /* "Trig tgl 01" 7 */
97 SQ_ITRG, /* "If trig act" 8 */
98 SQ_STOP, /* "Stop " 9 */
99 SQ_JUMP, /* "Jump to 000" 10 */
100 SQ_NULL, /* "???????????" 11 */
101 SQ_ISTM, /* "If stim act" 12 */
102 SQ_SREG, /* "Set R01=00 " 13 */
103 SQ_AREG, /* "Inc R01+00 " 14 */
104 SQ_IREQ, /* "If R01=00 " 15 */
105 SQ_IRLT, /* "If R01<00 " 16 */
106 SQ_IRGT /* "If R01>00 " 17 */
107};
108
109/*
110
111*/
112
113char *sqdsptb[] = { /* sequence action display strings by action */
114
115 " ", /* SQ_NULL 0x0000 null action */
116 "Kc 001 1 01", /* SQ_CKEY 0x0001 Key closure */
117 "Kr 001 1 01", /* SQ_RKEY 0x0002 Key release */
118 "Kt 001 1 01", /* SQ_TKEY 0x0003 Key transient */
119 "If 001 1 01", /* SQ_IKEY 0x0004 If key active */
120 "Trig on 01", /* SQ_STRG 0x0005 Trigger on */
121 "Trig off 01", /* SQ_CTRG 0x0006 Trigger off */
122 "Trig tgl 01", /* SQ_TTRG 0x0007 Trigger toggle */
123 "If trig 01", /* SQ_ITRG 0x0008 If trigger active */
124 "Set R01=00 ", /* SQ_SREG 0x0009 Set register */
125 "If R01=00 ", /* SQ_IREQ 0x000A If register = */
126 "If R01<00 ", /* SQ_IRLT 0x000B If register < */
127 "If R01>00 ", /* SQ_IRGT 0x000C If register > */
128 "If stim act", /* SQ_ISTM 0x000D If stimulus active */
129 "Jump to 000", /* SQ_JUMP 0x000E Jump to sequence line */
130 "Stop ", /* SQ_STOP 0x000F Stop sequence */
131 "Inc R01+00 " /* SQ_AREG 0x0010 Increment register */
132};
133
134/*
135
136*/
137
138/*
139 =============================================================================
140 initsq() -- initialize the sequence data structures
141 =============================================================================
142*/
143
144initsq()
145{
146 register short i;
147
148 for (i = 0; i < 16; i++) {
149
150 seqflag[i] = 0;
151 seqline[i] = 0;
152 sregval[i] = 0;
153 trstate[i] = 0;
154 seqstim[i] = 0;
155 seqtime[i] = 0;
156 }
157
158 memsetw(&seqtab, 0, (NSEQW * NSLINES));
159}
160
161/*
162
163*/
164
165/*
166 =============================================================================
167 dsact() -- convert sequence action code and data to display format
168 =============================================================================
169*/
170
171dsact(buf, act, dat)
172char *buf;
173unsigned short act, dat;
174{
175 unsigned short sqa, sqd, sqf, sqr, sqt, t1, t2, val;
176 unsigned short chan, i, key, port;
177
178 sqa = SQ_MACT & act;
179
180 strcpy(buf, sqdsptb[sqa]);
181
182 switch (sqa) {
183
184 case SQ_CKEY: /* Key closure */
185 case SQ_RKEY: /* Key release */
186 case SQ_TKEY: /* Key transient */
187 case SQ_IKEY: /* If key active */
188
189 port = 0x0003 & (dat >> 11);
190 chan = 0x000F & (dat >> 7);
191 key = 0x007F & dat;
192
193 if (port EQ 2)
194 sprintf(&buf[3], "%03u L ", 1 + key);
195 else
196 sprintf(&buf[3], "%03u %u %02u", 1 + key, 1 + port, 1 + chan);
197
198 break;
199
200 case SQ_STRG: /* Trigger on */
201 case SQ_CTRG: /* Trigger off */
202 case SQ_TTRG: /* Trigger toggle */
203 case SQ_ITRG: /* If trigger active */
204
205 sprintf(&buf[9], "%02u", 1 + dat);
206 break;
207/*
208
209*/
210 case SQ_AREG: /* Increment register */
211
212 sqf = (dat & SQ_MFLG) ? '-' : '+';
213 goto doval;
214
215 case SQ_SREG: /* Set register */
216 case SQ_IREQ: /* If register = */
217
218 sqf = '=';
219 goto doval;
220
221 case SQ_IRLT: /* If register < */
222
223 sqf = '<';
224 goto doval;
225
226 case SQ_IRGT: /* If register > */
227
228 sqf = '>';
229
230doval:
231
232 sqr = 1 + ((SQ_MOBJ & act) >> 8);
233 sqd = SQ_MVAL & dat;
234 sqt = SQ_MTYP & dat;
235
236 switch (sqt) {
237
238 case SQ_REG: /* register */
239
240 sprintf(&buf[4], "R%02u%cR%02u", sqr, sqf, 1 + sqd);
241 break;
242
243 case SQ_VAL: /* value */
244
245 sprintf(&buf[4], "R%02u%c%02u ", sqr, sqf, sqd);
246 break;
247
248 case SQ_VLT: /* voltage */
249
250 sprintf(&buf[4], "R%02u%cV%u ", sqr, sqf, 1 + sqd);
251 break;
252
253 case SQ_RND: /* random */
254
255 sprintf(&buf[4], "R%02u%c?%u ", sqr, sqf, sqd);
256 break;
257 }
258
259 break;
260/*
261
262*/
263 case SQ_JUMP: /* Jump to sequence line */
264
265 sprintf(&buf[8], "%03u", dat);
266 break;
267
268 case SQ_NULL: /* null action */
269 case SQ_ISTM: /* If stimulus active */
270 case SQ_STOP: /* Stop sequence */
271
272 break;
273 }
274
275 for (i = 0; i < 12; i++)
276 if (buf[i] EQ '\0')
277 buf[i] = ' ';
278}
279
280/*
281
282*/
283
284/*
285 =============================================================================
286 dsqlin() -- convert a sequence line to display format
287 =============================================================================
288*/
289
290dsqlin(buf, slin)
291char *buf;
292short slin;
293{
294 register struct seqent *sp;
295 register short i, t1, t2;
296
297 sp = &seqtab[slin];
298
299 t1 = sp->seqtime / 100;
300 t2 = sp->seqtime - (t1 * 100);
301
302 sprintf(buf, " %03u %02u.%02u", slin, t1, t2);
303
304 dsact(&buf[12], sp->seqact1, sp->seqdat1);
305 dsact(&buf[24], sp->seqact2, sp->seqdat2);
306 dsact(&buf[36], sp->seqact3, sp->seqdat3);
307
308 buf[0] = '\260';
309
310 for (i = 0; i < 48; i++)
311 if (buf[i] EQ '\0')
312 buf[i] = ' ';
313
314 buf[48] = '\0';
315}
316
317/*
318
319*/
320
321/*
322 =============================================================================
323 dcursq() -- display current sequence line
324 =============================================================================
325*/
326
327dcursq()
328{
329 dsqlin(TheBuf, curslin);
330 UpdVid(7, 0, TheBuf, PTEATR);
331 ctcon();
332}
333
334/*
335 =============================================================================
336 dstw() -- display sequence table window around current sequence line
337 =============================================================================
338*/
339
340dstw()
341{
342 register short slin, srow;
343
344 slin = curslin - 7;
345
346 if (slin < 0)
347 slin += NSLINES;
348
349 for (srow = 0; srow < 16; srow++) {
350
351 dsqlin(TheBuf, slin);
352 UpdVid(srow, 0, TheBuf, (srow EQ 7) ? PTEATR : PTPATR);
353
354 if (++slin GE NSLINES)
355 slin -= NSLINES;
356 }
357
358 seq2buf();
359 ctcon();
360}
361
362/*
363
364*/
365
366/*
367 =============================================================================
368 sqwin() -- fill in a sequence display window
369 =============================================================================
370*/
371
372sqwin(n)
373short n;
374{
375 register short i, j;
376 short atrbuf[64];
377 char linbuf[66];
378
379 if (v_regs[5] & 0x0180)
380 vbank(0);
381
382 switch (n) {
383
384 case 0: /* headings and box outline */
385
386 /* row 0 */
387
388 memset(linbuf, '\261', 63);
389 linbuf[0] = '\272';
390 linbuf[48] = '\267';
391 linbuf[62] = '\273';
392 linbuf[63] = '\0';
393
394 memsetw(atrbuf, PTBATR, 63);
395 atrbuf[63] = 0x0000;
396
397 vputsa(obj8, 0, 0, linbuf, atrbuf);
398
399 /* row 1 */
400
401 memsetw(atrbuf, PTHATR+0x0100, 64);
402 atrbuf[ 0] = PTBATR;
403 atrbuf[ 1] = PTHATR;
404 atrbuf[ 5] = PTHATR;
405 atrbuf[11] = PTHATR;
406 atrbuf[23] = PTHATR;
407 atrbuf[35] = PTHATR;
408 atrbuf[47] = PTHATR;
409 atrbuf[48] = PTBATR;
410 atrbuf[49] = PTHATR;
411 atrbuf[52] = PTHATR;
412 atrbuf[56] = PTHATR;
413 atrbuf[59] = PTHATR;
414 atrbuf[61] = PTHATR;
415 atrbuf[62] = PTBATR;
416 atrbuf[63] = 0x0000;
417
418 vputsa(obj8, 1, 0, sqhead, atrbuf);
419/*
420
421*/
422 /* row 18 */
423
424 memset(linbuf, '\261', 63);
425 linbuf[ 0] = '\266';
426 linbuf[48] = '\265';
427 linbuf[62] = '\264';
428 linbuf[63] = '\0';
429
430 memsetw(atrbuf, PTBATR, 63);
431 atrbuf[63] = 0x0000;
432
433 vputsa(obj11, 0, 0, linbuf, atrbuf);
434
435 /* row 24 */
436
437 memset(linbuf, '\261', 63);
438 linbuf[ 0] = '\271';
439 linbuf[62] = '\270';
440 linbuf[63] = '\0';
441
442 memsetw(atrbuf, PTBATR, 63);
443 atrbuf[63] = 0x0000;
444
445 vputsa(obj11, 6, 0, linbuf, atrbuf);
446
447 break;
448/*
449
450*/
451 case 1: /* sequences */
452
453 SetDTop(0, 13);
454 dstw();
455 break;
456
457 case 2: /* sequence status */
458
459 for (i = 0; i < 16; i++) {
460
461 sprintf(linbuf, " %03d %02d %d ",
462 seqline[i], sregval[i], trstate[i]);
463
464 vvputsv(obj10, 16, PDBORFG, PDSEQBG,
465 i, 0, "\260", 14, 14, cg3);
466
467 vvputsv(obj10, 16, PDSEQFG, PDSEQBG,
468 i, 1, linbuf, 14, 14, cg3);
469
470 vvputsv(obj10, 16, PDBORFG, PDSEQBG,
471 i, 14, "\260", 14, 14, cg3);
472
473 if (i EQ 7) {
474
475 if (48 EQ XTOC(cxval)) {
476
477 vsplot4(obj10, 16, PDPTRFG,
478 i, 0, "\277", 14, 14, cg3);
479
480 } else {
481
482 vsplot4(obj10, 16, PDPTRFG,
483 i, 0, "\274", 14, 14, cg3);
484 }
485 }
486
487 sprintf(linbuf, "%02d", i + 1);
488
489 vvputsv(obj10, 16,
490 (seqflag[i] & SQF_RUN) ? PDSEQRN : PDSEQFG, PDSEQBG,
491 i, 2, linbuf, 14, 14, cg3);
492 }
493
494 break;
495
496 case 3: /* menu */
497
498 memsetw(atrbuf, PTMATR, 64);
499 atrbuf[0] = PTBATR;
500 atrbuf[62] = PTBATR;
501 atrbuf[63] = 0x0000;
502
503 for (i = 0; i < 5; i++)
504 vputsa(obj11, (i + 1), 0, sqmcon[i], atrbuf);
505
506 break;
507 }
508}
509
510/*
511
512*/
513
514/*
515 =============================================================================
516 SqBakLn() -- return the next sequence line in the backward direction
517 =============================================================================
518*/
519
520char *
521SqBakLn()
522{
523 register short slin;
524
525 if (--curslin < 0)
526 curslin += NSLINES;
527
528 slin = curslin - 7;
529
530 if (slin < 0)
531 slin += NSLINES;
532
533 dsqlin(TheBuf, slin);
534 return(TheBuf);
535}
536
537/*
538
539*/
540
541/*
542 =============================================================================
543 SqFwdLn() -- return the next sequence line in the forward direction
544 =============================================================================
545*/
546
547char *
548SqFwdLn()
549{
550 register short slin;
551
552 if (++curslin GE NSLINES)
553 curslin -= NSLINES;
554
555 slin = curslin + 8;
556
557 if (slin GE NSLINES)
558 slin -= NSLINES;
559
560 dsqlin(TheBuf, slin);
561 return(TheBuf);
562}
563
564/*
565 =============================================================================
566 sqwins() -- draw the sequence display
567 =============================================================================
568*/
569
570sqwins()
571{
572 register short i;
573
574 for (i = 0; i < 4; i++)
575 sqwin(i);
576}
577
578/*
579
580*/
581
582/*
583 =============================================================================
584 sqdisp() -- setup the sequence display
585 =============================================================================
586*/
587
588sqdisp()
589{
590#if DEBUGSQ
591 if (debugsw AND debugsq)
592 printf("sqdisp(): ENTRY\n");
593#endif
594
595 dswap(); /* clear the video display */
596
597 BakLine = SqBakLn;
598 FwdLine = SqFwdLn;
599
600 /* setup object pointers */
601
602 obj8 = &v_score[OB08LOC]; /* 8 - headings */
603 obj9 = &v_score[OB09LOC]; /* 9 - sequences */
604 obj10 = &v_score[OB10LOC]; /* 10 - status */
605 obj11 = &v_score[OB11LOC]; /* 11 - menu */
606
607 ScrlObj = 9;
608 ScObAdr = obj9;
609 LineBuf = obj9;
610 OldLine = (unsigned short *)NULL;
611 LineAtr = PTPATR;
612
613 CurLine = 0;
614 CurScan = 13;
615
616 PdScDnF = FALSE;
617 PdScUpF = FALSE;
618
619 /* ---------------- initialize object table -------------------- */
620 /* obj, typ, bnk, base, xpix, ypix, x0, y0, flags, pri */
621
622 SetObj( 8, 1, 0, obj8, 512, 28, 0, 0, PDFL_08, -1);
623 SetObj( 9, 1, 0, obj9, 384, 224, 0, 28, PDFL_09, -1);
624 SetObj( 10, 0, 0, obj10, 128, 224, 384, 28, PDFL_10, -1);
625 SetObj( 11, 1, 0, obj11, 512, 98, 0, 252, PDFL_11, -1);
626
627 if (v_regs[5] & 0x0180)
628 vbank(0);
629
630 memsetw(v_score, 0, 32767); /* clear display objects */
631 memsetw(v_score+32767L, 0, 24577);
632
633 sqwins(); /* fill up the windows */
634
635/*
636
637*/
638 /* display some objects */
639
640 SetPri( 8, 8); /* headings */
641 SetPri( 9, 9); /* sequences */
642 SetPri(10, 10); /* sequence status */
643 SetPri(11, 11); /* menu */
644
645 if (v_regs[5] & 0x0180) /* select bank 0 */
646 vbank(0);
647
648 memcpyw(v_cgtab, cg3, 3584); /* setup character generator */
649 v_regs[1] = (v_regs[1] & 0x0FFF) | 0xE000;
650
651 /* fix the initial scan line specs in the object descriptor table */
652
653 v_odtab[ 8][0] = (v_odtab[ 8][0] & 0x0FFF) | 0xD000;
654 v_odtab[ 9][0] = (v_odtab[ 9][0] & 0x0FFF) | 0xD000;
655
656 v_odtab[11][0] = (v_odtab[11][0] & 0x0FFF) | 0xD000;
657
658 submenu = FALSE;
659
660 ctcsw = TRUE; /* enable cursor */
661 ctcpos(DATAROW, 2); /* set initial cursor */
662 postcm(); /* set initial submenu */
663
664 vsndpal(seqpal); /* set the palette */
665
666#if DEBUGSQ
667 if (debugsw AND debugsq)
668 printf("sqdisp(): EXIT\n");
669#endif
670
671}
Note: See TracBrowser for help on using the repository browser.