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