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

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

Make tables unsigned.

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