[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 |
|
---|
| 8 | #include "m7ver.h"
|
---|
| 9 | #include "stddefs.h"
|
---|
| 10 | #include "biosdefs.h"
|
---|
| 11 | #include "graphdef.h"
|
---|
| 12 | #include "vsdd.h"
|
---|
| 13 | #include "vsddsw.h"
|
---|
| 14 | #include "vsddvars.h"
|
---|
| 15 | #include "hwdefs.h"
|
---|
| 16 | #include "memory.h"
|
---|
| 17 | #include "fpu.h"
|
---|
| 18 | #include "panel.h"
|
---|
| 19 |
|
---|
| 20 | #include "midas.h"
|
---|
| 21 | #include "instdsp.h"
|
---|
| 22 | #include "score.h"
|
---|
| 23 | #include "scdsp.h"
|
---|
| 24 | #include "scfns.h"
|
---|
| 25 | #include "wsdsp.h"
|
---|
| 26 |
|
---|
| 27 | /* functions defined elsewhere */
|
---|
| 28 |
|
---|
[7258c6a] | 29 | extern uint16_t tofpu(uint16_t time);
|
---|
[f40a309] | 30 |
|
---|
[7258c6a] | 31 | extern uint16_t setipl(uint16_t arg);
|
---|
[f40a309] | 32 |
|
---|
[7258c6a] | 33 | extern int16_t amplval, ext_cv1, ext_cv2, ext_cv3, ext_cv4, ext_mod;
|
---|
| 34 | extern int16_t lstbgnc, lstendc, ps_intn, ps_rate, ps_dpth, sliders;
|
---|
[f40a309] | 35 |
|
---|
[7258c6a] | 36 | extern int16_t lastart[];
|
---|
| 37 | extern int16_t dyntab[];
|
---|
| 38 | extern int16_t expbit[];
|
---|
| 39 | extern int16_t fnoff[];
|
---|
| 40 | extern int16_t fp_resv[];
|
---|
| 41 | extern int16_t grpdyn[];
|
---|
| 42 | extern int16_t grploc[];
|
---|
| 43 | extern int16_t lastvce[];
|
---|
| 44 | extern int16_t prstab[];
|
---|
| 45 | extern int16_t vce2grp[];
|
---|
| 46 | extern int16_t vce2trg[];
|
---|
| 47 | extern int16_t veltab[];
|
---|
[f40a309] | 48 |
|
---|
[7258c6a] | 49 | extern int16_t sigtab[128][2];
|
---|
[f40a309] | 50 |
|
---|
[7258c6a] | 51 | extern int8_t keystat[];
|
---|
| 52 | extern int8_t mpsust[];
|
---|
| 53 | extern int8_t trgtab[];
|
---|
[f40a309] | 54 |
|
---|
| 55 | extern struct n_entry *lstbgns[NLSTENTS];
|
---|
| 56 | extern struct n_entry *lstends[NLSTENTS];
|
---|
| 57 |
|
---|
| 58 | /* |
---|
| 59 |
|
---|
| 60 | */
|
---|
| 61 |
|
---|
| 62 | /*
|
---|
| 63 | =============================================================================
|
---|
| 64 | sendval() -- send a value to a voice parameter
|
---|
| 65 | =============================================================================
|
---|
| 66 | */
|
---|
[7258c6a] | 67 |
|
---|
[f40a309] | 68 | void sendval(int16_t voice, int16_t par, int16_t ival)
|
---|
[7258c6a] | 69 | {
|
---|
| 70 | register uint16_t *fpu;
|
---|
| 71 | register int16_t oldi, val;
|
---|
| 72 | register int32_t ltmp;
|
---|
[f40a309] | 73 | int16_t nop;
|
---|
| 74 |
|
---|
| 75 | fpu = io_fpu + FPU_OFNC + (voice << 8) + (par << 4);
|
---|
| 76 |
|
---|
| 77 | switch (par) {
|
---|
| 78 |
|
---|
| 79 | case 1: /* freq 1 */
|
---|
| 80 | case 3: /* freq 2 */
|
---|
| 81 | case 5: /* freq 3 */
|
---|
| 82 | case 7: /* freq 4 */
|
---|
| 83 |
|
---|
| 84 | val = addpch(ival, 0);
|
---|
| 85 | break;
|
---|
| 86 |
|
---|
| 87 | case 4: /* location */
|
---|
| 88 |
|
---|
| 89 | val = (ival << 1) ^ 0x8000;
|
---|
| 90 | break;
|
---|
| 91 |
|
---|
| 92 | case 10: /* filter */
|
---|
[7258c6a] | 93 |
|
---|
[f40a309] | 94 | ltmp = ((int32_t)ival >> 1) + ((int32_t)ival >>2);
|
---|
[7258c6a] | 95 |
|
---|
| 96 | if (ltmp GT (int32_t)VALMAX)
|
---|
| 97 | ltmp = (int32_t)VALMAX;
|
---|
| 98 | else if (ltmp LT (int32_t)VALMIN)
|
---|
[f40a309] | 99 | ltmp = (int32_t)VALMIN;
|
---|
[7258c6a] | 100 |
|
---|
[f40a309] | 101 | val = (int16_t)ltmp;
|
---|
| 102 | break;
|
---|
| 103 | /* |
---|
| 104 |
|
---|
| 105 | */
|
---|
[7258c6a] | 106 | case 2: /* level */
|
---|
[f40a309] | 107 |
|
---|
| 108 | val = (((int16_t)ival >> 5) - 500) << 6;
|
---|
| 109 | break;
|
---|
| 110 |
|
---|
| 111 | default:
|
---|
| 112 |
|
---|
| 113 | val = ival;
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | oldi = setipl(FPU_DI);
|
---|
| 117 |
|
---|
[7258c6a] | 118 | /* ++++++++++++++++++++++++++++ FPU interrupts disabled +++++++++++++++++++++ */
|
---|
[f40a309] | 119 |
|
---|
[7258c6a] | 120 | *(fpu + (int32_t)FPU_TNV0) = val;
|
---|
[f40a309] | 121 | ++nop; ++nop; ++nop;
|
---|
[7258c6a] | 122 | *(fpu + (int32_t)FPU_TNV1) = val;
|
---|
[f40a309] | 123 | ++nop; ++nop; ++nop;
|
---|
| 124 | *(fpu + (int32_t)FPU_TCTL) = 0x0015;
|
---|
| 125 |
|
---|
| 126 | setipl(oldi);
|
---|
| 127 |
|
---|
| 128 | /* ++++++++++++++++++++++++++++ Interrupts restored +++++++++++++++++++++++++ */
|
---|
| 129 |
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | /* |
---|
| 133 |
|
---|
| 134 | */
|
---|
| 135 |
|
---|
| 136 | /*
|
---|
| 137 | =============================================================================
|
---|
| 138 | clearer() -- clear the FPU
|
---|
[7258c6a] | 139 | =============================================================================
|
---|
[f40a309] | 140 | */
|
---|
[7258c6a] | 141 |
|
---|
| 142 | void clearer(int16_t stat, int16_t sig)
|
---|
| 143 | {
|
---|
| 144 | register uint16_t *fpu;
|
---|
[f40a309] | 145 | register uint16_t fpexp, fpmant, fptime;
|
---|
| 146 | register int16_t oldi, i;
|
---|
| 147 | int16_t nop, olds;
|
---|
| 148 |
|
---|
| 149 | if (stat) {
|
---|
| 150 |
|
---|
| 151 | fp_resv[0] = 0x8300; /* amplitude (off) */
|
---|
| 152 | fp_resv[1] = (ps_intn * 10) << 5; /* intensity */
|
---|
| 153 | fp_resv[2] = (ps_rate * 10) << 5; /* sweep rate */
|
---|
| 154 | fp_resv[3] = (ps_dpth * 10) << 5; /* sweep depth */
|
---|
| 155 | fp_resv[4] = 0; /* - unused - */
|
---|
| 156 | fp_resv[5] = 0; /* - unused - */
|
---|
| 157 | fp_resv[6] = ext_cv3; /* CV-3 */
|
---|
| 158 | fp_resv[7] = 0; /* - unused - */
|
---|
| 159 | fp_resv[8] = ext_cv4; /* CV-4 */
|
---|
| 160 | fp_resv[9] = ext_mod; /* Aux Signal Mod */
|
---|
| 161 | fp_resv[10] = ext_cv2; /* CV-2 */
|
---|
| 162 | fp_resv[11] = ext_cv1; /* CV-1 */
|
---|
| 163 |
|
---|
| 164 | fpu = io_fpu + FPU_OFNC; /* setup to set slew rate */
|
---|
| 165 | fptime = tofpu(AMP_TIME);
|
---|
| 166 | fpexp = expbit[fptime & 0x000F];
|
---|
| 167 | fpmant = fptime & 0xFFF0;
|
---|
| 168 | /* |
---|
| 169 |
|
---|
| 170 | */
|
---|
| 171 | oldi = setipl(FPU_DI); /* disable FPU interrupts */
|
---|
| 172 |
|
---|
| 173 | /* ++++++++++++++++++++++++++++ FPU interrupts disabled +++++++++++++++++++++ */
|
---|
| 174 |
|
---|
| 175 | fpuclr(); /* reset the FPU to nominal */
|
---|
| 176 |
|
---|
| 177 | *(fpu + FPU_TMNT) = fpmant; /* set amplitude slew rate */
|
---|
| 178 | ++nop; ++nop;
|
---|
| 179 | *(fpu + FPU_TEXP) = fpexp;
|
---|
| 180 |
|
---|
| 181 | /* reset execution control tables */
|
---|
| 182 |
|
---|
| 183 | memset(trgtab, 0, NTRIGS); /* trigger table */
|
---|
| 184 | memset(keystat, 0, 24); /* local key status */
|
---|
| 185 |
|
---|
| 186 | memsetw(prstab, 0, NTRIGS); /* pressure table */
|
---|
| 187 | memsetw(veltab, SM_SCALE(64), NTRIGS); /* velocity table */
|
---|
| 188 |
|
---|
| 189 | clrpfl(); /* clear pendant functions */
|
---|
| 190 |
|
---|
| 191 | for (i = 0; i < 48; i++) /* sustain pedal table */
|
---|
| 192 | mpsust[i] = 0;
|
---|
| 193 |
|
---|
| 194 | for (i = 0; i < 12; i++) {
|
---|
| 195 |
|
---|
| 196 | vce2trg[i] = -1; /* voice to trigger table */
|
---|
| 197 | lastvce[i] = 0; /* last voice used table */
|
---|
| 198 | }
|
---|
| 199 |
|
---|
| 200 | olds = sliders; /* reset articulation pots */
|
---|
| 201 | sliders = LS_PRMTR;
|
---|
| 202 | l_init(1, 0);
|
---|
| 203 | sliders = LS_OTHER;
|
---|
| 204 | l_init(1, 0);
|
---|
| 205 | sliders = olds;
|
---|
| 206 |
|
---|
| 207 | setipl(oldi); /* restore interrupts */
|
---|
| 208 |
|
---|
| 209 | /* ++++++++++++++++++++++++++++ Interrupts restored +++++++++++++++++++++++++ */
|
---|
| 210 |
|
---|
| 211 | /* |
---|
| 212 |
|
---|
| 213 | */
|
---|
| 214 | lstbgnc = 0; /* reset last note begin count */
|
---|
[7848656] | 215 | lstendc = 0; /* reset last note end count */
|
---|
[f40a309] | 216 |
|
---|
| 217 | memsetw(lstbgns, 0, (NLSTENTS << 1)); /* clear begin table */
|
---|
| 218 | memsetw(lstends, 0, (NLSTENTS << 1)); /* clear end table */
|
---|
| 219 |
|
---|
| 220 | /* re-establish dynamics and locations */
|
---|
| 221 |
|
---|
| 222 | for (i = 0; i < 12; i++) {
|
---|
| 223 |
|
---|
| 224 | setdyn(i, grpdyn[i]);
|
---|
| 225 | setloc(i, grploc[i]);
|
---|
| 226 | }
|
---|
| 227 |
|
---|
| 228 | settune(); /* set tuning */
|
---|
| 229 | sendval(0, 0, amplval); /* set amplitude */
|
---|
| 230 | }
|
---|
| 231 | }
|
---|