/* ============================================================================= wsdsp.c -- MIDAS waveshape editor display driver Version 35 -- 1988-09-09 -- D.N. Lynx Crowe ============================================================================= */ #include "ram.h" int16_t wavpal[16][3] = { /* waveshape display color palette */ {0, 0, 0}, /* 0 */ {3, 3, 3}, /* 1 */ {2, 2, 2}, /* 2 */ {0, 1, 1}, /* 3 (was 0, 1, 0) */ {1, 0, 1}, /* 4 */ {0, 1, 1}, /* 5 (was 0, 1, 0) */ {2, 1, 2}, /* 6 */ {0, 3, 0}, /* 7 */ {2, 0, 0}, /* 8 */ {2, 0, 2}, /* 9 */ {0, 0, 0}, /* 10 */ {2, 3, 3}, /* 11 */ {3, 3, 0}, /* 12 */ {3, 0, 0}, /* 13 */ {0, 0, 1}, /* 14 (was 0, 0, 2) */ {0, 0, 3} /* 15 */ }; /* ============================================================================= advwcur() -- advance the waveshape display text cursor ============================================================================= */ void advwcur(void) { register int16_t newcol; newcol = stccol + 1; if (newcol LE cfetp->frcol) itcpos(stcrow, newcol); } /* ============================================================================= hdraw(h) -- draw harmonic 'h' for the current waveshape ============================================================================= */ void hdraw(int16_t *hv, int16_t h) { register int16_t bc, bx, by, j; bx = (h << 4) + 4; if (hv[h] < 0) { by = WBOFF - ((-hv[h] * WBSF1) / WBSF2); bc = WBCN; } else { by = WBOFF - ((hv[h] * WBSF1) / WBSF2); bc = WBCP; } for (j = 0; j < 8; j++) { lseg(bx, WBOFF, bx, by, bc); ++bx; } } /* ============================================================================= dsws() -- display the current waveshape ============================================================================= */ void dsws(int16_t how) { register struct instdef *ip; register int16_t *fv, *hv, *ov; register int16_t i; uint16_t cx; cx = exp_c(wdbox[0][0]); ip = &vbufs[curvce]; fv = curwslt ? ip->idhwvbf : ip->idhwvaf; ov = curwslt ? ip->idhwvbo : ip->idhwvao; hv = curwslt ? ip->idhwvbh : ip->idhwvah; point = wdpoint; if (v_regs[5] & 0x0180) vbank(0); if (how) vbfill4(waveob, 128, wdbox[0][0], wdbox[0][1], wdbox[0][2], wdbox[0][3], cx); lseg(1, 133, 510, 133, WZBC); /* draw the zero line and ... */ lseg(1, (WPOFF << 1), 510, (WPOFF << 1), WZBC); /* ... bottom limit */ for (i = 0; i < NUMHARM; i++) /* draw the harmonics */ hdraw(hv, i); for (i = 0; i < NUMWPNT; i++) { /* draw the values */ /* offset values */ wdpoint(((2 * i) + 2), (WPOFF - (((ov[i] >> 5) * WPSF1) / WPSF2)), WOVC); /* final values */ wdpoint(((2 * i) + 2), (WPOFF - (((fv[i] >> 5) * WPSF1) / WPSF2)), WFVC); } } /* ============================================================================= wdswin() -- display a window ============================================================================= */ void wdswin(int16_t n) { uint16_t cx; int16_t wval; int8_t wsgn; cx = exp_c(wdbox[n][5]); /* first, fill the box with the background color */ if (v_regs[5] & 0x0180) vbank(0); vbfill4(waveob, 128, wdbox[n][0], wdbox[n][1], wdbox[n][2], wdbox[n][3], cx); /* put in the box label */ tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6], wdbox[n][7], wdbxlb0[n], 14); tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1, wdbox[n][7], wdbxlb1[n], 14); switch (n) { /* final text - overlays above stuff */ case 0: /* points and bars */ dsws(0); return; case 2: /* waveshape - voice - instrument - slot */ sprintf(bfs, "%02d", curwave + 1); tsplot4(waveob, 64, wsnmod[curvce][curwslt] ? WS_CHGC : wdbox[n][4], wdbox[n][6], wdbox[n][7] + WAVE_OFF, bfs, 14); sprintf(bfs, "%02d", curvce + 1); tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6], wdbox[n][7] + WVCE_OFF, bfs, 14); sprintf(bfs, "%02d", curinst); tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1, wdbox[n][7] + WINS_OFF, bfs, 14); sprintf(bfs, "%c", curwslt + 'A'); tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1, wdbox[n][7] + WSLT_OFF, bfs, 14); return; case 4: /* point - offset - width - final */ sprintf(bfs, "%03d", curwpnt); tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6], wdbox[n][7] + WPNT_OFF, bfs, 14); if (curwoff < 0) { wval = - curwoff; wsgn = '-'; } else { wval = curwoff; wsgn = '+'; } sprintf(bfs, "%c%04d", wsgn, wval); tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6], wdbox[n][7] + WOFF_OFF, bfs, 14); if (curwdth EQ NUMWIDS) { tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1, wdbox[n][7], "Interp", 14); } else { tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1, wdbox[n][7], "Width", 14); sprintf(bfs, "%01d", curwdth); tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1, wdbox[n][7] + WDTH_OFF, bfs, 14); } if (curwfnl < 0) { wval = - curwfnl; wsgn = '-'; } else { wval = curwfnl; wsgn = '+'; } sprintf(bfs, "%c%04d", wsgn, wval); tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1, wdbox[n][7] + WFNL_OFF, bfs, 14); return; case 5: /* harmonic - value */ sprintf(bfs, "%02d", curwhrm + 1); tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6], wdbox[n][7] + WHRM_OFF, bfs, 14); if (curwhrv < 0) { wval = - curwhrv; wsgn = '-'; } else { wval = curwhrv; wsgn = '+'; } sprintf(bfs, "%c%03d", wsgn, wval); tsplot4(waveob, 64, wdbox[n][4], wdbox[n][6] + 1, wdbox[n][7] + WHRV_OFF, bfs, 14); return; } } /* ============================================================================= wwins() -- display all waveshape editor windows ============================================================================= */ void wwins(void) { register int16_t i; for (i = 0; i < 6; i++) wdswin(i); } /* ============================================================================= wdpoint() -- plot a point for the lseg function ============================================================================= */ void wdpoint(int16_t x, int16_t y, int16_t pen) { if (v_regs[5] & 0x0180) vbank(0); vputp(wdoct, x, y, pen); } /* ============================================================================= wdbord() -- draw the border for the waveshape display ============================================================================= */ void wdbord(void) { point = wdpoint; lseg( 0, 0, 511, 0, WBORD); /* outer border */ lseg(511, 0, 511, 349, WBORD); lseg(511, 349, 0, 349, WBORD); lseg( 0, 349, 0, 0, WBORD); lseg( 0, 308, 511, 308, WBORD); /* windows - H lines */ lseg(511, 321, 0, 321, WBORD); lseg(175, 322, 175, 349, WBORD); /* windows - V lines */ lseg(231, 322, 231, 349, WBORD); lseg(399, 322, 399, 349, WBORD); } /* ============================================================================= clrws() -- initialize waveshape to null values ============================================================================= */ void clrws(void) { register struct instdef *ip; ip = &vbufs[curvce]; if (curwslt) { memsetw(ip->idhwvbh, 0, NUMHARM); memsetw(ip->idhwvbo, 0, NUMWPNT); memsetw(ip->idhwvbf, 0, NUMWPNT); } else { memsetw(ip->idhwvah, 0, NUMHARM); memsetw(ip->idhwvao, 0, NUMWPNT); memsetw(ip->idhwvaf, 0, NUMWPNT); } clrwsa(); lstwpnt = wplast = curwpnt; lstwoff = wvlast = curwfnl = curwoff = 0; curwhrv = 0; updfpu(); /* update the FPU */ wsnmod[curvce][curwslt] = TRUE; /* tag WS as modified */ } /* ============================================================================= iniwslb() -- initialize waveshape library ============================================================================= */ void iniwslb(void) { register int16_t i, j; memsetw(wsnmod, FALSE, (sizeof wsnmod) / 2); for (i = 0; i < NUMWAVS; i++) { for (j = 0; j < NUMWPNT; j++) { wslib[i].final[j] = ((j + 1) << 8) ^ (int16_t)0x8000; wslib[i].offset[j] = ((j + 1) << 8) ^ (int16_t)0x8000; } memsetw(wslib[i].harmon, 0, NUMHARM); /* zero harmonics */ } } /* ============================================================================= wsdsp() -- put up the waveshape display ============================================================================= */ void wsdsp(void) { waveob = &v_score[0]; /* setup object pointer */ obj0 = &v_curs0[0]; /* setup cursor object pointer */ wdoct = &v_obtab[WAVEOBJ]; /* setup object control table pointer */ wpntsv = 0; /* point selection state = unselected */ newws(); /* set editing variables */ dswap(); /* initialize display */ if (v_regs[5] & 0x0180) vbank(0); memsetw(waveob, 0, 32767); memsetw(waveob+32767L, 0, 12033); SetObj(WAVEOBJ, 0, 0, waveob, 512, 350, 0, 0, WAVEFL, -1); SetObj( 0, 0, 1, obj0, 16, 16, WCURX, WCURY, OBFL_00, -1); arcurs(WDCURS); /* setup arrow cursor object */ itcini(WDCURS); /* setup text cursor object */ wdbord(); /* draw the border */ wwins(); SetPri(WAVEOBJ, WAVEPRI); SetPri(0, GCPRI); setgc(WCURX, WCURY); /* display the graphic cursor */ vsndpal(wavpal); /* send the palette */ }