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

Last change on this file was 58ff1a9, checked in by Thomas Lopatic <thomas@…>, 6 years ago

Fixed pointer signedness.

  • 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
51uint16_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 struct seqent *sp;
235 int16_t i;
236 uint16_t t1, t2;
237
238 sp = &seqtab[slin];
239
240 t1 = sp->seqtime / 100;
241 t2 = sp->seqtime - (t1 * 100);
242
243 sprintf(buf, " %03d %02u.%02u", slin, t1, t2);
244
245 dsact(&buf[12], sp->seqact1, sp->seqdat1);
246 dsact(&buf[24], sp->seqact2, sp->seqdat2);
247 dsact(&buf[36], sp->seqact3, sp->seqdat3);
248
249 buf[0] = '\260';
250
251 for (i = 0; i < 48; i++)
252 if (buf[i] EQ '\0')
253 buf[i] = ' ';
254
255 buf[48] = '\0';
256}
257
258/*
259 =============================================================================
260 dcursq() -- display current sequence line
261 =============================================================================
262*/
263
264void dcursq(void)
265{
266 dsqlin(TheBuf, curslin);
267 UpdVid(7, 0, TheBuf, PTEATR);
268 ctcon();
269}
270
271/*
272 =============================================================================
273 dstw() -- display sequence table window around current sequence line
274 =============================================================================
275*/
276
277void dstw(void)
278{
279 register int16_t slin, srow;
280
281 slin = curslin - 7;
282
283 if (slin < 0)
284 slin += NSLINES;
285
286 for (srow = 0; srow < 16; srow++) {
287
288 dsqlin(TheBuf, slin);
289 UpdVid(srow, 0, TheBuf, (srow EQ 7) ? PTEATR : PTPATR);
290
291 if (++slin GE NSLINES)
292 slin -= NSLINES;
293 }
294
295 seq2buf();
296 ctcon();
297}
298
299/*
300 =============================================================================
301 sqwin() -- fill in a sequence display window
302 =============================================================================
303*/
304
305void sqwin(int16_t n)
306{
307 register int16_t i;
308 uint16_t atrbuf[64];
309 int8_t linbuf[66];
310
311 if (v_regs[5] & 0x0180)
312 vbank(0);
313
314 switch (n) {
315
316 case 0: /* headings and box outline */
317
318 /* row 0 */
319
320 memset(linbuf, (uint8_t)'\261', 63);
321 linbuf[0] = '\272';
322 linbuf[48] = '\267';
323 linbuf[62] = '\273';
324 linbuf[63] = '\0';
325
326 memsetw(atrbuf, PTBATR, 63);
327 atrbuf[63] = 0x0000;
328
329 vputsa(obj8, 0, 0, linbuf, atrbuf);
330
331 /* row 1 */
332
333 memsetw(atrbuf, PTHATR+0x0100, 64);
334 atrbuf[ 0] = PTBATR;
335 atrbuf[ 1] = PTHATR;
336 atrbuf[ 5] = PTHATR;
337 atrbuf[11] = PTHATR;
338 atrbuf[23] = PTHATR;
339 atrbuf[35] = PTHATR;
340 atrbuf[47] = PTHATR;
341 atrbuf[48] = PTBATR;
342 atrbuf[49] = PTHATR;
343 atrbuf[52] = PTHATR;
344 atrbuf[56] = PTHATR;
345 atrbuf[59] = PTHATR;
346 atrbuf[61] = PTHATR;
347 atrbuf[62] = PTBATR;
348 atrbuf[63] = 0x0000;
349
350 vputsa(obj8, 1, 0, sqhead, atrbuf);
351
352 /* row 18 */
353
354 memset(linbuf, (uint8_t)'\261', 63);
355 linbuf[ 0] = '\266';
356 linbuf[48] = '\265';
357 linbuf[62] = '\264';
358 linbuf[63] = '\0';
359
360 memsetw(atrbuf, PTBATR, 63);
361 atrbuf[63] = 0x0000;
362
363 vputsa(obj11, 0, 0, linbuf, atrbuf);
364
365 /* row 24 */
366
367 memset(linbuf, (uint8_t)'\261', 63);
368 linbuf[ 0] = '\271';
369 linbuf[62] = '\270';
370 linbuf[63] = '\0';
371
372 memsetw(atrbuf, PTBATR, 63);
373 atrbuf[63] = 0x0000;
374
375 vputsa(obj11, 6, 0, linbuf, atrbuf);
376
377 break;
378
379 case 1: /* sequences */
380
381 SetDTop(0, 13);
382 dstw();
383 break;
384
385 case 2: /* sequence status */
386
387 for (i = 0; i < 16; i++) {
388
389 sprintf(linbuf, " %03d %02d %d ",
390 seqline[i], sregval[i], trstate[i]);
391
392 vvputsv(obj10, 16, PDBORFG, PDSEQBG,
393 i, 0, "\260", 14, 14, cg3);
394
395 vvputsv(obj10, 16, PDSEQFG, PDSEQBG,
396 i, 1, linbuf, 14, 14, cg3);
397
398 vvputsv(obj10, 16, PDBORFG, PDSEQBG,
399 i, 14, "\260", 14, 14, cg3);
400
401 if (i EQ 7) {
402
403 if (48 EQ XTOC(cxval)) {
404
405 vsplot4(obj10, 16, PDPTRFG,
406 i, 0, "\277", 14, 14, cg3);
407
408 } else {
409
410 vsplot4(obj10, 16, PDPTRFG,
411 i, 0, "\274", 14, 14, cg3);
412 }
413 }
414
415 sprintf(linbuf, "%02d", i + 1);
416
417 vvputsv(obj10, 16,
418 (seqflag[i] & SQF_RUN) ? PDSEQRN : PDSEQFG, PDSEQBG,
419 i, 2, linbuf, 14, 14, cg3);
420 }
421
422 break;
423
424 case 3: /* menu */
425
426 memsetw(atrbuf, PTMATR, 64);
427 atrbuf[0] = PTBATR;
428 atrbuf[62] = PTBATR;
429 atrbuf[63] = 0x0000;
430
431 for (i = 0; i < 5; i++)
432 vputsa(obj11, (i + 1), 0, sqmcon[i], atrbuf);
433
434 break;
435 }
436}
437
438/*
439 =============================================================================
440 SqBakLn() -- return the next sequence line in the backward direction
441 =============================================================================
442*/
443
444int8_t *SqBakLn(void)
445{
446 register int16_t slin;
447
448 if (--curslin < 0)
449 curslin += NSLINES;
450
451 slin = curslin - 7;
452
453 if (slin < 0)
454 slin += NSLINES;
455
456 dsqlin(TheBuf, slin);
457 return(TheBuf);
458}
459
460/*
461 =============================================================================
462 SqFwdLn() -- return the next sequence line in the forward direction
463 =============================================================================
464*/
465
466int8_t *SqFwdLn(void)
467{
468 register int16_t slin;
469
470 if (++curslin GE NSLINES)
471 curslin -= NSLINES;
472
473 slin = curslin + 8;
474
475 if (slin GE NSLINES)
476 slin -= NSLINES;
477
478 dsqlin(TheBuf, slin);
479 return(TheBuf);
480}
481
482/*
483 =============================================================================
484 sqwins() -- draw the sequence display
485 =============================================================================
486*/
487
488void sqwins(void)
489{
490 register int16_t i;
491
492 for (i = 0; i < 4; i++)
493 sqwin(i);
494}
495
496/*
497 =============================================================================
498 sqdisp() -- setup the sequence display
499 =============================================================================
500*/
501
502void sqdisp(void)
503{
504#if DEBUGSQ
505 if (debugsw AND debugsq)
506 printf("sqdisp(): ENTRY\n");
507#endif
508
509 dswap(); /* clear the video display */
510
511 BakLine = SqBakLn;
512 FwdLine = SqFwdLn;
513
514 /* setup object pointers */
515
516 obj8 = &v_score[OB08LOC]; /* 8 - headings */
517 obj9 = &v_score[OB09LOC]; /* 9 - sequences */
518 obj10 = &v_score[OB10LOC]; /* 10 - status */
519 obj11 = &v_score[OB11LOC]; /* 11 - menu */
520
521 ScrlObj = 9;
522 ScObAdr = obj9;
523 LineBuf = obj9;
524 OldLine = (uint16_t *)NULL;
525 LineAtr = PTPATR;
526
527 CurLine = 0;
528 CurScan = 13;
529
530 PdScDnF = FALSE;
531 PdScUpF = FALSE;
532
533 /* ---------------- initialize object table -------------------- */
534 /* obj, typ, bnk, base, xpix, ypix, x0, y0, flags, pri */
535
536 SetObj( 8, 1, 0, obj8, 512, 28, 0, 0, PDFL_08, -1);
537 SetObj( 9, 1, 0, obj9, 384, 224, 0, 28, PDFL_09, -1);
538 SetObj( 10, 0, 0, obj10, 128, 224, 384, 28, PDFL_10, -1);
539 SetObj( 11, 1, 0, obj11, 512, 98, 0, 252, PDFL_11, -1);
540
541 if (v_regs[5] & 0x0180)
542 vbank(0);
543
544 memsetw(v_score, 0, 32767); /* clear display objects */
545 memsetw(v_score+32767L, 0, 24577);
546
547 sqwins(); /* fill up the windows */
548
549
550 /* display some objects */
551
552 SetPri( 8, 8); /* headings */
553 SetPri( 9, 9); /* sequences */
554 SetPri(10, 10); /* sequence status */
555 SetPri(11, 11); /* menu */
556
557 if (v_regs[5] & 0x0180) /* select bank 0 */
558 vbank(0);
559
560 memcpyw(v_cgtab, cg3, 3584); /* setup character generator */
561 v_regs[1] = (v_regs[1] & 0x0FFF) | 0xE000;
562
563 /* fix the initial scan line specs in the object descriptor table */
564
565 v_odtab[ 8][0] = (v_odtab[ 8][0] & 0x0FFF) | 0xD000;
566 v_odtab[ 9][0] = (v_odtab[ 9][0] & 0x0FFF) | 0xD000;
567
568 v_odtab[11][0] = (v_odtab[11][0] & 0x0FFF) | 0xD000;
569
570 submenu = FALSE;
571
572 ctcsw = TRUE; /* enable cursor */
573 ctcpos(DATAROW, 2); /* set initial cursor */
574 postcm(); /* set initial submenu */
575
576 vsndpal(seqpal); /* set the palette */
577
578#if DEBUGSQ
579 if (debugsw AND debugsq)
580 printf("sqdisp(): EXIT\n");
581#endif
582
583}
584
Note: See TracBrowser for help on using the repository browser.