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