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