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