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

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

Code compiles, doesn't link.

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