source: buchla-68k/ram/idfield.c@ 5c13d64

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

Use void pointers for mem*() functions.

  • Property mode set to 100644
File size: 13.5 KB
Line 
1/*
2 =============================================================================
3 idfield.c -- instrument display field processing and cursor motion
4 Version 89 -- 1989-11-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#include "charset.h"
14#include "smdefs.h"
15#include "curpak.h"
16
17#include "midas.h"
18#include "instdsp.h"
19
20extern void select(void);
21extern void stdmkey(void);
22extern void stddkey(short k);
23extern void nokey(void);
24extern void cxkstd(void);
25extern void cykstd(void);
26extern short vtoy(short val, short window);
27extern short ttox(unsigned time, short window);
28extern short timeto(short fn, short pj);
29extern void vcputsv(int *obase, int nw, int fg, int bg, int row, int col, char *str, int pitch);
30extern void dswin(short n);
31extern short stdctp1(void);
32extern short whatbox(void);
33extern short inspnt(struct instdef *ip, short fn, short inpnt);
34extern void pntsel(void);
35extern void setseg(short pn, unsigned ptime);
36extern void showpt(short q);
37
38extern short et_null(short n);
39extern short ef_null(short n);
40extern short rd_null(short n);
41extern short nd_null(short n, short k);
42extern short et_ipnt(short n);
43extern short ef_ipnt(short n);
44extern short rd_ipnt(short n);
45extern short nd_ipnt(short n, short k);
46extern short et_idin(short n);
47extern short ef_idin(short n);
48extern short rd_idin(short n);
49extern short nd_idin(short n, short k);
50extern short et_ivce(short n);
51extern short ef_ivce(short n);
52extern short rd_ivce(short n);
53extern short nd_ivce(short n, short k);
54extern short et_icnf(short n);
55extern short ef_icnf(short n);
56extern short rd_icnf(short n);
57extern short nd_icnf(short n, short k);
58extern short et_ival(short n);
59extern short ef_ival(short n);
60extern short rd_ival(short n);
61extern short nd_ival(short n, short k);
62extern short et_itim(short n);
63extern short ef_itim(short n);
64extern short rd_itim(short n);
65extern short nd_itim(short n, short k);
66extern short et_iosc(short nn);
67extern short ef_iosc(short nn);
68extern short rd_iosc(short nn);
69extern short nd_iosc(short nn, short k);
70extern short et_iact(short nn);
71extern short ef_iact(short nn);
72extern short rd_iact(short nn);
73extern short nd_iact(short nn, short k);
74extern short et_iwsn(short nn);
75extern short ef_iwsn(short nn);
76extern short rd_iwsn(short nn);
77extern short nd_iwsn(short nn, short k);
78extern short et_ires(short n);
79extern short ef_ires(short n);
80extern short rd_ires(short n);
81extern short nd_ires(short n, short k);
82extern short et_imlt(short n);
83extern short ef_imlt(short n);
84extern short rd_imlt(short n);
85extern short nd_imlt(short n, short k);
86
87extern unsigned fromfpu(unsigned fputime);
88
89extern void *memset(void *vp, char c, int n);
90
91/*
92
93*/
94
95extern short curvce, curfunc, curpnt, hitbox, astat, idnamsw;
96extern short cxval, cyval, cxrate, cyrate, curslim, cmtype, cmfirst;
97extern short pecase, pntsv, npts, subj, idimsw, wcflag, imflag;
98extern short idcfsw, idsrcsw, vtcrow, vtccol, stcrow, stccol;
99extern short vtxval, vtyval;
100
101extern short temax, temin;
102
103extern short *cratex, *cratey, crate0[], crate1[];
104
105extern unsigned *instob;
106
107extern char bfs[];
108extern char *idbxlbl[];
109
110extern short fnoff[];
111extern short idbox[][8];
112
113extern struct selbox *csbp;
114extern struct selbox idboxes[];
115
116extern struct sment sments[];
117extern struct sment *vpsms[];
118
119extern struct valent valents[];
120
121extern struct instpnt *pntptr;
122
123extern struct instdef vbufs[];
124
125void idx_key(void);
126short idnfld(short k);
127void idcxupd(void);
128void idcyupd(void);
129void ikyup(void);
130void ikydn(void);
131
132/*
133
134*/
135
136short zonemax[9] = { 63, 119, 175, 231, 287, 343, 399, 455, 509};
137
138short zoneinc[9] = { 2, 2, 4, 9, 18, 36, 73, 146, 303};
139
140struct fet id_fet1[] = {
141
142 { 5, 62, 62, 12, et_ires, ef_ires, rd_ires, nd_ires},
143 {16, 1, 12, 13, et_imlt, ef_imlt, rd_imlt, nd_imlt},
144 {16, 15, 16, 14, et_ipnt, ef_ipnt, rd_ipnt, nd_ipnt},
145 {16, 19, 24, 15, et_itim, ef_itim, rd_itim, nd_itim},
146 {16, 27, 44, 16, et_ival, ef_ival, rd_ival, nd_ival},
147 {16, 47, 62, 17, et_iact, ef_iact, rd_iact, nd_iact},
148 {17, 12, 13, 18, et_icnf, ef_icnf, rd_icnf, nd_icnf},
149 {17, 23, 24, 19, et_ivce, ef_ivce, rd_ivce, nd_ivce},
150 {17, 31, 32, 19, et_idin, ef_idin, rd_idin, nd_idin},
151 {17, 57, 58, 0x0015, et_iwsn, ef_iwsn, rd_iwsn, nd_iwsn},
152 {17, 61, 62, 0x0115, et_iwsn, ef_iwsn, rd_iwsn, nd_iwsn},
153 {18, 36, 46, 0x8014, et_iosc, ef_iosc, rd_iosc, nd_iosc},
154 {18, 17, 32, 0, et_null, ef_null, rd_null, nd_null},
155 {19, 36, 46, 0x8114, et_iosc, ef_iosc, rd_iosc, nd_iosc},
156 {19, 17, 32, 0, et_null, ef_null, rd_null, nd_null},
157 {20, 36, 46, 0x8214, et_iosc, ef_iosc, rd_iosc, nd_iosc},
158 {20, 17, 32, 0, et_null, ef_null, rd_null, nd_null},
159 {21, 36, 46, 0x8314, et_iosc, ef_iosc, rd_iosc, nd_iosc},
160 {21, 17, 32, 0, et_null, ef_null, rd_null, nd_null},
161
162 { 0, 0, 0, 0x0000, FN_NULL, FN_NULL, FN_NULL, FN_NULL}
163};
164
165char *srctbl[] = { /* source label table */
166
167 " ", /* 0 */
168 "Random ", /* 1 */
169 "GPC/CV1", /* 2 */
170 "???????", /* 3 */
171 "???????", /* 4 */
172 "Pitch ", /* 5 */
173 "Key Prs", /* 6 */
174 "Key Vel", /* 7 */
175 "Pedal 1", /* 8 */
176 "???????", /* 9 */
177 "Freq ", /* 10 */
178 "PchW/HT", /* 11 */
179 "ModW/VT", /* 12 */
180 "Brth/LP", /* 13 */
181};
182
183/*
184
185*/
186
187struct curpak id_flds = {
188
189 stdctp1, /* curtype */
190 nokey, /* premove */
191 nokey, /* pstmove */
192 cxkstd, /* cx_key */
193 cykstd, /* cy_key */
194 idcxupd, /* cx_upd */
195 idcyupd, /* cy_upd */
196 ikyup, /* xy_up */
197 ikydn, /* xy_dn */
198 idx_key, /* x_key */
199 select, /* e_key */
200 stdmkey, /* m_key */
201 stddkey, /* d_key */
202 idnfld, /* not_fld */
203 id_fet1, /* curfet */
204 idboxes, /* csbp */
205 crate1, /* cratex */
206 crate1, /* cratey */
207 CT_GRAF, /* cmtype */
208 ICURX, /* cxval */
209 ICURY /* cyval */
210};
211
212/*
213
214*/
215
216/*
217 =============================================================================
218 ikydn() -- process instrument cursor key down
219 =============================================================================
220*/
221
222void ikydn(void)
223{
224 imflag = FALSE;
225}
226
227/*
228 =============================================================================
229 ikyup() -- process instrument cursor key up
230 =============================================================================
231*/
232
233void ikyup(void)
234{
235 if (imflag)
236 modinst();
237}
238/*
239
240*/
241
242/*
243 =============================================================================
244 idcyupd() -- update cursor y location from value
245 =============================================================================
246*/
247
248void idcyupd(void)
249{
250 register short pval, vh, vl;
251
252 if (wcflag NE -1) /* ws/cf menu page can't be up */
253 return;
254
255 if (idimsw) /* no y update if instrument menu is up */
256 return;
257
258 if (idsrcsw OR idcfsw) { /* see if we're in the menu area */
259
260 vtcrow = YTOR(vtyval += cyrate);
261
262 if (vtcrow > 24)
263 vtyval = RTOY(vtcrow = 24);
264 else if (vtcrow < 22)
265 vtyval = RTOY(vtcrow = 22);
266
267 } else if (idnamsw) { /* see if we're in the typewriter */
268
269 vtcyupd();
270
271 } else if (pntsv) { /* see if we're moving a point */
272
273 pval = (pntptr->ipval >> 5) - (cyrate * 7);
274
275 if (pval GT 1000) /* limit at +10.00 */
276 pval = 1000;
277 else if (pval LT 0) /* limit at +00.00 */
278 pval = 0;
279
280 cyval = vtoy(pval, 12); /* new cursor location */
281 pntptr->ipval = pval << 5; /* update function value */
282
283 vh = pval / 100; /* display the new value */
284 vl = pval - (vh * 100);
285
286 sprintf(bfs, "%02d.%02d", vh, vl);
287
288 vbank(0);
289 vcputsv(instob, 64, idbox[16][4], idbox[16][5],
290 idbox[16][6] + 1, idbox[16][7], bfs, 14);
291
292 imflag = TRUE;
293/*
294
295*/
296 } else { /* just moving the cursor */
297
298 cyval += cyrate;
299
300 if (cyval GT (CYMAX - 1))
301 cyval = CYMAX - 1;
302 else if (cyval LT 1)
303 cyval = 1;
304 }
305}
306
307/*
308
309*/
310
311/*
312 =============================================================================
313 idcxupd() -- update cursor x location from time
314 =============================================================================
315*/
316
317void idcxupd(void)
318{
319 register unsigned th, tl;
320 register unsigned fptime, stime;
321 short zone;
322
323 if (idimsw) { /* see if instrument menu is up */
324
325 cxval += cxrate;
326
327 if (cxval > CTOX(32))
328 cxval = CTOX(32);
329 else if (cxval < CTOX(26))
330 cxval = CTOX(26);
331
332 } if (idsrcsw OR idcfsw) { /* see if we're in a submenu */
333
334 vtccol = XTOC(vtxval += cxrate);
335
336 if (vtccol > 46)
337 vtxval = CTOX(vtccol = 46);
338 else if (vtccol < 17)
339 vtxval = CTOX(vtccol = 17);
340
341 } else if (idnamsw) { /* see if we're in the typewriter */
342
343 vtcxupd();
344/*
345
346*/
347 } else if (pntsv) { /* see if we're moving a point */
348
349 for (zone = 0; zone LE 8; zone++) /* find display zone */
350 if (cxval LE zonemax[zone])
351 break;
352
353 switch (pecase) {
354
355 case 0: /* single point */
356 case 1: /* last point */
357
358 if (cxrate GE 0)
359 fptime = addfpu(pntptr->iptim,
360 cxrate * zoneinc[zone]);
361 else
362 fptime = subfpu(pntptr->iptim,
363 -cxrate * zoneinc[zone]);
364
365 stime = segtime(subj, fptime);
366
367 if (stime GE temax) {
368
369 setseg(subj, temax - 1);
370 break;
371
372 } else if (stime EQ 0) {
373
374 setseg(subj, 1);
375 break;
376 }
377
378 setseg(subj, stime);
379 break;
380
381/*
382
383*/
384 case 2: /* interior point */
385
386 if (cxrate GE 0)
387 fptime = addfpu(pntptr->iptim, cxrate * zoneinc[zone]);
388 else
389 fptime = subfpu(pntptr->iptim, -cxrate * zoneinc[zone]);
390
391 stime = temin + fromfpu(fptime);
392
393 if (stime GE temax)
394 break;
395
396 setseg(subj, segtime(subj, fptime));
397 setseg(subj + 1, temax);
398 break;
399 }
400
401 th = timeto(curfunc, subj); /* display the time */
402 tl = th - ((th / 1000) * 1000);
403 th /= 1000;
404
405 sprintf(bfs, "%02d.%03d", th, tl);
406
407 if (v_regs[5] & 0x0180)
408 vbank(0);
409
410 vcputsv(instob, 64, idbox[15][4], idbox[15][5],
411 idbox[15][6] + 1, idbox[15][7], bfs, 14);
412
413 imflag = TRUE;
414 cxval = ttox(timeto(curfunc, subj), 12);
415
416 } else { /* just moving the cursor */
417
418 cxval += cxrate;
419
420 if (cxval GT (CXMAX- 1))
421 cxval = CXMAX - 1;
422 else if (cxval LT 1)
423 cxval = 1;
424 }
425}
426
427/*
428
429*/
430
431/*
432 =============================================================================
433 idnfld() -- process not-in-field key entry
434 =============================================================================
435*/
436
437short idnfld(short k)
438{
439 register short endpnt, basepnt, t, fn;
440 register struct idfnhdr *fp;
441 register struct instdef *ip;
442
443 ip = &vbufs[curvce];
444 fp = &ip->idhfnc[curfunc];
445
446 if (astat) {
447
448 if (whatbox()) {
449
450 if (hitbox EQ 12) { /* edit window */
451
452 if (k EQ 8) { /* - = toggle I_TM_KEY */
453
454 t = (fp->idftmd ^= I_TM_KEY);
455
456 if (v_regs[5] & 0x0180)
457 vbank(0);
458
459 tsplot4(instob, 64,
460 ((t & I_TM_KEY) ?
461 idbox[curfunc][4] : ID_INST),
462 4, 54, idbxlbl[curfunc], 14);
463
464 modinst();
465 return(SUCCESS);
466/*
467
468*/
469 } else if (k EQ 9) { /* + = new point */
470
471 basepnt = fp->idfpt1;
472 endpnt = basepnt + fp->idfpif - 1;
473
474 if (fp->idfpif EQ 99)
475 return(FAILURE);
476
477 if (FALSE EQ inspnt(ip, curfunc, endpnt)) {
478
479 return(FAILURE);
480
481 } else {
482
483 subj = fp->idfpif - 1;
484 pntsel();
485 pntsv = 1;
486 memset(pntptr, 0, sizeof (struct instpnt));
487 pntptr->ipval = (pntptr -1)->ipval;
488 setseg(subj, timeto(curfunc, subj - 1) + 1);
489 edfunc(curfunc);
490 showpt(1);
491 cxval = ttox(timeto(curfunc, subj), 12);
492 cyval = vtoy((pntptr->ipval >> 5), 12);
493 arcurs(ID_SELD);
494 gcurpos(cxval, cyval);
495 modinst();
496 return(SUCCESS);
497 }
498
499 }
500/*
501
502*/
503 } else if (hitbox < 12 ) { /* label window */
504
505 fn = (hitbox EQ curfunc) ? 12 : hitbox;
506
507 if (k EQ 8) { /* + = toggle I_TM_KEY */
508
509 if (v_regs[5] & 0x0180)
510 vbank(0);
511
512 tsplot4(instob, 64,
513 (((ip->idhfnc[fn].idftmd ^= I_TM_KEY) & I_TM_KEY)
514 ? idbox[fn][4] : ID_INST),
515 idbox[hitbox][6], idbox[hitbox][7],
516 idbxlbl[fn], 14);
517
518 modinst();
519 }
520 }
521 }
522
523 return(FAILURE);
524 }
525
526 return(FAILURE);
527}
528
529/*
530
531*/
532
533/*
534 =============================================================================
535 idx_key() -- process the 'X' (delete) key
536 =============================================================================
537*/
538
539void idx_key(void)
540{
541 register struct sment *smp;
542 register struct valent *vep;
543 register short i;
544 register struct instdef *ip;
545
546 if (astat) {
547
548 if (idsrcsw OR idcfsw OR idnamsw OR (wcflag NE -1))
549 return;
550
551 if (stcrow EQ 16) {
552
553 if ((stccol GE 1) AND (stccol LE 7)) {
554
555 /* general source */
556
557 vep = &valents[0];
558 smp = vpsms[(curvce << 4) + fnoff[curfunc]];
559
560 if (smp->sm NE SM_NONE) { /* check for new general S/M */
561
562 (smp->prv)->nxt = smp->nxt; /* unlink from old S/M chain */
563 (smp->nxt)->prv = smp->prv;
564
565 smp->prv = (struct sment *)vep; /* link into new S/M chain */
566 smp->nxt = vep->nxt;
567 (vep->nxt)->prv = smp;
568 vep->nxt = smp;
569
570 smp->sm = SM_NONE; /* update sment S/M entry */
571 }
572
573 vbufs[curvce].idhfnc[curfunc].idfsrc = SM_NONE;
574 dswin(13);
575 modinst();
576/*
577
578*/
579 } else if ((stccol EQ 15) OR (stccol EQ 16)) {
580
581 /* current point and points to the right */
582
583 delpnts();
584
585 } else if ((stccol GE 33) AND (stccol LE 39)) {
586
587 /* point source */
588
589 pntptr->ipvsrc = SM_NONE;
590 dswin(16);
591 modinst();
592 }
593
594 } else if ((stcrow EQ 17) AND
595 ((stccol EQ 31) OR (stccol EQ 32))) {
596
597 /* entire instrument */
598
599 initi(&vbufs[curvce]);
600 execins(curvce, 0, 0);
601 setinst();
602 allwins();
603 modinst();
604 }
605 }
606}
607
608/*
609
610*/
611
612/*
613 =============================================================================
614 idfield() -- setup field routines for the score display
615 =============================================================================
616*/
617
618void idfield(void)
619{
620 idimsw = FALSE;
621 curslim = 210;
622
623 curset(&id_flds);
624}
Note: See TracBrowser for help on using the repository browser.