source: buchla-68k/ram/asgdsp.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: 21.7 KB
Line 
1/*
2 =============================================================================
3 asgdsp.c -- MIDAS assignment editor
4 Version 50 -- 1988-10-04 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#define DEBUGIT 0
9
10#include "ram.h"
11
12#define PSG_ADDR 0
13#define PSG_READ 0
14#define PSG_WRIT 2
15
16#define PSG_IOEN 7
17#define PSG_IDLE 0xBF
18
19#define PSG_PRTB 15 /* PSG Port B */
20
21#define AUX_BIT 0x02 /* aux control bit in PSG port B */
22
23#define AK_WIDTH 115 /* width, in words, of keyboard icon */
24
25/* 4 bit pixel patterns */
26
27#define AKW_0 0x0000
28#define AKW_1 0xF000
29#define AKW_2 0x0F00
30#define AKW_3 0xFF00
31#define AKW_4 0x00F0
32#define AKW_5 0xF0F0
33#define AKW_6 0x0FF0
34#define AKW_7 0xFFF0
35#define AKW_8 0x000F
36#define AKW_9 0xF00F
37#define AKW_A 0x0F0F
38#define AKW_B 0xFF0F
39#define AKW_C 0x00FF
40#define AKW_D 0xF0FF
41#define AKW_E 0x0FFF
42#define AKW_F 0xFFFF
43
44/*
45
46*/
47
48int8_t *gprep[] = {" ", "1", "2", "L"};
49
50int8_t *asgsrc[] = { /* source labels */
51
52 "1 Pch/Hor",
53 "2 Mod/Vrt",
54 "3 Brth/LP",
55 "4 GPC/CV1",
56 "5 Pedal 1",
57 "6 Key Prs"
58};
59
60/* keys are 5 pixels wide on top, except the last one, which is 8 pixels wide */
61
62int16_t asgkble[88] = { /* key left edge offsets */
63
64 /* piano MIDI */
65
66 1, 6, 11, /* 1..3 21..23 */
67 17, 22, 27, 32, 37, /* 4..8 24..28 */
68 43, 48, 53, 58, 63, 68, 73, /* 9..15 29..35 */
69 79, 84, 89, 94, 99, /* 16..20 36..40 */
70 105, 110, 115, 120, 125, 130, 135, /* 21..27 41..47 */
71 141, 146, 151, 156, 161, /* 28..32 48..52 */
72 167, 172, 177, 182, 187, 192, 197, /* 33..39 53..59 */
73 203, 208, 213, 218, 223, /* 40..44 60..64 */
74 229, 234, 239, 244, 249, 254, 259, /* 45..51 65..71 */
75 265, 270, 275, 280, 285, /* 52..56 72..76 */
76 291, 296, 301, 306, 311, 316, 321, /* 57..63 77..83 */
77 327, 332, 337, 342, 347, /* 64..68 84..88 */
78 353, 358, 363, 368, 373, 378, 383, /* 69..75 89..95 */
79 389, 394, 399, 404, 409, /* 76..80 96..100 */
80 415, 420, 425, 430, 435, 440, 445, /* 81..87 101..107 */
81 451 /* 88 108 */
82};
83
84/*
85
86*/
87
88uint16_t asgkbtp[AK_WIDTH] = { /* keyboard icon top lines */
89
90 AKW_7, AKW_C, AKW_1, AKW_F,
91 AKW_7, AKW_C, AKW_1, AKW_F,
92 AKW_0, AKW_7, AKW_D, AKW_F,
93 AKW_0, AKW_7, AKW_C, AKW_1,
94 AKW_F, AKW_0, AKW_7, AKW_D,
95 AKW_F, AKW_0, AKW_7, AKW_C,
96 AKW_1, AKW_F,
97
98 AKW_7, AKW_C, AKW_1, AKW_F,
99 AKW_0, AKW_7, AKW_C, AKW_1,
100 AKW_F, AKW_7, AKW_C, AKW_1,
101 AKW_F, AKW_0, AKW_7, AKW_D,
102 AKW_F, AKW_0, AKW_7, AKW_C,
103 AKW_1, AKW_F, AKW_0, AKW_7,
104 AKW_D, AKW_F, AKW_0, AKW_7,
105 AKW_C, AKW_1, AKW_F,
106
107 AKW_7, AKW_C, AKW_1, AKW_F,
108 AKW_0, AKW_7, AKW_C, AKW_1,
109 AKW_F, AKW_7, AKW_C, AKW_1,
110 AKW_F, AKW_0, AKW_7, AKW_D,
111 AKW_F, AKW_0, AKW_7, AKW_C,
112 AKW_1, AKW_F, AKW_0, AKW_7,
113 AKW_D, AKW_F, AKW_0, AKW_7,
114 AKW_C, AKW_1, AKW_F,
115
116 AKW_7, AKW_C, AKW_1, AKW_F,
117 AKW_0, AKW_7, AKW_C, AKW_1,
118 AKW_F, AKW_7, AKW_C, AKW_1,
119 AKW_F, AKW_0, AKW_7, AKW_D,
120 AKW_F, AKW_0, AKW_7, AKW_C,
121 AKW_1, AKW_F, AKW_0, AKW_7,
122 AKW_D, AKW_F, AKW_E
123};
124
125/*
126
127*/
128
129uint16_t asgkbbt[AK_WIDTH] = { /* keyboard icon bottom lines */
130
131 AKW_7, AKW_F, AKW_7, AKW_F,
132 AKW_7, AKW_F, AKW_7, AKW_F,
133 AKW_B, AKW_F, AKW_D, AKW_F,
134 AKW_E, AKW_F, AKW_F, AKW_7,
135 AKW_F, AKW_B, AKW_F, AKW_D,
136 AKW_F, AKW_E, AKW_F, AKW_E,
137 AKW_F, AKW_F,
138
139 AKW_7, AKW_F, AKW_B, AKW_F,
140 AKW_D, AKW_F, AKW_E, AKW_F,
141 AKW_F, AKW_7, AKW_F, AKW_B,
142 AKW_F, AKW_B, AKW_F, AKW_D,
143 AKW_F, AKW_E, AKW_F, AKW_F,
144 AKW_7, AKW_F, AKW_B, AKW_F,
145 AKW_D, AKW_F, AKW_E, AKW_F,
146 AKW_E, AKW_F, AKW_F,
147
148 AKW_7, AKW_F, AKW_B, AKW_F,
149 AKW_D, AKW_F, AKW_E, AKW_F,
150 AKW_F, AKW_7, AKW_F, AKW_B,
151 AKW_F, AKW_B, AKW_F, AKW_D,
152 AKW_F, AKW_E, AKW_F, AKW_F,
153 AKW_7, AKW_F, AKW_B, AKW_F,
154 AKW_D, AKW_F, AKW_E, AKW_F,
155 AKW_E, AKW_F, AKW_F,
156
157 AKW_7, AKW_F, AKW_B, AKW_F,
158 AKW_D, AKW_F, AKW_E, AKW_F,
159 AKW_F, AKW_7, AKW_F, AKW_B,
160 AKW_F, AKW_B, AKW_F, AKW_D,
161 AKW_F, AKW_E, AKW_F, AKW_F,
162 AKW_7, AKW_F, AKW_B, AKW_F,
163 AKW_D, AKW_F, AKW_E
164};
165
166/*
167
168*/
169
170int16_t asgpal[16][3] = { /* assignment editor color palette */
171
172 {0, 0, 0}, /* 0 */
173 {3, 3, 3}, /* 1 */
174 {0, 0, 2}, /* 2 */
175 {1, 0, 1}, /* 3 */
176 {0, 1, 2}, /* 4 */
177 {0, 1, 1}, /* 5 (was 0, 1, 0) */
178 {1, 1, 2}, /* 6 */
179 {0, 0, 1}, /* 7 */
180 {2, 2, 2}, /* 8 */
181 {0, 0, 0}, /* 9 */
182 {2, 2, 2}, /* 10 (was 1, 1, 0) */
183 {2, 3, 3}, /* 11 */
184 {3, 3, 0}, /* 12 */
185 {3, 0, 0}, /* 13 */
186 {0, 0, 0}, /* 14 */
187 {0, 2, 3} /* 15 (was 0, 3, 2) */
188};
189
190int16_t dyntab[10] = { /* dynamics translation table */
191
192 0, /* 0 */
193 ( 120 << 5), /* 1 */
194 ( 180 << 5), /* 2 */
195 ( 250 << 5), /* 3 */
196 ( 320 << 5), /* 4 */
197 ( 400 << 5), /* 5 */
198 ( 500 << 5), /* 6 */
199 ( 630 << 5), /* 7 */
200 ( 790 << 5), /* 8 */
201 (1000 << 5) /* 9 */
202};
203
204/*
205
206*/
207
208/*
209 =============================================================================
210 advacur() -- advance the assignment display text cursor
211 =============================================================================
212*/
213
214void advacur(void)
215{
216 register int16_t newcol;
217
218 if (infield(stcrow, stccol, curfet))
219 cfetp = infetp;
220 else
221 return;
222
223 newcol = stccol + 1;
224
225 if (newcol LE cfetp->frcol)
226 itcpos(stcrow, newcol);
227
228 cxval = stccol << 3;
229 cyval = stcrow * 14;
230}
231
232/*
233 =============================================================================
234 bspacur() -- backspace the assignment display text cursor
235 =============================================================================
236*/
237
238void bspacur(void)
239{
240 register int16_t newcol;
241
242 if (infield(stcrow, stccol, curfet))
243 cfetp = infetp;
244 else
245 return;
246
247 newcol = stccol - 1;
248
249 if (newcol GE cfetp->flcol)
250 itcpos(stcrow, newcol);
251
252 cxval = stccol << 3;
253 cyval = stcrow * 14;
254}
255
256/*
257
258*/
259
260/*
261 =============================================================================
262 keycpyw() -- copy words into the keyboard object
263 =============================================================================
264*/
265
266void keycpyw(uint16_t *dest, uint16_t *src, int16_t len, uint16_t wk, uint16_t bk)
267{
268 register uint16_t wkey, bkey, theword;
269 register int16_t i;
270
271 wkey = exp_c(wk);
272 bkey = exp_c(bk);
273
274 for (i = 0; i < len; i++) {
275
276 theword = *src++;
277 *dest++ = (theword & wkey) | ((~theword) & bkey);
278 }
279}
280
281/*
282
283*/
284
285/*
286 =============================================================================
287 asgkb() -- draw the assignment keyboard icon
288 =============================================================================
289*/
290
291void asgkb(void)
292{
293 register uint16_t *p;
294 register uint16_t akline;
295 register int16_t i, j;
296
297 akline = exp_c(AK_LINE);
298 p = asgob + (int32_t)AKSTART;
299
300 for (j = 0; j < 12; j++) {
301
302 memsetw(p, akline, AK_WIDTH);
303 p += 128L;
304
305 for (i = 0; i < 13; i++) {
306
307 keycpyw(p, asgkbtp, AK_WIDTH, AK_WKEYT, AK_BKEYT);
308 p += 128L;
309 }
310 }
311
312 memsetw(p, akline, AK_WIDTH);
313 p += 128L;
314
315 for (i = 0; i < 14; i++) {
316
317 keycpyw(p, asgkbtp, AK_WIDTH, AK_WKEYB, AK_BKEYB);
318 p += 128L;
319 }
320
321 for (i = 0; i < 11; i++) {
322
323 keycpyw(p, asgkbbt, AK_WIDTH, AK_WKEYB, AK_BKEYB);
324 p += 128L;
325 }
326
327 memsetw(p, akline, AK_WIDTH);
328}
329
330/*
331
332*/
333
334/*
335 =============================================================================
336 drawk2g() -- display key assignments for a group
337 =============================================================================
338*/
339
340void drawk2g(int16_t grp)
341{
342 register int16_t i;
343 register int16_t n;
344 register int16_t key;
345 register int16_t line;
346 register int8_t *bfsp;
347 register uint16_t *lp;
348
349 n = 7; /* key to group window */
350
351 line = (14 * grp) + AK_BASE;
352 lp = asgob + ((int32_t)line << 7) + 6L;
353
354 for (i = 0; i < 4; i++) {
355
356 keycpyw(lp, asgkbtp, AK_WIDTH, AK_WKEYT, AK_BKEYT);
357 lp += 128L;
358 }
359
360 if (grp2prt[grp][0] EQ 1) {
361
362 for (key = 0; key < 88; key++)
363 if (key2grp[key] & (0x0001 << grp))
364 vbfill4(asgob, 128, asgkble[key] + 24, line,
365 asgkble[key] + (key EQ 87 ? 31 : 28),
366 line + 3, exp_c(AK_SELC));
367
368 sprintf(bfs, "%c", (grp > 8) ? (grp + 163) : (grp + '1'));
369 bfsp = bfs;
370
371 } else {
372
373 bfsp = " ";
374 }
375
376 vcputsv(asgob, 64, adbox[n][4], adbox[n][5],
377 adbox[n][6] + 1 + grp, adbox[n][7], bfsp, 14);
378
379 vcputsv(asgob, 64, adbox[n][4], adbox[n][5],
380 adbox[n][6] + 1 + grp, adbox[n][7] + 61, bfsp, 14);
381}
382
383/*
384
385*/
386
387/*
388 =============================================================================
389 adpoint() -- plot a point for the lseg function
390 =============================================================================
391*/
392
393void adpoint(int16_t x, int16_t y, int16_t pen)
394{
395 if (v_regs[5] & 0x0180)
396 vbank(0);
397
398 vputp(adoct, x, y, exp_c(pen));
399}
400
401/*
402 =============================================================================
403 numblk() -- return a number string or a blank string
404 =============================================================================
405*/
406
407int8_t *numblk(int8_t *buf, int16_t n)
408{
409 if (n EQ -1) {
410
411 strcpy(buf, " ");
412 return(buf);
413
414 } else {
415
416 sprintf(buf, "%02.2d", n);
417 return(buf);
418 }
419}
420
421/*
422
423*/
424
425/*
426 =============================================================================
427 adswin() -- display a window
428 =============================================================================
429*/
430
431void adswin(int16_t n)
432{
433 register int16_t cx, i;
434 register int8_t *bfsp;
435 int8_t buf1[4], buf2[4];
436
437 if ((n EQ 7) AND (admctl NE -1))
438 return;
439
440 cx = exp_c(adbox[n][5]);
441 point = adpoint;
442
443 /* first, fill the box with the background color */
444
445 vbank(0);
446 vbfill4(asgob, 128, adbox[n][0], adbox[n][1], adbox[n][2],
447 adbox[n][3], cx);
448
449 /* put in the box label */
450
451 tsplot4(asgob, 64, adbox[n][4], adbox[n][6], adbox[n][7],
452 adbxlb[n], 14);
453
454/*
455
456*/
457 switch (n) { /* final text - overlays above stuff */
458
459 case 0: /* assignment table number and name */
460
461 sprintf(bfs, "%02.2d", curasg);
462 tsplot4(asgob, 64, (asgmod ? AK_MODC : adbox[n][4]),
463 adbox[n][6], adbox[n][7] + 8, bfs, 14);
464
465 sprintf(bfs, "%-10.10s", caname);
466 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + 1,
467 adbox[n][7], bfs, 14);
468
469 return;
470
471 case 2: /* output MIDI port number */
472
473 tsplot4(asgob, 64, adbox[n][4], adbox[n][6], adbox[n][7] + 9,
474 gprep[curmop], 14);
475
476 return;
477
478 case 3: /* MIDI program change channel (always on port 1) */
479
480 sprintf(bfs, "%02.2d", prgchan);
481 tsplot4(asgob, 64, adbox[n][4], adbox[n][6], adbox[n][7] + 8,
482 bfs, 14);
483
484 return;
485/*
486
487*/
488 case 4: /* groups to voices */
489
490 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + 1, adbox[n][7],
491 "of Groups", 14);
492
493 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + 2, adbox[n][7],
494 "to Voices", 14);
495
496 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + 3, adbox[n][7],
497 "V Gr V Gr", 14);
498
499 lseg(CTOX(13), RTOY(3) + 13,
500 CTOX(13) + 7, RTOY(3) + 13, adbox[n][4]);
501
502 lseg(CTOX(15), RTOY(3) + 13,
503 CTOX(16) + 7, RTOY(3) + 13, adbox[n][4]);
504
505 lseg(CTOX(19), RTOY(3) + 13,
506 CTOX(19) + 7, RTOY(3) + 13, adbox[n][4]);
507
508 lseg(CTOX(21), RTOY(3) + 13,
509 CTOX(22) + 7, RTOY(3) + 13, adbox[n][4]);
510
511 for (i = 0; i < 6; i++) {
512
513 sprintf(bfs, "%c %s", i + '1',
514 numblk(buf1, vce2grp[i]));
515
516 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + i + 4,
517 adbox[n][7], bfs, 14);
518
519 sprintf(bfs, "%c %s", (i > 2 ? (i + 169) : (i + '7')),
520 numblk(buf2, vce2grp[i + 6]));
521
522 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + i + 4,
523 adbox[n][7] + 6, bfs, 14);
524 }
525
526 return;
527/*
528
529*/
530 case 5: /* MIDI controller number assignments */
531
532 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + 1, adbox[n][7],
533 "Sources and", 14);
534
535 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + 2, adbox[n][7],
536 "Controllers", 14);
537
538 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + 3, adbox[n][7],
539 "# Source CN", 14);
540
541 lseg(CTOX(25), RTOY(3) + 13,
542 CTOX(25) + 7, RTOY(3) + 13, adbox[n][4]);
543
544 lseg(CTOX(27), RTOY(3) + 13,
545 CTOX(33) + 7, RTOY(3) + 13, adbox[n][4]);
546
547 lseg(CTOX(35), RTOY(3) + 13,
548 CTOX(36) + 7, RTOY(3) + 13, adbox[n][4]);
549
550 for (i = 0; i < 6; i++)
551 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + i + 4,
552 adbox[n][7], asgsrc[i], 14);
553
554 for (i = 0; i < 4; i++) {
555
556 sprintf(bfs, "%s", numblk(buf1, (mctlnum[i] & 0x00FF)));
557
558 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + i + 5,
559 adbox[n][7] + 10, bfs, 14);
560
561 if ((mctlnum[i] NE -1) AND (mctlnum[i] & CTAG1)) {
562
563 bfs[0] = '2' + i;
564 bfs[1] = '\0';
565
566 tsplot4(asgob, 64, AK_MODC, adbox[n][6] + i + 5,
567 adbox[n][7], bfs, 14);
568 }
569 }
570
571 return;
572/*
573
574*/
575 case 6: /* instruments, dynamics, MIDI ports and channels to groups */
576
577 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + 1, adbox[n][7],
578 "Dynamics, MIDI Ports and", 14);
579
580 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + 2, adbox[n][7],
581 "Channels to Groups", 14);
582
583 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + 3, adbox[n][7],
584 "G In D I Ch G In D I Ch", 14);
585
586 lseg(CTOX(39), RTOY(3) + 13,
587 CTOX(39) + 7, RTOY(3) + 13, adbox[n][4]);
588
589 lseg(CTOX(41), RTOY(3) + 13,
590 CTOX(42) + 7, RTOY(3) + 13, adbox[n][4]);
591
592 lseg(CTOX(44), RTOY(3) + 13,
593 CTOX(44) + 7, RTOY(3) + 13, adbox[n][4]);
594
595 lseg(CTOX(46), RTOY(3) + 13,
596 CTOX(46) + 7, RTOY(3) + 13, adbox[n][4]);
597
598 lseg(CTOX(48), RTOY(3) + 13,
599 CTOX(49) + 7, RTOY(3) + 13, adbox[n][4]);
600
601
602 lseg(CTOX(52), RTOY(3) + 13,
603 CTOX(52) + 7, RTOY(3) + 13, adbox[n][4]);
604
605 lseg(CTOX(54), RTOY(3) + 13,
606 CTOX(55) + 7, RTOY(3) + 13, adbox[n][4]);
607
608 lseg(CTOX(57), RTOY(3) + 13,
609 CTOX(57) + 7, RTOY(3) + 13, adbox[n][4]);
610
611 lseg(CTOX(59), RTOY(3) + 13,
612 CTOX(59) + 7, RTOY(3) + 13, adbox[n][4]);
613
614 lseg(CTOX(61), RTOY(3) + 13,
615 CTOX(62) + 7, RTOY(3) + 13, adbox[n][4]);
616
617/*
618
619*/
620 for (i = 0; i < 6; i++) {
621
622 sprintf(bfs, "%c %02.2d %d %s %s %c %02.2d %d %s %s",
623
624 i + '1',
625 (ins2grp[i] & 0x00FF), grpdyn[i],
626 gprep[grp2prt[i][0]],
627 numblk(buf1, grp2prt[i][1]),
628
629 ((i > 2) ? (i + 169) : (i + '7')),
630 (ins2grp[i + 6] & 0x00FF), grpdyn[i + 6],
631 gprep[grp2prt[i + 6][0]],
632 numblk(buf2, grp2prt[i + 6][1]));
633
634 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + i + 4,
635 adbox[n][7], bfs, 14);
636
637 if (GTAG1 & ins2grp[i]) {
638
639 bfs[1] = '\0';
640
641 tsplot4(asgob, 64, AK_MODC, adbox[n][6] + i + 4,
642 adbox[n][7], bfs, 14);
643 }
644
645 if (GTAG1 & ins2grp[i + 6]) {
646
647 bfs[14] = '\0';
648
649 tsplot4(asgob, 64, AK_MODC, adbox[n][6] + i + 4,
650 adbox[n][7] + 13, &bfs[13], 14);
651 }
652 }
653
654 return;
655/*
656
657*/
658 case 7: /* port 1 key to group assignments */
659
660 lseg( 8, 153, 15, 153, exp_c(adbox[n][4])); /* underlines */
661 lseg(496, 153, 503, 153, exp_c(adbox[n][4]));
662
663 asgkb(); /* icon */
664
665 for (i = 0; i < 12; i++) /* assignments */
666 drawk2g(i);
667
668 return;
669
670 case 8: /* aux control */
671
672 tsplot4(asgob, 64, (auxctl ? AK_MODC : adbox[n][4]),
673 adbox[n][6], adbox[n][7], "Aux", 14);
674
675 return;
676
677 case 9: /* tuning table */
678
679 tsplot4(asgob, 64, adbox[n][4], adbox[n][6], adbox[n][7],
680 "Tun", 14);
681
682 sprintf(bfs, "%d", curtun);
683 tsplot4(asgob, 64, (tunmod ? AK_MODC : adbox[n][4]),
684 adbox[n][6], adbox[n][7] + 4, bfs, 14);
685
686 return;
687
688 case 10: /* phase shifter variables -- intensity, rate depth */
689
690 sprintf(bfs, "Intnsty %02.2d", ps_intn);
691 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + 1, adbox[n][7],
692 bfs, 14);
693
694 sprintf(bfs, "ModRate %02.2d", ps_rate);
695 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + 2, adbox[n][7],
696 bfs, 14);
697
698 sprintf(bfs, "ModDpth %02.2d", ps_dpth);
699 tsplot4(asgob, 64, adbox[n][4], adbox[n][6] + 3, adbox[n][7],
700 bfs, 14);
701
702 return;
703 }
704}
705
706/*
707
708*/
709
710/*
711 =============================================================================
712 initat() -- initialize assignment table
713 =============================================================================
714*/
715
716void initat(int16_t n)
717{
718 register struct asgent *ap;
719 register int16_t i;
720
721 ap = &asgtab[n];
722 ap->a_mop = 0; /* output to NULL */
723 ap->a_tun = 0; /* tuning = default */
724 ap->a_aux = 0; /* aux ctl = OFF */
725 ap->a_intn = 70; /* intensity */
726 ap->a_rate = 0; /* rate */
727 ap->a_dpth = 70; /* depth */
728
729 for (i = 0; i < 12; i++) { /* groups 1..12 */
730
731 ap->a_i2grp[i] = 0; /* instrument */
732 ap->a_gpdyn[i] = 9; /* dynamics */
733 }
734
735 for (i = 0; i < 8; i++) /* voices 1..8 to group 1 */
736 ap->a_v2grp[i] = 1;
737
738 for (i = 8; i < 12; i++) /* voices 9..12 to group 2 */
739 ap->a_v2grp[i] = 2;
740
741 ap->a_mctln[0] = 1; /* modulation wheel */
742 ap->a_mctln[1] = 2; /* breath controller */
743 ap->a_mctln[2] = 80; /* general controller 1 */
744 ap->a_mctln[3] = 4; /* pedal controller 1 */
745
746 ap->a_g2prt[0][0] = 1; /* group 1: port 1 input */
747 ap->a_g2prt[0][1] = 1; /* group 1: channel 1 in and out */
748 ap->a_g2prt[1][0] = 3; /* group 2: local input */
749 ap->a_g2prt[1][1] = 1; /* group 2: channel 1 in and out*/
750
751 for (i = 2; i < 12; i++) { /* groups 3..12 */
752
753 ap->a_g2prt[i][0] = 0; /* no input port */
754 ap->a_g2prt[i][1] = -1; /* no channel */
755 }
756
757 memsetw(ap->a_k2grp, 0x0001, 88); /* all keys in group 1 */
758
759 memcpy(ap->a_name, n ? "{unused} " : "{Default} ", 16);
760}
761
762/*
763
764*/
765
766/*
767 =============================================================================
768 setaux() -- set aux control
769 =============================================================================
770*/
771
772void setaux(int16_t aux)
773{
774 register int16_t psgdata;
775 register int8_t *psg;
776
777 auxctl = aux;
778 psg = &io_tone;
779
780 *(psg + PSG_ADDR) = PSG_IOEN; /* setup PSG I/O controls */
781 *(psg + PSG_WRIT) = PSG_IDLE;
782
783 *(psg + PSG_ADDR) = PSG_PRTB; /* read current psg data */
784 psgdata = *(psg + PSG_READ) & ~AUX_BIT;
785
786 *(psg + PSG_ADDR) = PSG_PRTB; /* send out updated aux data */
787 *(psg + PSG_WRIT) = psgdata | (aux ? 0 : AUX_BIT);
788}
789
790/*
791
792*/
793
794/*
795 =============================================================================
796 getasg() -- get an assignment table from the library
797 =============================================================================
798*/
799
800void getasg(int16_t n)
801{
802 register struct asgent *ap;
803 register int16_t i, grp, vce;
804
805 ap = &asgtab[n];
806 curmop = ap->a_mop;
807 gettun(ap->a_tun);
808 setaux(ap->a_aux);
809 ps_intn = ap->a_intn;
810 ps_rate = ap->a_rate;
811 ps_dpth = ap->a_dpth;
812 memcpyw(ins2grp, ap->a_i2grp, sizeof ins2grp / 2);
813 memcpyw(grpdyn, ap->a_gpdyn, sizeof grpdyn / 2);
814 memcpyw(vce2grp, ap->a_v2grp, sizeof vce2grp / 2);
815 memcpyw(mctlnum, ap->a_mctln, sizeof mctlnum / 2);
816 memcpyw(grp2prt, ap->a_g2prt, sizeof grp2prt / 2);
817 memcpyw(key2grp, ap->a_k2grp, sizeof key2grp / 2);
818 memcpy(caname, ap->a_name, 16);
819
820 for (i = 0; i < 12; i++) /* fix old tables */
821 if (grp2prt[i][0] EQ 4)
822 grp2prt[i][0] = 3;
823
824 sendval(1, 0, (ps_intn * 10) << 5);
825 sendval(2, 0, (ps_rate * 10) << 5);
826 sendval(3, 0, (ps_dpth * 10) << 5);
827
828 for (vce = 0; vce < 12; vce++) {
829
830 grp = vce2grp[vce];
831
832 if (grp NE -1) {
833
834 s_inst[vce] = ins2grp[grp - 1] & 0x00FF;
835 execins(vce, s_inst[vce], 1);
836 sendval(vce, 8, dyntab[grpdyn[grp - 1]]);
837 }
838 }
839
840 newvce(curvce);
841 asgmod = FALSE;
842}
843
844/*
845
846*/
847
848/*
849 =============================================================================
850 putasg() -- put an assignment table into the library
851 =============================================================================
852*/
853
854void putasg(int16_t n)
855{
856 register struct asgent *ap;
857 register int16_t i;
858
859 for (i = 0; i < 12; i++) /* fix old tables */
860 if (grp2prt[i][0] EQ 4)
861 grp2prt[i][0] = 3;
862
863 ap = &asgtab[n];
864 ap->a_mop = curmop;
865 ap->a_tun = curtun;
866 ap->a_aux = auxctl;
867 ap->a_intn = ps_intn;
868 ap->a_rate = ps_rate;
869 ap->a_dpth = ps_dpth;
870 memcpyw(ap->a_i2grp, ins2grp, sizeof ins2grp / 2);
871 memcpyw(ap->a_gpdyn, grpdyn, sizeof grpdyn / 2);
872 memcpyw(ap->a_v2grp, vce2grp, sizeof vce2grp / 2);
873 memcpyw(ap->a_mctln, mctlnum, sizeof mctlnum / 2);
874 memcpyw(ap->a_g2prt, grp2prt, sizeof grp2prt / 2);
875 memcpyw(ap->a_k2grp, key2grp, sizeof key2grp / 2);
876 memcpy(ap->a_name, caname, 16);
877 asgmod = FALSE;
878}
879
880/*
881
882*/
883
884/*
885 =============================================================================
886 awins() -- display all assignment editor windows
887 =============================================================================
888*/
889
890void awins(void)
891{
892 register int16_t i;
893
894 for (i = 0; i < 11; i++)
895 adswin(i);
896}
897
898/*
899 =============================================================================
900 inital() -- initialize assignment library
901 =============================================================================
902*/
903
904void inital(void)
905{
906 register int16_t n;
907
908 for (n = 0; n < NASGS; n++)
909 initat(n);
910
911 getasg(0);
912 prgchan = 1;
913}
914
915/*
916
917*/
918
919/*
920 =============================================================================
921 adbord() -- draw the border for the display
922 =============================================================================
923*/
924
925void adbord(void)
926{
927 point = adpoint;
928
929 lseg( 0, 0, 511, 0, AK_BORD); /* outer border */
930 lseg(511, 0, 511, 349, AK_BORD);
931 lseg(511, 349, 0, 349, AK_BORD);
932 lseg( 0, 349, 0, 0, AK_BORD);
933
934 lseg( 0, 41, 95, 41, AK_BORD); /* windows - H lines */
935 lseg( 0, 55, 95, 55, AK_BORD);
936 lseg( 0, 69, 95, 69, AK_BORD);
937 lseg( 0, 83, 95, 83, AK_BORD);
938 lseg( 0, 139, 511, 139, AK_BORD);
939
940 lseg( 39, 69, 39, 83, AK_BORD); /* windows - V lines */
941 lseg( 95, 0, 95, 139, AK_BORD);
942 lseg(191, 0, 191, 139, AK_BORD);
943 lseg(303, 0, 303, 139, AK_BORD);
944}
945
946/*
947
948*/
949
950/*
951 =============================================================================
952 asgdsp() -- put up the assignment display
953 =============================================================================
954*/
955
956void asgdsp(void)
957{
958 asgob = v_score; /* setup object pointer */
959 obj0 = v_curs0; /* setup cursor object pointer */
960 obj2 = v_tcur; /* setup typewriter object pointer */
961 adoct = &v_obtab[ASGOBJ]; /* setup object control table pointer */
962
963 adnamsw = FALSE; /* virtual typewriter not up */
964 submenu = FALSE; /* no submenu cursor up */
965 admctl = -1; /* no submenu up */
966
967 dswap(); /* initialize display */
968
969 vbank(0); /* clear the display */
970 memsetw(asgob, 0, 32767);
971 memsetw(asgob+32767L, 0, 12033);
972
973 SetObj(ASGOBJ, 0, 0, asgob, 512, 350, 0, 0, ASGNFL, -1);
974 SetObj( 0, 0, 1, obj0, 16, 16, CTOX(9), RTOY(0), OBFL_00, -1);
975 SetObj(TTCURS, 0, 1, obj2, 16, 16, 0, 0, TTCCFL, -1);
976
977 arcurs(AK_CURS); /* setup arrow cursor object */
978 itcini(AK_CURS); /* setup text cursor object */
979 ttcini(AK_CURS); /* setup virtual typewriter cursor object */
980
981 adbord(); /* draw the border */
982 awins(); /* fill in the windows */
983
984 SetPri(ASGOBJ, ASGPRI); /* enable screen object */
985
986 settc(0, 9); /* display text cursor */
987
988 vsndpal(asgpal); /* set the palette */
989}
990
Note: See TracBrowser for help on using the repository browser.