source: buchla-68k/ram/idfield.c@ 39a696b

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