source: buchla-68k/ram/asgdsp.c@ 572daa7

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

Fix conversion warnings.

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