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

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

Unused variables and parameters.

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