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