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

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

Point of no return.

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