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(unsigned 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 | void wdpoint(short x, short y, short pen);
|
---|
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 | void advwcur(void)
|
---|
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 | void hdraw(short *hv, short h)
|
---|
137 | {
|
---|
138 | register short bc, bx, by, j;
|
---|
139 |
|
---|
140 | bx = (h << 4) + 4;
|
---|
141 |
|
---|
142 | if (hv[h] < 0) {
|
---|
143 |
|
---|
144 | by = WBOFF - ((-hv[h] * WBSF1) / WBSF2);
|
---|
145 | bc = WBCN;
|
---|
146 |
|
---|
147 | } else {
|
---|
148 |
|
---|
149 | by = WBOFF - ((hv[h] * WBSF1) / WBSF2);
|
---|
150 | bc = WBCP;
|
---|
151 | }
|
---|
152 |
|
---|
153 | for (j = 0; j < 8; j++) {
|
---|
154 |
|
---|
155 | lseg(bx, WBOFF, bx, by, bc);
|
---|
156 | ++bx;
|
---|
157 | }
|
---|
158 | }
|
---|
159 |
|
---|
160 | /* |
---|
161 |
|
---|
162 | */
|
---|
163 |
|
---|
164 | /*
|
---|
165 | =============================================================================
|
---|
166 | dsws() -- display the current waveshape
|
---|
167 | =============================================================================
|
---|
168 | */
|
---|
169 |
|
---|
170 | void dsws(short how)
|
---|
171 | {
|
---|
172 | register struct instdef *ip;
|
---|
173 | register short *fv, *hv, *ov;
|
---|
174 | register short i;
|
---|
175 | short cx;
|
---|
176 |
|
---|
177 | cx = exp_c(wdbox[0][0]);
|
---|
178 |
|
---|
179 | ip = &vbufs[curvce];
|
---|
180 | fv = curwslt ? &ip->idhwvbf : &ip->idhwvaf;
|
---|
181 | ov = curwslt ? &ip->idhwvbo : &ip->idhwvao;
|
---|
182 | hv = curwslt ? &ip->idhwvbh : &ip->idhwvah;
|
---|
183 |
|
---|
184 | point = wdpoint;
|
---|
185 |
|
---|
186 | if (v_regs[5] & 0x0180)
|
---|
187 | vbank(0);
|
---|
188 |
|
---|
189 | if (how)
|
---|
190 | vbfill4(waveob, 128, wdbox[0][0], wdbox[0][1],
|
---|
191 | wdbox[0][2], wdbox[0][3], cx);
|
---|
192 |
|
---|
193 | lseg(1, 133, 510, 133, WZBC); /* draw the zero line and ... */
|
---|
194 | lseg(1, (WPOFF << 1), 510, (WPOFF << 1), WZBC); /* ... bottom limit */
|
---|
195 |
|
---|
196 | for (i = 0; i < NUMHARM; i++) /* draw the harmonics */
|
---|
197 | hdraw(hv, i);
|
---|
198 |
|
---|
199 | for (i = 0; i < NUMWPNT; i++) { /* draw the values */
|
---|
200 |
|
---|
201 | /* offset values */
|
---|
202 |
|
---|
203 | wdpoint(((2 * i) + 2),
|
---|
204 | (WPOFF - (((ov[i] >> 5) * WPSF1) / WPSF2)), WOVC);
|
---|
205 |
|
---|
206 | /* final values */
|
---|
207 |
|
---|
208 | wdpoint(((2 * i) + 2),
|
---|
209 | (WPOFF - (((fv[i] >> 5) * WPSF1) / WPSF2)), WFVC);
|
---|
210 | }
|
---|
211 | }
|
---|
212 |
|
---|
213 | /* |
---|
214 |
|
---|
215 | */
|
---|
216 |
|
---|
217 | /*
|
---|
218 | =============================================================================
|
---|
219 | wdswin() -- display a window
|
---|
220 | =============================================================================
|
---|
221 | */
|
---|
222 |
|
---|
223 | void wdswin(short n)
|
---|
224 | {
|
---|
225 | register short cx, wval;
|
---|
226 | register char wsgn;
|
---|
227 |
|
---|
228 | cx = wdbox[n][5];
|
---|
229 | cx |= cx << 4;
|
---|
230 | cx |= cx << 8;
|
---|
231 |
|
---|
232 | /* first, fill the box with the background color */
|
---|
233 |
|
---|
234 | if (v_regs[5] & 0x0180)
|
---|
235 | vbank(0);
|
---|
236 |
|
---|
237 | vbfill4(waveob, 128, wdbox[n][0], wdbox[n][1], wdbox[n][2],
|
---|
238 | wdbox[n][3], cx);
|
---|
239 |
|
---|
240 | /* put in the box label */
|
---|
241 |
|
---|
242 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6], wdbox[n][7],
|
---|
243 | wdbxlb0[n], 14);
|
---|
244 |
|
---|
245 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1, wdbox[n][7],
|
---|
246 | wdbxlb1[n], 14);
|
---|
247 |
|
---|
248 | /* |
---|
249 |
|
---|
250 | */
|
---|
251 | switch (n) { /* final text - overlays above stuff */
|
---|
252 |
|
---|
253 | case 0: /* points and bars */
|
---|
254 |
|
---|
255 | dsws(0);
|
---|
256 | return;
|
---|
257 |
|
---|
258 | case 2: /* waveshape - voice - instrument - slot */
|
---|
259 |
|
---|
260 | sprintf(bfs, "%02d", curwave + 1);
|
---|
261 | tsplot4(waveob, 64,
|
---|
262 | exp_c(wsnmod[curvce][curwslt] ? WS_CHGC : wdbox[n][4]),
|
---|
263 | wdbox[n][6], wdbox[n][7] + WAVE_OFF, bfs, 14);
|
---|
264 |
|
---|
265 | sprintf(bfs, "%02d", curvce + 1);
|
---|
266 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6],
|
---|
267 | wdbox[n][7] + WVCE_OFF, bfs, 14);
|
---|
268 |
|
---|
269 | sprintf(bfs, "%02d", curinst);
|
---|
270 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
271 | wdbox[n][7] + WINS_OFF, bfs, 14);
|
---|
272 |
|
---|
273 | sprintf(bfs, "%c", curwslt + 'A');
|
---|
274 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
275 | wdbox[n][7] + WSLT_OFF, bfs, 14);
|
---|
276 |
|
---|
277 | return;
|
---|
278 |
|
---|
279 | /* |
---|
280 |
|
---|
281 | */
|
---|
282 | case 4: /* point - offset - width - final */
|
---|
283 |
|
---|
284 | sprintf(bfs, "%03d", curwpnt);
|
---|
285 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6],
|
---|
286 | wdbox[n][7] + WPNT_OFF, bfs, 14);
|
---|
287 |
|
---|
288 | if (curwoff < 0) {
|
---|
289 |
|
---|
290 | wval = - curwoff;
|
---|
291 | wsgn = '-';
|
---|
292 |
|
---|
293 | } else {
|
---|
294 |
|
---|
295 | wval = curwoff;
|
---|
296 | wsgn = '+';
|
---|
297 | }
|
---|
298 |
|
---|
299 | sprintf(bfs, "%c%04d", wsgn, wval);
|
---|
300 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6],
|
---|
301 | wdbox[n][7] + WOFF_OFF, bfs, 14);
|
---|
302 |
|
---|
303 | if (curwdth EQ NUMWIDS) {
|
---|
304 |
|
---|
305 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
306 | wdbox[n][7], "Interp", 14);
|
---|
307 |
|
---|
308 | } else {
|
---|
309 |
|
---|
310 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
311 | wdbox[n][7], "Width", 14);
|
---|
312 |
|
---|
313 | sprintf(bfs, "%01d", curwdth);
|
---|
314 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
315 | wdbox[n][7] + WDTH_OFF, bfs, 14);
|
---|
316 | }
|
---|
317 |
|
---|
318 | if (curwfnl < 0) {
|
---|
319 |
|
---|
320 | wval = - curwfnl;
|
---|
321 | wsgn = '-';
|
---|
322 |
|
---|
323 | } else {
|
---|
324 |
|
---|
325 | wval = curwfnl;
|
---|
326 | wsgn = '+';
|
---|
327 | }
|
---|
328 |
|
---|
329 | sprintf(bfs, "%c%04d", wsgn, wval);
|
---|
330 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
331 | wdbox[n][7] + WFNL_OFF, bfs, 14);
|
---|
332 |
|
---|
333 | return;
|
---|
334 | /* |
---|
335 |
|
---|
336 | */
|
---|
337 | case 5: /* harmonic - value */
|
---|
338 |
|
---|
339 | sprintf(bfs, "%02d", curwhrm + 1);
|
---|
340 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6],
|
---|
341 | wdbox[n][7] + WHRM_OFF, bfs, 14);
|
---|
342 |
|
---|
343 | if (curwhrv < 0) {
|
---|
344 |
|
---|
345 | wval = - curwhrv;
|
---|
346 | wsgn = '-';
|
---|
347 |
|
---|
348 | } else {
|
---|
349 |
|
---|
350 | wval = curwhrv;
|
---|
351 | wsgn = '+';
|
---|
352 | }
|
---|
353 |
|
---|
354 | sprintf(bfs, "%c%03d", wsgn, wval);
|
---|
355 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
356 | wdbox[n][7] + WHRV_OFF, bfs, 14);
|
---|
357 |
|
---|
358 | return;
|
---|
359 |
|
---|
360 | }
|
---|
361 | }
|
---|
362 |
|
---|
363 | /* |
---|
364 |
|
---|
365 | */
|
---|
366 |
|
---|
367 | /*
|
---|
368 | =============================================================================
|
---|
369 | wwins() -- display all waveshape editor windows
|
---|
370 | =============================================================================
|
---|
371 | */
|
---|
372 |
|
---|
373 | void wwins(void)
|
---|
374 | {
|
---|
375 | register short i;
|
---|
376 |
|
---|
377 | for (i = 0; i < 6; i++)
|
---|
378 | wdswin(i);
|
---|
379 | }
|
---|
380 |
|
---|
381 | /*
|
---|
382 | =============================================================================
|
---|
383 | wdpoint() -- plot a point for the lseg function
|
---|
384 | =============================================================================
|
---|
385 | */
|
---|
386 |
|
---|
387 | void wdpoint(short x, short y, short pen)
|
---|
388 | {
|
---|
389 | if (v_regs[5] & 0x0180)
|
---|
390 | vbank(0);
|
---|
391 |
|
---|
392 | vputp(wdoct, x, y, pen);
|
---|
393 | }
|
---|
394 |
|
---|
395 | /* |
---|
396 |
|
---|
397 | */
|
---|
398 |
|
---|
399 | /*
|
---|
400 | =============================================================================
|
---|
401 | wdbord() -- draw the border for the waveshape display
|
---|
402 | =============================================================================
|
---|
403 | */
|
---|
404 |
|
---|
405 | void wdbord(void)
|
---|
406 | {
|
---|
407 | point = wdpoint;
|
---|
408 |
|
---|
409 | lseg( 0, 0, 511, 0, WBORD); /* outer border */
|
---|
410 | lseg(511, 0, 511, 349, WBORD);
|
---|
411 | lseg(511, 349, 0, 349, WBORD);
|
---|
412 | lseg( 0, 349, 0, 0, WBORD);
|
---|
413 |
|
---|
414 | lseg( 0, 308, 511, 308, WBORD); /* windows - H lines */
|
---|
415 | lseg(511, 321, 0, 321, WBORD);
|
---|
416 |
|
---|
417 | lseg(175, 322, 175, 349, WBORD); /* windows - V lines */
|
---|
418 | lseg(231, 322, 231, 349, WBORD);
|
---|
419 | lseg(399, 322, 399, 349, WBORD);
|
---|
420 | }
|
---|
421 |
|
---|
422 | /* |
---|
423 |
|
---|
424 | */
|
---|
425 |
|
---|
426 | /*
|
---|
427 | =============================================================================
|
---|
428 | clrws() -- initialize waveshape to null values
|
---|
429 | =============================================================================
|
---|
430 | */
|
---|
431 |
|
---|
432 | void clrws(void)
|
---|
433 | {
|
---|
434 | register struct instdef *ip;
|
---|
435 |
|
---|
436 | ip = &vbufs[curvce];
|
---|
437 |
|
---|
438 | if (curwslt) {
|
---|
439 |
|
---|
440 | memsetw(ip->idhwvbh, 0, NUMHARM);
|
---|
441 | memsetw(ip->idhwvbo, 0, NUMWPNT);
|
---|
442 | memsetw(ip->idhwvbf, 0, NUMWPNT);
|
---|
443 |
|
---|
444 | } else {
|
---|
445 |
|
---|
446 | memsetw(ip->idhwvah, 0, NUMHARM);
|
---|
447 | memsetw(ip->idhwvao, 0, NUMWPNT);
|
---|
448 | memsetw(ip->idhwvaf, 0, NUMWPNT);
|
---|
449 | }
|
---|
450 |
|
---|
451 | clrwsa();
|
---|
452 |
|
---|
453 | lstwpnt = wplast = curwpnt;
|
---|
454 |
|
---|
455 | lstwoff = wvlast = curwfnl = curwoff = 0;
|
---|
456 |
|
---|
457 | curwhrv = 0;
|
---|
458 |
|
---|
459 | updfpu(); /* update the FPU */
|
---|
460 | wsnmod[curvce][curwslt] = TRUE; /* tag WS as modified */
|
---|
461 | }
|
---|
462 |
|
---|
463 | /* |
---|
464 |
|
---|
465 | */
|
---|
466 |
|
---|
467 | /*
|
---|
468 | =============================================================================
|
---|
469 | iniwslb() -- initialize waveshape library
|
---|
470 | =============================================================================
|
---|
471 | */
|
---|
472 |
|
---|
473 | void iniwslb(void)
|
---|
474 | {
|
---|
475 | register short i, j;
|
---|
476 |
|
---|
477 | memsetw(wsnmod, FALSE, (sizeof wsnmod) / 2);
|
---|
478 |
|
---|
479 | for (i = 0; i < NUMWAVS; i++) {
|
---|
480 |
|
---|
481 | for (j = 0; j < NUMWPNT; j++) {
|
---|
482 |
|
---|
483 | wslib[i].final[j] = ((j + 1) << 8) ^ 0x8000;
|
---|
484 | wslib[i].offset[j] = ((j + 1) << 8) ^ 0x8000;
|
---|
485 | }
|
---|
486 |
|
---|
487 | memsetw(wslib[i].harmon, 0, NUMHARM); /* zero harmonics */
|
---|
488 | }
|
---|
489 | }
|
---|
490 |
|
---|
491 | /* |
---|
492 |
|
---|
493 | */
|
---|
494 |
|
---|
495 | /*
|
---|
496 | =============================================================================
|
---|
497 | wsdsp() -- put up the waveshape display
|
---|
498 | =============================================================================
|
---|
499 | */
|
---|
500 |
|
---|
501 | void wsdsp(void)
|
---|
502 | {
|
---|
503 | waveob = &v_score[0]; /* setup object pointer */
|
---|
504 | obj0 = &v_curs0[0]; /* setup cursor object pointer */
|
---|
505 | wdoct = &v_obtab[WAVEOBJ]; /* setup object control table pointer */
|
---|
506 |
|
---|
507 | wpntsv = 0; /* point selection state = unselected */
|
---|
508 | newws(); /* set editing variables */
|
---|
509 |
|
---|
510 | dswap(); /* initialize display */
|
---|
511 |
|
---|
512 | if (v_regs[5] & 0x0180)
|
---|
513 | vbank(0);
|
---|
514 |
|
---|
515 | memsetw(waveob, 0, 32767);
|
---|
516 | memsetw(waveob+32767L, 0, 12033);
|
---|
517 |
|
---|
518 | SetObj(WAVEOBJ, 0, 0, waveob, 512, 350, 0, 0, WAVEFL, -1);
|
---|
519 | SetObj( 0, 0, 1, obj0, 16, 16, WCURX, WCURY, OBFL_00, -1);
|
---|
520 |
|
---|
521 | arcurs(WDCURS); /* setup arrow cursor object */
|
---|
522 | itcini(WDCURS); /* setup text cursor object */
|
---|
523 |
|
---|
524 | wdbord(); /* draw the border */
|
---|
525 | wwins();
|
---|
526 |
|
---|
527 | SetPri(WAVEOBJ, WAVEPRI);
|
---|
528 | SetPri(0, GCPRI);
|
---|
529 | setgc(WCURX, WCURY); /* display the graphic cursor */
|
---|
530 |
|
---|
531 | vsndpal(wavpal); /* send the palette */
|
---|
532 | }
|
---|