[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | initi.c -- MIDAS-VII - instrument editor support functions
|
---|
| 4 | Version 2 -- 1989-12-19 -- D.N. Lynx Crowe
|
---|
| 5 | =============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #define DEBUGPS 0 /* define non-zero to debug pntsel() */
|
---|
| 9 |
|
---|
| 10 | #include "stddefs.h"
|
---|
| 11 | #include "fpu.h"
|
---|
| 12 | #include "hwdefs.h"
|
---|
| 13 | #include "vsdd.h"
|
---|
| 14 | #include "graphdef.h"
|
---|
| 15 |
|
---|
| 16 | #include "midas.h"
|
---|
| 17 | #include "instdsp.h"
|
---|
| 18 |
|
---|
[7258c6a] | 19 | extern uint16_t setipl(uint16_t arg);
|
---|
[f40a309] | 20 |
|
---|
[7258c6a] | 21 | extern uint16_t tofpu(uint16_t time);
|
---|
| 22 | extern uint16_t fromfpu(uint16_t fputime);
|
---|
[f40a309] | 23 |
|
---|
[e225e77] | 24 | extern void clrvce(int16_t vce);
|
---|
| 25 | extern void dosync(int16_t vce);
|
---|
| 26 | extern void dswin(int16_t n);
|
---|
| 27 | extern void execkey(int16_t trg, int16_t pch, int16_t vce, int16_t tag);
|
---|
| 28 | extern void fpuclr(void);
|
---|
| 29 | extern void newws(void);
|
---|
| 30 |
|
---|
[7258c6a] | 31 | extern int16_t s_inst[], vce2trg[], vce2grp[];
|
---|
[f40a309] | 32 |
|
---|
[7258c6a] | 33 | extern int16_t curfunc; /* current function number */
|
---|
| 34 | extern int16_t curinst; /* current instrument number */
|
---|
| 35 | extern int16_t curpnt; /* current point number (absolute) */
|
---|
| 36 | extern int16_t curvce; /* current voice number */
|
---|
| 37 | extern int16_t cxval; /* graphics cursor x value */
|
---|
| 38 | extern int16_t editsw; /* edit mode switch */
|
---|
| 39 | extern int16_t initcfg; /* initialization cfg value */
|
---|
| 40 | extern int16_t npts; /* number of points in function */
|
---|
| 41 | extern int16_t pecase; /* point edit case variable */
|
---|
| 42 | extern int16_t pntsv; /* point selection state variable */
|
---|
| 43 | extern int16_t subj; /* edited point number (relative) */
|
---|
| 44 | extern int16_t temax; /* time upper limit */
|
---|
| 45 | extern int16_t temin; /* time lower limit */
|
---|
[f40a309] | 46 |
|
---|
[7258c6a] | 47 | extern int8_t *funcndx[256][2]; /* function header pointers */
|
---|
[f40a309] | 48 |
|
---|
[7258c6a] | 49 | extern int16_t idbox[][8]; /* display box parameters */
|
---|
| 50 | extern int16_t instmod[12]; /* intrument data modified */
|
---|
[f40a309] | 51 |
|
---|
[7258c6a] | 52 | extern int16_t fnoff[]; /* instrument fn to FPU fn table */
|
---|
[f40a309] | 53 |
|
---|
| 54 | extern struct instpnt *pntptr; /* pointer to edited point */
|
---|
| 55 |
|
---|
| 56 | extern struct instdef idefs[NINST]; /* current instrument definitions */
|
---|
| 57 | extern struct instdef vbufs[12]; /* voice instrument buffers */
|
---|
| 58 |
|
---|
| 59 | /* |
---|
| 60 |
|
---|
| 61 | */
|
---|
| 62 |
|
---|
[7258c6a] | 63 | #include "dfltins.h" /* short dfltins[]; default instrument */
|
---|
[f40a309] | 64 | #include "ptoftab.h" /* int16_t ptoftab[]; pitch to frequency table */
|
---|
[e225e77] | 65 |
|
---|
| 66 | #include "memory.h"
|
---|
[7258c6a] | 67 |
|
---|
[f40a309] | 68 | int16_t finival[NFINST] = { /* initial function values */
|
---|
| 69 |
|
---|
| 70 | FPUVAL(500), /* 0: Freq 1 */
|
---|
| 71 | FPUVAL(500), /* 1: Freq 2 */
|
---|
| 72 | FPUVAL(500), /* 2: Freq 3 */
|
---|
| 73 | FPUVAL(500), /* 3: Freq 4 */
|
---|
| 74 | FPUVAL(500), /* 4: Filter / Resonance */
|
---|
| 75 | FPUVAL(500), /* 5: Location */
|
---|
| 76 |
|
---|
| 77 | FPUVAL(0), /* 6: Index 1 */
|
---|
| 78 | FPUVAL(0), /* 7: Index 2 */
|
---|
| 79 | FPUVAL(0), /* 8: Index 3 */
|
---|
| 80 | FPUVAL(0), /* 9: Index 4 */
|
---|
| 81 | FPUVAL(0), /* 10: Index 5 */
|
---|
| 82 | FPUVAL(0), /* 11: Index 6 */
|
---|
| 83 |
|
---|
| 84 | FPUVAL(0) /* 12: Level */
|
---|
| 85 | };
|
---|
[7258c6a] | 86 |
|
---|
[f40a309] | 87 | int16_t expbit[16] = { /* FPU time exponent bit expansion table */
|
---|
| 88 |
|
---|
| 89 | 0x0001, /* 0 */
|
---|
| 90 | 0x0002, /* 1 */
|
---|
| 91 | 0x0004, /* 2 */
|
---|
| 92 | 0x0008, /* 3 */
|
---|
| 93 | 0x0010, /* 4 */
|
---|
| 94 | 0x0020, /* 5 */
|
---|
| 95 | 0x0040, /* 6 */
|
---|
| 96 | 0x0080, /* 7 */
|
---|
| 97 | 0x0100, /* 8 */
|
---|
| 98 | 0x0200, /* 9 */
|
---|
| 99 | 0x0400, /* 10 */
|
---|
| 100 | 0x0800, /* 11 */
|
---|
| 101 | 0x1000, /* 12 */
|
---|
| 102 | 0x2000, /* 13 */
|
---|
| 103 | 0x4000, /* 14 */
|
---|
| 104 | 0x8000 /* 15 */
|
---|
| 105 | };
|
---|
| 106 |
|
---|
| 107 | /* |
---|
| 108 |
|
---|
| 109 | */
|
---|
| 110 |
|
---|
| 111 | /*
|
---|
| 112 | =============================================================================
|
---|
| 113 | segtime() -- determine time to a point using a new segment time
|
---|
| 114 | =============================================================================
|
---|
[7258c6a] | 115 | */
|
---|
[f40a309] | 116 |
|
---|
| 117 | int16_t segtime(int16_t pn, uint16_t ptime)
|
---|
[7258c6a] | 118 | {
|
---|
| 119 | register struct instpnt *pp;
|
---|
[f40a309] | 120 | register int16_t i;
|
---|
| 121 | register uint16_t tacc;
|
---|
| 122 |
|
---|
| 123 | pp = &vbufs[curvce].idhpnt[vbufs[curvce].idhfnc[curfunc].idfpt1];
|
---|
| 124 | tacc = 0;
|
---|
| 125 |
|
---|
| 126 | for (i = 0; i < pn; i++)
|
---|
| 127 | tacc += fromfpu(pp++->iptim);
|
---|
| 128 |
|
---|
| 129 | tacc += fromfpu(ptime);
|
---|
| 130 |
|
---|
| 131 | return(tacc);
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | /*
|
---|
| 135 | =============================================================================
|
---|
| 136 | setseg() -- set the time to a segment
|
---|
| 137 | =============================================================================
|
---|
[7258c6a] | 138 | */
|
---|
[f40a309] | 139 |
|
---|
[7258c6a] | 140 | void setseg(int16_t pn, uint16_t ptime)
|
---|
| 141 | {
|
---|
[f40a309] | 142 | register int16_t i;
|
---|
| 143 | register uint16_t tacc;
|
---|
| 144 | register struct instpnt *pp;
|
---|
| 145 |
|
---|
| 146 | pp = &vbufs[curvce].idhpnt[vbufs[curvce].idhfnc[curfunc].idfpt1];
|
---|
| 147 | tacc = 0;
|
---|
| 148 |
|
---|
| 149 | for (i = 0; i < pn; i++)
|
---|
| 150 | tacc += fromfpu(pp++->iptim);
|
---|
| 151 |
|
---|
| 152 | pp->iptim = tofpu(ptime - tacc);
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | /* |
---|
| 156 |
|
---|
| 157 | */
|
---|
| 158 |
|
---|
| 159 | /*
|
---|
| 160 | =============================================================================
|
---|
| 161 | timeto() -- find the time at a point in a function
|
---|
[7258c6a] | 162 | =============================================================================
|
---|
[f40a309] | 163 | */
|
---|
| 164 |
|
---|
| 165 | int16_t timeto(int16_t fn, int16_t pj)
|
---|
[7258c6a] | 166 | {
|
---|
[f40a309] | 167 | register struct instdef *ip;
|
---|
| 168 | register struct instpnt *pt;
|
---|
| 169 | register int16_t tf, pm, pn;
|
---|
| 170 |
|
---|
| 171 | ip = &vbufs[curvce];
|
---|
| 172 | pn = ip->idhfnc[fn].idfpt1;
|
---|
| 173 | pt = &ip->idhpnt[pn];
|
---|
| 174 | pm = pn + pj;
|
---|
| 175 | tf = 0;
|
---|
| 176 |
|
---|
| 177 | while (pn LE pm) {
|
---|
| 178 |
|
---|
| 179 | tf += fromfpu(pt->iptim);
|
---|
| 180 | ++pt;
|
---|
| 181 | ++pn;
|
---|
| 182 | }
|
---|
| 183 |
|
---|
| 184 | return(tf);
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | /* |
---|
| 188 |
|
---|
| 189 | */
|
---|
| 190 |
|
---|
| 191 | /*
|
---|
| 192 | =============================================================================
|
---|
[0580615] | 193 | pntsel() -- setup editing limits for subj in the current function
|
---|
[f40a309] | 194 | =============================================================================
|
---|
| 195 | */
|
---|
| 196 |
|
---|
| 197 | void pntsel(void)
|
---|
| 198 | {
|
---|
| 199 | register struct idfnhdr *fp;
|
---|
| 200 |
|
---|
| 201 | fp = &vbufs[curvce].idhfnc[curfunc];
|
---|
| 202 |
|
---|
| 203 | curpnt = fp->idfpt1 + subj;
|
---|
| 204 | pntptr = &vbufs[curvce].idhpnt[curpnt];
|
---|
| 205 |
|
---|
| 206 | npts = fp->idfpif;
|
---|
| 207 |
|
---|
| 208 | if (npts EQ 1) { /* detemine editing case */
|
---|
| 209 |
|
---|
| 210 | pecase = 0; /* single point */
|
---|
| 211 | temin = 1;
|
---|
| 212 | temax = 32767;
|
---|
| 213 |
|
---|
| 214 | } else if (subj EQ (npts - 1)) {
|
---|
| 215 |
|
---|
| 216 | pecase = 1; /* last point */
|
---|
| 217 | temin = timeto(curfunc, subj - 1);
|
---|
| 218 | temax = 32767;
|
---|
| 219 |
|
---|
| 220 | } else {
|
---|
| 221 |
|
---|
| 222 | pecase = 2; /* interior point */
|
---|
| 223 | temin = timeto(curfunc, subj - 1);
|
---|
| 224 | temax = timeto(curfunc, subj + 1);
|
---|
| 225 | }
|
---|
| 226 |
|
---|
| 227 | #if DEBUGPS
|
---|
| 228 | printf("pntsel(): curpnt=%d, subj=%d, fp=0x%08lx, pntptr=0x%08lx\r\n",
|
---|
| 229 | curpnt, subj, fp, pntptr);
|
---|
| 230 | printf("pntsel(): npts=%d, pecase=%d, temin=%d, temax=%d\r\n",
|
---|
| 231 | npts, pecase, temin, temax);
|
---|
| 232 | #endif
|
---|
| 233 | }
|
---|
| 234 |
|
---|
| 235 | /* |
---|
| 236 |
|
---|
| 237 | */
|
---|
| 238 |
|
---|
| 239 | /*
|
---|
[7258c6a] | 240 | =============================================================================
|
---|
[f40a309] | 241 | vtoy() -- convert a value to a y coordinate for display
|
---|
[7258c6a] | 242 | =============================================================================
|
---|
[f40a309] | 243 | */
|
---|
| 244 |
|
---|
| 245 | int16_t vtoy(int16_t val, int16_t window)
|
---|
| 246 | {
|
---|
| 247 | register int16_t yval;
|
---|
| 248 |
|
---|
| 249 | if (val GT 1000)
|
---|
[7258c6a] | 250 | val = 1000;
|
---|
[f40a309] | 251 |
|
---|
| 252 | yval = 56 + (((1000 - val) * 14) / 100);
|
---|
| 253 |
|
---|
| 254 | if (window < 12)
|
---|
| 255 | return((int16_t)(idbox[window][1] + (((yval - 56) * 100L) / 540L)));
|
---|
| 256 | else
|
---|
| 257 | return(yval);
|
---|
| 258 | }
|
---|
| 259 |
|
---|
| 260 | /* |
---|
| 261 |
|
---|
| 262 | */
|
---|
| 263 |
|
---|
[7258c6a] | 264 | /*
|
---|
[f40a309] | 265 | =============================================================================
|
---|
[7258c6a] | 266 | ttox() -- convert a time to an x coordinate for display
|
---|
[f40a309] | 267 | =============================================================================
|
---|
| 268 | */
|
---|
[7258c6a] | 269 |
|
---|
[f40a309] | 270 | int16_t ttox(uint16_t time, int16_t window)
|
---|
[7258c6a] | 271 | {
|
---|
[f40a309] | 272 | register int16_t xval;
|
---|
[7258c6a] | 273 |
|
---|
[f40a309] | 274 | if (time < 128) /* 0..127 */
|
---|
[7258c6a] | 275 | xval = 8 + (int16_t)(((time * 1000L) / 2309L));
|
---|
[f40a309] | 276 | else if (time < 256) /* 128..255 */
|
---|
[7258c6a] | 277 | xval = 64 + (int16_t)((((time - 128) * 1000L) / 2309L));
|
---|
[f40a309] | 278 | else if (time < 512) /* 256..511 */
|
---|
[7258c6a] | 279 | xval = 120 + (int16_t)((((time - 256) * 1000L) / 4636L));
|
---|
[f40a309] | 280 | else if (time < 1024) /* 512..1023 */
|
---|
[7258c6a] | 281 | xval = 176 + (int16_t)((((time - 512) * 1000L) / 9290L));
|
---|
[f40a309] | 282 | else if (time < 2048) /* 1024..2047 */
|
---|
[7258c6a] | 283 | xval = 232 + (int16_t)((((time - 1024) * 1000L) / 18600L));
|
---|
| 284 | else if (time < 4096) /* 2048..4095 */
|
---|
| 285 | xval = 288 + (int16_t)((((time - 2048) * 1000L) / 37218L));
|
---|
[f40a309] | 286 | else if (time < 8192) /* 4096..8191 */
|
---|
| 287 | xval = 344 + (int16_t)((((time - 4096) * 1000L)/ 74454L));
|
---|
| 288 | else if (time < 16384) /* 8192..16383 */
|
---|
| 289 | xval = 400 + (int16_t)((((time - 8192) * 1000L) / 148927L));
|
---|
| 290 | else if (time < (uint16_t)32768) /* 16384..32767 */
|
---|
| 291 | xval = 456 + (int16_t)((((time - 16384) * 1000L) / 309113L));
|
---|
| 292 | else
|
---|
[7258c6a] | 293 | xval = 509;
|
---|
[f40a309] | 294 |
|
---|
| 295 | if (xval > 509)
|
---|
| 296 | xval = 509;
|
---|
| 297 |
|
---|
| 298 | if (window < 12)
|
---|
| 299 | return((int16_t)(idbox[window][0] + (((xval - 8) * 100L) / 599L)));
|
---|
| 300 | else
|
---|
| 301 | return(xval);
|
---|
| 302 | }
|
---|
| 303 |
|
---|
| 304 | /* |
---|
| 305 |
|
---|
| 306 | */
|
---|
[7258c6a] | 307 |
|
---|
[f40a309] | 308 | /*
|
---|
| 309 | =============================================================================
|
---|
| 310 | selpnt() -- select a point for editing
|
---|
[7258c6a] | 311 | =============================================================================
|
---|
[f40a309] | 312 | */
|
---|
[7258c6a] | 313 |
|
---|
[f40a309] | 314 | int16_t selpnt(void)
|
---|
| 315 | {
|
---|
| 316 | register struct idfnhdr *fp;
|
---|
| 317 |
|
---|
| 318 | register int16_t i, xv, np;
|
---|
| 319 |
|
---|
| 320 | int16_t lo_x, lo_x_pt, hi_x, hi_x_pt;
|
---|
| 321 |
|
---|
| 322 | fp = &vbufs[curvce].idhfnc[curfunc];
|
---|
| 323 | np = fp->idfpif;
|
---|
| 324 | lo_x_pt = 0;
|
---|
| 325 | lo_x = ttox(timeto(curfunc, lo_x_pt), 12);
|
---|
| 326 | hi_x_pt = np - 1;
|
---|
| 327 | hi_x = ttox(timeto(curfunc, hi_x_pt), 12);
|
---|
| 328 |
|
---|
| 329 | for (i = 0; i < np; i++) {
|
---|
| 330 |
|
---|
| 331 | xv = ttox(timeto(curfunc, i), 12);
|
---|
| 332 |
|
---|
| 333 | if (xv LE cxval) /* largest x LE cxval */
|
---|
| 334 | if (xv GE lo_x) {
|
---|
| 335 |
|
---|
| 336 | lo_x = xv;
|
---|
| 337 | lo_x_pt = i;
|
---|
| 338 | }
|
---|
| 339 |
|
---|
| 340 | if (xv GE cxval) /* smallest x GE cxval*/
|
---|
| 341 | if (xv LT hi_x) {
|
---|
| 342 |
|
---|
| 343 | hi_x = xv;
|
---|
| 344 | hi_x_pt = i;
|
---|
| 345 | }
|
---|
| 346 | }
|
---|
| 347 |
|
---|
| 348 | if (lo_x EQ hi_x)
|
---|
| 349 | return(lo_x_pt);
|
---|
| 350 |
|
---|
| 351 | if ((cxval - lo_x) LT (hi_x - cxval))
|
---|
| 352 | return(lo_x_pt);
|
---|
| 353 | else
|
---|
| 354 | return(hi_x_pt);
|
---|
| 355 | }
|
---|
| 356 |
|
---|
| 357 | /* |
---|
| 358 |
|
---|
[0580615] | 359 | */
|
---|
[f40a309] | 360 |
|
---|
| 361 | /*
|
---|
| 362 | =============================================================================
|
---|
| 363 | setinst() -- setup for editing a new instrument
|
---|
| 364 | =============================================================================
|
---|
| 365 | */
|
---|
| 366 |
|
---|
| 367 | void setinst(void)
|
---|
| 368 | {
|
---|
| 369 | register struct instdef *ip;
|
---|
| 370 | register struct idfnhdr *fp;
|
---|
| 371 |
|
---|
| 372 | curfunc = 12; /* current function = 12 = level */
|
---|
| 373 | subj = 0; /* current edited point = 0 (first point) */
|
---|
| 374 | pntsv = 0; /* point selection state = unselected */
|
---|
| 375 | pecase = 0; /* point selection case = 0 (first point) */
|
---|
| 376 |
|
---|
| 377 | ip = &vbufs[curvce]; /* instrument definition pointer */
|
---|
| 378 | fp = &ip->idhfnc[curfunc]; /* function pointer */
|
---|
| 379 |
|
---|
| 380 | curpnt = subj + fp->idfpt1; /* current point in function */
|
---|
| 381 | pntptr = &ip->idhpnt[curpnt]; /* current point pointer */
|
---|
| 382 |
|
---|
| 383 | newws(); /* setup waveshape variables */
|
---|
| 384 | }
|
---|
| 385 |
|
---|
| 386 | /* |
---|
[7258c6a] | 387 |
|
---|
[f40a309] | 388 | */
|
---|
| 389 |
|
---|
| 390 | /*
|
---|
| 391 | =============================================================================
|
---|
| 392 | newinst() -- select a new instrument
|
---|
| 393 | =============================================================================
|
---|
| 394 | */
|
---|
| 395 |
|
---|
| 396 | void newinst(int16_t inst)
|
---|
| 397 | {
|
---|
| 398 | curinst = inst;
|
---|
| 399 | s_inst[curvce] = inst;
|
---|
[7258c6a] | 400 | setinst();
|
---|
[f40a309] | 401 | }
|
---|
| 402 |
|
---|
| 403 | /*
|
---|
| 404 | =============================================================================
|
---|
| 405 | newvce() -- select a new voice
|
---|
| 406 | =============================================================================
|
---|
| 407 | */
|
---|
| 408 |
|
---|
| 409 | void newvce(int16_t voice)
|
---|
| 410 | {
|
---|
| 411 | curvce = voice;
|
---|
| 412 | curinst = s_inst[curvce];
|
---|
| 413 | setinst();
|
---|
| 414 | }
|
---|
| 415 |
|
---|
[7258c6a] | 416 | /* |
---|
[f40a309] | 417 |
|
---|
[7258c6a] | 418 | */
|
---|
[f40a309] | 419 |
|
---|
| 420 | /*
|
---|
| 421 | =============================================================================
|
---|
| 422 | setivce() -- set instrument definition for a voice
|
---|
| 423 | =============================================================================
|
---|
| 424 | */
|
---|
| 425 |
|
---|
| 426 | void setivce(int16_t voice)
|
---|
| 427 | {
|
---|
| 428 | register int16_t i, j, k, oldi;
|
---|
| 429 | register struct instdef *ip;
|
---|
| 430 |
|
---|
| 431 | ip = &vbufs[voice];
|
---|
| 432 |
|
---|
| 433 | oldi = setipl(FPU_DI); /* disable FPU interrupts */
|
---|
| 434 |
|
---|
| 435 | /* +++++++++++++++++++++++ FPU interrupts disabled ++++++++++++++++++++++++++ */
|
---|
| 436 |
|
---|
| 437 | for (j = 0; j < NFINST; j++) { /* set funcndx[] entries */
|
---|
| 438 |
|
---|
| 439 | k = (voice << 4) + fnoff[j];
|
---|
| 440 | funcndx[k][0] = &ip->idhfnc[j];
|
---|
| 441 | funcndx[k][1] = ip->idhpnt;
|
---|
| 442 | }
|
---|
| 443 |
|
---|
| 444 | /* set waveshapes */
|
---|
| 445 |
|
---|
| 446 | memcpyw((io_fpu + FPU_OWST + (voice << 9) + 0x0100 + 1),
|
---|
| 447 | ip->idhwvaf, NUMWPNT);
|
---|
| 448 |
|
---|
| 449 | memcpyw((io_fpu + FPU_OWST + (voice << 9) + 1),
|
---|
| 450 | ip->idhwvbf, NUMWPNT);
|
---|
| 451 |
|
---|
| 452 | setipl(oldi); /* restore interrupts */
|
---|
| 453 |
|
---|
| 454 | /* ++++++++++++++++++++++++++ Interrupts restored +++++++++++++++++++++++++++ */
|
---|
| 455 |
|
---|
| 456 | instmod[voice] = FALSE; /* instrument matches library */
|
---|
| 457 | }
|
---|
[0580615] | 458 |
|
---|
[f40a309] | 459 | /* |
---|
[7258c6a] | 460 |
|
---|
[f40a309] | 461 | */
|
---|
| 462 |
|
---|
| 463 | /*
|
---|
| 464 | =============================================================================
|
---|
| 465 | modinst() -- handle instrument modifications
|
---|
| 466 | =============================================================================
|
---|
| 467 | */
|
---|
| 468 |
|
---|
| 469 | void modinst(void)
|
---|
| 470 | {
|
---|
| 471 | int16_t f, i, grp, oldi;
|
---|
| 472 |
|
---|
| 473 | if (NOT instmod[curvce]) {
|
---|
| 474 |
|
---|
| 475 | instmod[curvce] = TRUE;
|
---|
| 476 | dswin(19);
|
---|
| 477 | }
|
---|
| 478 |
|
---|
| 479 | if (NOT editsw) {
|
---|
| 480 |
|
---|
| 481 | if ((grp = vce2grp[curvce]) > 0) {
|
---|
| 482 |
|
---|
| 483 | oldi = setipl(FPU_DI); /* +++++ disable FPU interrupts */
|
---|
| 484 |
|
---|
| 485 | for (i = 0; i < 12; i++) {
|
---|
| 486 |
|
---|
| 487 | if (vce2grp[i] EQ grp) {
|
---|
| 488 |
|
---|
| 489 | memcpyw(&vbufs[i], &vbufs[curvce],
|
---|
| 490 | sizeof (struct instdef) / 2);
|
---|
| 491 |
|
---|
| 492 | for (f = 0; f < 12; f++)
|
---|
| 493 | vbufs[i].idhfnc[f].idftmd
|
---|
| 494 | &= ~I_ACTIVE;
|
---|
| 495 |
|
---|
| 496 | s_inst[i] = curinst;
|
---|
| 497 | clrvce(i);
|
---|
| 498 | setivce(i);
|
---|
| 499 | dosync(i);
|
---|
| 500 | execkey(0, 0, i, 1);
|
---|
| 501 | vce2trg[i] = -1;
|
---|
| 502 | }
|
---|
| 503 | }
|
---|
| 504 |
|
---|
| 505 | setipl(oldi); /* +++++ enable FPU interrupts */
|
---|
| 506 | }
|
---|
| 507 | }
|
---|
[0580615] | 508 | }
|
---|
[f40a309] | 509 |
|
---|
[7258c6a] | 510 | /* |
---|
[f40a309] | 511 |
|
---|
| 512 | */
|
---|
| 513 |
|
---|
| 514 | /*
|
---|
| 515 | =============================================================================
|
---|
| 516 | initi() -- initialize an instrument definition
|
---|
| 517 | =============================================================================
|
---|
| 518 | */
|
---|
| 519 |
|
---|
| 520 | void initi(struct instdef *ip)
|
---|
| 521 | {
|
---|
| 522 | register int16_t i, mintfpu, rb;
|
---|
| 523 |
|
---|
| 524 | memsetw(ip, 0, sizeof (struct instdef) / 2);
|
---|
| 525 |
|
---|
| 526 | memcpy(ip->idhname, " ", MAXIDLN+1);
|
---|
| 527 | memcpy(ip->idhcom1, " ", MAXIDLN+1);
|
---|
| 528 | memcpy(ip->idhcom2, " ", MAXIDLN+1);
|
---|
| 529 | memcpy(ip->idhcom3, " ", MAXIDLN+1);
|
---|
| 530 |
|
---|
| 531 | ip->idhplft = NIPNTS - NFINST;
|
---|
| 532 | ip->idhcfg = (initcfg >> 8) & 0x00FF;
|
---|
| 533 | mintfpu = tofpu(1);
|
---|
| 534 |
|
---|
| 535 | for (i = 0; i < NFINST; i++) { /* for each function ... */
|
---|
| 536 |
|
---|
| 537 | /* initialize the function header */
|
---|
| 538 |
|
---|
| 539 | rb = ((i < 4) AND (i NE 0)) ? 0 : I_NRATIO;
|
---|
| 540 | ip->idhfnc[i].idfpif = 1;
|
---|
| 541 | ip->idhfnc[i].idfpt1 = i;
|
---|
| 542 | ip->idhfnc[i].idftmd = (I_TM_KEY | 0x0010) | rb;
|
---|
| 543 |
|
---|
| 544 | /* initialize the first point in the function */
|
---|
| 545 |
|
---|
| 546 | ip->idhpnt[i].iptim = mintfpu;
|
---|
| 547 | ip->idhpnt[i].ipval = finival[i];
|
---|
| 548 | }
|
---|
| 549 |
|
---|
| 550 | for (i = 0; i < NUMWPNT; i++) {
|
---|
| 551 |
|
---|
| 552 | ip->idhwvaf[i] = (ip->idhwvao[i] = 0x8000 ^ ((i + 1) << 8));
|
---|
| 553 | ip->idhwvbf[i] = (ip->idhwvbo[i] = 0x8000 ^ ((i + 1) << 8));
|
---|
[0580615] | 554 | }
|
---|
[f40a309] | 555 | }
|
---|
[7258c6a] | 556 |
|
---|
[f40a309] | 557 | /* |
---|
| 558 |
|
---|
| 559 | */
|
---|
| 560 |
|
---|
| 561 | /*
|
---|
| 562 | =============================================================================
|
---|
| 563 | initil() -- initialize instrument library
|
---|
| 564 | =============================================================================
|
---|
| 565 | */
|
---|
| 566 |
|
---|
| 567 | void initil(void)
|
---|
| 568 | {
|
---|
| 569 | register int16_t i;
|
---|
| 570 |
|
---|
| 571 | setipl(FPU_DI); /* disable FPU interrupts */
|
---|
| 572 |
|
---|
| 573 | /* +++++++++++++++++++++++ FPU interrupts disabled ++++++++++++++++++++++++++ */
|
---|
| 574 |
|
---|
| 575 | fpuclr(); /* clear the FPU */
|
---|
| 576 |
|
---|
| 577 | memcpyw(&idefs[0], dfltins, sizeof (struct instdef) / 2);
|
---|
| 578 |
|
---|
| 579 | for (i = 1; i < NINST; i++) /* initialize each instrument */
|
---|
| 580 | initi(&idefs[i]);
|
---|
| 581 |
|
---|
| 582 | memset(funcndx, 0, sizeof funcndx);
|
---|
| 583 |
|
---|
| 584 | for (i = 0; i < 12; i++) { /* initialize voices */
|
---|
| 585 |
|
---|
| 586 | memcpyw(&vbufs[i], &idefs[0], sizeof (struct instdef) / 2);
|
---|
| 587 | setivce(i);
|
---|
| 588 | }
|
---|
| 589 |
|
---|
| 590 | setipl(FPU_EI); /* enable FPU interrupts */
|
---|
| 591 |
|
---|
| 592 | /* ++++++++++++++++++++++++++ Interrupts enabled ++++++++++++++++++++++++++++ */
|
---|
| 593 |
|
---|
| 594 | newvce(0); /* setup editing for instrument 0, voice 0 */
|
---|
| 595 | newinst(0);
|
---|
| 596 | }
|
---|
| 597 |
|
---|