source: buchla-68k/ram/sqdisp.c@ 9519422

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

Strip trailing tabs and spaces.

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