source: buchla-68k/orig/RAM/IDFIELD.C@ 6888aa2

Last change on this file since 6888aa2 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

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