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

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

Added include files for global functions and variables.

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