[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | msl.c -- midas main scan loop
|
---|
| 4 | Version 102 -- 1989-11-14 -- D.N. Lynx Crowe
|
---|
| 5 |
|
---|
| 6 | List with pr -e4 option to expand tabs to 4 spaces instead of 8.
|
---|
| 7 | =============================================================================
|
---|
| 8 | */
|
---|
| 9 |
|
---|
| 10 | #define DEBUGIT 0 /* enable debug code */
|
---|
| 11 |
|
---|
| 12 | #define OLDTIME 0 /* use old tempo time calculations */
|
---|
| 13 |
|
---|
| 14 | #include "stddefs.h"
|
---|
| 15 | #include "biosdefs.h"
|
---|
| 16 | #include "graphdef.h"
|
---|
| 17 | #include "glcfns.h"
|
---|
| 18 | #include "glcdefs.h"
|
---|
| 19 | #include "vsdd.h"
|
---|
| 20 | #include "vsddsw.h"
|
---|
| 21 | #include "vsddvars.h"
|
---|
| 22 | #include "hwdefs.h"
|
---|
| 23 | #include "memory.h"
|
---|
| 24 | #include "cmeta.h"
|
---|
| 25 | #include "fields.h"
|
---|
| 26 | #include "fpu.h"
|
---|
| 27 | #include "macros.h"
|
---|
| 28 | #include "patch.h"
|
---|
| 29 | #include "smdefs.h"
|
---|
| 30 | #include "sclock.h"
|
---|
| 31 | #include "scwheel.h"
|
---|
| 32 | #include "slice.h"
|
---|
| 33 | #include "timers.h"
|
---|
| 34 | #include "wordq.h"
|
---|
| 35 |
|
---|
| 36 | #include "midas.h"
|
---|
| 37 | #include "instdsp.h"
|
---|
| 38 | #include "score.h"
|
---|
| 39 | #include "scdsp.h"
|
---|
| 40 | #include "scfns.h"
|
---|
| 41 | #include "wsdsp.h"
|
---|
| 42 | #include "asgdsp.h"
|
---|
| 43 |
|
---|
[e225e77] | 44 | extern int16_t newsv(int16_t grp, int16_t src, int16_t ival);
|
---|
| 45 | extern int16_t sc_trak(int32_t tval);
|
---|
| 46 | extern int16_t sc_trek(int32_t tval);
|
---|
| 47 | extern uint16_t setsr(uint16_t sr);
|
---|
| 48 | extern void asgvce(int16_t grp, int16_t port, int16_t chan, int16_t key, int16_t vel);
|
---|
| 49 | extern void chgsdb(void);
|
---|
| 50 | extern void chgsdf(void);
|
---|
| 51 | extern void chgseb(void);
|
---|
| 52 | extern void chgsef(void);
|
---|
| 53 | extern void clkset(int16_t st);
|
---|
| 54 | extern void curproc(void);
|
---|
| 55 | extern void dclkmd(void);
|
---|
| 56 | extern void doslide(void);
|
---|
| 57 | extern void dsanval(int16_t var);
|
---|
| 58 | extern void dsclk(void);
|
---|
| 59 | extern void dsmem(void);
|
---|
| 60 | extern void dsrpmod(void);
|
---|
| 61 | extern void lcd_on(void);
|
---|
| 62 | extern void localkb(int16_t sig);
|
---|
| 63 | extern void msm(void);
|
---|
| 64 | extern void procpfl(uint16_t trig);
|
---|
| 65 | extern void se_disp(struct s_entry *ep, int16_t sd, struct gdsel *gdstb[], int16_t cf);
|
---|
| 66 | extern void sendval(int16_t voice, int16_t par, int16_t ival);
|
---|
| 67 | extern void seqproc(void);
|
---|
| 68 | extern void settune(void);
|
---|
| 69 | extern void stmproc(uint16_t trg);
|
---|
| 70 | extern void wheel(void);
|
---|
| 71 |
|
---|
[f40a309] | 72 | #define LCL_PRT 3 /* 1-origin local keyboard port number */
|
---|
| 73 |
|
---|
| 74 | #if DEBUGIT
|
---|
| 75 | extern short debugsw;
|
---|
| 76 |
|
---|
| 77 | short debugms = 1;
|
---|
| 78 | #endif
|
---|
| 79 |
|
---|
| 80 | /* |
---|
| 81 |
|
---|
| 82 | */
|
---|
| 83 |
|
---|
| 84 | /* variables defined elsewhere */
|
---|
[0c834c5] | 85 |
|
---|
| 86 | extern void (*cx_key)(void);
|
---|
[7258c6a] | 87 | extern void (*cy_key)(void);
|
---|
[0c834c5] | 88 | extern void (*d_key)(int16_t k);
|
---|
| 89 | extern void (*e_key)(void);
|
---|
| 90 | extern void (*m_key)(void);
|
---|
[f40a309] | 91 | extern void (*x_key)(void);
|
---|
[60288f5] | 92 |
|
---|
[f40a309] | 93 | extern LPF (*swpt)[];
|
---|
[7258c6a] | 94 |
|
---|
| 95 | extern int16_t aflag;
|
---|
| 96 | extern int16_t amplval;
|
---|
| 97 | extern int16_t ancmsw;
|
---|
| 98 | extern int16_t angroup;
|
---|
| 99 | extern int16_t asig;
|
---|
| 100 | extern int16_t astat;
|
---|
| 101 | extern int16_t aval;
|
---|
| 102 | extern int16_t clkctl;
|
---|
| 103 | extern int16_t clkrun;
|
---|
| 104 | extern int16_t ctrsw;
|
---|
| 105 | extern int16_t cxrate;
|
---|
| 106 | extern int16_t cxval;
|
---|
| 107 | extern int16_t cyrate;
|
---|
| 108 | extern int16_t cyval;
|
---|
| 109 | extern int16_t dsp_ok;
|
---|
| 110 | extern int16_t editss;
|
---|
| 111 | extern int16_t editsw;
|
---|
| 112 | extern int16_t lampsw;
|
---|
| 113 | extern int16_t ndisp;
|
---|
| 114 | extern int16_t nxtflag;
|
---|
| 115 | extern int16_t pchsw;
|
---|
| 116 | extern int16_t recsw;
|
---|
| 117 | extern int16_t runit;
|
---|
| 118 | extern int16_t swback;
|
---|
| 119 | extern int16_t swctrl;
|
---|
| 120 | extern int16_t swdelta;
|
---|
| 121 | extern int16_t swdir;
|
---|
| 122 | extern int16_t swfiin;
|
---|
| 123 | extern int16_t swflag;
|
---|
| 124 | extern int16_t swlast;
|
---|
| 125 | extern int16_t swndx;
|
---|
| 126 | extern int16_t swstop;
|
---|
| 127 | extern int16_t swthr;
|
---|
| 128 | extern int16_t swtime;
|
---|
| 129 | extern int16_t swwait;
|
---|
| 130 | extern int16_t sd;
|
---|
| 131 | extern int16_t se;
|
---|
| 132 | extern int16_t stcrow;
|
---|
| 133 | extern int16_t stccol;
|
---|
| 134 | extern int16_t tglclk;
|
---|
| 135 | extern int16_t tglpch;
|
---|
| 136 | extern int16_t timemlt;
|
---|
| 137 | extern int16_t tmpomlt;
|
---|
| 138 | extern int16_t tmpoval;
|
---|
| 139 | extern int16_t tuneval;
|
---|
| 140 | extern int16_t vtpcol;
|
---|
[f40a309] | 141 | extern int16_t vtprow;
|
---|
| 142 |
|
---|
| 143 | /* |
---|
| 144 |
|
---|
[7258c6a] | 145 | */
|
---|
[f40a309] | 146 |
|
---|
[7258c6a] | 147 | extern uint16_t *obj8;
|
---|
| 148 |
|
---|
| 149 | extern int32_t afi;
|
---|
| 150 | extern int32_t lcdtime;
|
---|
| 151 | extern int32_t swcount;
|
---|
| 152 | extern int32_t swrate;
|
---|
[f40a309] | 153 | extern int32_t swrmin;
|
---|
[7258c6a] | 154 | extern int32_t swtemp;
|
---|
| 155 |
|
---|
| 156 | extern int16_t grpmode[];
|
---|
| 157 | extern int16_t grpstat[];
|
---|
| 158 | extern int16_t prstab[];
|
---|
[c3aee8a] | 159 | extern int16_t simled[];
|
---|
[7258c6a] | 160 | extern int16_t swfifo[NSWFIFO];
|
---|
| 161 | extern uint16_t tmultab[];
|
---|
[f40a309] | 162 | extern int16_t vce2trg[];
|
---|
[7258c6a] | 163 | extern int16_t veltab[];
|
---|
[f40a309] | 164 |
|
---|
[7258c6a] | 165 | extern int8_t trgtab[];
|
---|
| 166 |
|
---|
| 167 | extern int16_t grp2prt[][2];
|
---|
[f40a309] | 168 | extern int16_t sigtab[][2];
|
---|
| 169 | extern int16_t varmode[][16];
|
---|
| 170 |
|
---|
| 171 | extern struct gdsel *gdstbc[];
|
---|
| 172 |
|
---|
[7258c6a] | 173 | extern struct wordq ptefifo;
|
---|
[f40a309] | 174 |
|
---|
| 175 | uint16_t fifoval;
|
---|
| 176 |
|
---|
| 177 | /* |
---|
[9519422] | 178 |
|
---|
[f40a309] | 179 | */
|
---|
| 180 |
|
---|
| 181 | /*
|
---|
| 182 | =============================================================================
|
---|
| 183 | clk_ped() -- process clock on/off toggle pedal
|
---|
[7258c6a] | 184 | =============================================================================
|
---|
[f40a309] | 185 | */
|
---|
| 186 |
|
---|
| 187 | void clk_ped(int16_t stat)
|
---|
| 188 | {
|
---|
| 189 | if (stat)
|
---|
[9519422] | 190 | tglclk = TRUE;
|
---|
[f40a309] | 191 | }
|
---|
| 192 |
|
---|
| 193 | /*
|
---|
| 194 | =============================================================================
|
---|
| 195 | pch_ped() -- process punch in/out toggle pedal
|
---|
[7258c6a] | 196 | =============================================================================
|
---|
[f40a309] | 197 | */
|
---|
| 198 |
|
---|
| 199 | void pch_ped(int16_t stat)
|
---|
| 200 | {
|
---|
| 201 | if (stat AND pchsw)
|
---|
| 202 | tglpch = TRUE;
|
---|
| 203 | }
|
---|
| 204 |
|
---|
| 205 | /* |
---|
| 206 |
|
---|
| 207 | */
|
---|
| 208 |
|
---|
| 209 | /*
|
---|
| 210 | =============================================================================
|
---|
[0580615] | 211 | msl() -- MIDAS main scan loop
|
---|
[f40a309] | 212 | =============================================================================
|
---|
[7258c6a] | 213 | */
|
---|
| 214 |
|
---|
[f40a309] | 215 | void msl(void)
|
---|
[7258c6a] | 216 | {
|
---|
| 217 | register int8_t *ioadr;
|
---|
| 218 | register uint16_t *fpu;
|
---|
| 219 | register struct s_entry *ep;
|
---|
| 220 | register int16_t i, ti, val;
|
---|
[f40a309] | 221 | register int32_t rt;
|
---|
| 222 | uint16_t chan, crel, oldsr, port, trg, trig, vel;
|
---|
| 223 | int16_t cxprev, cyprev, esi, newsig, oldclk, oldrec;
|
---|
| 224 | int32_t fctemp;
|
---|
| 225 |
|
---|
| 226 | #if DEBUGIT
|
---|
| 227 | if (debugsw AND debugms)
|
---|
| 228 | printf("msl(): ENTRY ndisp=%d\n", ndisp);
|
---|
| 229 | #endif
|
---|
| 230 |
|
---|
| 231 | runit = TRUE; /* set run state */
|
---|
| 232 |
|
---|
| 233 | while (runit) {
|
---|
| 234 |
|
---|
| 235 | dsp_ok = TRUE; /* set display-OK flag for this pass */
|
---|
| 236 |
|
---|
| 237 | ioadr = &io_ser + 2L; /* get edit switch status */
|
---|
| 238 | esi = *ioadr & 0x0008;
|
---|
| 239 |
|
---|
| 240 | if (editss NE esi) { /* check for edit switch change */
|
---|
| 241 |
|
---|
| 242 | editss = esi;
|
---|
| 243 |
|
---|
| 244 | if (editss) /* toggle edit state if it went hi */
|
---|
| 245 | editsw = NOT editsw;
|
---|
| 246 | }
|
---|
| 247 |
|
---|
| 248 | if (editsw) /* update edit LED */
|
---|
| 249 | io_leds = 0x9E;
|
---|
| 250 | else
|
---|
| 251 | io_leds = 0x1E;
|
---|
| 252 |
|
---|
| 253 | if ((NOT lampsw) AND lcdtime) {
|
---|
| 254 |
|
---|
| 255 | if (0 EQ --lcdtime)
|
---|
| 256 | io_leds = 0x1F; /* turn off the LCD backlight */
|
---|
| 257 | }
|
---|
| 258 |
|
---|
| 259 | msm(); /* scan the MIDI ports */
|
---|
| 260 | /* |
---|
| 261 |
|
---|
| 262 | */
|
---|
| 263 |
|
---|
| 264 | if (tglclk) { /* check for clock on/off toggle */
|
---|
| 265 |
|
---|
| 266 | oldsr = setsr(0x2700); /* disable interrupts */
|
---|
| 267 | tglclk = FALSE; /* cancel toggle flag */
|
---|
| 268 | setsr(oldsr); /* enable interrupts */
|
---|
| 269 |
|
---|
| 270 | clkset(NOT clkrun); /* toggle clock mode */
|
---|
| 271 | dclkmd(); /* update display */
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | if (tglpch) { /* check for punch in/out toggle */
|
---|
| 275 |
|
---|
| 276 | oldsr = setsr(0x2700); /* disable interrupts */
|
---|
| 277 | tglpch = FALSE; /* cancel toggle flag */
|
---|
| 278 | setsr(oldsr); /* enable interrupts */
|
---|
| 279 |
|
---|
| 280 | if ((ndisp EQ 2) AND (v_regs[5] & 0x0180))
|
---|
| 281 | vbank(0);
|
---|
| 282 |
|
---|
| 283 | for (i = 0; i < 12; i++) { /* scan the groups */
|
---|
| 284 |
|
---|
| 285 | if (grpmode[i] EQ 1) { /* stdby -> rec */
|
---|
| 286 |
|
---|
| 287 | grpmode[i] = 2;
|
---|
| 288 |
|
---|
| 289 | if (ndisp EQ 2)
|
---|
| 290 | vputc(obj8, 2, 6 + (i * 5),
|
---|
| 291 | '*', simled[grpmode[i]]);
|
---|
| 292 |
|
---|
| 293 | } else if (grpmode[i] EQ 2) { /* rec -> play */
|
---|
| 294 |
|
---|
| 295 | grpmode[i] = 0;
|
---|
| 296 |
|
---|
| 297 | if (ndisp EQ 2)
|
---|
| 298 | vputc(obj8, 2, 6 + (i * 5),
|
---|
| 299 | '*', simled[grpmode[i]]);
|
---|
| 300 | }
|
---|
| 301 | }
|
---|
| 302 | }
|
---|
| 303 |
|
---|
| 304 | /* |
---|
| 305 |
|
---|
| 306 | */
|
---|
| 307 | /* process stimulli from the patch stimulus fifo */
|
---|
| 308 |
|
---|
| 309 | if (getwq(&ptefifo, &fifoval) GE 0) {
|
---|
| 310 |
|
---|
| 311 | crel = 0x8000 & fifoval;
|
---|
| 312 |
|
---|
| 313 | trg = TRG_MASK & fifoval;
|
---|
| 314 | port = 0x0003 & (fifoval >> 11);
|
---|
| 315 | chan = 0x000F & (fifoval >> 7);
|
---|
| 316 | trig = 0x007F & fifoval;
|
---|
| 317 |
|
---|
| 318 | veltab[trg] = vel = SM_SCALE(64);
|
---|
| 319 | prstab[trg] = 0;
|
---|
| 320 |
|
---|
| 321 | if (crel) { /* release */
|
---|
| 322 |
|
---|
| 323 | trgtab[trg] &= ~M_KSTATE;
|
---|
| 324 |
|
---|
| 325 | for (i = 0; i < 12; i++) {
|
---|
| 326 |
|
---|
| 327 | if (vce2trg[i] EQ trg) {
|
---|
| 328 |
|
---|
| 329 | vce2trg[i] = -1;
|
---|
| 330 | procpfl(trg);
|
---|
| 331 |
|
---|
| 332 | }
|
---|
| 333 | }
|
---|
| 334 |
|
---|
| 335 | stmproc(fifoval); /* do it as a patch stimulus */
|
---|
| 336 |
|
---|
| 337 | } else { /* closure */
|
---|
| 338 |
|
---|
| 339 | trgtab[trg] |= M_KSTATE;
|
---|
| 340 |
|
---|
| 341 | stmproc(fifoval); /* do it as a patch stimulus */
|
---|
| 342 |
|
---|
| 343 | for (i = 0; i < 12; i++)
|
---|
| 344 | if ((grp2prt[i][0] EQ 1 + port) AND
|
---|
| 345 | (grp2prt[i][1] EQ 1 + chan))
|
---|
| 346 | asgvce(i, port, chan, trig, vel);
|
---|
| 347 | }
|
---|
| 348 | }
|
---|
| 349 | /* |
---|
| 350 |
|
---|
| 351 | */
|
---|
| 352 | if (-1L NE (afi = XBIOS(X_ANALOG))) { /* check panel inputs */
|
---|
| 353 |
|
---|
| 354 | asig = (afi >> 8) & 0x007F; /* signal number */
|
---|
| 355 | astat = (afi >> 7) & 0x0001; /* status */
|
---|
| 356 | aval = afi & 0x007F; /* value */
|
---|
| 357 |
|
---|
| 358 | if (asig) { /* active signal */
|
---|
| 359 |
|
---|
| 360 | aflag = TRUE;
|
---|
| 361 | newsig = astat AND (NOT sigtab[asig][1]);
|
---|
| 362 |
|
---|
| 363 | sigtab[asig][0] = aval;
|
---|
| 364 | sigtab[asig][1] = astat;
|
---|
| 365 |
|
---|
| 366 | } else { /* all keys up */
|
---|
| 367 |
|
---|
| 368 | aflag = FALSE;
|
---|
| 369 | newsig = FALSE;
|
---|
| 370 |
|
---|
| 371 | for (i = 0; i < 128; i++)
|
---|
| 372 | sigtab[i][1] = 0;
|
---|
| 373 | }
|
---|
| 374 |
|
---|
| 375 | /* |
---|
| 376 |
|
---|
| 377 | */
|
---|
| 378 | if (aflag) { /* anything changed ? */
|
---|
| 379 |
|
---|
| 380 | if ((asig GE 1) AND (asig LE 24)) {
|
---|
| 381 |
|
---|
| 382 | /* local keyboard performance key */
|
---|
| 383 |
|
---|
| 384 | localkb(asig);
|
---|
| 385 |
|
---|
| 386 | } else if ((asig GE 25) AND (asig LE 38)) {
|
---|
| 387 |
|
---|
| 388 | if (astat)
|
---|
| 389 | lcd_on();
|
---|
| 390 |
|
---|
| 391 | if (NOT newsig)
|
---|
| 392 | doslide();
|
---|
| 393 |
|
---|
| 394 | } else if ((asig GE 39) AND (asig LE 52)) {
|
---|
[60288f5] | 395 |
|
---|
[f40a309] | 396 | if (astat)
|
---|
| 397 | lcd_on();
|
---|
| 398 |
|
---|
| 399 | (*(*swpt)[asig - 39])(astat, (asig - 39));
|
---|
| 400 |
|
---|
| 401 | } else if ((asig GE 60) AND (asig LE 69)) {
|
---|
| 402 |
|
---|
| 403 | (*d_key)(asig - 60);
|
---|
| 404 |
|
---|
| 405 | /* |
---|
| 406 |
|
---|
| 407 | */
|
---|
| 408 | } else switch (asig) {
|
---|
| 409 |
|
---|
| 410 | case 53: /* tablet x */
|
---|
| 411 |
|
---|
| 412 | val = SM_SCALE(aval);
|
---|
| 413 |
|
---|
| 414 | for (i = 0; i < 12; i++) {
|
---|
| 415 |
|
---|
| 416 | if (grp2prt[i][0] EQ LCL_PRT) {
|
---|
| 417 |
|
---|
| 418 | if (newsv(i, SM_HTPW, val)) {
|
---|
[7258c6a] | 419 |
|
---|
[f40a309] | 420 | if (recsw AND grpstat[i] AND
|
---|
| 421 | (2 EQ (ancmsw ? varmode[0][i] : grpmode[i]))) {
|
---|
| 422 |
|
---|
| 423 | if (E_NULL NE (ep = e_alc(E_SIZE2))) {
|
---|
| 424 |
|
---|
| 425 | ep->e_time = t_cur;
|
---|
| 426 | ep->e_type = EV_ANVL;
|
---|
| 427 | ep->e_data1 = i;
|
---|
| 428 | ep->e_dn = (struct s_entry *)((int32_t)val << 16);
|
---|
| 429 | p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
| 430 | ctrsw = TRUE;
|
---|
| 431 | se_disp(ep, D_FWD, gdstbc, 1);
|
---|
| 432 | ctrsw = FALSE;
|
---|
| 433 | }
|
---|
| 434 |
|
---|
| 435 | } else if ((angroup - 1) EQ i) {
|
---|
| 436 |
|
---|
| 437 | dsanval(0);
|
---|
| 438 | }
|
---|
| 439 | }
|
---|
| 440 | }
|
---|
| 441 | }
|
---|
| 442 |
|
---|
| 443 | break;
|
---|
| 444 | /* |
---|
| 445 |
|
---|
| 446 | */
|
---|
| 447 | case 54: /* tablet y */
|
---|
| 448 |
|
---|
| 449 | val = SM_SCALE(aval);
|
---|
| 450 |
|
---|
| 451 | for (i = 0; i < 12; i++) {
|
---|
| 452 |
|
---|
| 453 | if (grp2prt[i][0] EQ LCL_PRT) {
|
---|
| 454 |
|
---|
[7258c6a] | 455 | if (newsv(i, SM_VTMW, val)) {
|
---|
[f40a309] | 456 |
|
---|
| 457 | if (recsw AND grpstat[i] AND
|
---|
| 458 | (2 EQ (ancmsw ? varmode[1][i] : grpmode[i]))) {
|
---|
| 459 |
|
---|
| 460 | if (E_NULL NE (ep = e_alc(E_SIZE2))) {
|
---|
| 461 |
|
---|
| 462 | ep->e_time = t_cur;
|
---|
| 463 | ep->e_type = EV_ANVL;
|
---|
| 464 | ep->e_data1 = 0x0010 | i;
|
---|
| 465 | ep->e_dn = (struct s_entry *)((int32_t)val << 16);
|
---|
| 466 | p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
| 467 | ctrsw = TRUE;
|
---|
| 468 | se_disp(ep, D_FWD, gdstbc, 1);
|
---|
| 469 | ctrsw = FALSE;
|
---|
| 470 | }
|
---|
| 471 |
|
---|
| 472 | } else if ((angroup - 1) EQ i) {
|
---|
[9519422] | 473 |
|
---|
[f40a309] | 474 | dsanval(1);
|
---|
| 475 | }
|
---|
| 476 | }
|
---|
| 477 | }
|
---|
| 478 | }
|
---|
| 479 |
|
---|
| 480 | break;
|
---|
| 481 |
|
---|
| 482 | case 55: /* cursor x */
|
---|
| 483 |
|
---|
| 484 | (*cx_key)(); break;
|
---|
| 485 |
|
---|
| 486 | case 56: /* cursor y */
|
---|
| 487 |
|
---|
| 488 | (*cy_key)(); break;
|
---|
| 489 | /* |
---|
| 490 |
|
---|
| 491 | */
|
---|
| 492 | case 58: /* longpot r */
|
---|
| 493 |
|
---|
| 494 | val = SM_SCALE(aval);
|
---|
| 495 |
|
---|
| 496 | for (i = 0; i < 12; i++) {
|
---|
| 497 |
|
---|
| 498 | if (grp2prt[i][0] EQ LCL_PRT) {
|
---|
[7258c6a] | 499 |
|
---|
[f40a309] | 500 | if (newsv(i, SM_LPBR, val)) {
|
---|
| 501 |
|
---|
| 502 | if (recsw AND grpstat[i] AND
|
---|
| 503 | (2 EQ (ancmsw ? varmode[2][i] : grpmode[i]))) {
|
---|
| 504 |
|
---|
| 505 | if (E_NULL NE (ep = e_alc(E_SIZE2))) {
|
---|
| 506 |
|
---|
| 507 | ep->e_time = t_cur;
|
---|
| 508 | ep->e_type = EV_ANVL;
|
---|
| 509 | ep->e_data1 = 0x0020 | i;
|
---|
| 510 | ep->e_dn = (struct s_entry *)((int32_t)val << 16);
|
---|
| 511 | p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
| 512 | ctrsw = TRUE;
|
---|
| 513 | se_disp(ep, D_FWD, gdstbc, 1);
|
---|
| 514 | ctrsw = FALSE;
|
---|
| 515 | }
|
---|
| 516 |
|
---|
| 517 | } else if ((angroup - 1) EQ i) {
|
---|
| 518 |
|
---|
| 519 | dsanval(2);
|
---|
| 520 | }
|
---|
| 521 | }
|
---|
| 522 | }
|
---|
| 523 | }
|
---|
| 524 |
|
---|
| 525 | break;
|
---|
| 526 |
|
---|
| 527 | /* |
---|
| 528 |
|
---|
| 529 | */
|
---|
| 530 | case 59: /* scroll wheel */
|
---|
| 531 |
|
---|
| 532 | wheel(); break;
|
---|
| 533 |
|
---|
| 534 | case 70: /* X key */
|
---|
| 535 |
|
---|
| 536 | (*x_key)(); break;
|
---|
| 537 |
|
---|
| 538 | case 71: /* E key */
|
---|
| 539 |
|
---|
| 540 | #if DEBUGIT
|
---|
| 541 | if (debugsw AND debugms)
|
---|
| 542 | printf("msl(): -> e_key ($%lX) astat=%d ndisp=%d\n",
|
---|
| 543 | e_key, astat, ndisp);
|
---|
| 544 | #endif
|
---|
| 545 | (*e_key)();
|
---|
| 546 |
|
---|
| 547 | #if DEBUGIT
|
---|
| 548 | if (debugsw AND debugms)
|
---|
| 549 | printf("msl(): <- e_key ($%lX) astat=%d ndisp=%d runit=%d\n",
|
---|
| 550 | e_key, astat, ndisp, runit);
|
---|
| 551 | #endif
|
---|
| 552 |
|
---|
| 553 | break;
|
---|
| 554 |
|
---|
| 555 | case 72: /* M key */
|
---|
| 556 |
|
---|
| 557 | (*m_key)(); break;
|
---|
| 558 |
|
---|
| 559 | case 73: /* Tempo */
|
---|
| 560 |
|
---|
[7258c6a] | 561 | if (aval > 50) /* dead band */
|
---|
[f40a309] | 562 | if (aval < 53)
|
---|
| 563 | aval = 50;
|
---|
| 564 | else
|
---|
| 565 | aval -= 2;
|
---|
| 566 |
|
---|
| 567 | tmpomlt = aval > 100 ? 100 : aval;
|
---|
| 568 | #if OLDTIME
|
---|
| 569 | ti = ( (tmpomlt + 50) * tmpoval) / 100;
|
---|
| 570 | ti = (short)( (192000L / ti) - 1);
|
---|
| 571 | #else
|
---|
| 572 | ti = (tmpomlt + 50) * tmpoval;
|
---|
| 573 | ti = (int16_t)( (19200000L / ti) - 1);
|
---|
| 574 | #endif
|
---|
| 575 | TIME_T2H = ti >> 8;
|
---|
| 576 | TIME_T2L = ti & 0x00FF;
|
---|
| 577 |
|
---|
| 578 | if (tmpomlt EQ 50) { /* 0 */
|
---|
| 579 |
|
---|
| 580 | io_leds = 0x18; /* green off */
|
---|
| 581 | io_leds = 0x19; /* red off */
|
---|
| 582 |
|
---|
| 583 | } else if (tmpomlt GT 50) { /* hi */
|
---|
| 584 |
|
---|
| 585 | io_leds = 0x98; /* green on */
|
---|
| 586 | io_leds = 0x19; /* red off */
|
---|
| 587 |
|
---|
| 588 | } else { /* lo */
|
---|
| 589 |
|
---|
| 590 | io_leds = 0x18; /* green off */
|
---|
| 591 | io_leds = 0x99; /* red on */
|
---|
| 592 | }
|
---|
| 593 |
|
---|
| 594 | break;
|
---|
| 595 | /* |
---|
| 596 |
|
---|
| 597 | */
|
---|
| 598 | case 74: /* Time */
|
---|
| 599 |
|
---|
| 600 | if (aval > 50) /* dead band */
|
---|
| 601 | if (aval < 53)
|
---|
| 602 | aval = 50;
|
---|
| 603 | else
|
---|
| 604 | aval -= 2;
|
---|
| 605 |
|
---|
| 606 | ti = aval > 100 ? 100 : aval;
|
---|
| 607 | timemlt = tmultab[ti];
|
---|
| 608 |
|
---|
| 609 | if (ti EQ 50) { /* 0 */
|
---|
| 610 |
|
---|
| 611 | io_leds = 0x1A; /* green off */
|
---|
| 612 | io_leds = 0x1B; /* red off */
|
---|
| 613 |
|
---|
| 614 | } else if (ti GT 50) { /* hi */
|
---|
| 615 |
|
---|
| 616 | io_leds = 0x9A; /* green on */
|
---|
| 617 | io_leds = 0x1B; /* red off */
|
---|
| 618 |
|
---|
| 619 | } else { /* lo */
|
---|
| 620 |
|
---|
| 621 | io_leds = 0x1A; /* green off */
|
---|
| 622 | io_leds = 0x9B; /* red on */
|
---|
| 623 | }
|
---|
| 624 |
|
---|
| 625 | break;
|
---|
| 626 |
|
---|
| 627 | /* |
---|
| 628 |
|
---|
| 629 | */
|
---|
| 630 | case 75: /* Tuning */
|
---|
| 631 |
|
---|
| 632 | if (aval > 50) /* dead band */
|
---|
| 633 | if (aval < 53)
|
---|
| 634 | aval = 50;
|
---|
| 635 | else
|
---|
| 636 | aval -= 2;
|
---|
| 637 |
|
---|
| 638 | i = (aval > 100) ? 100 : aval;
|
---|
| 639 | tuneval = (i - 50) << 2;
|
---|
| 640 | settune();
|
---|
| 641 |
|
---|
| 642 | if (i EQ 50) {
|
---|
| 643 |
|
---|
| 644 | io_leds = 0x1C; /* green off */
|
---|
| 645 | io_leds = 0x1D; /* red off */
|
---|
| 646 |
|
---|
| 647 | } else if (i GT 50) {
|
---|
| 648 |
|
---|
| 649 | io_leds = 0x9C; /* green on */
|
---|
| 650 | io_leds = 0x1D; /* red off */
|
---|
| 651 |
|
---|
| 652 | } else {
|
---|
| 653 |
|
---|
| 654 | io_leds = 0x1C; /* green off */
|
---|
| 655 | io_leds = 0x9D; /* red on */
|
---|
| 656 | }
|
---|
| 657 |
|
---|
| 658 | break;
|
---|
| 659 | /* |
---|
| 660 |
|
---|
| 661 | */
|
---|
| 662 | case 76: /* amplitude */
|
---|
| 663 |
|
---|
| 664 | aval += aval >> 2;
|
---|
| 665 |
|
---|
| 666 | if (aval > 127)
|
---|
| 667 | aval = 127;
|
---|
| 668 |
|
---|
| 669 | amplval = (aval << 9) ^ 0x8000;
|
---|
| 670 | sendval(0, 0, amplval);
|
---|
| 671 | break;
|
---|
| 672 |
|
---|
| 673 | case 77: /* pedal 1 */
|
---|
| 674 |
|
---|
| 675 | val = SM_SCALE(aval);
|
---|
[7258c6a] | 676 |
|
---|
[f40a309] | 677 | for (i = 0; i < 12; i++) {
|
---|
| 678 |
|
---|
| 679 | if (grp2prt[i][0] EQ LCL_PRT) {
|
---|
| 680 |
|
---|
| 681 | if (newsv(i, SM_PED1, val)) {
|
---|
| 682 |
|
---|
| 683 | if (recsw AND grpstat[i] AND
|
---|
| 684 | (2 EQ (ancmsw ? varmode[4][i] : grpmode[i]))) {
|
---|
| 685 |
|
---|
| 686 | if (E_NULL NE (ep = e_alc(E_SIZE2))) {
|
---|
| 687 |
|
---|
| 688 | ep->e_time = t_cur;
|
---|
| 689 | ep->e_type = EV_ANVL;
|
---|
| 690 | ep->e_data1 = 0x0040 | i;
|
---|
| 691 | ep->e_dn = (struct s_entry *)((int32_t)val << 16);
|
---|
| 692 | p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
| 693 | ctrsw = TRUE;
|
---|
| 694 | se_disp(ep, D_FWD, gdstbc, 1);
|
---|
| 695 | ctrsw = FALSE;
|
---|
| 696 | }
|
---|
| 697 |
|
---|
| 698 | } else if ((angroup - 1) EQ i) {
|
---|
| 699 |
|
---|
| 700 | dsanval(4);
|
---|
| 701 | }
|
---|
| 702 | }
|
---|
| 703 | }
|
---|
| 704 | }
|
---|
| 705 |
|
---|
| 706 | break;
|
---|
| 707 |
|
---|
| 708 | /* |
---|
| 709 |
|
---|
| 710 | */
|
---|
| 711 | case 79: /* cv 1 */
|
---|
| 712 |
|
---|
[7258c6a] | 713 | val = SM_SCALE(aval);
|
---|
[f40a309] | 714 |
|
---|
| 715 | for (i = 0; i < 12; i++) {
|
---|
| 716 |
|
---|
| 717 | if (grp2prt[i][0] EQ LCL_PRT) {
|
---|
| 718 |
|
---|
| 719 | if (newsv(i, SM_CTL1, val)) {
|
---|
| 720 |
|
---|
| 721 | if (recsw AND grpstat[i] AND
|
---|
| 722 | (2 EQ (ancmsw ? varmode[3][i] : grpmode[i]))) {
|
---|
| 723 |
|
---|
| 724 | if (E_NULL NE (ep = e_alc(E_SIZE2))) {
|
---|
| 725 |
|
---|
| 726 | ep->e_time = t_cur;
|
---|
| 727 | ep->e_type = EV_ANVL;
|
---|
| 728 | ep->e_data1 = 0x0030 | i;
|
---|
| 729 | ep->e_dn = (struct s_entry *)((int32_t)val << 16);
|
---|
| 730 | p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
| 731 | ctrsw = TRUE;
|
---|
| 732 | se_disp(ep, D_FWD, gdstbc, 1);
|
---|
| 733 | ctrsw = FALSE;
|
---|
| 734 | }
|
---|
| 735 |
|
---|
| 736 | } if ((angroup - 1)EQ i) {
|
---|
| 737 |
|
---|
| 738 | dsanval(3);
|
---|
| 739 | }
|
---|
| 740 | }
|
---|
| 741 | }
|
---|
| 742 | }
|
---|
| 743 |
|
---|
| 744 | break;
|
---|
| 745 |
|
---|
| 746 | }
|
---|
| 747 | }
|
---|
| 748 | }
|
---|
| 749 | /* |
---|
| 750 |
|
---|
| 751 | */
|
---|
| 752 |
|
---|
| 753 | #if DEBUGIT
|
---|
| 754 | if (debugsw AND debugms AND (NOT runit))
|
---|
| 755 | printf("msl(): end of asig cases -- dsp_ok = %d\n", dsp_ok);
|
---|
| 756 | #endif
|
---|
| 757 |
|
---|
| 758 | /* memory allocation changed ? */
|
---|
| 759 |
|
---|
| 760 | if ((ndisp EQ 2) AND se_chg AND dsp_ok) {
|
---|
| 761 |
|
---|
| 762 | dsmem(); /* display memory remaining */
|
---|
| 763 | se_chg = FALSE;
|
---|
| 764 | }
|
---|
| 765 |
|
---|
| 766 | nxtflag = FALSE; /* clear 'next score' flag */
|
---|
| 767 | fctemp = fc_val; /* sample the frame clock */
|
---|
| 768 |
|
---|
| 769 | if (t_cur NE fctemp) { /* see if frame clock changed */
|
---|
| 770 |
|
---|
| 771 | if (t_cur LT fctemp) { /* clock incremented */
|
---|
| 772 |
|
---|
| 773 | if (se EQ D_BAK) /* change direction ? */
|
---|
| 774 | chgsef();
|
---|
| 775 |
|
---|
| 776 | sc_trek(fctemp); /* track frame clock */
|
---|
| 777 |
|
---|
| 778 | } else { /* clock decremented */
|
---|
| 779 |
|
---|
| 780 | if (se EQ D_FWD) /* change direction ? */
|
---|
| 781 | chgseb();
|
---|
| 782 |
|
---|
| 783 | sc_trek(fctemp); /* track frame clock */
|
---|
| 784 | }
|
---|
| 785 |
|
---|
| 786 | /* handle display update if there's time for it */
|
---|
| 787 |
|
---|
| 788 | } else if (dsp_ok AND (t_ctr NE t_cur)) {
|
---|
| 789 |
|
---|
| 790 | if (t_ctr LT t_cur) { /* clock incremented */
|
---|
| 791 |
|
---|
| 792 | if (sd EQ D_BAK) /* change direction ? */
|
---|
| 793 | chgsdf();
|
---|
| 794 |
|
---|
| 795 | sc_trak(t_ctr + 1); /* track frame clock */
|
---|
| 796 |
|
---|
| 797 | } else { /* clock decremented */
|
---|
| 798 |
|
---|
| 799 | if (sd EQ D_FWD) /* change direction ? */
|
---|
| 800 | chgsdb();
|
---|
| 801 |
|
---|
| 802 | sc_trak(t_ctr - 1); /* track frame clock */
|
---|
| 803 | }
|
---|
| 804 | }
|
---|
| 805 | /* |
---|
| 806 |
|
---|
| 807 | */
|
---|
| 808 | #if DEBUGIT
|
---|
| 809 | if (debugsw AND debugms AND (NOT runit))
|
---|
| 810 | printf("msl(): end of clock processing -- dsp_ok = %d\n",
|
---|
| 811 | dsp_ok);
|
---|
| 812 | #endif
|
---|
| 813 |
|
---|
| 814 | /* handle 'next score' flag */
|
---|
| 815 |
|
---|
| 816 | if (nxtflag AND (sd EQ D_FWD)) { /* switch scores ? */
|
---|
| 817 |
|
---|
| 818 | oldrec = recsw;
|
---|
| 819 | oldclk = clkrun;
|
---|
| 820 |
|
---|
| 821 | ti = curscor + 1;
|
---|
| 822 |
|
---|
| 823 | if (ti GE N_SCORES)
|
---|
| 824 | ti = 0;
|
---|
| 825 |
|
---|
| 826 | for (i = 0; i < N_SCORES; i++) {
|
---|
| 827 |
|
---|
| 828 | if (E_NULL NE scores[ti]) {
|
---|
| 829 |
|
---|
| 830 | selscor(ti);
|
---|
| 831 | break;
|
---|
| 832 | }
|
---|
| 833 |
|
---|
| 834 | if (++ti GE N_SCORES)
|
---|
| 835 | ti = 0;
|
---|
| 836 | }
|
---|
| 837 |
|
---|
| 838 | clkset(oldclk); /* restore clock mode */
|
---|
| 839 | dsclk();
|
---|
| 840 | recsw = oldrec; /* restore record/play mode */
|
---|
| 841 | dsrpmod();
|
---|
| 842 | nxtflag = FALSE; /* clear 'next score' flag */
|
---|
| 843 | }
|
---|
| 844 |
|
---|
| 845 | #if DEBUGIT
|
---|
| 846 | if (debugsw AND debugms AND (NOT runit))
|
---|
| 847 | printf("msl(): curproc\n");
|
---|
| 848 | #endif
|
---|
| 849 |
|
---|
| 850 | curproc(); /* process wheel and ball */
|
---|
| 851 |
|
---|
| 852 | #if DEBUGIT
|
---|
| 853 | if (debugsw AND debugms AND (NOT runit))
|
---|
| 854 | printf("msl(): seqproc\n");
|
---|
| 855 | #endif
|
---|
| 856 |
|
---|
| 857 | seqproc(); /* process sequences */
|
---|
| 858 | }
|
---|
| 859 |
|
---|
| 860 | #if DEBUGIT
|
---|
| 861 | if (debugsw AND debugms)
|
---|
| 862 | printf("msl(): EXIT ndisp=%d\n", ndisp);
|
---|
| 863 | #endif
|
---|
| 864 | }
|
---|