1 | /*
|
---|
2 | =============================================================================
|
---|
3 | wdfield.c -- waveshape display field processing and cursor motion
|
---|
4 | Version 46 -- 1989-11-15 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #define DOUBLED 1 /* non-zero for doubled WS outputs */
|
---|
9 |
|
---|
10 | #include "stddefs.h"
|
---|
11 | #include "fields.h"
|
---|
12 | #include "vsdd.h"
|
---|
13 | #include "graphdef.h"
|
---|
14 | #include "charset.h"
|
---|
15 | #include "hwdefs.h"
|
---|
16 | #include "fpu.h"
|
---|
17 | #include "macros.h"
|
---|
18 | #include "curpak.h"
|
---|
19 |
|
---|
20 | #include "midas.h"
|
---|
21 | #include "instdsp.h"
|
---|
22 | #include "wsdsp.h"
|
---|
23 |
|
---|
24 | #define WCSCALE 32768L
|
---|
25 | #define WCROUND 16384L
|
---|
26 |
|
---|
27 | extern void select(void);
|
---|
28 | extern int16_t whatbox(void);
|
---|
29 | extern void nokey(void);
|
---|
30 | extern int16_t nonf(int16_t k);
|
---|
31 | extern int16_t stdctp1(void);
|
---|
32 | extern void cxkstd(void);
|
---|
33 | extern void cykstd(void);
|
---|
34 | extern void stdmkey(void);
|
---|
35 | extern void stddkey(int16_t k);
|
---|
36 |
|
---|
37 | extern int16_t et_null(int16_t n);
|
---|
38 | extern int16_t ef_null(int16_t n);
|
---|
39 | extern int16_t rd_null(int16_t n);
|
---|
40 | extern int16_t nd_null(int16_t n, int16_t k);
|
---|
41 | extern int16_t et_wavs(int16_t n);
|
---|
42 | extern int16_t ef_wavs(int16_t n);
|
---|
43 | extern int16_t rd_wavs(int16_t n);
|
---|
44 | extern int16_t nd_wavs(int16_t n, int16_t k);
|
---|
45 | extern int16_t et_wvce(int16_t n);
|
---|
46 | extern int16_t ef_wvce(int16_t n);
|
---|
47 | extern int16_t rd_wvce(int16_t n);
|
---|
48 | extern int16_t nd_wvce(int16_t n, int16_t k);
|
---|
49 | extern int16_t et_wslt(int16_t n);
|
---|
50 | extern int16_t ef_wslt(int16_t n);
|
---|
51 | extern int16_t rd_wslt(int16_t n);
|
---|
52 | extern int16_t nd_wslt(int16_t n, int16_t k);
|
---|
53 | extern int16_t et_wpnt(int16_t n);
|
---|
54 | extern int16_t ef_wpnt(int16_t n);
|
---|
55 | extern int16_t rd_wpnt(int16_t n);
|
---|
56 | extern int16_t nd_wpnt(int16_t n, int16_t k);
|
---|
57 | extern int16_t et_woff(int16_t n);
|
---|
58 | extern int16_t ef_woff(int16_t n);
|
---|
59 | extern int16_t rd_woff(int16_t n);
|
---|
60 | extern int16_t nd_woff(int16_t n, int16_t k);
|
---|
61 | extern int16_t et_whar(int16_t n);
|
---|
62 | extern int16_t ef_whar(int16_t n);
|
---|
63 | extern int16_t rd_whar(int16_t n);
|
---|
64 | extern int16_t nd_whar(int16_t n, int16_t k);
|
---|
65 | extern int16_t et_whrv(int16_t n);
|
---|
66 | extern int16_t ef_whrv(int16_t n);
|
---|
67 | extern int16_t rd_whrv(int16_t n);
|
---|
68 | extern int16_t nd_whrv(int16_t n, int16_t k);
|
---|
69 |
|
---|
70 | extern 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);
|
---|
71 |
|
---|
72 | extern void *memset(void *vp, int8_t c, int16_t n);
|
---|
73 |
|
---|
74 | /* |
---|
75 |
|
---|
76 | */
|
---|
77 |
|
---|
78 | extern int16_t astat;
|
---|
79 | extern int16_t cmtype;
|
---|
80 | extern int16_t curfunc;
|
---|
81 | extern int16_t curinst;
|
---|
82 | extern int16_t curslim;
|
---|
83 | extern int16_t curvce;
|
---|
84 | extern int16_t curwave;
|
---|
85 | extern int16_t curwdth;
|
---|
86 | extern int16_t curwfnl;
|
---|
87 | extern int16_t curwhrm;
|
---|
88 | extern int16_t curwhrv;
|
---|
89 | extern int16_t curwoff;
|
---|
90 | extern int16_t curwpnt;
|
---|
91 | extern int16_t curwslt;
|
---|
92 | extern int16_t cxrate;
|
---|
93 | extern int16_t cxval;
|
---|
94 | extern int16_t cyrate;
|
---|
95 | extern int16_t cyval;
|
---|
96 | extern int16_t hitbox;
|
---|
97 | extern int16_t lstwoff;
|
---|
98 | extern int16_t lstwpnt;
|
---|
99 | extern int16_t stccol;
|
---|
100 | extern int16_t stcrow;
|
---|
101 | extern int16_t wdupdfl;
|
---|
102 | extern int16_t wplast;
|
---|
103 | extern int16_t wpntsv;
|
---|
104 | extern int16_t wvlast;
|
---|
105 |
|
---|
106 | /* |
---|
107 |
|
---|
108 | */
|
---|
109 |
|
---|
110 | extern int16_t crate1[];
|
---|
111 | extern int16_t offsets[NUMWPCAL];
|
---|
112 | extern int16_t vmtab[NUMHARM];
|
---|
113 | extern int16_t wsbuf[NUMWPCAL];
|
---|
114 |
|
---|
115 | extern int16_t wsnmod[12][2];
|
---|
116 |
|
---|
117 | extern uint16_t *waveob;
|
---|
118 |
|
---|
119 | extern int8_t bfs[];
|
---|
120 |
|
---|
121 | extern struct instdef vbufs[];
|
---|
122 |
|
---|
123 | extern struct selbox *csbp;
|
---|
124 | extern struct selbox wdboxes[];
|
---|
125 |
|
---|
126 | /* forward references */
|
---|
127 |
|
---|
128 | void wdxkey(void);
|
---|
129 | int16_t wdnfld(int16_t k);
|
---|
130 | void wdcxupd(void);
|
---|
131 | void wdcyupd(void);
|
---|
132 | void wdykup(void);
|
---|
133 | void wdykdn(void);
|
---|
134 |
|
---|
135 | /* |
---|
136 |
|
---|
137 | */
|
---|
138 |
|
---|
139 | #include "wdcurtb.h" /* int16_t wdcurtb[]; int16_t wdcurct[8][2]; */
|
---|
140 |
|
---|
141 | int16_t wxrate = 1; /* WS interpolate X movement increment */
|
---|
142 |
|
---|
143 | struct fet wd_fet1[] = {
|
---|
144 |
|
---|
145 | {23, 10, 11, 0x0002, et_wavs, ef_wavs, rd_wavs, nd_wavs},
|
---|
146 | {23, 19, 20, 0x0102, et_wvce, ef_wvce, rd_wvce, nd_wvce},
|
---|
147 | {23, 34, 36, 0x0004, et_wpnt, ef_wpnt, rd_wpnt, nd_wpnt},
|
---|
148 | {23, 44, 48, 0x0104, et_woff, ef_woff, rd_woff, nd_woff},
|
---|
149 | {23, 61, 62, 0x0005, et_whar, ef_whar, rd_whar, nd_whar},
|
---|
150 |
|
---|
151 | {24, 20, 20, 0x0302, et_wslt, ef_wslt, rd_wslt, nd_wslt},
|
---|
152 | {24, 57, 60, 0x0105, et_whrv, ef_whrv, rd_whrv, nd_whrv},
|
---|
153 |
|
---|
154 | { 0, 0, 0, 0x0000, FN_NULL, FN_NULL, FN_NULL, FN_NULL}
|
---|
155 | };
|
---|
156 |
|
---|
157 | int16_t wdbox[][8] = { /* display box parameters */
|
---|
158 |
|
---|
159 | { 1, 1, 510, 307, WCFBX00, WCBBX00, 0, 1}, /* 0 */
|
---|
160 | { 1, 309, 510, 320, WCFBX01, WCBBX01, 22, 0}, /* 1 */
|
---|
161 | { 1, 322, 174, 348, WCFBX02, WCBBX02, 23, 1}, /* 2 */
|
---|
162 | {176, 322, 230, 348, WCFBX03, WCBBX03, 23, 23}, /* 3 */
|
---|
163 | {232, 322, 398, 348, WCFBX04, WCBBX04, 23, 30}, /* 4 */
|
---|
164 | {400, 322, 510, 348, WCFBX05, WCBBX05, 23, 51} /* 5 */
|
---|
165 | };
|
---|
166 |
|
---|
167 | int8_t *wdbxlb0[] = { /* display box labels -- row 0 */
|
---|
168 |
|
---|
169 | "", /* 0 */
|
---|
170 |
|
---|
171 | "\320\301 \320\303 \320\305 \320\307 \320\311 \
|
---|
172 | \321\301 \321\303 \321\305 \321\307 \321\311 \
|
---|
173 | \322\301 \322\303 \322\305 \322\307 \322\311 \323\301 ", /* 1 */
|
---|
174 |
|
---|
175 | "Waveshpe Voice", /* 2 */
|
---|
176 | "Store", /* 3 */
|
---|
177 | "Pnt Offst", /* 4 */
|
---|
178 | "Harmonic #" /* 5 */
|
---|
179 | };
|
---|
180 |
|
---|
181 | int8_t *wdbxlb1[] = { /* display box labels -- row 1 */
|
---|
182 |
|
---|
183 | "", /* 0 */
|
---|
184 | "", /* 1 */
|
---|
185 | "Instrument Slot", /* 2 */
|
---|
186 | "Fetch", /* 3 */
|
---|
187 | " Final", /* 4 */
|
---|
188 | "Value" /* 5 */
|
---|
189 | };
|
---|
190 |
|
---|
191 | /* |
---|
192 |
|
---|
193 | */
|
---|
194 |
|
---|
195 | struct curpak wd_flds = {
|
---|
196 |
|
---|
197 | stdctp1, /* curtype */
|
---|
198 | nokey, /* premove */
|
---|
199 | nokey, /* pstmove */
|
---|
200 | cxkstd, /* cx_key */
|
---|
201 | cykstd, /* cy_key */
|
---|
202 | wdcxupd, /* cx_upd */
|
---|
203 | wdcyupd, /* cy_upd */
|
---|
204 | wdykup, /* xy_up */
|
---|
205 | wdykdn, /* xy_dn */
|
---|
206 | wdxkey, /* x_key */
|
---|
207 | select, /* e_key */
|
---|
208 | stdmkey, /* m_key */
|
---|
209 | stddkey, /* d_key */
|
---|
210 | wdnfld, /* not_fld */
|
---|
211 | wd_fet1, /* curfet */
|
---|
212 | wdboxes, /* csbp */
|
---|
213 | crate1, /* cratex */
|
---|
214 | crate1, /* cratey */
|
---|
215 | CT_GRAF, /* cmtype */
|
---|
216 | WCURX, /* cxval */
|
---|
217 | WCURY /* cyval */
|
---|
218 | };
|
---|
219 |
|
---|
220 | /* |
---|
221 |
|
---|
222 | */
|
---|
223 |
|
---|
224 | /*
|
---|
225 | =============================================================================
|
---|
226 | updfpu() -- update the FPU with a new waveshape
|
---|
227 | =============================================================================
|
---|
228 | */
|
---|
229 |
|
---|
230 | void updfpu(void)
|
---|
231 | {
|
---|
232 | register int16_t i;
|
---|
233 | register int16_t *wsp1, *wsp2;
|
---|
234 |
|
---|
235 | /* calculate instrument source and FPU destination pointers */
|
---|
236 |
|
---|
237 | wsp1 = io_fpu + FPU_OWST + (curvce << 9) + (curwslt ? 0 : 0x0100) + 1;
|
---|
238 | wsp2 = curwslt ? vbufs[curvce].idhwvbf : vbufs[curvce].idhwvaf;
|
---|
239 |
|
---|
240 | memcpyw(wsp1, wsp2, NUMWPNT);
|
---|
241 |
|
---|
242 | /* make endpoints track */
|
---|
243 |
|
---|
244 | *(wsp1 - 1) = *(wsp2 - 1); /* lowest point */
|
---|
245 | *(wsp1 + NUMWPNT) = *(wsp2 + NUMWPNT - 1); /* highest point */
|
---|
246 |
|
---|
247 | #if DOUBLED
|
---|
248 |
|
---|
249 | /* do outputs again to get around hardware bug */
|
---|
250 |
|
---|
251 | memcpyw(wsp1, wsp2, NUMWPNT);
|
---|
252 |
|
---|
253 | *(wsp1 - 1) = *(wsp2 - 1); /* lowest point */
|
---|
254 | *(wsp1 + NUMWPNT) = *(wsp2 + NUMWPNT - 1); /* highest point */
|
---|
255 | #endif
|
---|
256 |
|
---|
257 | curwfnl = wsp2[curwpnt] >> 5; /* udpate final value */
|
---|
258 | }
|
---|
259 |
|
---|
260 | /* |
---|
261 |
|
---|
262 | */
|
---|
263 |
|
---|
264 | /*
|
---|
265 | =============================================================================
|
---|
266 | wsupd() -- update the instrument definition and FPU for new WS offsets
|
---|
267 | =============================================================================
|
---|
268 | */
|
---|
269 |
|
---|
270 | void wsupd(void)
|
---|
271 | {
|
---|
272 | register int16_t i;
|
---|
273 | register int16_t *wsp1, *wsp2;
|
---|
274 |
|
---|
275 | /* update the offsets[] array from the instrument definition */
|
---|
276 |
|
---|
277 | wsp2 = curwslt ? vbufs[curvce].idhwvbo : vbufs[curvce].idhwvao;
|
---|
278 |
|
---|
279 | for (i = 0; i < NUMWPNT; i++)
|
---|
280 | offsets[i + 1] = wsp2[i] >> 5;
|
---|
281 |
|
---|
282 | offsets[0] = offsets[1];
|
---|
283 |
|
---|
284 | wscalc(); /* calculate the final values */
|
---|
285 |
|
---|
286 | /* update the final values in the instrument definition */
|
---|
287 |
|
---|
288 | wsp1 = curwslt ? vbufs[curvce].idhwvbf : vbufs[curvce].idhwvaf;
|
---|
289 |
|
---|
290 | for (i = 0; i < NUMWPNT; i++)
|
---|
291 | wsp1[i] = wsbuf[1 + i] << 5;
|
---|
292 |
|
---|
293 | updfpu();
|
---|
294 | wsnmod[curvce][curwslt] = TRUE; /* tag WS as modified */
|
---|
295 | }
|
---|
296 |
|
---|
297 | /*
|
---|
298 | =============================================================================
|
---|
299 | whupd() -- update the FPU for new WS harmonics
|
---|
300 | =============================================================================
|
---|
301 | */
|
---|
302 |
|
---|
303 | void whupd(void)
|
---|
304 | {
|
---|
305 | register int16_t i;
|
---|
306 | register int16_t *wsp1;
|
---|
307 |
|
---|
308 | /* update the final values in the instrument definition */
|
---|
309 |
|
---|
310 | wsp1 = curwslt ? vbufs[curvce].idhwvbf : vbufs[curvce].idhwvaf;
|
---|
311 |
|
---|
312 | for (i = 0; i < NUMWPNT; i++)
|
---|
313 | wsp1[i] = wsbuf[i + 1] << 5;
|
---|
314 |
|
---|
315 | updfpu(); /* update the FPU */
|
---|
316 | wsnmod[curvce][curwslt] = TRUE; /* tag WS as modified */
|
---|
317 | }
|
---|
318 |
|
---|
319 | /* |
---|
320 |
|
---|
321 | */
|
---|
322 |
|
---|
323 | /*
|
---|
324 | =============================================================================
|
---|
325 | pntsup() -- update waveshape points with the cursor 'brush'
|
---|
326 | =============================================================================
|
---|
327 | */
|
---|
328 |
|
---|
329 | void pntsup(void)
|
---|
330 | {
|
---|
331 | register struct instdef *ip;
|
---|
332 | int16_t *ov;
|
---|
333 | register int16_t i, j, k, tv, curdif;
|
---|
334 | int16_t cwnp, cwin;
|
---|
335 |
|
---|
336 | ip = &vbufs[curvce]; /* instrument definition */
|
---|
337 |
|
---|
338 | ov = curwslt ? &ip->idhwvbo /* offsets in definition */
|
---|
339 | : &ip->idhwvao;
|
---|
340 |
|
---|
341 | cwnp = wdcurct[curwdth][0]; /* number of points effected */
|
---|
342 |
|
---|
343 | cwin = wdcurct[curwdth][1]; /* table increment */
|
---|
344 |
|
---|
345 | curdif = lstwoff - curwoff; /* calculate the difference */
|
---|
346 |
|
---|
347 | /* |
---|
348 |
|
---|
349 | */
|
---|
350 | for (i = 0 , k = 0; i < cwnp; i++ , k += cwin) {
|
---|
351 |
|
---|
352 | if (i EQ 0) { /* first point */
|
---|
353 |
|
---|
354 | ov[curwpnt] = curwoff << 5;
|
---|
355 |
|
---|
356 | } else { /* subsequent points */
|
---|
357 |
|
---|
358 | j = curwpnt + i; /* update point on the right */
|
---|
359 |
|
---|
360 | if (j < NUMWPNT) { /* ... if it exists */
|
---|
361 |
|
---|
362 | tv = (ov[j] >> 5) -
|
---|
363 | ((((long)curdif * wdcurtb[k])
|
---|
364 | + WCROUND) / WCSCALE);
|
---|
365 |
|
---|
366 | if (tv GT 1023)
|
---|
367 | tv = 1023;
|
---|
368 | else if (tv LT -1023)
|
---|
369 | tv = -1023;
|
---|
370 |
|
---|
371 | ov[j] = tv << 5;
|
---|
372 | }
|
---|
373 |
|
---|
374 | j = curwpnt - i; /* update point on the left */
|
---|
375 |
|
---|
376 | if (j GE 0) { /* ... if it exists */
|
---|
377 |
|
---|
378 | tv = (ov[j] >> 5) -
|
---|
379 | ((((long)curdif * wdcurtb[k])
|
---|
380 | + WCROUND) / WCSCALE);
|
---|
381 |
|
---|
382 | if (tv GT 1023)
|
---|
383 | tv = 1023;
|
---|
384 | else if (tv LT -1023)
|
---|
385 | tv = -1023;
|
---|
386 |
|
---|
387 | ov[j] = tv << 5;
|
---|
388 | }
|
---|
389 | }
|
---|
390 | }
|
---|
391 |
|
---|
392 | wsupd();
|
---|
393 | }
|
---|
394 |
|
---|
395 | /* |
---|
396 |
|
---|
397 | */
|
---|
398 |
|
---|
399 | /*
|
---|
400 | =============================================================================
|
---|
401 | wdintp() -- interpolate between waveshape points
|
---|
402 | =============================================================================
|
---|
403 | */
|
---|
404 |
|
---|
405 | void wdintp(void)
|
---|
406 | {
|
---|
407 | register struct instdef *ip;
|
---|
408 | register int16_t *ov;
|
---|
409 | register int16_t i, j, k, n;
|
---|
410 | register long t;
|
---|
411 | int16_t to, from;
|
---|
412 |
|
---|
413 | to = curwpnt;
|
---|
414 | from = wplast;
|
---|
415 |
|
---|
416 | ip = &vbufs[curvce];
|
---|
417 | ov = curwslt ? &ip->idhwvbo : &ip->idhwvao;
|
---|
418 |
|
---|
419 | ov[curwpnt] = curwoff << 5; /* force current point value */
|
---|
420 |
|
---|
421 | if (from > to) { /* make 'from' the leftmost point number */
|
---|
422 |
|
---|
423 | i = from;
|
---|
424 | from = to;
|
---|
425 | to = i;
|
---|
426 | }
|
---|
427 |
|
---|
428 | n = to - from; /* number of points */
|
---|
429 |
|
---|
430 | if (n > 1) { /* have to have at least 1 point difference */
|
---|
431 |
|
---|
432 | k = ov[from] >> 5;
|
---|
433 | t = ((long)((long)(ov[to] >> 5) - (long)k) << 16) / n;
|
---|
434 | j = 1 + from;
|
---|
435 | --n;
|
---|
436 |
|
---|
437 | for (i = 0; i < n; i++)
|
---|
438 | ov[j++] = ((int16_t)((t * (1 + i)) >> 16) + k) << 5;
|
---|
439 | }
|
---|
440 |
|
---|
441 | wplast = curwpnt;
|
---|
442 | wvlast = curwoff;
|
---|
443 |
|
---|
444 | wsupd();
|
---|
445 | }
|
---|
446 |
|
---|
447 | /* |
---|
448 |
|
---|
449 | */
|
---|
450 |
|
---|
451 | /*
|
---|
452 | =============================================================================
|
---|
453 | wdykdn() -- cursor y finger down processing
|
---|
454 | =============================================================================
|
---|
455 | */
|
---|
456 |
|
---|
457 | void wdykdn(void)
|
---|
458 | {
|
---|
459 | if (wpntsv EQ 0)
|
---|
460 | return;
|
---|
461 |
|
---|
462 | lstwpnt = curwpnt;
|
---|
463 | lstwoff = curwoff;
|
---|
464 | }
|
---|
465 |
|
---|
466 | /*
|
---|
467 | =============================================================================
|
---|
468 | wdykup() -- cursor y finger up processing
|
---|
469 | =============================================================================
|
---|
470 | */
|
---|
471 |
|
---|
472 | void wdykup(void)
|
---|
473 | {
|
---|
474 | if ((wpntsv EQ 0) OR (wdupdfl EQ FALSE))
|
---|
475 | return;
|
---|
476 |
|
---|
477 | if (wpntsv EQ 1) { /* offsets */
|
---|
478 |
|
---|
479 | if (curwdth EQ NUMWIDS)
|
---|
480 | wdintp(); /* interpolate mode */
|
---|
481 | else
|
---|
482 | pntsup(); /* brush mode */
|
---|
483 |
|
---|
484 | } else { /* harmonics */
|
---|
485 |
|
---|
486 | adj(curwhrm); /* adjust vknm[curwhrm][] */
|
---|
487 | wscalc(); /* recalculate the waveshape */
|
---|
488 | whupd(); /* update the FPU */
|
---|
489 | }
|
---|
490 |
|
---|
491 | wdswin(0); /* display updated waveshape */
|
---|
492 | wdswin(2);
|
---|
493 | wdswin(4);
|
---|
494 |
|
---|
495 | wdupdfl = FALSE;
|
---|
496 | }
|
---|
497 |
|
---|
498 | /* |
---|
499 |
|
---|
500 | */
|
---|
501 |
|
---|
502 | /*
|
---|
503 | =============================================================================
|
---|
504 | wdcyupd() -- update cursor y location
|
---|
505 | =============================================================================
|
---|
506 | */
|
---|
507 |
|
---|
508 | void wdcyupd(void)
|
---|
509 | {
|
---|
510 | register struct instdef *ip;
|
---|
511 | register int16_t *ov, *hv;
|
---|
512 | register int16_t i, j, k, tv;
|
---|
513 | register int8_t wsgn;
|
---|
514 | int16_t wval, cwnp, cwin;
|
---|
515 |
|
---|
516 | ip = &vbufs[curvce];
|
---|
517 |
|
---|
518 | switch (wpntsv) {
|
---|
519 |
|
---|
520 | case 0: /* nothing selected -- just move cursor */
|
---|
521 |
|
---|
522 | cyval += cyrate;
|
---|
523 |
|
---|
524 | if (cyval GT (CYMAX - 1))
|
---|
525 | cyval = CYMAX - 1;
|
---|
526 | else if (cyval LT 1)
|
---|
527 | cyval = 1;
|
---|
528 |
|
---|
529 | return;
|
---|
530 | /* |
---|
531 |
|
---|
532 | */
|
---|
533 | case 1: /* offset selected */
|
---|
534 |
|
---|
535 | curwoff -= cyrate;
|
---|
536 |
|
---|
537 | if (curwoff GT 1023)
|
---|
538 | curwoff = 1023;
|
---|
539 | else if (curwoff LT -1023)
|
---|
540 | curwoff = -1023;
|
---|
541 |
|
---|
542 | cyval = WPOFF - ((curwoff * WPSF1) / WPSF2);
|
---|
543 |
|
---|
544 | if (curwoff < 0) {
|
---|
545 |
|
---|
546 | wval = - curwoff;
|
---|
547 | wsgn = '-';
|
---|
548 |
|
---|
549 | } else {
|
---|
550 |
|
---|
551 | wval = curwoff;
|
---|
552 | wsgn = '+';
|
---|
553 | }
|
---|
554 |
|
---|
555 | sprintf(bfs, "%c%04d", wsgn, wval);
|
---|
556 |
|
---|
557 | if (v_regs[5] & 0x0180)
|
---|
558 | vbank(0);
|
---|
559 |
|
---|
560 | vcputsv(waveob, 64, wdbox[4][4], wdbox[4][5], wdbox[4][6],
|
---|
561 | wdbox[4][7] + WOFF_OFF, bfs, 14);
|
---|
562 |
|
---|
563 | wdupdfl = TRUE;
|
---|
564 | return;
|
---|
565 | /* |
---|
566 |
|
---|
567 | */
|
---|
568 | case 2: /* harmonic selected */
|
---|
569 |
|
---|
570 | hv = curwslt ? &ip->idhwvbh : &ip->idhwvah;
|
---|
571 |
|
---|
572 | curwhrv = abs(hv[curwhrm]) - cyrate;
|
---|
573 |
|
---|
574 | if (curwhrv > 100)
|
---|
575 | curwhrv = 100;
|
---|
576 | else if (curwhrv < 0)
|
---|
577 | curwhrv = 0;
|
---|
578 |
|
---|
579 | curwhrv = (hv[curwhrm] < 0) ? -curwhrv : curwhrv;
|
---|
580 |
|
---|
581 | hv[curwhrm] = curwhrv;
|
---|
582 | vmtab[curwhrm] = curwhrv;
|
---|
583 |
|
---|
584 | if (curwhrv < 0) {
|
---|
585 |
|
---|
586 | wval = -curwhrv;
|
---|
587 | wsgn = '-';
|
---|
588 |
|
---|
589 | } else {
|
---|
590 |
|
---|
591 | wval = curwhrv;
|
---|
592 | wsgn = '+';
|
---|
593 | }
|
---|
594 |
|
---|
595 | if (v_regs[5] & 0x0180)
|
---|
596 | vbank(0);
|
---|
597 |
|
---|
598 | sprintf(bfs, "%c%03d", wsgn, wval);
|
---|
599 |
|
---|
600 | vcputsv(waveob, 64, wdbox[5][4], wdbox[5][5],
|
---|
601 | wdbox[5][6] + 1, wdbox[5][7] + WHRV_OFF, bfs, 14);
|
---|
602 |
|
---|
603 | if (curwhrv < 0)
|
---|
604 | cyval = WBOFF - ((-curwhrv * WBSF1) / WBSF2);
|
---|
605 | else
|
---|
606 | cyval = WBOFF - ((curwhrv * WBSF1) / WBSF2);
|
---|
607 |
|
---|
608 | wdupdfl = TRUE;
|
---|
609 | return;
|
---|
610 | }
|
---|
611 | }
|
---|
612 |
|
---|
613 | /* |
---|
614 |
|
---|
615 | */
|
---|
616 |
|
---|
617 | /*
|
---|
618 | =============================================================================
|
---|
619 | wdcxupd() -- update cursor x location
|
---|
620 | =============================================================================
|
---|
621 | */
|
---|
622 |
|
---|
623 | void wdcxupd(void)
|
---|
624 | {
|
---|
625 | switch (wpntsv) {
|
---|
626 |
|
---|
627 | case 0: /* nothing selected - just move cursor */
|
---|
628 |
|
---|
629 | cxval += cxrate;
|
---|
630 |
|
---|
631 | if (cxval GT (CXMAX - 1))
|
---|
632 | cxval = CXMAX - 1;
|
---|
633 | else if (cxval LT 1)
|
---|
634 | cxval = 1;
|
---|
635 |
|
---|
636 | return;
|
---|
637 |
|
---|
638 | case 1: /* offset selected - maybe do interpolate move */
|
---|
639 |
|
---|
640 | if (curwdth NE NUMWIDS)
|
---|
641 | return;
|
---|
642 |
|
---|
643 | curwpnt += sign(cxrate, wxrate);
|
---|
644 |
|
---|
645 | if (curwpnt GE NUMWPNT)
|
---|
646 | curwpnt = NUMWPNT - 1;
|
---|
647 | else if (curwpnt < 0)
|
---|
648 | curwpnt = 0;
|
---|
649 |
|
---|
650 | cxval = (curwpnt << 1) + 2;
|
---|
651 |
|
---|
652 | if (v_regs[5] & 0x0180)
|
---|
653 | vbank(0);
|
---|
654 |
|
---|
655 | sprintf(bfs, "%03d", curwpnt);
|
---|
656 | vcputsv(waveob, 64, wdbox[4][4], wdbox[4][5],
|
---|
657 | wdbox[4][6], wdbox[4][7] + WPNT_OFF, bfs, 14);
|
---|
658 | }
|
---|
659 | }
|
---|
660 |
|
---|
661 | /* |
---|
662 |
|
---|
663 | */
|
---|
664 |
|
---|
665 | /*
|
---|
666 | =============================================================================
|
---|
667 | wdnfld() -- process not-in-field key entry
|
---|
668 | =============================================================================
|
---|
669 | */
|
---|
670 |
|
---|
671 | int16_t wdnfld(int16_t k)
|
---|
672 | {
|
---|
673 | register int16_t *hv;
|
---|
674 | register struct instdef *ip;
|
---|
675 |
|
---|
676 | if (astat) {
|
---|
677 |
|
---|
678 | if (whatbox()) {
|
---|
679 |
|
---|
680 | ip = &vbufs[curvce];
|
---|
681 | hv = curwslt ? &ip->idhwvbh : &ip->idhwvah;
|
---|
682 |
|
---|
683 | if (hitbox EQ 0) { /* waveshape area */
|
---|
684 |
|
---|
685 | switch (wpntsv) {
|
---|
686 |
|
---|
687 | case 0: /* nothing selected */
|
---|
688 |
|
---|
689 | if (k EQ 8) { /* - */
|
---|
690 |
|
---|
691 | if (--curwdth < 0)
|
---|
692 | curwdth = NUMWIDS;
|
---|
693 |
|
---|
694 | wdswin(4);
|
---|
695 | return(SUCCESS);
|
---|
696 |
|
---|
697 | } else if (k EQ 9) { /* + */
|
---|
698 |
|
---|
699 | if (++curwdth > NUMWIDS)
|
---|
700 | curwdth = 0;
|
---|
701 |
|
---|
702 | wdswin(4);
|
---|
703 | return(SUCCESS);
|
---|
704 | }
|
---|
705 |
|
---|
706 | return(FAILURE);
|
---|
707 | /* |
---|
708 |
|
---|
709 | */
|
---|
710 | case 1: /* offset selected */
|
---|
711 |
|
---|
712 | if (k EQ 8) { /* - */
|
---|
713 |
|
---|
714 | if (curwdth EQ NUMWIDS)
|
---|
715 | return(FAILURE);
|
---|
716 |
|
---|
717 | if (--curwdth LT 0)
|
---|
718 | curwdth = NUMWIDS - 1;
|
---|
719 |
|
---|
720 | wdswin(4);
|
---|
721 | return(SUCCESS);
|
---|
722 |
|
---|
723 | } else if (k EQ 9) { /* + */
|
---|
724 |
|
---|
725 | if (curwdth EQ NUMWIDS) {
|
---|
726 |
|
---|
727 | wdintp();
|
---|
728 | wdswin(0);
|
---|
729 | wdswin(2);
|
---|
730 |
|
---|
731 | } else if (++curwdth GE NUMWIDS)
|
---|
732 | curwdth = 0;
|
---|
733 |
|
---|
734 | wdswin(4);
|
---|
735 | return(SUCCESS);
|
---|
736 | }
|
---|
737 |
|
---|
738 | return(FAILURE);
|
---|
739 | /* |
---|
740 |
|
---|
741 | */
|
---|
742 | case 2: /* harmonic selected */
|
---|
743 |
|
---|
744 | if (k EQ 8) { /* - */
|
---|
745 |
|
---|
746 | if (hv[curwhrm] > 0)
|
---|
747 | hv[curwhrm] = -hv[curwhrm];
|
---|
748 | else
|
---|
749 | return(FAILURE);
|
---|
750 |
|
---|
751 | } else if (k EQ 9) { /* + */
|
---|
752 |
|
---|
753 | if (hv[curwhrm] < 0)
|
---|
754 | hv[curwhrm] = -hv[curwhrm];
|
---|
755 | else
|
---|
756 | return(FAILURE);
|
---|
757 |
|
---|
758 | } else {
|
---|
759 |
|
---|
760 | return(FAILURE);
|
---|
761 | }
|
---|
762 |
|
---|
763 | curwhrv = hv[curwhrm];
|
---|
764 | vmtab[curwhrm] = curwhrv;
|
---|
765 | adj(curwhrm);
|
---|
766 | wscalc();
|
---|
767 | whupd();
|
---|
768 | wdswin(0);
|
---|
769 | wdswin(4);
|
---|
770 | wdswin(5);
|
---|
771 | return(SUCCESS);
|
---|
772 | }
|
---|
773 |
|
---|
774 | } else
|
---|
775 | return(FAILURE);
|
---|
776 | /* |
---|
777 |
|
---|
778 | */
|
---|
779 | } else if (hitbox EQ 1) { /* harmonic legend */
|
---|
780 |
|
---|
781 | if (k EQ 8) { /* - */
|
---|
782 |
|
---|
783 | if (hv[curwhrm] > 0)
|
---|
784 | hv[curwhrm] = -hv[curwhrm];
|
---|
785 | else
|
---|
786 | return(FAILURE);
|
---|
787 |
|
---|
788 | } else if (k EQ 9) { /* + */
|
---|
789 |
|
---|
790 | if (hv[curwhrm] < 0)
|
---|
791 | hv[curwhrm] = -hv[curwhrm];
|
---|
792 | else
|
---|
793 | return(FAILURE);
|
---|
794 |
|
---|
795 | } else {
|
---|
796 |
|
---|
797 | return(FAILURE);
|
---|
798 | }
|
---|
799 |
|
---|
800 | curwhrv = hv[curwhrm];
|
---|
801 | vmtab[curwhrm] = curwhrv;
|
---|
802 | adj(curwhrm);
|
---|
803 | wscalc();
|
---|
804 | whupd();
|
---|
805 | wdswin(0);
|
---|
806 | wdswin(4);
|
---|
807 | wdswin(5);
|
---|
808 | return(SUCCESS);
|
---|
809 | }
|
---|
810 |
|
---|
811 | return(FAILURE);
|
---|
812 | }
|
---|
813 |
|
---|
814 | return(FAILURE);
|
---|
815 | }
|
---|
816 |
|
---|
817 | /* |
---|
818 |
|
---|
819 | */
|
---|
820 |
|
---|
821 | /*
|
---|
822 | =============================================================================
|
---|
823 | wdxkey() -- process X key
|
---|
824 | =============================================================================
|
---|
825 | */
|
---|
826 |
|
---|
827 | void wdxkey(void)
|
---|
828 | {
|
---|
829 | if (NOT astat)
|
---|
830 | return; /* FAILURE */
|
---|
831 |
|
---|
832 | stcrow = cyval / 14;
|
---|
833 | stccol = cxval >> 3;
|
---|
834 |
|
---|
835 | if (stcrow EQ 23) {
|
---|
836 |
|
---|
837 | if ((stccol GE 2) OR (stccol LE 8)) {
|
---|
838 |
|
---|
839 | clrws();
|
---|
840 |
|
---|
841 | } else if ((stccol GE 38) AND (stccol LE 42)) {
|
---|
842 |
|
---|
843 | memsetw(curwslt ? vbufs[curvce].idhwvbo
|
---|
844 | : vbufs[curvce].idhwvbo,
|
---|
845 | 0, NUMWPNT);
|
---|
846 |
|
---|
847 | curwoff = 0;
|
---|
848 | wsupd();
|
---|
849 |
|
---|
850 | } else if ((stccol GE 51) AND (stccol LE 58)) {
|
---|
851 |
|
---|
852 | memsetw(vmtab, 0, NUMHARM);
|
---|
853 | curwhrv = 0;
|
---|
854 | wadj();
|
---|
855 | wscalc();
|
---|
856 | whupd();
|
---|
857 |
|
---|
858 | } else {
|
---|
859 |
|
---|
860 | return; /* FAILURE */
|
---|
861 | }
|
---|
862 |
|
---|
863 | wsnmod[curvce][curwslt] = TRUE;
|
---|
864 | wwins();
|
---|
865 | return; /* SUCCESS */
|
---|
866 | }
|
---|
867 |
|
---|
868 | return; /* FAILURE */
|
---|
869 | }
|
---|
870 |
|
---|
871 | /* |
---|
872 |
|
---|
873 | */
|
---|
874 |
|
---|
875 | /*
|
---|
876 | =============================================================================
|
---|
877 | wdfield() -- setup field routines for the waveshape editor
|
---|
878 | =============================================================================
|
---|
879 | */
|
---|
880 |
|
---|
881 | void wdfield(void)
|
---|
882 | {
|
---|
883 | curslim = 307;
|
---|
884 |
|
---|
885 | curset(&wd_flds);
|
---|
886 | }
|
---|