[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;
|
---|
| 51 | /* |
---|
| 52 |
|
---|
| 53 | */
|
---|
| 54 | case 2: /* level */
|
---|
[7258c6a] | 55 |
|
---|
[f40a309] | 56 | val = (((int16_t)ival >> 5) - 500) << 6;
|
---|
| 57 | break;
|
---|
| 58 |
|
---|
| 59 | default:
|
---|
| 60 |
|
---|
| 61 | val = ival;
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | oldi = setipl(FPU_DI);
|
---|
| 65 |
|
---|
| 66 | /* ++++++++++++++++++++++++++++ FPU interrupts disabled +++++++++++++++++++++ */
|
---|
[7258c6a] | 67 |
|
---|
[f40a309] | 68 | *(fpu + (int32_t)FPU_TNV0) = val;
|
---|
[7258c6a] | 69 | ++nop; ++nop; ++nop;
|
---|
[f40a309] | 70 | *(fpu + (int32_t)FPU_TNV1) = val;
|
---|
[7258c6a] | 71 | ++nop; ++nop; ++nop;
|
---|
[f40a309] | 72 | *(fpu + (int32_t)FPU_TCTL) = 0x0015;
|
---|
| 73 |
|
---|
| 74 | setipl(oldi);
|
---|
| 75 |
|
---|
| 76 | /* ++++++++++++++++++++++++++++ Interrupts restored +++++++++++++++++++++++++ */
|
---|
| 77 |
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | /* |
---|
| 81 |
|
---|
| 82 | */
|
---|
| 83 |
|
---|
| 84 | /*
|
---|
| 85 | =============================================================================
|
---|
| 86 | clearer() -- clear the FPU
|
---|
| 87 | =============================================================================
|
---|
[7258c6a] | 88 | */
|
---|
[f40a309] | 89 |
|
---|
[7258c6a] | 90 | void clearer(int16_t stat, int16_t sig)
|
---|
| 91 | {
|
---|
| 92 | register uint16_t *fpu;
|
---|
| 93 | register uint16_t fpexp, fpmant, fptime;
|
---|
[f40a309] | 94 | register int16_t oldi, i;
|
---|
| 95 | int16_t nop, olds;
|
---|
| 96 |
|
---|
| 97 | if (stat) {
|
---|
| 98 |
|
---|
| 99 | fp_resv[0] = 0x8300; /* amplitude (off) */
|
---|
| 100 | fp_resv[1] = (ps_intn * 10) << 5; /* intensity */
|
---|
| 101 | fp_resv[2] = (ps_rate * 10) << 5; /* sweep rate */
|
---|
| 102 | fp_resv[3] = (ps_dpth * 10) << 5; /* sweep depth */
|
---|
| 103 | fp_resv[4] = 0; /* - unused - */
|
---|
| 104 | fp_resv[5] = 0; /* - unused - */
|
---|
| 105 | fp_resv[6] = ext_cv3; /* CV-3 */
|
---|
| 106 | fp_resv[7] = 0; /* - unused - */
|
---|
| 107 | fp_resv[8] = ext_cv4; /* CV-4 */
|
---|
| 108 | fp_resv[9] = ext_mod; /* Aux Signal Mod */
|
---|
| 109 | fp_resv[10] = ext_cv2; /* CV-2 */
|
---|
| 110 | fp_resv[11] = ext_cv1; /* CV-1 */
|
---|
| 111 |
|
---|
| 112 | fpu = io_fpu + FPU_OFNC; /* setup to set slew rate */
|
---|
| 113 | fptime = tofpu(AMP_TIME);
|
---|
| 114 | fpexp = expbit[fptime & 0x000F];
|
---|
| 115 | fpmant = fptime & 0xFFF0;
|
---|
| 116 | /* |
---|
| 117 |
|
---|
| 118 | */
|
---|
| 119 | oldi = setipl(FPU_DI); /* disable FPU interrupts */
|
---|
| 120 |
|
---|
| 121 | /* ++++++++++++++++++++++++++++ FPU interrupts disabled +++++++++++++++++++++ */
|
---|
| 122 |
|
---|
| 123 | fpuclr(); /* reset the FPU to nominal */
|
---|
| 124 |
|
---|
| 125 | *(fpu + FPU_TMNT) = fpmant; /* set amplitude slew rate */
|
---|
| 126 | ++nop; ++nop;
|
---|
| 127 | *(fpu + FPU_TEXP) = fpexp;
|
---|
| 128 |
|
---|
| 129 | /* reset execution control tables */
|
---|
| 130 |
|
---|
| 131 | memset(trgtab, 0, NTRIGS); /* trigger table */
|
---|
| 132 | memset(keystat, 0, 24); /* local key status */
|
---|
| 133 |
|
---|
| 134 | memsetw(prstab, 0, NTRIGS); /* pressure table */
|
---|
| 135 | memsetw(veltab, SM_SCALE(64), NTRIGS); /* velocity table */
|
---|
| 136 |
|
---|
| 137 | clrpfl(); /* clear pendant functions */
|
---|
| 138 |
|
---|
| 139 | for (i = 0; i < 48; i++) /* sustain pedal table */
|
---|
| 140 | mpsust[i] = 0;
|
---|
| 141 |
|
---|
| 142 | for (i = 0; i < 12; i++) {
|
---|
| 143 |
|
---|
| 144 | vce2trg[i] = -1; /* voice to trigger table */
|
---|
| 145 | lastvce[i] = 0; /* last voice used table */
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | olds = sliders; /* reset articulation pots */
|
---|
| 149 | sliders = LS_PRMTR;
|
---|
| 150 | l_init(1, 0);
|
---|
| 151 | sliders = LS_OTHER;
|
---|
| 152 | l_init(1, 0);
|
---|
| 153 | sliders = olds;
|
---|
| 154 |
|
---|
| 155 | setipl(oldi); /* restore interrupts */
|
---|
| 156 |
|
---|
| 157 | /* ++++++++++++++++++++++++++++ Interrupts restored +++++++++++++++++++++++++ */
|
---|
| 158 |
|
---|
| 159 | /* |
---|
| 160 |
|
---|
| 161 | */
|
---|
| 162 | lstbgnc = 0; /* reset last note begin count */
|
---|
| 163 | lstendc = 0; /* reset last note end count */
|
---|
[7848656] | 164 |
|
---|
[f40a309] | 165 | memsetw(lstbgns, 0, (NLSTENTS << 1)); /* clear begin table */
|
---|
| 166 | memsetw(lstends, 0, (NLSTENTS << 1)); /* clear end table */
|
---|
| 167 |
|
---|
| 168 | /* re-establish dynamics and locations */
|
---|
| 169 |
|
---|
| 170 | for (i = 0; i < 12; i++) {
|
---|
| 171 |
|
---|
| 172 | setdyn(i, grpdyn[i]);
|
---|
| 173 | setloc(i, grploc[i]);
|
---|
| 174 | }
|
---|
| 175 |
|
---|
[6262b5c] | 176 | settune(); /* set tuning */
|
---|
| 177 | sendval(0, 0, amplval); /* set amplitude */
|
---|
| 178 | }
|
---|
| 179 | }
|
---|
| 180 |
|
---|