source: buchla-68k/ram/idfield.c@ 411371e

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

Removed redundant declarations.

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