1 | /*
|
---|
2 | =============================================================================
|
---|
3 | wsdsp.c -- MIDAS waveshape editor display driver
|
---|
4 | Version 35 -- 1988-09-09 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include "stddefs.h"
|
---|
9 | #include "memory.h"
|
---|
10 |
|
---|
11 | #include "fpu.h"
|
---|
12 | #include "hwdefs.h"
|
---|
13 | #include "vsdd.h"
|
---|
14 | #include "vsddsw.h"
|
---|
15 | #include "vsddvars.h"
|
---|
16 | #include "graphdef.h"
|
---|
17 | #include "charset.h"
|
---|
18 | #include "fields.h"
|
---|
19 |
|
---|
20 | #include "midas.h"
|
---|
21 | #include "instdsp.h"
|
---|
22 | #include "wsdsp.h"
|
---|
23 |
|
---|
24 | /* things defined elsewhere */
|
---|
25 |
|
---|
26 | extern unsigned exp_c();
|
---|
27 |
|
---|
28 | extern int (*point)();
|
---|
29 |
|
---|
30 | extern unsigned *obj0;
|
---|
31 |
|
---|
32 | extern char bfs[];
|
---|
33 |
|
---|
34 | extern char *wdbxlb0[];
|
---|
35 | extern char *wdbxlb1[];
|
---|
36 |
|
---|
37 | extern short wdbox[][8];
|
---|
38 |
|
---|
39 | extern struct instdef vbufs[];
|
---|
40 |
|
---|
41 | /* |
---|
42 |
|
---|
43 | */
|
---|
44 |
|
---|
45 | extern short curinst;
|
---|
46 | extern short curvce;
|
---|
47 | extern short curwave; /* current waveshape library slot */
|
---|
48 | extern short curwdth; /* current waveshape cursor width */
|
---|
49 | extern short curwfnl; /* current waveshape final value */
|
---|
50 | extern short curwhrm; /* current waveshape harmonic number */
|
---|
51 | extern short curwhrv; /* current waveshape harmonic value */
|
---|
52 | extern short curwpnt; /* current waveshape point number */
|
---|
53 | extern short curwoff; /* current waveshape offset value */
|
---|
54 | extern short curwslt; /* current waveshape instrument slot */
|
---|
55 | extern short cxval;
|
---|
56 | extern short cyval;
|
---|
57 | extern short lstwoff;
|
---|
58 | extern short lstwpnt;
|
---|
59 | extern short stccol;
|
---|
60 | extern short stcrow;
|
---|
61 | extern short wpntsv; /* waveshape point selection state variable */
|
---|
62 | extern short wplast;
|
---|
63 | extern short wvlast;
|
---|
64 |
|
---|
65 | extern short vmtab[NUMHARM]; /* harmonic table */
|
---|
66 | extern short wsbuf[NUMWPCAL]; /* waveshape generation buffer */
|
---|
67 |
|
---|
68 | extern long vknm[NUMHARM][NUMWPCAL]; /* scaled harmonics */
|
---|
69 |
|
---|
70 | extern unsigned *waveob; /* waveshape display object pointer */
|
---|
71 |
|
---|
72 | extern short wsnmod[12][2]; /* waveshape number or data modified */
|
---|
73 |
|
---|
74 | extern struct wstbl wslib[NUMWAVS]; /* waveshape library */
|
---|
75 |
|
---|
76 | extern struct octent *wdoct; /* object control table pointer */
|
---|
77 |
|
---|
78 | /* forward references */
|
---|
79 |
|
---|
80 | short wdpoint();
|
---|
81 |
|
---|
82 | /* |
---|
83 |
|
---|
84 | */
|
---|
85 |
|
---|
86 | short wavpal[16][3] = { /* waveshape display color palette */
|
---|
87 |
|
---|
88 | {0, 0, 0}, /* 0 */
|
---|
89 | {3, 3, 3}, /* 1 */
|
---|
90 | {2, 2, 2}, /* 2 */
|
---|
91 | {0, 1, 1}, /* 3 (was 0, 1, 0) */
|
---|
92 | {1, 0, 1}, /* 4 */
|
---|
93 | {0, 1, 1}, /* 5 (was 0, 1, 0) */
|
---|
94 | {2, 1, 2}, /* 6 */
|
---|
95 | {0, 3, 0}, /* 7 */
|
---|
96 | {2, 0, 0}, /* 8 */
|
---|
97 | {2, 0, 2}, /* 9 */
|
---|
98 | {0, 0, 0}, /* 10 */
|
---|
99 | {2, 3, 3}, /* 11 */
|
---|
100 | {3, 3, 0}, /* 12 */
|
---|
101 | {3, 0, 0}, /* 13 */
|
---|
102 | {0, 0, 1}, /* 14 (was 0, 0, 2) */
|
---|
103 | {0, 0, 3} /* 15 */
|
---|
104 | };
|
---|
105 |
|
---|
106 | /* |
---|
107 |
|
---|
108 | */
|
---|
109 |
|
---|
110 | /*
|
---|
111 | =============================================================================
|
---|
112 | advwcur() -- advance the waveshape display text cursor
|
---|
113 | =============================================================================
|
---|
114 | */
|
---|
115 |
|
---|
116 | advwcur()
|
---|
117 | {
|
---|
118 | register short newcol;
|
---|
119 |
|
---|
120 | newcol = stccol + 1;
|
---|
121 |
|
---|
122 | if (newcol LE cfetp->frcol)
|
---|
123 | itcpos(stcrow, newcol);
|
---|
124 | }
|
---|
125 |
|
---|
126 | /* |
---|
127 |
|
---|
128 | */
|
---|
129 |
|
---|
130 | /*
|
---|
131 | =============================================================================
|
---|
132 | hdraw(h) -- draw harmonic 'h' for the current waveshape
|
---|
133 | =============================================================================
|
---|
134 | */
|
---|
135 |
|
---|
136 | hdraw(hv, h)
|
---|
137 | register short *hv;
|
---|
138 | short h;
|
---|
139 | {
|
---|
140 | register short bc, bx, by, j;
|
---|
141 |
|
---|
142 | bx = (h << 4) + 4;
|
---|
143 |
|
---|
144 | if (hv[h] < 0) {
|
---|
145 |
|
---|
146 | by = WBOFF - ((-hv[h] * WBSF1) / WBSF2);
|
---|
147 | bc = WBCN;
|
---|
148 |
|
---|
149 | } else {
|
---|
150 |
|
---|
151 | by = WBOFF - ((hv[h] * WBSF1) / WBSF2);
|
---|
152 | bc = WBCP;
|
---|
153 | }
|
---|
154 |
|
---|
155 | for (j = 0; j < 8; j++) {
|
---|
156 |
|
---|
157 | lseg(bx, WBOFF, bx, by, bc);
|
---|
158 | ++bx;
|
---|
159 | }
|
---|
160 | }
|
---|
161 |
|
---|
162 | /* |
---|
163 |
|
---|
164 | */
|
---|
165 |
|
---|
166 | /*
|
---|
167 | =============================================================================
|
---|
168 | dsws() -- display the current waveshape
|
---|
169 | =============================================================================
|
---|
170 | */
|
---|
171 |
|
---|
172 | dsws(how)
|
---|
173 | short how;
|
---|
174 | {
|
---|
175 | register struct instdef *ip;
|
---|
176 | register short *fv, *hv, *ov;
|
---|
177 | register short i;
|
---|
178 | short cx;
|
---|
179 |
|
---|
180 | cx = exp_c(wdbox[0][0]);
|
---|
181 |
|
---|
182 | ip = &vbufs[curvce];
|
---|
183 | fv = curwslt ? &ip->idhwvbf : &ip->idhwvaf;
|
---|
184 | ov = curwslt ? &ip->idhwvbo : &ip->idhwvao;
|
---|
185 | hv = curwslt ? &ip->idhwvbh : &ip->idhwvah;
|
---|
186 |
|
---|
187 | point = wdpoint;
|
---|
188 |
|
---|
189 | if (v_regs[5] & 0x0180)
|
---|
190 | vbank(0);
|
---|
191 |
|
---|
192 | if (how)
|
---|
193 | vbfill4(waveob, 128, wdbox[0][0], wdbox[0][1],
|
---|
194 | wdbox[0][2], wdbox[0][3], cx);
|
---|
195 |
|
---|
196 | lseg(1, 133, 510, 133, WZBC); /* draw the zero line and ... */
|
---|
197 | lseg(1, (WPOFF << 1), 510, (WPOFF << 1), WZBC); /* ... bottom limit */
|
---|
198 |
|
---|
199 | for (i = 0; i < NUMHARM; i++) /* draw the harmonics */
|
---|
200 | hdraw(hv, i);
|
---|
201 |
|
---|
202 | for (i = 0; i < NUMWPNT; i++) { /* draw the values */
|
---|
203 |
|
---|
204 | /* offset values */
|
---|
205 |
|
---|
206 | wdpoint(((2 * i) + 2),
|
---|
207 | (WPOFF - (((ov[i] >> 5) * WPSF1) / WPSF2)), WOVC);
|
---|
208 |
|
---|
209 | /* final values */
|
---|
210 |
|
---|
211 | wdpoint(((2 * i) + 2),
|
---|
212 | (WPOFF - (((fv[i] >> 5) * WPSF1) / WPSF2)), WFVC);
|
---|
213 | }
|
---|
214 | }
|
---|
215 |
|
---|
216 | /* |
---|
217 |
|
---|
218 | */
|
---|
219 |
|
---|
220 | /*
|
---|
221 | =============================================================================
|
---|
222 | wdswin() -- display a window
|
---|
223 | =============================================================================
|
---|
224 | */
|
---|
225 |
|
---|
226 | wdswin(n)
|
---|
227 | register short n;
|
---|
228 | {
|
---|
229 | register short cx, wval;
|
---|
230 | register char wsgn;
|
---|
231 |
|
---|
232 | cx = wdbox[n][5];
|
---|
233 | cx |= cx << 4;
|
---|
234 | cx |= cx << 8;
|
---|
235 |
|
---|
236 | /* first, fill the box with the background color */
|
---|
237 |
|
---|
238 | if (v_regs[5] & 0x0180)
|
---|
239 | vbank(0);
|
---|
240 |
|
---|
241 | vbfill4(waveob, 128, wdbox[n][0], wdbox[n][1], wdbox[n][2],
|
---|
242 | wdbox[n][3], cx);
|
---|
243 |
|
---|
244 | /* put in the box label */
|
---|
245 |
|
---|
246 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6], wdbox[n][7],
|
---|
247 | wdbxlb0[n], 14);
|
---|
248 |
|
---|
249 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1, wdbox[n][7],
|
---|
250 | wdbxlb1[n], 14);
|
---|
251 |
|
---|
252 | /* |
---|
253 |
|
---|
254 | */
|
---|
255 | switch (n) { /* final text - overlays above stuff */
|
---|
256 |
|
---|
257 | case 0: /* points and bars */
|
---|
258 |
|
---|
259 | dsws(0);
|
---|
260 | return;
|
---|
261 |
|
---|
262 | case 2: /* waveshape - voice - instrument - slot */
|
---|
263 |
|
---|
264 | sprintf(bfs, "%02d", curwave + 1);
|
---|
265 | tsplot4(waveob, 64,
|
---|
266 | exp_c(wsnmod[curvce][curwslt] ? WS_CHGC : wdbox[n][4]),
|
---|
267 | wdbox[n][6], wdbox[n][7] + WAVE_OFF, bfs, 14);
|
---|
268 |
|
---|
269 | sprintf(bfs, "%02d", curvce + 1);
|
---|
270 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6],
|
---|
271 | wdbox[n][7] + WVCE_OFF, bfs, 14);
|
---|
272 |
|
---|
273 | sprintf(bfs, "%02d", curinst);
|
---|
274 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
275 | wdbox[n][7] + WINS_OFF, bfs, 14);
|
---|
276 |
|
---|
277 | sprintf(bfs, "%c", curwslt + 'A');
|
---|
278 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
279 | wdbox[n][7] + WSLT_OFF, bfs, 14);
|
---|
280 |
|
---|
281 | return;
|
---|
282 |
|
---|
283 | /* |
---|
284 |
|
---|
285 | */
|
---|
286 | case 4: /* point - offset - width - final */
|
---|
287 |
|
---|
288 | sprintf(bfs, "%03d", curwpnt);
|
---|
289 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6],
|
---|
290 | wdbox[n][7] + WPNT_OFF, bfs, 14);
|
---|
291 |
|
---|
292 | if (curwoff < 0) {
|
---|
293 |
|
---|
294 | wval = - curwoff;
|
---|
295 | wsgn = '-';
|
---|
296 |
|
---|
297 | } else {
|
---|
298 |
|
---|
299 | wval = curwoff;
|
---|
300 | wsgn = '+';
|
---|
301 | }
|
---|
302 |
|
---|
303 | sprintf(bfs, "%c%04d", wsgn, wval);
|
---|
304 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6],
|
---|
305 | wdbox[n][7] + WOFF_OFF, bfs, 14);
|
---|
306 |
|
---|
307 | if (curwdth EQ NUMWIDS) {
|
---|
308 |
|
---|
309 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
310 | wdbox[n][7], "Interp", 14);
|
---|
311 |
|
---|
312 | } else {
|
---|
313 |
|
---|
314 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
315 | wdbox[n][7], "Width", 14);
|
---|
316 |
|
---|
317 | sprintf(bfs, "%01d", curwdth);
|
---|
318 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
319 | wdbox[n][7] + WDTH_OFF, bfs, 14);
|
---|
320 | }
|
---|
321 |
|
---|
322 | if (curwfnl < 0) {
|
---|
323 |
|
---|
324 | wval = - curwfnl;
|
---|
325 | wsgn = '-';
|
---|
326 |
|
---|
327 | } else {
|
---|
328 |
|
---|
329 | wval = curwfnl;
|
---|
330 | wsgn = '+';
|
---|
331 | }
|
---|
332 |
|
---|
333 | sprintf(bfs, "%c%04d", wsgn, wval);
|
---|
334 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
335 | wdbox[n][7] + WFNL_OFF, bfs, 14);
|
---|
336 |
|
---|
337 | return;
|
---|
338 | /* |
---|
339 |
|
---|
340 | */
|
---|
341 | case 5: /* harmonic - value */
|
---|
342 |
|
---|
343 | sprintf(bfs, "%02d", curwhrm + 1);
|
---|
344 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6],
|
---|
345 | wdbox[n][7] + WHRM_OFF, bfs, 14);
|
---|
346 |
|
---|
347 | if (curwhrv < 0) {
|
---|
348 |
|
---|
349 | wval = - curwhrv;
|
---|
350 | wsgn = '-';
|
---|
351 |
|
---|
352 | } else {
|
---|
353 |
|
---|
354 | wval = curwhrv;
|
---|
355 | wsgn = '+';
|
---|
356 | }
|
---|
357 |
|
---|
358 | sprintf(bfs, "%c%03d", wsgn, wval);
|
---|
359 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
360 | wdbox[n][7] + WHRV_OFF, bfs, 14);
|
---|
361 |
|
---|
362 | return;
|
---|
363 |
|
---|
364 | }
|
---|
365 | }
|
---|
366 |
|
---|
367 | /* |
---|
368 |
|
---|
369 | */
|
---|
370 |
|
---|
371 | /*
|
---|
372 | =============================================================================
|
---|
373 | wwins() -- display all waveshape editor windows
|
---|
374 | =============================================================================
|
---|
375 | */
|
---|
376 |
|
---|
377 | wwins()
|
---|
378 | {
|
---|
379 | register short i;
|
---|
380 |
|
---|
381 | for (i = 0; i < 6; i++)
|
---|
382 | wdswin(i);
|
---|
383 | }
|
---|
384 |
|
---|
385 | /*
|
---|
386 | =============================================================================
|
---|
387 | wdpoint() -- plot a point for the lseg function
|
---|
388 | =============================================================================
|
---|
389 | */
|
---|
390 |
|
---|
391 | short
|
---|
392 | wdpoint(x, y, pen)
|
---|
393 | short x, y, pen;
|
---|
394 | {
|
---|
395 | if (v_regs[5] & 0x0180)
|
---|
396 | vbank(0);
|
---|
397 |
|
---|
398 | vputp(wdoct, x, y, pen);
|
---|
399 | }
|
---|
400 |
|
---|
401 | /* |
---|
402 |
|
---|
403 | */
|
---|
404 |
|
---|
405 | /*
|
---|
406 | =============================================================================
|
---|
407 | wdbord() -- draw the border for the waveshape display
|
---|
408 | =============================================================================
|
---|
409 | */
|
---|
410 |
|
---|
411 | wdbord()
|
---|
412 | {
|
---|
413 | point = wdpoint;
|
---|
414 |
|
---|
415 | lseg( 0, 0, 511, 0, WBORD); /* outer border */
|
---|
416 | lseg(511, 0, 511, 349, WBORD);
|
---|
417 | lseg(511, 349, 0, 349, WBORD);
|
---|
418 | lseg( 0, 349, 0, 0, WBORD);
|
---|
419 |
|
---|
420 | lseg( 0, 308, 511, 308, WBORD); /* windows - H lines */
|
---|
421 | lseg(511, 321, 0, 321, WBORD);
|
---|
422 |
|
---|
423 | lseg(175, 322, 175, 349, WBORD); /* windows - V lines */
|
---|
424 | lseg(231, 322, 231, 349, WBORD);
|
---|
425 | lseg(399, 322, 399, 349, WBORD);
|
---|
426 | }
|
---|
427 |
|
---|
428 | /* |
---|
429 |
|
---|
430 | */
|
---|
431 |
|
---|
432 | /*
|
---|
433 | =============================================================================
|
---|
434 | clrws() -- initialize waveshape to null values
|
---|
435 | =============================================================================
|
---|
436 | */
|
---|
437 |
|
---|
438 | clrws()
|
---|
439 | {
|
---|
440 | register struct instdef *ip;
|
---|
441 |
|
---|
442 | ip = &vbufs[curvce];
|
---|
443 |
|
---|
444 | if (curwslt) {
|
---|
445 |
|
---|
446 | memsetw(ip->idhwvbh, 0, NUMHARM);
|
---|
447 | memsetw(ip->idhwvbo, 0, NUMWPNT);
|
---|
448 | memsetw(ip->idhwvbf, 0, NUMWPNT);
|
---|
449 |
|
---|
450 | } else {
|
---|
451 |
|
---|
452 | memsetw(ip->idhwvah, 0, NUMHARM);
|
---|
453 | memsetw(ip->idhwvao, 0, NUMWPNT);
|
---|
454 | memsetw(ip->idhwvaf, 0, NUMWPNT);
|
---|
455 | }
|
---|
456 |
|
---|
457 | clrwsa();
|
---|
458 |
|
---|
459 | lstwpnt = wplast = curwpnt;
|
---|
460 |
|
---|
461 | lstwoff = wvlast = curwfnl = curwoff = 0;
|
---|
462 |
|
---|
463 | curwhrv = 0;
|
---|
464 |
|
---|
465 | updfpu(); /* update the FPU */
|
---|
466 | wsnmod[curvce][curwslt] = TRUE; /* tag WS as modified */
|
---|
467 | }
|
---|
468 |
|
---|
469 | /* |
---|
470 |
|
---|
471 | */
|
---|
472 |
|
---|
473 | /*
|
---|
474 | =============================================================================
|
---|
475 | iniwslb() -- initialize waveshape library
|
---|
476 | =============================================================================
|
---|
477 | */
|
---|
478 |
|
---|
479 | iniwslb()
|
---|
480 | {
|
---|
481 | register short i, j;
|
---|
482 |
|
---|
483 | memsetw(wsnmod, FALSE, (sizeof wsnmod) / 2);
|
---|
484 |
|
---|
485 | for (i = 0; i < NUMWAVS; i++) {
|
---|
486 |
|
---|
487 | for (j = 0; j < NUMWPNT; j++) {
|
---|
488 |
|
---|
489 | wslib[i].final[j] = ((j + 1) << 8) ^ 0x8000;
|
---|
490 | wslib[i].offset[j] = ((j + 1) << 8) ^ 0x8000;
|
---|
491 | }
|
---|
492 |
|
---|
493 | memsetw(wslib[i].harmon, 0, NUMHARM); /* zero harmonics */
|
---|
494 | }
|
---|
495 | }
|
---|
496 |
|
---|
497 | /* |
---|
498 |
|
---|
499 | */
|
---|
500 |
|
---|
501 | /*
|
---|
502 | =============================================================================
|
---|
503 | wsdsp() -- put up the waveshape display
|
---|
504 | =============================================================================
|
---|
505 | */
|
---|
506 |
|
---|
507 | wsdsp()
|
---|
508 | {
|
---|
509 | waveob = &v_score[0]; /* setup object pointer */
|
---|
510 | obj0 = &v_curs0[0]; /* setup cursor object pointer */
|
---|
511 | wdoct = &v_obtab[WAVEOBJ]; /* setup object control table pointer */
|
---|
512 |
|
---|
513 | wpntsv = 0; /* point selection state = unselected */
|
---|
514 | newws(); /* set editing variables */
|
---|
515 |
|
---|
516 | dswap(); /* initialize display */
|
---|
517 |
|
---|
518 | if (v_regs[5] & 0x0180)
|
---|
519 | vbank(0);
|
---|
520 |
|
---|
521 | memsetw(waveob, 0, 32767);
|
---|
522 | memsetw(waveob+32767L, 0, 12033);
|
---|
523 |
|
---|
524 | SetObj(WAVEOBJ, 0, 0, waveob, 512, 350, 0, 0, WAVEFL, -1);
|
---|
525 | SetObj( 0, 0, 1, obj0, 16, 16, WCURX, WCURY, OBFL_00, -1);
|
---|
526 |
|
---|
527 | arcurs(WDCURS); /* setup arrow cursor object */
|
---|
528 | itcini(WDCURS); /* setup text cursor object */
|
---|
529 |
|
---|
530 | wdbord(); /* draw the border */
|
---|
531 | wwins();
|
---|
532 |
|
---|
533 | SetPri(WAVEOBJ, WAVEPRI);
|
---|
534 | SetPri(0, GCPRI);
|
---|
535 | setgc(WCURX, WCURY); /* display the graphic cursor */
|
---|
536 |
|
---|
537 | vsndpal(wavpal); /* send the palette */
|
---|
538 | }
|
---|