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