source: buchla-68k/orig/RAM/IDSELBX.C@ c93e44d

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

Imported original source code.

  • Property mode set to 100755
File size: 13.1 KB
Line 
1/*
2 =============================================================================
3 idselbx.c -- instrument definition box selection functions
4 Version 46 -- 1988-09-15 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "stddefs.h"
9#include "fields.h"
10#include "hwdefs.h"
11#include "vsdd.h"
12#include "graphdef.h"
13
14#include "midas.h"
15#include "instdsp.h"
16
17extern short (*itxput)();
18
19extern short lseg(), dswin(), tsplot4(), vbfill4(), enterit(), vtdisp();
20extern short advicur(), bspicur();
21
22extern short drawfn(), selpnt(), ttox(), vtoy();
23
24extern unsigned timeto(), exp_c();
25
26/*
27
28*/
29
30extern short cursbox, cxval, cyval;
31extern short curvce, curfunc, curpnt;
32extern short hitbox, hitcx, hitcy, idnamsw, idimsw, idtdat;
33extern short pntsv, pecase, stccol, subj, submenu;
34
35extern unsigned temin, temax;
36
37extern struct selbox *csbp, *curboxp;
38extern struct instdef vbufs[];
39extern struct instdef idefs[];
40
41extern struct instpnt *pntptr;
42
43extern short idbox[][8];
44extern short instmod[];
45
46extern char *vtdeptr;
47
48extern char *idbxlbl[];
49extern char idhlbl[];
50extern char bfs[];
51
52extern unsigned *instob;
53
54/* forward references */
55
56short bx_null(), idfnbox();
57
58/*
59
60*/
61
62struct selbox idboxes[] = {
63
64 { 1, 1, 84, 26, 0, idfnbox}, /* 0: Freq 1 */
65 { 86, 1, 169, 26, 1, idfnbox}, /* 1: Freq 2 */
66 {171, 1, 254, 26, 2, idfnbox}, /* 2: Freq 3 */
67 {256, 1, 339, 26, 3, idfnbox}, /* 3: Freq 4 */
68 {341, 1, 424, 26, 4, idfnbox}, /* 4: Filter / Resonance */
69 {426, 1, 509, 26, 5, idfnbox}, /* 5: Location */
70
71 { 1, 28, 84, 54, 6, idfnbox}, /* 6: Index 1 */
72 { 86, 28, 169, 54, 7, idfnbox}, /* 7: Index 2 */
73 {171, 28, 254, 54, 8, idfnbox}, /* 8: Index 3 */
74 {256, 28, 339, 54, 9, idfnbox}, /* 9: Index 4 */
75 {341, 28, 424, 54, 10, idfnbox}, /* 10: Index 5 */
76 {426, 28, 509, 54, 11, idfnbox}, /* 11: Index 6 */
77
78 { 1, 56, 509, 208, 12, idfnbox}, /* 12: Level */
79
80 { 1, 210, 110, 236, 0x0000, enterit}, /* 13: Source- Mlt */
81 {112, 210, 142, 236, 0x0000, enterit}, /* 14: Pt */
82 {144, 210, 206, 236, 0x0000, enterit}, /* 15: Time */
83 {208, 210, 366, 236, 0x0000, enterit}, /* 16: Value */
84 {368, 210, 509, 236, 0x0000, enterit}, /* 17: Action */
85
86 { 1, 238, 131, 348, 0x0000, idfnbox}, /* 18: Algorithm */
87 {133, 238, 267, 251, 0x0000, idfnbox}, /* 19: Voice & Inst */
88 {269, 238, 379, 306, 0x0000, enterit}, /* 20: Oscillators */
89 {381, 238, 509, 348, 0x0000, idfnbox}, /* 21: Waveshape */
90
91 {133, 308, 379, 348, 0x0000, enterit}, /* 22: Variables */
92
93 {133, 252, 267, 306, 19, idfnbox}, /* 23: Name & Comments */
94
95 { 0, 0, 0, 0, 0, FN_NULL} /* end of table */
96};
97
98/*
99
100*/
101
102/*
103 =============================================================================
104 idtxput() -- put out instrument menu text for the instrument display
105 =============================================================================
106*/
107
108idtxput(row, col, txt, tag)
109short row, col;
110char *txt;
111short tag;
112{
113 if (v_regs[5] & 0x0180)
114 vbank(0);
115
116 tsplot4(instob, 64, CFBX19, row, col, txt, 14);
117}
118
119/*
120 =============================================================================
121 showim() -- show the instrument menu
122 =============================================================================
123*/
124
125showim()
126{
127 register short row, col, ins;
128
129 ins = 0;
130
131 for (col = 1; col < 46; col += 22) {
132
133 (*itxput)(0, col, "No Instrument", 0);
134
135 for (row = 1; row < 15; row++) {
136
137 if (ins GE NINST)
138 break;
139
140 sprintf(bfs, "%02d %-16.16s", ins, idefs[ins].idhname);
141 (*itxput)(row, col, bfs, 1);
142 ++ins;
143 }
144 }
145}
146
147/*
148
149*/
150
151/*
152 =============================================================================
153 cdnicur() -- instrument definition virtual typewriter -- cursor down
154 =============================================================================
155*/
156
157cdnicur()
158{
159 register struct instdef *ip;
160
161 ip = &vbufs[curvce];
162
163 switch (idtdat) {
164
165 case 0:
166 idtdat = 1;
167 vtdeptr = ip->idhcom1;
168 settc(19, stccol);
169 return;
170
171 case 1:
172 idtdat = 2;
173 vtdeptr = ip->idhcom2;
174 settc(20, stccol);
175 return;
176
177 case 2:
178 idtdat = 3;
179 vtdeptr = ip->idhcom3;
180 settc(21, stccol);
181 return;
182
183 case 3:
184 idtdat = 0;
185 vtdeptr = ip->idhname;
186 settc(18, stccol);
187 return;
188 }
189}
190
191/*
192
193*/
194
195/*
196 =============================================================================
197 cupicur() -- instrument definition virtual typewriter -- cursor up
198 =============================================================================
199*/
200
201cupicur()
202{
203 register struct instdef *ip;
204
205 ip = &vbufs[curvce];
206
207 switch (idtdat) {
208
209 case 0:
210 idtdat = 3;
211 vtdeptr = ip->idhcom3;
212 settc(21, stccol);
213 return;
214
215 case 1:
216 idtdat = 0;
217 vtdeptr = ip->idhname;
218 settc(18, stccol);
219 return;
220
221 case 2:
222 idtdat = 1;
223 vtdeptr = ip->idhcom1;
224 settc(19, stccol);
225 return;
226
227 case 3:
228 idtdat = 2;
229 vtdeptr = ip->idhcom2;
230 settc(20, stccol);
231 return;
232 }
233}
234
235/*
236
237*/
238
239/*
240 =============================================================================
241 edfunc() -- setup to edit a function
242 =============================================================================
243*/
244
245short
246edfunc(n)
247short n;
248{
249 register unsigned cx;
250 register struct instdef *ip;
251
252 ip = &vbufs[curvce];
253
254 /* first, put level in selected window */
255
256 cx = exp_c(ID_LVLC); /* label background = level background */
257
258 vbank(0);
259 vbfill4(instob, 128, idbox[n][0], idbox[n][1],
260 idbox[n][2], idbox[n][3], cx);
261
262 tsplot4(instob, 64,
263 ((ip->idhfnc[12].idftmd & I_TM_KEY) ? idbox[n][4] : ID_INST),
264 idbox[n][6], idbox[n][7], idbxlbl[12], 14);
265
266 if (n NE 12) /* if not editing the level, draw it in the label */
267 drawfn(12, 0, ID_CLVL, n);
268
269/*
270
271*/
272 /* next, put the level and selected functions in the level window */
273
274 vbank(0); /* clear the edit/level box */
275 vbfill4(instob, 128, idbox[12][0], idbox[12][1],
276 idbox[12][2], idbox[12][3], cx);
277
278 /* label the function */
279
280 tsplot4(instob, 64,
281 ((ip->idhfnc[n].idftmd & I_TM_KEY) ? idbox[n][4] : ID_INST),
282 idbox[12][6], idbox[12][7], idbxlbl[n], 14);
283
284 /* scale -- x labels */
285
286 tsplot4(instob, 64, TGRID, 14, 0, idhlbl, 14);
287
288 /* scale -- y labels */
289
290 tsplot4(instob, 64, TGRID, 14, 0, "\300", 14);
291 tsplot4(instob, 64, TGRID, 12, 0, "\302", 14);
292 tsplot4(instob, 64, TGRID, 10, 0, "\304", 14);
293 tsplot4(instob, 64, TGRID, 8, 0, "\306", 14);
294 tsplot4(instob, 64, TGRID, 6, 0, "\310", 14);
295 tsplot4(instob, 64, TGRID, 4, 0, "\312", 14);
296
297 lseg( 7, 56, 7, 196, LGRID); /* draw the scale */
298 lseg( 7, 196, 509, 196, LGRID);
299
300 /* plot functions: first level, then selected function */
301
302 if (n NE 12) /* if not editing level, draw it as a reference */
303 drawfn(12, 0, ID_CLVL, 12);
304
305 drawfn(n, pntsv, ID_CLIN, 12);
306
307 curfunc = n; /* make n the current function */
308
309 if (curfunc EQ 4) {
310
311 tsplot4(instob, 64,
312 ((ip->idhfnc[n].idftmd & I_TM_KEY) ?
313 idbox[12][4] : ID_INST),
314 idbox[12][6] + 1, idbox[12][7] + 4, "Res", 14);
315
316 rd_ires(12);
317 }
318
319 return(TRUE);
320}
321
322/*
323
324*/
325
326/*
327 =============================================================================
328 showpt() -- show the data about a point
329 =============================================================================
330*/
331
332showpt(q)
333short q;
334{
335 register short ptx, pty, i, j, k;
336 register struct instdef *ip;
337 short ptc;
338
339 if (q)
340 dswin(14); /* point number */
341
342 dswin(15); /* time */
343 dswin(16); /* value */
344 dswin(17); /* action */
345
346 ip = &vbufs[curvce];
347 j = ip->idhfnc[curfunc].idfpif;
348 k = ip->idhfnc[curfunc].idfpt1;
349
350 for (i = 0; i < j; i++) {
351
352 ptx = ttox(timeto(curfunc, i), 12);
353 pty = vtoy((ip->idhpnt[k + i].ipval) >> 5, 12);
354 ptc = ((ip->idhpnt[k + i].ipvsrc) OR (ip->idhpnt[k + i].ipact) ?
355 ID_ACTP : ID_CPNT);
356
357 drawpt(ptx, pty, ptc);
358 }
359
360 ptx = ttox(timeto(curfunc, subj), 12);
361 pty = vtoy((ip->idhpnt[k + subj].ipval) >> 5, 12);
362 drawpt(ptx, pty, ID_SELD);
363}
364
365/*
366
367*/
368
369/*
370 =============================================================================
371 endityp() -- exit instrument definition virtual typewriter
372 =============================================================================
373*/
374
375endityp()
376{
377 idnamsw = FALSE;
378 submenu = FALSE;
379 idvlblc();
380 dswin(19);
381 dswin(22);
382}
383
384/*
385 =============================================================================
386 showfn() show the data about a function
387 =============================================================================
388*/
389
390showfn()
391{
392 dswin(13); /* source multiplier */
393 showpt(1); /* point, time, value, action */
394}
395
396/*
397 =============================================================================
398 bx_null() -- null item selection processor
399 =============================================================================
400*/
401
402short
403bx_null()
404{
405 return(TRUE);
406}
407
408/*
409 =============================================================================
410 iclrwin() -- clear an instrument editor window
411 =============================================================================
412*/
413
414iclrwin(n)
415register short n;
416{
417 if (v_regs[5] & 0x0180)
418 vbank(0);
419
420 vbfill4(instob, 128, idbox[n][0], idbox[n][1], idbox[n][2], idbox[n][3],
421 exp_c(idbox[n][5]));
422}
423
424/*
425
426*/
427
428/*
429 =============================================================================
430 idfnbox() -- instrument display function box hit processor
431 =============================================================================
432*/
433
434short
435idfnbox(n)
436short n;
437{
438 register short col, i, row;
439 register struct instdef *ip;
440 register char *ivtdptr;
441
442 ip = &vbufs[curvce];
443
444 row = hitcy / 14;
445 col = hitcx >> 3;
446
447/*
448
449*/
450 if (hitbox EQ 12) { /* process a hit in the level window */
451
452 /* handle data entry special case for resonance in filter fn. */
453
454 if ((curfunc EQ 4) AND (row EQ 5) AND (col EQ 62))
455 return(enterit());
456
457 switch (pntsv) { /* dispatch off of point select state */
458
459 case 0: /* nothing selected so far: select a point */
460
461 subj = selpnt(); /* decide on the point */
462 pntsel(); /* make it current */
463 pntsv = 1; /* say it's selected */
464
465 edfunc(curfunc); /* update the display */
466 showpt(1);
467
468 /* set cursor to point */
469
470 cxval = ttox(timeto(curfunc, subj), 12);
471 cyval = vtoy((pntptr->ipval >> 5), 12);
472 arcurs(ID_SELD);
473 gcurpos(cxval, cyval);
474 break;
475
476 case 1: /* point was selected: unselect it */
477
478 pntsv = 0;
479 edfunc(curfunc);
480 arcurs(ID_NCUR);
481 gcurpos(cxval, cyval);
482 break;
483 }
484
485 return(TRUE);
486
487 } else if (hitbox EQ 18) { /* configuration */
488
489 if ((row EQ 17) AND (col GE 4) AND (col LE 9)) {
490
491 wcmenu(0);
492 return(TRUE);
493
494 } else {
495
496 return(enterit());
497 }
498/*
499
500*/
501 } else if (hitbox EQ 19) { /* voice & inst. */
502
503 if ((col GE 26) AND (col LE 29) AND (row EQ 17)) {
504
505 if (idimsw) { /* menu is up, take it down */
506
507 idimsw = FALSE;
508
509 if (v_regs[5] & 0x0180)
510 vbank(0);
511
512 idbord();
513 allwins();
514
515 } else { /* menu is down, put it up */
516
517 idimsw = TRUE;
518 itxput = idtxput;
519
520 if (v_regs[5] & 0x0180)
521 vbank(0);
522
523 vbfill4(instob, 128, 1, 1, 510, 208,
524 exp_c(idbox[19][5]));
525
526 for (i = 13; i LE 18; i++)
527 iclrwin(i);
528
529 for (i = 20; i LE 22; i++)
530 iclrwin(i);
531
532 showim();
533 }
534
535 return(SUCCESS);
536
537 } else {
538
539 return(enterit()); /* do data entry */
540 }
541/*
542
543*/
544 } else if (hitbox EQ 21) { /* waveshapes */
545
546 if ((row EQ 17) AND (col GE 48) AND (col LE 54)) {
547
548 wcmenu(1);
549 return(TRUE);
550
551 } else {
552
553 return(enterit());
554 }
555
556 } else if (hitbox EQ 23) { /* process a hit in the name window */
557
558 if (idnamsw) { /* typewriter up - enter data */
559
560 vtyper();
561 instmod[curvce] = TRUE;
562
563 } else { /* put up the typewriter */
564
565 /* set data pointer */
566
567 if (row EQ 18)
568 ivtdptr = ip->idhname;
569 else if (row EQ 19)
570 ivtdptr = ip->idhcom1;
571 else if (row EQ 20)
572 ivtdptr = ip->idhcom2;
573 else
574 ivtdptr = ip->idhcom3;
575
576 idtdat = row - 18;
577
578 idvtyp(); /* display typewriter */
579 dswin(22);
580 idnamsw = TRUE;
581 submenu = TRUE;
582
583 vtsetup(instob, vtdisp, 17, ivtdptr, 22, 17,
584 advicur, bspicur, cupicur, cdnicur, endityp,
585 idbox[19][4], idbox[19][5]);
586 }
587
588 return(TRUE);
589/*
590
591*/
592 } else if (hitbox < 12) { /* process a hit in a label window */
593
594 pntsv = 0; /* unselect previous point */
595
596 arcurs(ID_NCUR); /* set cursor color */
597 gcurpos(cxval, cyval);
598
599 if (n NE curfunc) { /* new function selected */
600
601 if (curfunc NE 12)
602 dswin(curfunc); /* stow old function */
603
604 edfunc(n); /* select new function */
605
606 } else { /* reselect level */
607
608 dswin(curfunc); /* stow old function */
609 edfunc(12); /* select level */
610 }
611
612 subj = 0; /* reset function selection */
613 pntsel();
614
615 showfn(); /* update display */
616
617 setgc(ICURX, ICURY); /* put cursor in center */
618 return(TRUE);
619 }
620
621 return(FALSE);
622}
Note: See TracBrowser for help on using the repository browser.