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

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

Use standard integer types.

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