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