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