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

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

Removed redundant declarations.

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