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

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

Zero redundant declarations.

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