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

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

Added missing includes and declarations.

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