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

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

Zero redundant declarations.

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