source: buchla-68k/orig/RAM/WSDSP.C@ ee49131

Last change on this file since ee49131 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 11.2 KB
Line 
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
26extern unsigned exp_c();
27
28extern int (*point)();
29
30extern unsigned *obj0;
31
32extern char bfs[];
33
34extern char *wdbxlb0[];
35extern char *wdbxlb1[];
36
37extern short wdbox[][8];
38
39extern struct instdef vbufs[];
40
41/*
42
43*/
44
45extern short curinst;
46extern short curvce;
47extern short curwave; /* current waveshape library slot */
48extern short curwdth; /* current waveshape cursor width */
49extern short curwfnl; /* current waveshape final value */
50extern short curwhrm; /* current waveshape harmonic number */
51extern short curwhrv; /* current waveshape harmonic value */
52extern short curwpnt; /* current waveshape point number */
53extern short curwoff; /* current waveshape offset value */
54extern short curwslt; /* current waveshape instrument slot */
55extern short cxval;
56extern short cyval;
57extern short lstwoff;
58extern short lstwpnt;
59extern short stccol;
60extern short stcrow;
61extern short wpntsv; /* waveshape point selection state variable */
62extern short wplast;
63extern short wvlast;
64
65extern short vmtab[NUMHARM]; /* harmonic table */
66extern short wsbuf[NUMWPCAL]; /* waveshape generation buffer */
67
68extern long vknm[NUMHARM][NUMWPCAL]; /* scaled harmonics */
69
70extern unsigned *waveob; /* waveshape display object pointer */
71
72extern short wsnmod[12][2]; /* waveshape number or data modified */
73
74extern struct wstbl wslib[NUMWAVS]; /* waveshape library */
75
76extern struct octent *wdoct; /* object control table pointer */
77
78/* forward references */
79
80short wdpoint();
81
82/*
83
84*/
85
86short 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
116advwcur()
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
136hdraw(hv, h)
137register short *hv;
138short 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
172dsws(how)
173short 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
226wdswin(n)
227register 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
377wwins()
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
391wdpoint(x, y, pen)
392short x, y, pen;
393{
394 if (v_regs[5] & 0x0180)
395 vbank(0);
396
397 vputp(wdoct, x, y, pen);
398}
399
400/*
401
402*/
403
404/*
405 =============================================================================
406 wdbord() -- draw the border for the waveshape display
407 =============================================================================
408*/
409
410wdbord()
411{
412 point = wdpoint;
413
414 lseg( 0, 0, 511, 0, WBORD); /* outer border */
415 lseg(511, 0, 511, 349, WBORD);
416 lseg(511, 349, 0, 349, WBORD);
417 lseg( 0, 349, 0, 0, WBORD);
418
419 lseg( 0, 308, 511, 308, WBORD); /* windows - H lines */
420 lseg(511, 321, 0, 321, WBORD);
421
422 lseg(175, 322, 175, 349, WBORD); /* windows - V lines */
423 lseg(231, 322, 231, 349, WBORD);
424 lseg(399, 322, 399, 349, WBORD);
425}
426
427/*
428
429*/
430
431/*
432 =============================================================================
433 clrws() -- initialize waveshape to null values
434 =============================================================================
435*/
436
437clrws()
438{
439 register struct instdef *ip;
440
441 ip = &vbufs[curvce];
442
443 if (curwslt) {
444
445 memsetw(ip->idhwvbh, 0, NUMHARM);
446 memsetw(ip->idhwvbo, 0, NUMWPNT);
447 memsetw(ip->idhwvbf, 0, NUMWPNT);
448
449 } else {
450
451 memsetw(ip->idhwvah, 0, NUMHARM);
452 memsetw(ip->idhwvao, 0, NUMWPNT);
453 memsetw(ip->idhwvaf, 0, NUMWPNT);
454 }
455
456 clrwsa();
457
458 lstwpnt = wplast = curwpnt;
459
460 lstwoff = wvlast = curwfnl = curwoff = 0;
461
462 curwhrv = 0;
463
464 updfpu(); /* update the FPU */
465 wsnmod[curvce][curwslt] = TRUE; /* tag WS as modified */
466}
467
468/*
469
470*/
471
472/*
473 =============================================================================
474 iniwslb() -- initialize waveshape library
475 =============================================================================
476*/
477
478iniwslb()
479{
480 register short i, j;
481
482 memsetw(wsnmod, FALSE, (sizeof wsnmod) / 2);
483
484 for (i = 0; i < NUMWAVS; i++) {
485
486 for (j = 0; j < NUMWPNT; j++) {
487
488 wslib[i].final[j] = ((j + 1) << 8) ^ 0x8000;
489 wslib[i].offset[j] = ((j + 1) << 8) ^ 0x8000;
490 }
491
492 memsetw(wslib[i].harmon, 0, NUMHARM); /* zero harmonics */
493 }
494}
495
496/*
497
498*/
499
500/*
501 =============================================================================
502 wsdsp() -- put up the waveshape display
503 =============================================================================
504*/
505
506wsdsp()
507{
508 waveob = &v_score[0]; /* setup object pointer */
509 obj0 = &v_curs0[0]; /* setup cursor object pointer */
510 wdoct = &v_obtab[WAVEOBJ]; /* setup object control table pointer */
511
512 wpntsv = 0; /* point selection state = unselected */
513 newws(); /* set editing variables */
514
515 dswap(); /* initialize display */
516
517 if (v_regs[5] & 0x0180)
518 vbank(0);
519
520 memsetw(waveob, 0, 32767);
521 memsetw(waveob+32767L, 0, 12033);
522
523 SetObj(WAVEOBJ, 0, 0, waveob, 512, 350, 0, 0, WAVEFL, -1);
524 SetObj( 0, 0, 1, obj0, 16, 16, WCURX, WCURY, OBFL_00, -1);
525
526 arcurs(WDCURS); /* setup arrow cursor object */
527 itcini(WDCURS); /* setup text cursor object */
528
529 wdbord(); /* draw the border */
530 wwins();
531
532 SetPri(WAVEOBJ, WAVEPRI);
533 SetPri(0, GCPRI);
534 setgc(WCURX, WCURY); /* display the graphic cursor */
535
536 vsndpal(wavpal); /* send the palette */
537}
Note: See TracBrowser for help on using the repository browser.