source: buchla-68k/ram/idselbx.c@ 5399628

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

Unused variables and parameters.

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