source: buchla-68k/ram/wsdsp.c

Last change on this file was 72741f4, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Fixed incompatible pointers.

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