[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | wsdsp.c -- MIDAS waveshape editor display driver
|
---|
| 4 | Version 35 -- 1988-09-09 -- D.N. Lynx Crowe
|
---|
| 5 | =============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[b28a12e] | 8 | #include "ram.h"
|
---|
[f40a309] | 9 |
|
---|
[7258c6a] | 10 | int16_t wavpal[16][3] = { /* waveshape display color palette */
|
---|
[f40a309] | 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 |
|
---|
[0580615] | 36 | void advwcur(void)
|
---|
[f40a309] | 37 | {
|
---|
[7258c6a] | 38 | register int16_t newcol;
|
---|
[f40a309] | 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 |
|
---|
[7258c6a] | 52 | void hdraw(int16_t *hv, int16_t h)
|
---|
[f40a309] | 53 | {
|
---|
[7258c6a] | 54 | register int16_t bc, bx, by, j;
|
---|
[f40a309] | 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 |
|
---|
[7258c6a] | 82 | void dsws(int16_t how)
|
---|
[f40a309] | 83 | {
|
---|
| 84 | register struct instdef *ip;
|
---|
[7258c6a] | 85 | register int16_t *fv, *hv, *ov;
|
---|
| 86 | register int16_t i;
|
---|
| 87 | int16_t cx;
|
---|
[f40a309] | 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 |
|
---|
[7258c6a] | 131 | void wdswin(int16_t n)
|
---|
[f40a309] | 132 | {
|
---|
[7258c6a] | 133 | register int16_t cx, wval;
|
---|
| 134 | register int8_t wsgn;
|
---|
[f40a309] | 135 |
|
---|
| 136 | cx = wdbox[n][5];
|
---|
| 137 | cx |= cx << 4;
|
---|
| 138 | cx |= cx << 8;
|
---|
| 139 |
|
---|
| 140 | /* first, fill the box with the background color */
|
---|
| 141 |
|
---|
| 142 | if (v_regs[5] & 0x0180)
|
---|
| 143 | vbank(0);
|
---|
| 144 |
|
---|
| 145 | vbfill4(waveob, 128, wdbox[n][0], wdbox[n][1], wdbox[n][2],
|
---|
| 146 | wdbox[n][3], cx);
|
---|
| 147 |
|
---|
| 148 | /* put in the box label */
|
---|
| 149 |
|
---|
| 150 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6], wdbox[n][7],
|
---|
| 151 | wdbxlb0[n], 14);
|
---|
| 152 |
|
---|
| 153 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1, wdbox[n][7],
|
---|
| 154 | wdbxlb1[n], 14);
|
---|
| 155 |
|
---|
[fa38804] | 156 |
|
---|
[f40a309] | 157 | switch (n) { /* final text - overlays above stuff */
|
---|
| 158 |
|
---|
| 159 | case 0: /* points and bars */
|
---|
| 160 |
|
---|
| 161 | dsws(0);
|
---|
| 162 | return;
|
---|
| 163 |
|
---|
| 164 | case 2: /* waveshape - voice - instrument - slot */
|
---|
| 165 |
|
---|
| 166 | sprintf(bfs, "%02d", curwave + 1);
|
---|
| 167 | tsplot4(waveob, 64,
|
---|
| 168 | exp_c(wsnmod[curvce][curwslt] ? WS_CHGC : wdbox[n][4]),
|
---|
| 169 | wdbox[n][6], wdbox[n][7] + WAVE_OFF, bfs, 14);
|
---|
| 170 |
|
---|
| 171 | sprintf(bfs, "%02d", curvce + 1);
|
---|
| 172 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6],
|
---|
| 173 | wdbox[n][7] + WVCE_OFF, bfs, 14);
|
---|
| 174 |
|
---|
| 175 | sprintf(bfs, "%02d", curinst);
|
---|
| 176 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
| 177 | wdbox[n][7] + WINS_OFF, bfs, 14);
|
---|
| 178 |
|
---|
| 179 | sprintf(bfs, "%c", curwslt + 'A');
|
---|
| 180 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
| 181 | wdbox[n][7] + WSLT_OFF, bfs, 14);
|
---|
| 182 |
|
---|
| 183 | return;
|
---|
| 184 |
|
---|
[fa38804] | 185 |
|
---|
[f40a309] | 186 | case 4: /* point - offset - width - final */
|
---|
| 187 |
|
---|
| 188 | sprintf(bfs, "%03d", curwpnt);
|
---|
| 189 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6],
|
---|
| 190 | wdbox[n][7] + WPNT_OFF, bfs, 14);
|
---|
| 191 |
|
---|
| 192 | if (curwoff < 0) {
|
---|
| 193 |
|
---|
| 194 | wval = - curwoff;
|
---|
| 195 | wsgn = '-';
|
---|
| 196 |
|
---|
| 197 | } else {
|
---|
| 198 |
|
---|
| 199 | wval = curwoff;
|
---|
| 200 | wsgn = '+';
|
---|
| 201 | }
|
---|
| 202 |
|
---|
| 203 | sprintf(bfs, "%c%04d", wsgn, wval);
|
---|
| 204 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6],
|
---|
| 205 | wdbox[n][7] + WOFF_OFF, bfs, 14);
|
---|
| 206 |
|
---|
| 207 | if (curwdth EQ NUMWIDS) {
|
---|
| 208 |
|
---|
| 209 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
| 210 | wdbox[n][7], "Interp", 14);
|
---|
| 211 |
|
---|
| 212 | } else {
|
---|
| 213 |
|
---|
| 214 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
| 215 | wdbox[n][7], "Width", 14);
|
---|
| 216 |
|
---|
| 217 | sprintf(bfs, "%01d", curwdth);
|
---|
| 218 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
| 219 | wdbox[n][7] + WDTH_OFF, bfs, 14);
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | if (curwfnl < 0) {
|
---|
| 223 |
|
---|
| 224 | wval = - curwfnl;
|
---|
| 225 | wsgn = '-';
|
---|
| 226 |
|
---|
| 227 | } else {
|
---|
| 228 |
|
---|
| 229 | wval = curwfnl;
|
---|
| 230 | wsgn = '+';
|
---|
| 231 | }
|
---|
| 232 |
|
---|
| 233 | sprintf(bfs, "%c%04d", wsgn, wval);
|
---|
| 234 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
| 235 | wdbox[n][7] + WFNL_OFF, bfs, 14);
|
---|
| 236 |
|
---|
| 237 | return;
|
---|
[fa38804] | 238 |
|
---|
[f40a309] | 239 | case 5: /* harmonic - value */
|
---|
| 240 |
|
---|
| 241 | sprintf(bfs, "%02d", curwhrm + 1);
|
---|
| 242 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6],
|
---|
| 243 | wdbox[n][7] + WHRM_OFF, bfs, 14);
|
---|
| 244 |
|
---|
| 245 | if (curwhrv < 0) {
|
---|
| 246 |
|
---|
| 247 | wval = - curwhrv;
|
---|
| 248 | wsgn = '-';
|
---|
| 249 |
|
---|
| 250 | } else {
|
---|
| 251 |
|
---|
| 252 | wval = curwhrv;
|
---|
| 253 | wsgn = '+';
|
---|
| 254 | }
|
---|
| 255 |
|
---|
| 256 | sprintf(bfs, "%c%03d", wsgn, wval);
|
---|
| 257 | tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1,
|
---|
| 258 | wdbox[n][7] + WHRV_OFF, bfs, 14);
|
---|
| 259 |
|
---|
| 260 | return;
|
---|
| 261 |
|
---|
| 262 | }
|
---|
| 263 | }
|
---|
| 264 |
|
---|
| 265 | /*
|
---|
| 266 | =============================================================================
|
---|
| 267 | wwins() -- display all waveshape editor windows
|
---|
| 268 | =============================================================================
|
---|
| 269 | */
|
---|
| 270 |
|
---|
[0580615] | 271 | void wwins(void)
|
---|
[f40a309] | 272 | {
|
---|
[7258c6a] | 273 | register int16_t i;
|
---|
[f40a309] | 274 |
|
---|
| 275 | for (i = 0; i < 6; i++)
|
---|
| 276 | wdswin(i);
|
---|
| 277 | }
|
---|
| 278 |
|
---|
| 279 | /*
|
---|
| 280 | =============================================================================
|
---|
| 281 | wdpoint() -- plot a point for the lseg function
|
---|
| 282 | =============================================================================
|
---|
| 283 | */
|
---|
| 284 |
|
---|
[7258c6a] | 285 | void wdpoint(int16_t x, int16_t y, int16_t pen)
|
---|
[f40a309] | 286 | {
|
---|
| 287 | if (v_regs[5] & 0x0180)
|
---|
| 288 | vbank(0);
|
---|
| 289 |
|
---|
| 290 | vputp(wdoct, x, y, pen);
|
---|
| 291 | }
|
---|
| 292 |
|
---|
| 293 | /*
|
---|
| 294 | =============================================================================
|
---|
| 295 | wdbord() -- draw the border for the waveshape display
|
---|
| 296 | =============================================================================
|
---|
| 297 | */
|
---|
| 298 |
|
---|
[0580615] | 299 | void wdbord(void)
|
---|
[f40a309] | 300 | {
|
---|
| 301 | point = wdpoint;
|
---|
| 302 |
|
---|
| 303 | lseg( 0, 0, 511, 0, WBORD); /* outer border */
|
---|
| 304 | lseg(511, 0, 511, 349, WBORD);
|
---|
| 305 | lseg(511, 349, 0, 349, WBORD);
|
---|
| 306 | lseg( 0, 349, 0, 0, WBORD);
|
---|
| 307 |
|
---|
| 308 | lseg( 0, 308, 511, 308, WBORD); /* windows - H lines */
|
---|
| 309 | lseg(511, 321, 0, 321, WBORD);
|
---|
| 310 |
|
---|
| 311 | lseg(175, 322, 175, 349, WBORD); /* windows - V lines */
|
---|
| 312 | lseg(231, 322, 231, 349, WBORD);
|
---|
| 313 | lseg(399, 322, 399, 349, WBORD);
|
---|
| 314 | }
|
---|
| 315 |
|
---|
| 316 | /*
|
---|
| 317 | =============================================================================
|
---|
| 318 | clrws() -- initialize waveshape to null values
|
---|
| 319 | =============================================================================
|
---|
| 320 | */
|
---|
| 321 |
|
---|
[0580615] | 322 | void clrws(void)
|
---|
[f40a309] | 323 | {
|
---|
| 324 | register struct instdef *ip;
|
---|
| 325 |
|
---|
| 326 | ip = &vbufs[curvce];
|
---|
| 327 |
|
---|
| 328 | if (curwslt) {
|
---|
| 329 |
|
---|
| 330 | memsetw(ip->idhwvbh, 0, NUMHARM);
|
---|
| 331 | memsetw(ip->idhwvbo, 0, NUMWPNT);
|
---|
| 332 | memsetw(ip->idhwvbf, 0, NUMWPNT);
|
---|
| 333 |
|
---|
| 334 | } else {
|
---|
| 335 |
|
---|
| 336 | memsetw(ip->idhwvah, 0, NUMHARM);
|
---|
| 337 | memsetw(ip->idhwvao, 0, NUMWPNT);
|
---|
| 338 | memsetw(ip->idhwvaf, 0, NUMWPNT);
|
---|
| 339 | }
|
---|
| 340 |
|
---|
| 341 | clrwsa();
|
---|
| 342 |
|
---|
| 343 | lstwpnt = wplast = curwpnt;
|
---|
| 344 |
|
---|
| 345 | lstwoff = wvlast = curwfnl = curwoff = 0;
|
---|
| 346 |
|
---|
| 347 | curwhrv = 0;
|
---|
| 348 |
|
---|
| 349 | updfpu(); /* update the FPU */
|
---|
| 350 | wsnmod[curvce][curwslt] = TRUE; /* tag WS as modified */
|
---|
| 351 | }
|
---|
| 352 |
|
---|
| 353 | /*
|
---|
| 354 | =============================================================================
|
---|
| 355 | iniwslb() -- initialize waveshape library
|
---|
| 356 | =============================================================================
|
---|
| 357 | */
|
---|
| 358 |
|
---|
[0580615] | 359 | void iniwslb(void)
|
---|
[f40a309] | 360 | {
|
---|
[7258c6a] | 361 | register int16_t i, j;
|
---|
[f40a309] | 362 |
|
---|
| 363 | memsetw(wsnmod, FALSE, (sizeof wsnmod) / 2);
|
---|
| 364 |
|
---|
| 365 | for (i = 0; i < NUMWAVS; i++) {
|
---|
| 366 |
|
---|
| 367 | for (j = 0; j < NUMWPNT; j++) {
|
---|
| 368 |
|
---|
| 369 | wslib[i].final[j] = ((j + 1) << 8) ^ 0x8000;
|
---|
| 370 | wslib[i].offset[j] = ((j + 1) << 8) ^ 0x8000;
|
---|
| 371 | }
|
---|
| 372 |
|
---|
| 373 | memsetw(wslib[i].harmon, 0, NUMHARM); /* zero harmonics */
|
---|
| 374 | }
|
---|
| 375 | }
|
---|
[9519422] | 376 |
|
---|
[f40a309] | 377 | /*
|
---|
| 378 | =============================================================================
|
---|
| 379 | wsdsp() -- put up the waveshape display
|
---|
| 380 | =============================================================================
|
---|
| 381 | */
|
---|
| 382 |
|
---|
[0580615] | 383 | void wsdsp(void)
|
---|
[f40a309] | 384 | {
|
---|
| 385 | waveob = &v_score[0]; /* setup object pointer */
|
---|
| 386 | obj0 = &v_curs0[0]; /* setup cursor object pointer */
|
---|
| 387 | wdoct = &v_obtab[WAVEOBJ]; /* setup object control table pointer */
|
---|
| 388 |
|
---|
| 389 | wpntsv = 0; /* point selection state = unselected */
|
---|
| 390 | newws(); /* set editing variables */
|
---|
| 391 |
|
---|
| 392 | dswap(); /* initialize display */
|
---|
| 393 |
|
---|
| 394 | if (v_regs[5] & 0x0180)
|
---|
| 395 | vbank(0);
|
---|
| 396 |
|
---|
| 397 | memsetw(waveob, 0, 32767);
|
---|
| 398 | memsetw(waveob+32767L, 0, 12033);
|
---|
| 399 |
|
---|
| 400 | SetObj(WAVEOBJ, 0, 0, waveob, 512, 350, 0, 0, WAVEFL, -1);
|
---|
| 401 | SetObj( 0, 0, 1, obj0, 16, 16, WCURX, WCURY, OBFL_00, -1);
|
---|
| 402 |
|
---|
| 403 | arcurs(WDCURS); /* setup arrow cursor object */
|
---|
| 404 | itcini(WDCURS); /* setup text cursor object */
|
---|
| 405 |
|
---|
| 406 | wdbord(); /* draw the border */
|
---|
| 407 | wwins();
|
---|
| 408 |
|
---|
| 409 | SetPri(WAVEOBJ, WAVEPRI);
|
---|
| 410 | SetPri(0, GCPRI);
|
---|
| 411 | setgc(WCURX, WCURY); /* display the graphic cursor */
|
---|
| 412 |
|
---|
| 413 | vsndpal(wavpal); /* send the palette */
|
---|
| 414 | }
|
---|
[6262b5c] | 415 |
|
---|