[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | sendval.c -- MIDAS-VII -- FPU output and clear functions
|
---|
| 4 | Version 4 -- 1988-09-27 -- D.N. Lynx Crowe
|
---|
| 5 | =============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[b28a12e] | 8 | #include "ram.h"
|
---|
[f40a309] | 9 |
|
---|
| 10 | /*
|
---|
| 11 | =============================================================================
|
---|
| 12 | sendval() -- send a value to a voice parameter
|
---|
| 13 | =============================================================================
|
---|
| 14 | */
|
---|
| 15 |
|
---|
[7258c6a] | 16 | void sendval(int16_t voice, int16_t par, int16_t ival)
|
---|
[f40a309] | 17 | {
|
---|
[7258c6a] | 18 | register uint16_t *fpu;
|
---|
| 19 | register int16_t oldi, val;
|
---|
| 20 | register int32_t ltmp;
|
---|
| 21 | int16_t nop;
|
---|
[f40a309] | 22 |
|
---|
| 23 | fpu = io_fpu + FPU_OFNC + (voice << 8) + (par << 4);
|
---|
| 24 |
|
---|
| 25 | switch (par) {
|
---|
| 26 |
|
---|
| 27 | case 1: /* freq 1 */
|
---|
| 28 | case 3: /* freq 2 */
|
---|
| 29 | case 5: /* freq 3 */
|
---|
| 30 | case 7: /* freq 4 */
|
---|
| 31 |
|
---|
| 32 | val = addpch(ival, 0);
|
---|
| 33 | break;
|
---|
| 34 |
|
---|
| 35 | case 4: /* location */
|
---|
| 36 |
|
---|
| 37 | val = (ival << 1) ^ 0x8000;
|
---|
| 38 | break;
|
---|
| 39 |
|
---|
| 40 | case 10: /* filter */
|
---|
| 41 |
|
---|
[7258c6a] | 42 | ltmp = ((int32_t)ival >> 1) + ((int32_t)ival >>2);
|
---|
[f40a309] | 43 |
|
---|
[7258c6a] | 44 | if (ltmp GT (int32_t)VALMAX)
|
---|
| 45 | ltmp = (int32_t)VALMAX;
|
---|
| 46 | else if (ltmp LT (int32_t)VALMIN)
|
---|
| 47 | ltmp = (int32_t)VALMIN;
|
---|
[f40a309] | 48 |
|
---|
[7258c6a] | 49 | val = (int16_t)ltmp;
|
---|
[f40a309] | 50 | break;
|
---|
[fa38804] | 51 |
|
---|
[f40a309] | 52 | case 2: /* level */
|
---|
| 53 |
|
---|
[7258c6a] | 54 | val = (((int16_t)ival >> 5) - 500) << 6;
|
---|
[f40a309] | 55 | break;
|
---|
| 56 |
|
---|
| 57 | default:
|
---|
| 58 |
|
---|
| 59 | val = ival;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | oldi = setipl(FPU_DI);
|
---|
| 63 |
|
---|
| 64 | /* ++++++++++++++++++++++++++++ FPU interrupts disabled +++++++++++++++++++++ */
|
---|
| 65 |
|
---|
[7258c6a] | 66 | *(fpu + (int32_t)FPU_TNV0) = val;
|
---|
[f40a309] | 67 | ++nop; ++nop; ++nop;
|
---|
[7258c6a] | 68 | *(fpu + (int32_t)FPU_TNV1) = val;
|
---|
[f40a309] | 69 | ++nop; ++nop; ++nop;
|
---|
[7258c6a] | 70 | *(fpu + (int32_t)FPU_TCTL) = 0x0015;
|
---|
[f40a309] | 71 |
|
---|
| 72 | setipl(oldi);
|
---|
| 73 |
|
---|
| 74 | /* ++++++++++++++++++++++++++++ Interrupts restored +++++++++++++++++++++++++ */
|
---|
| 75 |
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | /*
|
---|
| 79 | =============================================================================
|
---|
| 80 | clearer() -- clear the FPU
|
---|
| 81 | =============================================================================
|
---|
| 82 | */
|
---|
| 83 |
|
---|
[7ecfb7b] | 84 | void clearer(int16_t stat)
|
---|
[f40a309] | 85 | {
|
---|
[7258c6a] | 86 | register uint16_t *fpu;
|
---|
| 87 | register uint16_t fpexp, fpmant, fptime;
|
---|
| 88 | register int16_t oldi, i;
|
---|
| 89 | int16_t nop, olds;
|
---|
[f40a309] | 90 |
|
---|
| 91 | if (stat) {
|
---|
| 92 |
|
---|
| 93 | fp_resv[0] = 0x8300; /* amplitude (off) */
|
---|
| 94 | fp_resv[1] = (ps_intn * 10) << 5; /* intensity */
|
---|
| 95 | fp_resv[2] = (ps_rate * 10) << 5; /* sweep rate */
|
---|
| 96 | fp_resv[3] = (ps_dpth * 10) << 5; /* sweep depth */
|
---|
| 97 | fp_resv[4] = 0; /* - unused - */
|
---|
| 98 | fp_resv[5] = 0; /* - unused - */
|
---|
| 99 | fp_resv[6] = ext_cv3; /* CV-3 */
|
---|
| 100 | fp_resv[7] = 0; /* - unused - */
|
---|
| 101 | fp_resv[8] = ext_cv4; /* CV-4 */
|
---|
| 102 | fp_resv[9] = ext_mod; /* Aux Signal Mod */
|
---|
| 103 | fp_resv[10] = ext_cv2; /* CV-2 */
|
---|
| 104 | fp_resv[11] = ext_cv1; /* CV-1 */
|
---|
| 105 |
|
---|
| 106 | fpu = io_fpu + FPU_OFNC; /* setup to set slew rate */
|
---|
| 107 | fptime = tofpu(AMP_TIME);
|
---|
| 108 | fpexp = expbit[fptime & 0x000F];
|
---|
| 109 | fpmant = fptime & 0xFFF0;
|
---|
[fa38804] | 110 |
|
---|
[f40a309] | 111 | oldi = setipl(FPU_DI); /* disable FPU interrupts */
|
---|
| 112 |
|
---|
| 113 | /* ++++++++++++++++++++++++++++ FPU interrupts disabled +++++++++++++++++++++ */
|
---|
| 114 |
|
---|
| 115 | fpuclr(); /* reset the FPU to nominal */
|
---|
| 116 |
|
---|
| 117 | *(fpu + FPU_TMNT) = fpmant; /* set amplitude slew rate */
|
---|
| 118 | ++nop; ++nop;
|
---|
| 119 | *(fpu + FPU_TEXP) = fpexp;
|
---|
| 120 |
|
---|
| 121 | /* reset execution control tables */
|
---|
| 122 |
|
---|
| 123 | memset(trgtab, 0, NTRIGS); /* trigger table */
|
---|
| 124 | memset(keystat, 0, 24); /* local key status */
|
---|
| 125 |
|
---|
| 126 | memsetw(prstab, 0, NTRIGS); /* pressure table */
|
---|
| 127 | memsetw(veltab, SM_SCALE(64), NTRIGS); /* velocity table */
|
---|
| 128 |
|
---|
| 129 | clrpfl(); /* clear pendant functions */
|
---|
| 130 |
|
---|
| 131 | for (i = 0; i < 48; i++) /* sustain pedal table */
|
---|
| 132 | mpsust[i] = 0;
|
---|
| 133 |
|
---|
| 134 | for (i = 0; i < 12; i++) {
|
---|
| 135 |
|
---|
| 136 | vce2trg[i] = -1; /* voice to trigger table */
|
---|
| 137 | lastvce[i] = 0; /* last voice used table */
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | olds = sliders; /* reset articulation pots */
|
---|
| 141 | sliders = LS_PRMTR;
|
---|
| 142 | l_init(1, 0);
|
---|
| 143 | sliders = LS_OTHER;
|
---|
| 144 | l_init(1, 0);
|
---|
| 145 | sliders = olds;
|
---|
| 146 |
|
---|
| 147 | setipl(oldi); /* restore interrupts */
|
---|
| 148 |
|
---|
| 149 | /* ++++++++++++++++++++++++++++ Interrupts restored +++++++++++++++++++++++++ */
|
---|
| 150 |
|
---|
[fa38804] | 151 |
|
---|
[f40a309] | 152 | lstbgnc = 0; /* reset last note begin count */
|
---|
| 153 | lstendc = 0; /* reset last note end count */
|
---|
| 154 |
|
---|
| 155 | memsetw(lstbgns, 0, (NLSTENTS << 1)); /* clear begin table */
|
---|
| 156 | memsetw(lstends, 0, (NLSTENTS << 1)); /* clear end table */
|
---|
| 157 |
|
---|
[7848656] | 158 | /* re-establish dynamics and locations */
|
---|
[f40a309] | 159 |
|
---|
| 160 | for (i = 0; i < 12; i++) {
|
---|
| 161 |
|
---|
| 162 | setdyn(i, grpdyn[i]);
|
---|
| 163 | setloc(i, grploc[i]);
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 | settune(); /* set tuning */
|
---|
| 167 | sendval(0, 0, amplval); /* set amplitude */
|
---|
| 168 | }
|
---|
| 169 | }
|
---|
[6262b5c] | 170 |
|
---|