[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | wdfield.c -- waveshape display field processing and cursor motion
|
---|
| 4 | Version 46 -- 1989-11-15 -- D.N. Lynx Crowe
|
---|
| 5 | =============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #define DOUBLED 1 /* non-zero for doubled WS outputs */
|
---|
| 9 |
|
---|
[6262b5c] | 10 | #include "all.h"
|
---|
[e225e77] | 11 |
|
---|
[f40a309] | 12 | #define WCSCALE 32768L
|
---|
| 13 | #define WCROUND 16384L
|
---|
| 14 |
|
---|
[0292fbb] | 15 | extern void select(void);
|
---|
[7258c6a] | 16 | extern int16_t whatbox(void);
|
---|
[0292fbb] | 17 | extern void nokey(void);
|
---|
[7258c6a] | 18 | extern int16_t nonf(int16_t k);
|
---|
| 19 | extern int16_t stdctp1(void);
|
---|
[0292fbb] | 20 | extern void cxkstd(void);
|
---|
| 21 | extern void cykstd(void);
|
---|
| 22 | extern void stdmkey(void);
|
---|
[7258c6a] | 23 | extern void stddkey(int16_t k);
|
---|
| 24 |
|
---|
| 25 | extern int16_t et_null(int16_t n);
|
---|
| 26 | extern int16_t ef_null(int16_t n);
|
---|
| 27 | extern int16_t rd_null(int16_t n);
|
---|
| 28 | extern int16_t nd_null(int16_t n, int16_t k);
|
---|
| 29 | extern int16_t et_wavs(int16_t n);
|
---|
| 30 | extern int16_t ef_wavs(int16_t n);
|
---|
| 31 | extern int16_t rd_wavs(int16_t n);
|
---|
| 32 | extern int16_t nd_wavs(int16_t n, int16_t k);
|
---|
| 33 | extern int16_t et_wvce(int16_t n);
|
---|
| 34 | extern int16_t ef_wvce(int16_t n);
|
---|
| 35 | extern int16_t rd_wvce(int16_t n);
|
---|
| 36 | extern int16_t nd_wvce(int16_t n, int16_t k);
|
---|
| 37 | extern int16_t et_wslt(int16_t n);
|
---|
| 38 | extern int16_t ef_wslt(int16_t n);
|
---|
| 39 | extern int16_t rd_wslt(int16_t n);
|
---|
| 40 | extern int16_t nd_wslt(int16_t n, int16_t k);
|
---|
| 41 | extern int16_t et_wpnt(int16_t n);
|
---|
| 42 | extern int16_t ef_wpnt(int16_t n);
|
---|
| 43 | extern int16_t rd_wpnt(int16_t n);
|
---|
| 44 | extern int16_t nd_wpnt(int16_t n, int16_t k);
|
---|
| 45 | extern int16_t et_woff(int16_t n);
|
---|
| 46 | extern int16_t ef_woff(int16_t n);
|
---|
| 47 | extern int16_t rd_woff(int16_t n);
|
---|
| 48 | extern int16_t nd_woff(int16_t n, int16_t k);
|
---|
| 49 | extern int16_t et_whar(int16_t n);
|
---|
| 50 | extern int16_t ef_whar(int16_t n);
|
---|
| 51 | extern int16_t rd_whar(int16_t n);
|
---|
| 52 | extern int16_t nd_whar(int16_t n, int16_t k);
|
---|
| 53 | extern int16_t et_whrv(int16_t n);
|
---|
| 54 | extern int16_t ef_whrv(int16_t n);
|
---|
| 55 | extern int16_t rd_whrv(int16_t n);
|
---|
| 56 | extern int16_t nd_whrv(int16_t n, int16_t k);
|
---|
| 57 |
|
---|
[e225e77] | 58 | extern void wscalc(void);
|
---|
| 59 | extern void adj(int16_t wshar);
|
---|
| 60 | extern void wdswin(int16_t n);
|
---|
| 61 | extern void clrws(void);
|
---|
| 62 | extern void wadj(void);
|
---|
| 63 | extern void wwins(void);
|
---|
| 64 | extern void curset(struct curpak *s);
|
---|
[f40a309] | 65 |
|
---|
| 66 | /* |
---|
| 67 |
|
---|
| 68 | */
|
---|
[7258c6a] | 69 |
|
---|
| 70 | extern int16_t astat;
|
---|
| 71 | extern int16_t cmtype;
|
---|
| 72 | extern int16_t curfunc;
|
---|
| 73 | extern int16_t curinst;
|
---|
| 74 | extern int16_t curslim;
|
---|
| 75 | extern int16_t curvce;
|
---|
| 76 | extern int16_t curwave;
|
---|
| 77 | extern int16_t curwdth;
|
---|
| 78 | extern int16_t curwfnl;
|
---|
| 79 | extern int16_t curwhrm;
|
---|
| 80 | extern int16_t curwhrv;
|
---|
| 81 | extern int16_t curwoff;
|
---|
| 82 | extern int16_t curwpnt;
|
---|
| 83 | extern int16_t curwslt;
|
---|
| 84 | extern int16_t cxrate;
|
---|
| 85 | extern int16_t cxval;
|
---|
| 86 | extern int16_t cyrate;
|
---|
| 87 | extern int16_t cyval;
|
---|
| 88 | extern int16_t hitbox;
|
---|
| 89 | extern int16_t lstwoff;
|
---|
| 90 | extern int16_t lstwpnt;
|
---|
| 91 | extern int16_t stccol;
|
---|
| 92 | extern int16_t stcrow;
|
---|
| 93 | extern int16_t wdupdfl;
|
---|
| 94 | extern int16_t wplast;
|
---|
| 95 | extern int16_t wpntsv;
|
---|
[f40a309] | 96 | extern int16_t wvlast;
|
---|
| 97 |
|
---|
| 98 | /* |
---|
| 99 |
|
---|
[7258c6a] | 100 | */
|
---|
| 101 |
|
---|
| 102 | extern int16_t crate1[];
|
---|
| 103 | extern int16_t offsets[NUMWPCAL];
|
---|
[f40a309] | 104 | extern int16_t vmtab[NUMHARM];
|
---|
[7258c6a] | 105 | extern int16_t wsbuf[NUMWPCAL];
|
---|
[f40a309] | 106 |
|
---|
[7258c6a] | 107 | extern int16_t wsnmod[12][2];
|
---|
[f40a309] | 108 |
|
---|
[7258c6a] | 109 | extern uint16_t *waveob;
|
---|
[f40a309] | 110 |
|
---|
| 111 | extern int8_t bfs[];
|
---|
| 112 |
|
---|
| 113 | extern struct instdef vbufs[];
|
---|
| 114 |
|
---|
| 115 | extern struct selbox *csbp;
|
---|
| 116 | extern struct selbox wdboxes[];
|
---|
| 117 |
|
---|
[0292fbb] | 118 | /* forward references */
|
---|
[7258c6a] | 119 |
|
---|
[0292fbb] | 120 | void wdxkey(void);
|
---|
| 121 | int16_t wdnfld(int16_t k);
|
---|
| 122 | void wdcxupd(void);
|
---|
| 123 | void wdcyupd(void);
|
---|
[f40a309] | 124 | void wdykup(void);
|
---|
| 125 | void wdykdn(void);
|
---|
| 126 |
|
---|
| 127 | /* |
---|
[7258c6a] | 128 |
|
---|
[f40a309] | 129 | */
|
---|
[7258c6a] | 130 |
|
---|
[f40a309] | 131 | #include "wdcurtb.h" /* int16_t wdcurtb[]; int16_t wdcurct[8][2]; */
|
---|
| 132 |
|
---|
| 133 | int16_t wxrate = 1; /* WS interpolate X movement increment */
|
---|
| 134 |
|
---|
| 135 | struct fet wd_fet1[] = {
|
---|
| 136 |
|
---|
| 137 | {23, 10, 11, 0x0002, et_wavs, ef_wavs, rd_wavs, nd_wavs},
|
---|
| 138 | {23, 19, 20, 0x0102, et_wvce, ef_wvce, rd_wvce, nd_wvce},
|
---|
| 139 | {23, 34, 36, 0x0004, et_wpnt, ef_wpnt, rd_wpnt, nd_wpnt},
|
---|
| 140 | {23, 44, 48, 0x0104, et_woff, ef_woff, rd_woff, nd_woff},
|
---|
| 141 | {23, 61, 62, 0x0005, et_whar, ef_whar, rd_whar, nd_whar},
|
---|
| 142 |
|
---|
| 143 | {24, 20, 20, 0x0302, et_wslt, ef_wslt, rd_wslt, nd_wslt},
|
---|
| 144 | {24, 57, 60, 0x0105, et_whrv, ef_whrv, rd_whrv, nd_whrv},
|
---|
| 145 |
|
---|
[7258c6a] | 146 | { 0, 0, 0, 0x0000, FN_NULL, FN_NULL, FN_NULL, FN_NULL}
|
---|
[f40a309] | 147 | };
|
---|
| 148 |
|
---|
| 149 | int16_t wdbox[][8] = { /* display box parameters */
|
---|
| 150 |
|
---|
| 151 | { 1, 1, 510, 307, WCFBX00, WCBBX00, 0, 1}, /* 0 */
|
---|
| 152 | { 1, 309, 510, 320, WCFBX01, WCBBX01, 22, 0}, /* 1 */
|
---|
| 153 | { 1, 322, 174, 348, WCFBX02, WCBBX02, 23, 1}, /* 2 */
|
---|
| 154 | {176, 322, 230, 348, WCFBX03, WCBBX03, 23, 23}, /* 3 */
|
---|
| 155 | {232, 322, 398, 348, WCFBX04, WCBBX04, 23, 30}, /* 4 */
|
---|
[7258c6a] | 156 | {400, 322, 510, 348, WCFBX05, WCBBX05, 23, 51} /* 5 */
|
---|
[f40a309] | 157 | };
|
---|
| 158 |
|
---|
| 159 | int8_t *wdbxlb0[] = { /* display box labels -- row 0 */
|
---|
| 160 |
|
---|
| 161 | "", /* 0 */
|
---|
| 162 |
|
---|
| 163 | "\320\301 \320\303 \320\305 \320\307 \320\311 \
|
---|
| 164 | \321\301 \321\303 \321\305 \321\307 \321\311 \
|
---|
| 165 | \322\301 \322\303 \322\305 \322\307 \322\311 \323\301 ", /* 1 */
|
---|
| 166 |
|
---|
| 167 | "Waveshpe Voice", /* 2 */
|
---|
| 168 | "Store", /* 3 */
|
---|
| 169 | "Pnt Offst", /* 4 */
|
---|
[7258c6a] | 170 | "Harmonic #" /* 5 */
|
---|
[f40a309] | 171 | };
|
---|
| 172 |
|
---|
| 173 | int8_t *wdbxlb1[] = { /* display box labels -- row 1 */
|
---|
| 174 |
|
---|
| 175 | "", /* 0 */
|
---|
| 176 | "", /* 1 */
|
---|
| 177 | "Instrument Slot", /* 2 */
|
---|
| 178 | "Fetch", /* 3 */
|
---|
| 179 | " Final", /* 4 */
|
---|
| 180 | "Value" /* 5 */
|
---|
| 181 | };
|
---|
| 182 |
|
---|
| 183 | /* |
---|
| 184 |
|
---|
| 185 | */
|
---|
| 186 |
|
---|
| 187 | struct curpak wd_flds = {
|
---|
| 188 |
|
---|
| 189 | stdctp1, /* curtype */
|
---|
| 190 | nokey, /* premove */
|
---|
| 191 | nokey, /* pstmove */
|
---|
| 192 | cxkstd, /* cx_key */
|
---|
| 193 | cykstd, /* cy_key */
|
---|
| 194 | wdcxupd, /* cx_upd */
|
---|
| 195 | wdcyupd, /* cy_upd */
|
---|
| 196 | wdykup, /* xy_up */
|
---|
| 197 | wdykdn, /* xy_dn */
|
---|
| 198 | wdxkey, /* x_key */
|
---|
| 199 | select, /* e_key */
|
---|
| 200 | stdmkey, /* m_key */
|
---|
| 201 | stddkey, /* d_key */
|
---|
| 202 | wdnfld, /* not_fld */
|
---|
| 203 | wd_fet1, /* curfet */
|
---|
| 204 | wdboxes, /* csbp */
|
---|
| 205 | crate1, /* cratex */
|
---|
| 206 | crate1, /* cratey */
|
---|
| 207 | CT_GRAF, /* cmtype */
|
---|
| 208 | WCURX, /* cxval */
|
---|
| 209 | WCURY /* cyval */
|
---|
| 210 | };
|
---|
| 211 |
|
---|
| 212 | /* |
---|
| 213 |
|
---|
| 214 | */
|
---|
| 215 |
|
---|
| 216 | /*
|
---|
[0292fbb] | 217 | =============================================================================
|
---|
[f40a309] | 218 | updfpu() -- update the FPU with a new waveshape
|
---|
[7258c6a] | 219 | =============================================================================
|
---|
| 220 | */
|
---|
[f40a309] | 221 |
|
---|
| 222 | void updfpu(void)
|
---|
[9519422] | 223 | {
|
---|
[f40a309] | 224 | register int16_t i;
|
---|
| 225 | register int16_t *wsp1, *wsp2;
|
---|
| 226 |
|
---|
| 227 | /* calculate instrument source and FPU destination pointers */
|
---|
| 228 |
|
---|
| 229 | wsp1 = io_fpu + FPU_OWST + (curvce << 9) + (curwslt ? 0 : 0x0100) + 1;
|
---|
| 230 | wsp2 = curwslt ? vbufs[curvce].idhwvbf : vbufs[curvce].idhwvaf;
|
---|
| 231 |
|
---|
| 232 | memcpyw(wsp1, wsp2, NUMWPNT);
|
---|
| 233 |
|
---|
| 234 | /* make endpoints track */
|
---|
| 235 |
|
---|
| 236 | *(wsp1 - 1) = *(wsp2 - 1); /* lowest point */
|
---|
| 237 | *(wsp1 + NUMWPNT) = *(wsp2 + NUMWPNT - 1); /* highest point */
|
---|
| 238 |
|
---|
| 239 | #if DOUBLED
|
---|
| 240 |
|
---|
| 241 | /* do outputs again to get around hardware bug */
|
---|
| 242 |
|
---|
| 243 | memcpyw(wsp1, wsp2, NUMWPNT);
|
---|
| 244 |
|
---|
| 245 | *(wsp1 - 1) = *(wsp2 - 1); /* lowest point */
|
---|
| 246 | *(wsp1 + NUMWPNT) = *(wsp2 + NUMWPNT - 1); /* highest point */
|
---|
| 247 | #endif
|
---|
| 248 |
|
---|
| 249 | curwfnl = wsp2[curwpnt] >> 5; /* udpate final value */
|
---|
| 250 | }
|
---|
| 251 |
|
---|
| 252 | /* |
---|
| 253 |
|
---|
| 254 | */
|
---|
| 255 |
|
---|
[0292fbb] | 256 | /*
|
---|
[f40a309] | 257 | =============================================================================
|
---|
[7258c6a] | 258 | wsupd() -- update the instrument definition and FPU for new WS offsets
|
---|
| 259 | =============================================================================
|
---|
[f40a309] | 260 | */
|
---|
| 261 |
|
---|
| 262 | void wsupd(void)
|
---|
| 263 | {
|
---|
| 264 | register int16_t i;
|
---|
| 265 | register int16_t *wsp1, *wsp2;
|
---|
| 266 |
|
---|
| 267 | /* update the offsets[] array from the instrument definition */
|
---|
| 268 |
|
---|
| 269 | wsp2 = curwslt ? vbufs[curvce].idhwvbo : vbufs[curvce].idhwvao;
|
---|
| 270 |
|
---|
| 271 | for (i = 0; i < NUMWPNT; i++)
|
---|
| 272 | offsets[i + 1] = wsp2[i] >> 5;
|
---|
| 273 |
|
---|
| 274 | offsets[0] = offsets[1];
|
---|
| 275 |
|
---|
| 276 | wscalc(); /* calculate the final values */
|
---|
| 277 |
|
---|
| 278 | /* update the final values in the instrument definition */
|
---|
| 279 |
|
---|
| 280 | wsp1 = curwslt ? vbufs[curvce].idhwvbf : vbufs[curvce].idhwvaf;
|
---|
| 281 |
|
---|
| 282 | for (i = 0; i < NUMWPNT; i++)
|
---|
| 283 | wsp1[i] = wsbuf[1 + i] << 5;
|
---|
| 284 |
|
---|
| 285 | updfpu();
|
---|
| 286 | wsnmod[curvce][curwslt] = TRUE; /* tag WS as modified */
|
---|
| 287 | }
|
---|
| 288 |
|
---|
[0292fbb] | 289 | /*
|
---|
[f40a309] | 290 | =============================================================================
|
---|
[7258c6a] | 291 | whupd() -- update the FPU for new WS harmonics
|
---|
| 292 | =============================================================================
|
---|
[f40a309] | 293 | */
|
---|
| 294 |
|
---|
| 295 | void whupd(void)
|
---|
| 296 | {
|
---|
| 297 | register int16_t i;
|
---|
| 298 | register int16_t *wsp1;
|
---|
| 299 |
|
---|
| 300 | /* update the final values in the instrument definition */
|
---|
| 301 |
|
---|
| 302 | wsp1 = curwslt ? vbufs[curvce].idhwvbf : vbufs[curvce].idhwvaf;
|
---|
| 303 |
|
---|
| 304 | for (i = 0; i < NUMWPNT; i++)
|
---|
| 305 | wsp1[i] = wsbuf[i + 1] << 5;
|
---|
| 306 |
|
---|
| 307 | updfpu(); /* update the FPU */
|
---|
| 308 | wsnmod[curvce][curwslt] = TRUE; /* tag WS as modified */
|
---|
| 309 | }
|
---|
| 310 |
|
---|
| 311 | /* |
---|
| 312 |
|
---|
| 313 | */
|
---|
[0292fbb] | 314 |
|
---|
[f40a309] | 315 | /*
|
---|
| 316 | =============================================================================
|
---|
[7258c6a] | 317 | pntsup() -- update waveshape points with the cursor 'brush'
|
---|
| 318 | =============================================================================
|
---|
| 319 | */
|
---|
[f40a309] | 320 |
|
---|
| 321 | void pntsup(void)
|
---|
| 322 | {
|
---|
| 323 | register struct instdef *ip;
|
---|
| 324 | int16_t *ov;
|
---|
| 325 | register int16_t i, j, k, tv, curdif;
|
---|
| 326 | int16_t cwnp, cwin;
|
---|
| 327 |
|
---|
| 328 | ip = &vbufs[curvce]; /* instrument definition */
|
---|
| 329 |
|
---|
| 330 | ov = curwslt ? &ip->idhwvbo /* offsets in definition */
|
---|
| 331 | : &ip->idhwvao;
|
---|
| 332 |
|
---|
| 333 | cwnp = wdcurct[curwdth][0]; /* number of points effected */
|
---|
| 334 |
|
---|
| 335 | cwin = wdcurct[curwdth][1]; /* table increment */
|
---|
| 336 |
|
---|
| 337 | curdif = lstwoff - curwoff; /* calculate the difference */
|
---|
| 338 |
|
---|
| 339 | /* |
---|
| 340 |
|
---|
| 341 | */
|
---|
| 342 | for (i = 0 , k = 0; i < cwnp; i++ , k += cwin) {
|
---|
| 343 |
|
---|
| 344 | if (i EQ 0) { /* first point */
|
---|
| 345 |
|
---|
| 346 | ov[curwpnt] = curwoff << 5;
|
---|
| 347 |
|
---|
| 348 | } else { /* subsequent points */
|
---|
| 349 |
|
---|
| 350 | j = curwpnt + i; /* update point on the right */
|
---|
| 351 |
|
---|
| 352 | if (j < NUMWPNT) { /* ... if it exists */
|
---|
| 353 |
|
---|
| 354 | tv = (ov[j] >> 5) -
|
---|
| 355 | ((((long)curdif * wdcurtb[k])
|
---|
| 356 | + WCROUND) / WCSCALE);
|
---|
| 357 |
|
---|
| 358 | if (tv GT 1023)
|
---|
| 359 | tv = 1023;
|
---|
| 360 | else if (tv LT -1023)
|
---|
| 361 | tv = -1023;
|
---|
| 362 |
|
---|
| 363 | ov[j] = tv << 5;
|
---|
| 364 | }
|
---|
| 365 |
|
---|
| 366 | j = curwpnt - i; /* update point on the left */
|
---|
| 367 |
|
---|
| 368 | if (j GE 0) { /* ... if it exists */
|
---|
| 369 |
|
---|
| 370 | tv = (ov[j] >> 5) -
|
---|
| 371 | ((((long)curdif * wdcurtb[k])
|
---|
| 372 | + WCROUND) / WCSCALE);
|
---|
| 373 |
|
---|
| 374 | if (tv GT 1023)
|
---|
| 375 | tv = 1023;
|
---|
| 376 | else if (tv LT -1023)
|
---|
| 377 | tv = -1023;
|
---|
| 378 |
|
---|
| 379 | ov[j] = tv << 5;
|
---|
| 380 | }
|
---|
| 381 | }
|
---|
| 382 | }
|
---|
| 383 |
|
---|
| 384 | wsupd();
|
---|
| 385 | }
|
---|
| 386 |
|
---|
| 387 | /* |
---|
[0292fbb] | 388 |
|
---|
[f40a309] | 389 | */
|
---|
| 390 |
|
---|
[7258c6a] | 391 | /*
|
---|
| 392 | =============================================================================
|
---|
[f40a309] | 393 | wdintp() -- interpolate between waveshape points
|
---|
[7258c6a] | 394 | =============================================================================
|
---|
[f40a309] | 395 | */
|
---|
| 396 |
|
---|
| 397 | void wdintp(void)
|
---|
| 398 | {
|
---|
| 399 | register struct instdef *ip;
|
---|
| 400 | register int16_t *ov;
|
---|
| 401 | register int16_t i, j, k, n;
|
---|
| 402 | register long t;
|
---|
| 403 | int16_t to, from;
|
---|
| 404 |
|
---|
| 405 | to = curwpnt;
|
---|
| 406 | from = wplast;
|
---|
| 407 |
|
---|
| 408 | ip = &vbufs[curvce];
|
---|
| 409 | ov = curwslt ? &ip->idhwvbo : &ip->idhwvao;
|
---|
| 410 |
|
---|
| 411 | ov[curwpnt] = curwoff << 5; /* force current point value */
|
---|
| 412 |
|
---|
| 413 | if (from > to) { /* make 'from' the leftmost point number */
|
---|
| 414 |
|
---|
| 415 | i = from;
|
---|
| 416 | from = to;
|
---|
| 417 | to = i;
|
---|
| 418 | }
|
---|
| 419 |
|
---|
| 420 | n = to - from; /* number of points */
|
---|
[7258c6a] | 421 |
|
---|
[f40a309] | 422 | if (n > 1) { /* have to have at least 1 point difference */
|
---|
| 423 |
|
---|
| 424 | k = ov[from] >> 5;
|
---|
| 425 | t = ((long)((long)(ov[to] >> 5) - (long)k) << 16) / n;
|
---|
| 426 | j = 1 + from;
|
---|
| 427 | --n;
|
---|
| 428 |
|
---|
| 429 | for (i = 0; i < n; i++)
|
---|
| 430 | ov[j++] = ((int16_t)((t * (1 + i)) >> 16) + k) << 5;
|
---|
| 431 | }
|
---|
| 432 |
|
---|
| 433 | wplast = curwpnt;
|
---|
| 434 | wvlast = curwoff;
|
---|
| 435 |
|
---|
| 436 | wsupd();
|
---|
| 437 | }
|
---|
| 438 |
|
---|
[0292fbb] | 439 | /* |
---|
[f40a309] | 440 |
|
---|
| 441 | */
|
---|
| 442 |
|
---|
| 443 | /*
|
---|
| 444 | =============================================================================
|
---|
| 445 | wdykdn() -- cursor y finger down processing
|
---|
| 446 | =============================================================================
|
---|
| 447 | */
|
---|
| 448 |
|
---|
| 449 | void wdykdn(void)
|
---|
| 450 | {
|
---|
| 451 | if (wpntsv EQ 0)
|
---|
| 452 | return;
|
---|
| 453 |
|
---|
[0292fbb] | 454 | lstwpnt = curwpnt;
|
---|
[f40a309] | 455 | lstwoff = curwoff;
|
---|
| 456 | }
|
---|
| 457 |
|
---|
| 458 | /*
|
---|
| 459 | =============================================================================
|
---|
| 460 | wdykup() -- cursor y finger up processing
|
---|
| 461 | =============================================================================
|
---|
| 462 | */
|
---|
| 463 |
|
---|
| 464 | void wdykup(void)
|
---|
| 465 | {
|
---|
| 466 | if ((wpntsv EQ 0) OR (wdupdfl EQ FALSE))
|
---|
| 467 | return;
|
---|
| 468 |
|
---|
| 469 | if (wpntsv EQ 1) { /* offsets */
|
---|
| 470 |
|
---|
| 471 | if (curwdth EQ NUMWIDS)
|
---|
| 472 | wdintp(); /* interpolate mode */
|
---|
| 473 | else
|
---|
| 474 | pntsup(); /* brush mode */
|
---|
| 475 |
|
---|
| 476 | } else { /* harmonics */
|
---|
| 477 |
|
---|
| 478 | adj(curwhrm); /* adjust vknm[curwhrm][] */
|
---|
| 479 | wscalc(); /* recalculate the waveshape */
|
---|
| 480 | whupd(); /* update the FPU */
|
---|
| 481 | }
|
---|
| 482 |
|
---|
| 483 | wdswin(0); /* display updated waveshape */
|
---|
| 484 | wdswin(2);
|
---|
| 485 | wdswin(4);
|
---|
| 486 |
|
---|
| 487 | wdupdfl = FALSE;
|
---|
| 488 | }
|
---|
[0292fbb] | 489 |
|
---|
[f40a309] | 490 | /* |
---|
| 491 |
|
---|
[7258c6a] | 492 | */
|
---|
| 493 |
|
---|
| 494 | /*
|
---|
| 495 | =============================================================================
|
---|
[f40a309] | 496 | wdcyupd() -- update cursor y location
|
---|
| 497 | =============================================================================
|
---|
| 498 | */
|
---|
| 499 |
|
---|
| 500 | void wdcyupd(void)
|
---|
| 501 | {
|
---|
| 502 | register struct instdef *ip;
|
---|
| 503 | register int16_t *ov, *hv;
|
---|
| 504 | register int16_t i, j, k, tv;
|
---|
| 505 | register int8_t wsgn;
|
---|
| 506 | int16_t wval, cwnp, cwin;
|
---|
| 507 |
|
---|
| 508 | ip = &vbufs[curvce];
|
---|
| 509 |
|
---|
| 510 | switch (wpntsv) {
|
---|
| 511 |
|
---|
| 512 | case 0: /* nothing selected -- just move cursor */
|
---|
| 513 |
|
---|
| 514 | cyval += cyrate;
|
---|
| 515 |
|
---|
| 516 | if (cyval GT (CYMAX - 1))
|
---|
| 517 | cyval = CYMAX - 1;
|
---|
| 518 | else if (cyval LT 1)
|
---|
| 519 | cyval = 1;
|
---|
| 520 |
|
---|
| 521 | return;
|
---|
| 522 | /* |
---|
| 523 |
|
---|
| 524 | */
|
---|
| 525 | case 1: /* offset selected */
|
---|
| 526 |
|
---|
| 527 | curwoff -= cyrate;
|
---|
| 528 |
|
---|
| 529 | if (curwoff GT 1023)
|
---|
| 530 | curwoff = 1023;
|
---|
| 531 | else if (curwoff LT -1023)
|
---|
| 532 | curwoff = -1023;
|
---|
| 533 |
|
---|
| 534 | cyval = WPOFF - ((curwoff * WPSF1) / WPSF2);
|
---|
| 535 |
|
---|
| 536 | if (curwoff < 0) {
|
---|
| 537 |
|
---|
| 538 | wval = - curwoff;
|
---|
| 539 | wsgn = '-';
|
---|
| 540 |
|
---|
| 541 | } else {
|
---|
| 542 |
|
---|
| 543 | wval = curwoff;
|
---|
| 544 | wsgn = '+';
|
---|
| 545 | }
|
---|
| 546 |
|
---|
| 547 | sprintf(bfs, "%c%04d", wsgn, wval);
|
---|
| 548 |
|
---|
| 549 | if (v_regs[5] & 0x0180)
|
---|
| 550 | vbank(0);
|
---|
| 551 |
|
---|
| 552 | vcputsv(waveob, 64, wdbox[4][4], wdbox[4][5], wdbox[4][6],
|
---|
| 553 | wdbox[4][7] + WOFF_OFF, bfs, 14);
|
---|
| 554 |
|
---|
| 555 | wdupdfl = TRUE;
|
---|
| 556 | return;
|
---|
| 557 | /* |
---|
| 558 |
|
---|
| 559 | */
|
---|
| 560 | case 2: /* harmonic selected */
|
---|
| 561 |
|
---|
| 562 | hv = curwslt ? &ip->idhwvbh : &ip->idhwvah;
|
---|
| 563 |
|
---|
| 564 | curwhrv = abs(hv[curwhrm]) - cyrate;
|
---|
| 565 |
|
---|
| 566 | if (curwhrv > 100)
|
---|
| 567 | curwhrv = 100;
|
---|
| 568 | else if (curwhrv < 0)
|
---|
| 569 | curwhrv = 0;
|
---|
| 570 |
|
---|
| 571 | curwhrv = (hv[curwhrm] < 0) ? -curwhrv : curwhrv;
|
---|
| 572 |
|
---|
| 573 | hv[curwhrm] = curwhrv;
|
---|
| 574 | vmtab[curwhrm] = curwhrv;
|
---|
| 575 |
|
---|
| 576 | if (curwhrv < 0) {
|
---|
| 577 |
|
---|
| 578 | wval = -curwhrv;
|
---|
| 579 | wsgn = '-';
|
---|
| 580 |
|
---|
| 581 | } else {
|
---|
| 582 |
|
---|
| 583 | wval = curwhrv;
|
---|
| 584 | wsgn = '+';
|
---|
| 585 | }
|
---|
| 586 |
|
---|
| 587 | if (v_regs[5] & 0x0180)
|
---|
| 588 | vbank(0);
|
---|
| 589 |
|
---|
| 590 | sprintf(bfs, "%c%03d", wsgn, wval);
|
---|
| 591 |
|
---|
| 592 | vcputsv(waveob, 64, wdbox[5][4], wdbox[5][5],
|
---|
| 593 | wdbox[5][6] + 1, wdbox[5][7] + WHRV_OFF, bfs, 14);
|
---|
| 594 |
|
---|
| 595 | if (curwhrv < 0)
|
---|
| 596 | cyval = WBOFF - ((-curwhrv * WBSF1) / WBSF2);
|
---|
| 597 | else
|
---|
| 598 | cyval = WBOFF - ((curwhrv * WBSF1) / WBSF2);
|
---|
| 599 |
|
---|
| 600 | wdupdfl = TRUE;
|
---|
[0292fbb] | 601 | return;
|
---|
[f40a309] | 602 | }
|
---|
| 603 | }
|
---|
| 604 |
|
---|
| 605 | /* |
---|
| 606 |
|
---|
| 607 | */
|
---|
| 608 |
|
---|
| 609 | /*
|
---|
| 610 | =============================================================================
|
---|
| 611 | wdcxupd() -- update cursor x location
|
---|
| 612 | =============================================================================
|
---|
| 613 | */
|
---|
| 614 |
|
---|
| 615 | void wdcxupd(void)
|
---|
| 616 | {
|
---|
| 617 | switch (wpntsv) {
|
---|
| 618 |
|
---|
| 619 | case 0: /* nothing selected - just move cursor */
|
---|
| 620 |
|
---|
| 621 | cxval += cxrate;
|
---|
| 622 |
|
---|
| 623 | if (cxval GT (CXMAX - 1))
|
---|
| 624 | cxval = CXMAX - 1;
|
---|
| 625 | else if (cxval LT 1)
|
---|
| 626 | cxval = 1;
|
---|
| 627 |
|
---|
| 628 | return;
|
---|
| 629 |
|
---|
| 630 | case 1: /* offset selected - maybe do interpolate move */
|
---|
| 631 |
|
---|
| 632 | if (curwdth NE NUMWIDS)
|
---|
| 633 | return;
|
---|
| 634 |
|
---|
| 635 | curwpnt += sign(cxrate, wxrate);
|
---|
| 636 |
|
---|
| 637 | if (curwpnt GE NUMWPNT)
|
---|
| 638 | curwpnt = NUMWPNT - 1;
|
---|
| 639 | else if (curwpnt < 0)
|
---|
| 640 | curwpnt = 0;
|
---|
| 641 |
|
---|
| 642 | cxval = (curwpnt << 1) + 2;
|
---|
| 643 |
|
---|
| 644 | if (v_regs[5] & 0x0180)
|
---|
| 645 | vbank(0);
|
---|
| 646 |
|
---|
| 647 | sprintf(bfs, "%03d", curwpnt);
|
---|
[7258c6a] | 648 | vcputsv(waveob, 64, wdbox[4][4], wdbox[4][5],
|
---|
[f40a309] | 649 | wdbox[4][6], wdbox[4][7] + WPNT_OFF, bfs, 14);
|
---|
[7258c6a] | 650 | }
|
---|
[f40a309] | 651 | }
|
---|
| 652 |
|
---|
| 653 | /* |
---|
| 654 |
|
---|
| 655 | */
|
---|
| 656 |
|
---|
| 657 | /*
|
---|
| 658 | =============================================================================
|
---|
| 659 | wdnfld() -- process not-in-field key entry
|
---|
| 660 | =============================================================================
|
---|
| 661 | */
|
---|
| 662 |
|
---|
| 663 | int16_t wdnfld(int16_t k)
|
---|
| 664 | {
|
---|
| 665 | register int16_t *hv;
|
---|
| 666 | register struct instdef *ip;
|
---|
| 667 |
|
---|
| 668 | if (astat) {
|
---|
| 669 |
|
---|
| 670 | if (whatbox()) {
|
---|
| 671 |
|
---|
| 672 | ip = &vbufs[curvce];
|
---|
| 673 | hv = curwslt ? &ip->idhwvbh : &ip->idhwvah;
|
---|
| 674 |
|
---|
| 675 | if (hitbox EQ 0) { /* waveshape area */
|
---|
| 676 |
|
---|
| 677 | switch (wpntsv) {
|
---|
| 678 |
|
---|
| 679 | case 0: /* nothing selected */
|
---|
| 680 |
|
---|
| 681 | if (k EQ 8) { /* - */
|
---|
| 682 |
|
---|
| 683 | if (--curwdth < 0)
|
---|
| 684 | curwdth = NUMWIDS;
|
---|
| 685 |
|
---|
| 686 | wdswin(4);
|
---|
| 687 | return(SUCCESS);
|
---|
| 688 |
|
---|
| 689 | } else if (k EQ 9) { /* + */
|
---|
| 690 |
|
---|
| 691 | if (++curwdth > NUMWIDS)
|
---|
| 692 | curwdth = 0;
|
---|
| 693 |
|
---|
| 694 | wdswin(4);
|
---|
| 695 | return(SUCCESS);
|
---|
| 696 | }
|
---|
| 697 |
|
---|
| 698 | return(FAILURE);
|
---|
| 699 | /* |
---|
| 700 |
|
---|
| 701 | */
|
---|
| 702 | case 1: /* offset selected */
|
---|
| 703 |
|
---|
| 704 | if (k EQ 8) { /* - */
|
---|
| 705 |
|
---|
| 706 | if (curwdth EQ NUMWIDS)
|
---|
| 707 | return(FAILURE);
|
---|
| 708 |
|
---|
| 709 | if (--curwdth LT 0)
|
---|
| 710 | curwdth = NUMWIDS - 1;
|
---|
| 711 |
|
---|
| 712 | wdswin(4);
|
---|
| 713 | return(SUCCESS);
|
---|
| 714 |
|
---|
| 715 | } else if (k EQ 9) { /* + */
|
---|
| 716 |
|
---|
| 717 | if (curwdth EQ NUMWIDS) {
|
---|
| 718 |
|
---|
| 719 | wdintp();
|
---|
| 720 | wdswin(0);
|
---|
| 721 | wdswin(2);
|
---|
| 722 |
|
---|
| 723 | } else if (++curwdth GE NUMWIDS)
|
---|
| 724 | curwdth = 0;
|
---|
| 725 |
|
---|
| 726 | wdswin(4);
|
---|
| 727 | return(SUCCESS);
|
---|
| 728 | }
|
---|
| 729 |
|
---|
| 730 | return(FAILURE);
|
---|
| 731 | /* |
---|
| 732 |
|
---|
| 733 | */
|
---|
| 734 | case 2: /* harmonic selected */
|
---|
| 735 |
|
---|
| 736 | if (k EQ 8) { /* - */
|
---|
| 737 |
|
---|
| 738 | if (hv[curwhrm] > 0)
|
---|
| 739 | hv[curwhrm] = -hv[curwhrm];
|
---|
| 740 | else
|
---|
| 741 | return(FAILURE);
|
---|
| 742 |
|
---|
| 743 | } else if (k EQ 9) { /* + */
|
---|
| 744 |
|
---|
| 745 | if (hv[curwhrm] < 0)
|
---|
| 746 | hv[curwhrm] = -hv[curwhrm];
|
---|
| 747 | else
|
---|
| 748 | return(FAILURE);
|
---|
[9519422] | 749 |
|
---|
[f40a309] | 750 | } else {
|
---|
| 751 |
|
---|
| 752 | return(FAILURE);
|
---|
| 753 | }
|
---|
| 754 |
|
---|
| 755 | curwhrv = hv[curwhrm];
|
---|
| 756 | vmtab[curwhrm] = curwhrv;
|
---|
| 757 | adj(curwhrm);
|
---|
| 758 | wscalc();
|
---|
| 759 | whupd();
|
---|
| 760 | wdswin(0);
|
---|
| 761 | wdswin(4);
|
---|
| 762 | wdswin(5);
|
---|
| 763 | return(SUCCESS);
|
---|
| 764 | }
|
---|
| 765 |
|
---|
| 766 | } else
|
---|
| 767 | return(FAILURE);
|
---|
| 768 | /* |
---|
| 769 |
|
---|
| 770 | */
|
---|
| 771 | } else if (hitbox EQ 1) { /* harmonic legend */
|
---|
| 772 |
|
---|
| 773 | if (k EQ 8) { /* - */
|
---|
| 774 |
|
---|
| 775 | if (hv[curwhrm] > 0)
|
---|
| 776 | hv[curwhrm] = -hv[curwhrm];
|
---|
| 777 | else
|
---|
| 778 | return(FAILURE);
|
---|
| 779 |
|
---|
| 780 | } else if (k EQ 9) { /* + */
|
---|
| 781 |
|
---|
| 782 | if (hv[curwhrm] < 0)
|
---|
| 783 | hv[curwhrm] = -hv[curwhrm];
|
---|
| 784 | else
|
---|
| 785 | return(FAILURE);
|
---|
| 786 |
|
---|
[599d89b] | 787 | } else {
|
---|
| 788 |
|
---|
[f40a309] | 789 | return(FAILURE);
|
---|
| 790 | }
|
---|
| 791 |
|
---|
| 792 | curwhrv = hv[curwhrm];
|
---|
| 793 | vmtab[curwhrm] = curwhrv;
|
---|
| 794 | adj(curwhrm);
|
---|
| 795 | wscalc();
|
---|
| 796 | whupd();
|
---|
| 797 | wdswin(0);
|
---|
| 798 | wdswin(4);
|
---|
| 799 | wdswin(5);
|
---|
[0292fbb] | 800 | return(SUCCESS);
|
---|
[f40a309] | 801 | }
|
---|
| 802 |
|
---|
[0292fbb] | 803 | return(FAILURE);
|
---|
[f40a309] | 804 | }
|
---|
| 805 |
|
---|
| 806 | return(FAILURE);
|
---|
| 807 | }
|
---|
| 808 |
|
---|
| 809 | /* |
---|
| 810 |
|
---|
| 811 | */
|
---|
| 812 |
|
---|
| 813 | /*
|
---|
| 814 | =============================================================================
|
---|
| 815 | wdxkey() -- process X key
|
---|
| 816 | =============================================================================
|
---|
| 817 | */
|
---|
| 818 |
|
---|
| 819 | void wdxkey(void)
|
---|
| 820 | {
|
---|
| 821 | if (NOT astat)
|
---|
| 822 | return; /* FAILURE */
|
---|
| 823 |
|
---|
| 824 | stcrow = cyval / 14;
|
---|
| 825 | stccol = cxval >> 3;
|
---|
| 826 |
|
---|
| 827 | if (stcrow EQ 23) {
|
---|
| 828 |
|
---|
| 829 | if ((stccol GE 2) OR (stccol LE 8)) {
|
---|
| 830 |
|
---|
| 831 | clrws();
|
---|
| 832 |
|
---|
[0292fbb] | 833 | } else if ((stccol GE 38) AND (stccol LE 42)) {
|
---|
[f40a309] | 834 |
|
---|
| 835 | memsetw(curwslt ? vbufs[curvce].idhwvbo
|
---|
| 836 | : vbufs[curvce].idhwvbo,
|
---|
| 837 | 0, NUMWPNT);
|
---|
[0292fbb] | 838 |
|
---|
[f40a309] | 839 | curwoff = 0;
|
---|
| 840 | wsupd();
|
---|
[0292fbb] | 841 |
|
---|
[f40a309] | 842 | } else if ((stccol GE 51) AND (stccol LE 58)) {
|
---|
| 843 |
|
---|
| 844 | memsetw(vmtab, 0, NUMHARM);
|
---|
| 845 | curwhrv = 0;
|
---|
| 846 | wadj();
|
---|
| 847 | wscalc();
|
---|
| 848 | whupd();
|
---|
| 849 |
|
---|
| 850 | } else {
|
---|
| 851 |
|
---|
| 852 | return; /* FAILURE */
|
---|
[0292fbb] | 853 | }
|
---|
[f40a309] | 854 |
|
---|
| 855 | wsnmod[curvce][curwslt] = TRUE;
|
---|
| 856 | wwins();
|
---|
| 857 | return; /* SUCCESS */
|
---|
| 858 | }
|
---|
| 859 |
|
---|
| 860 | return; /* FAILURE */
|
---|
| 861 | }
|
---|
| 862 |
|
---|
| 863 | /* |
---|
| 864 |
|
---|
| 865 | */
|
---|
| 866 |
|
---|
| 867 | /*
|
---|
| 868 | =============================================================================
|
---|
| 869 | wdfield() -- setup field routines for the waveshape editor
|
---|
| 870 | =============================================================================
|
---|
| 871 | */
|
---|
| 872 |
|
---|
| 873 | void wdfield(void)
|
---|
| 874 | {
|
---|
| 875 | curslim = 307;
|
---|
| 876 |
|
---|
| 877 | curset(&wd_flds);
|
---|
| 878 | }
|
---|