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 "ram.h"
|
---|
15 |
|
---|
16 | #define LCL_PRT 3 /* 1-origin local keyboard port number */
|
---|
17 |
|
---|
18 | #if DEBUGIT
|
---|
19 | short debugms = 1;
|
---|
20 | #endif
|
---|
21 |
|
---|
22 | uint16_t fifoval;
|
---|
23 |
|
---|
24 | /*
|
---|
25 | =============================================================================
|
---|
26 | clk_ped() -- process clock on/off toggle pedal
|
---|
27 | =============================================================================
|
---|
28 | */
|
---|
29 |
|
---|
30 | void clk_ped(int16_t stat)
|
---|
31 | {
|
---|
32 | if (stat)
|
---|
33 | tglclk = TRUE;
|
---|
34 | }
|
---|
35 |
|
---|
36 | /*
|
---|
37 | =============================================================================
|
---|
38 | pch_ped() -- process punch in/out toggle pedal
|
---|
39 | =============================================================================
|
---|
40 | */
|
---|
41 |
|
---|
42 | void pch_ped(int16_t stat)
|
---|
43 | {
|
---|
44 | if (stat AND pchsw)
|
---|
45 | tglpch = TRUE;
|
---|
46 | }
|
---|
47 |
|
---|
48 | /*
|
---|
49 | =============================================================================
|
---|
50 | msl() -- MIDAS main scan loop
|
---|
51 | =============================================================================
|
---|
52 | */
|
---|
53 |
|
---|
54 | void msl(void)
|
---|
55 | {
|
---|
56 | volatile uint8_t *ioadr;
|
---|
57 | struct s_entry *ep;
|
---|
58 | int16_t i, ti, val;
|
---|
59 | uint16_t crel, oldsr;
|
---|
60 | int16_t chan, port, trg, trig, vel;
|
---|
61 | int16_t esi, newsig, oldclk, oldrec;
|
---|
62 | int32_t fctemp;
|
---|
63 |
|
---|
64 | #if DEBUGIT
|
---|
65 | if (debugsw AND debugms)
|
---|
66 | printf("msl(): ENTRY ndisp=%d\n", ndisp);
|
---|
67 | #endif
|
---|
68 |
|
---|
69 | runit = TRUE; /* set run state */
|
---|
70 |
|
---|
71 | while (runit) {
|
---|
72 |
|
---|
73 | dsp_ok = TRUE; /* set display-OK flag for this pass */
|
---|
74 |
|
---|
75 | ioadr = &io_ser + 2L; /* get edit switch status */
|
---|
76 | esi = *ioadr & 0x0008;
|
---|
77 |
|
---|
78 | if (editss NE esi) { /* check for edit switch change */
|
---|
79 |
|
---|
80 | editss = esi;
|
---|
81 |
|
---|
82 | if (editss) /* toggle edit state if it went hi */
|
---|
83 | editsw = NOT editsw;
|
---|
84 | }
|
---|
85 |
|
---|
86 | if (editsw) /* update edit LED */
|
---|
87 | io_leds = 0x9E;
|
---|
88 | else
|
---|
89 | io_leds = 0x1E;
|
---|
90 |
|
---|
91 | if ((NOT lampsw) AND lcdtime) {
|
---|
92 |
|
---|
93 | if (0 EQ --lcdtime)
|
---|
94 | io_leds = 0x1F; /* turn off the LCD backlight */
|
---|
95 | }
|
---|
96 |
|
---|
97 | msm(); /* scan the MIDI ports */
|
---|
98 |
|
---|
99 | if (tglclk) { /* check for clock on/off toggle */
|
---|
100 |
|
---|
101 | oldsr = setsr(0x2700); /* disable interrupts */
|
---|
102 | tglclk = FALSE; /* cancel toggle flag */
|
---|
103 | setsr(oldsr); /* enable interrupts */
|
---|
104 |
|
---|
105 | clkset(NOT clkrun); /* toggle clock mode */
|
---|
106 | dclkmd(); /* update display */
|
---|
107 | }
|
---|
108 |
|
---|
109 | if (tglpch) { /* check for punch in/out toggle */
|
---|
110 |
|
---|
111 | oldsr = setsr(0x2700); /* disable interrupts */
|
---|
112 | tglpch = FALSE; /* cancel toggle flag */
|
---|
113 | setsr(oldsr); /* enable interrupts */
|
---|
114 |
|
---|
115 | if ((ndisp EQ 2) AND (v_regs[5] & 0x0180))
|
---|
116 | vbank(0);
|
---|
117 |
|
---|
118 | for (i = 0; i < 12; i++) { /* scan the groups */
|
---|
119 |
|
---|
120 | if (grpmode[i] EQ 1) { /* stdby -> rec */
|
---|
121 |
|
---|
122 | grpmode[i] = 2;
|
---|
123 |
|
---|
124 | if (ndisp EQ 2)
|
---|
125 | vputc(obj8, 2, 6 + (i * 5),
|
---|
126 | '*', simled[grpmode[i]]);
|
---|
127 |
|
---|
128 | } else if (grpmode[i] EQ 2) { /* rec -> play */
|
---|
129 |
|
---|
130 | grpmode[i] = 0;
|
---|
131 |
|
---|
132 | if (ndisp EQ 2)
|
---|
133 | vputc(obj8, 2, 6 + (i * 5),
|
---|
134 | '*', simled[grpmode[i]]);
|
---|
135 | }
|
---|
136 | }
|
---|
137 | }
|
---|
138 |
|
---|
139 |
|
---|
140 | /* process stimulli from the patch stimulus fifo */
|
---|
141 |
|
---|
142 | if (getwq(&ptefifo, &fifoval) GE 0) {
|
---|
143 |
|
---|
144 | crel = 0x8000 & fifoval;
|
---|
145 |
|
---|
146 | trg = TRG_MASK & fifoval;
|
---|
147 | port = 0x0003 & (fifoval >> 11);
|
---|
148 | chan = 0x000F & (fifoval >> 7);
|
---|
149 | trig = 0x007F & fifoval;
|
---|
150 |
|
---|
151 | veltab[trg] = vel = SM_SCALE(64);
|
---|
152 | prstab[trg] = 0;
|
---|
153 |
|
---|
154 | if (crel) { /* release */
|
---|
155 |
|
---|
156 | trgtab[trg] &= ~M_KSTATE;
|
---|
157 |
|
---|
158 | for (i = 0; i < 12; i++) {
|
---|
159 |
|
---|
160 | if (vce2trg[i] EQ trg) {
|
---|
161 |
|
---|
162 | vce2trg[i] = -1;
|
---|
163 | procpfl(trg);
|
---|
164 |
|
---|
165 | }
|
---|
166 | }
|
---|
167 |
|
---|
168 | stmproc(fifoval); /* do it as a patch stimulus */
|
---|
169 |
|
---|
170 | } else { /* closure */
|
---|
171 |
|
---|
172 | trgtab[trg] |= M_KSTATE;
|
---|
173 |
|
---|
174 | stmproc(fifoval); /* do it as a patch stimulus */
|
---|
175 |
|
---|
176 | for (i = 0; i < 12; i++)
|
---|
177 | if ((grp2prt[i][0] EQ 1 + port) AND
|
---|
178 | (grp2prt[i][1] EQ 1 + chan))
|
---|
179 | asgvce(i, port, chan, trig, vel);
|
---|
180 | }
|
---|
181 | }
|
---|
182 |
|
---|
183 | if (-1L NE (afi = XBIOS(X_ANALOG))) { /* check panel inputs */
|
---|
184 |
|
---|
185 | asig = (afi >> 8) & 0x007F; /* signal number */
|
---|
186 | astat = (afi >> 7) & 0x0001; /* status */
|
---|
187 | aval = afi & 0x007F; /* value */
|
---|
188 |
|
---|
189 | if (asig) { /* active signal */
|
---|
190 |
|
---|
191 | aflag = TRUE;
|
---|
192 | newsig = astat AND (NOT sigtab[asig][1]);
|
---|
193 |
|
---|
194 | sigtab[asig][0] = aval;
|
---|
195 | sigtab[asig][1] = astat;
|
---|
196 |
|
---|
197 | } else { /* all keys up */
|
---|
198 |
|
---|
199 | aflag = FALSE;
|
---|
200 | newsig = FALSE;
|
---|
201 |
|
---|
202 | for (i = 0; i < 128; i++)
|
---|
203 | sigtab[i][1] = 0;
|
---|
204 | }
|
---|
205 |
|
---|
206 |
|
---|
207 | if (aflag) { /* anything changed ? */
|
---|
208 |
|
---|
209 | if ((asig GE 1) AND (asig LE 24)) {
|
---|
210 |
|
---|
211 | /* local keyboard performance key */
|
---|
212 |
|
---|
213 | localkb(asig);
|
---|
214 |
|
---|
215 | } else if ((asig GE 25) AND (asig LE 38)) {
|
---|
216 |
|
---|
217 | if (astat)
|
---|
218 | lcd_on();
|
---|
219 |
|
---|
220 | if (NOT newsig)
|
---|
221 | doslide();
|
---|
222 |
|
---|
223 | } else if ((asig GE 39) AND (asig LE 52)) {
|
---|
224 |
|
---|
225 | if (astat)
|
---|
226 | lcd_on();
|
---|
227 |
|
---|
228 | (*(*swpt)[asig - 39])(astat, (asig - 39));
|
---|
229 |
|
---|
230 | } else if ((asig GE 60) AND (asig LE 69)) {
|
---|
231 |
|
---|
232 | (*d_key)(asig - 60);
|
---|
233 |
|
---|
234 |
|
---|
235 | } else switch (asig) {
|
---|
236 |
|
---|
237 | case 53: /* tablet x */
|
---|
238 |
|
---|
239 | val = SM_SCALE(aval);
|
---|
240 |
|
---|
241 | for (i = 0; i < 12; i++) {
|
---|
242 |
|
---|
243 | if (grp2prt[i][0] EQ LCL_PRT) {
|
---|
244 |
|
---|
245 | if (newsv(i, SM_HTPW, val)) {
|
---|
246 |
|
---|
247 | if (recsw AND grpstat[i] AND
|
---|
248 | (2 EQ (ancmsw ? varmode[0][i] : grpmode[i]))) {
|
---|
249 |
|
---|
250 | if (E_NULL NE (ep = e_alc(E_SIZE2))) {
|
---|
251 |
|
---|
252 | ep->e_time = t_cur;
|
---|
253 | ep->e_type = EV_ANVL;
|
---|
254 | ep->e_data1 = (int8_t)i;
|
---|
255 | ep->e_dn = (struct s_entry *)((int32_t)val << 16);
|
---|
256 | p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
257 | ctrsw = TRUE;
|
---|
258 | se_disp(ep, D_FWD, gdstbc, 1);
|
---|
259 | ctrsw = FALSE;
|
---|
260 | }
|
---|
261 |
|
---|
262 | } else if ((angroup - 1) EQ i) {
|
---|
263 |
|
---|
264 | dsanval(0);
|
---|
265 | }
|
---|
266 | }
|
---|
267 | }
|
---|
268 | }
|
---|
269 |
|
---|
270 | break;
|
---|
271 |
|
---|
272 | case 54: /* tablet y */
|
---|
273 |
|
---|
274 | val = SM_SCALE(aval);
|
---|
275 |
|
---|
276 | for (i = 0; i < 12; i++) {
|
---|
277 |
|
---|
278 | if (grp2prt[i][0] EQ LCL_PRT) {
|
---|
279 |
|
---|
280 | if (newsv(i, SM_VTMW, val)) {
|
---|
281 |
|
---|
282 | if (recsw AND grpstat[i] AND
|
---|
283 | (2 EQ (ancmsw ? varmode[1][i] : grpmode[i]))) {
|
---|
284 |
|
---|
285 | if (E_NULL NE (ep = e_alc(E_SIZE2))) {
|
---|
286 |
|
---|
287 | ep->e_time = t_cur;
|
---|
288 | ep->e_type = EV_ANVL;
|
---|
289 | ep->e_data1 = (int8_t)(0x0010 | i);
|
---|
290 | ep->e_dn = (struct s_entry *)((int32_t)val << 16);
|
---|
291 | p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
292 | ctrsw = TRUE;
|
---|
293 | se_disp(ep, D_FWD, gdstbc, 1);
|
---|
294 | ctrsw = FALSE;
|
---|
295 | }
|
---|
296 |
|
---|
297 | } else if ((angroup - 1) EQ i) {
|
---|
298 |
|
---|
299 | dsanval(1);
|
---|
300 | }
|
---|
301 | }
|
---|
302 | }
|
---|
303 | }
|
---|
304 |
|
---|
305 | break;
|
---|
306 |
|
---|
307 | case 55: /* cursor x */
|
---|
308 |
|
---|
309 | (*cx_key)(); break;
|
---|
310 |
|
---|
311 | case 56: /* cursor y */
|
---|
312 |
|
---|
313 | (*cy_key)(); break;
|
---|
314 |
|
---|
315 | case 58: /* longpot r */
|
---|
316 |
|
---|
317 | val = SM_SCALE(aval);
|
---|
318 |
|
---|
319 | for (i = 0; i < 12; i++) {
|
---|
320 |
|
---|
321 | if (grp2prt[i][0] EQ LCL_PRT) {
|
---|
322 |
|
---|
323 | if (newsv(i, SM_LPBR, val)) {
|
---|
324 |
|
---|
325 | if (recsw AND grpstat[i] AND
|
---|
326 | (2 EQ (ancmsw ? varmode[2][i] : grpmode[i]))) {
|
---|
327 |
|
---|
328 | if (E_NULL NE (ep = e_alc(E_SIZE2))) {
|
---|
329 |
|
---|
330 | ep->e_time = t_cur;
|
---|
331 | ep->e_type = EV_ANVL;
|
---|
332 | ep->e_data1 = (int8_t)(0x0020 | i);
|
---|
333 | ep->e_dn = (struct s_entry *)((int32_t)val << 16);
|
---|
334 | p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
335 | ctrsw = TRUE;
|
---|
336 | se_disp(ep, D_FWD, gdstbc, 1);
|
---|
337 | ctrsw = FALSE;
|
---|
338 | }
|
---|
339 |
|
---|
340 | } else if ((angroup - 1) EQ i) {
|
---|
341 |
|
---|
342 | dsanval(2);
|
---|
343 | }
|
---|
344 | }
|
---|
345 | }
|
---|
346 | }
|
---|
347 |
|
---|
348 | break;
|
---|
349 |
|
---|
350 |
|
---|
351 | case 59: /* scroll wheel */
|
---|
352 |
|
---|
353 | wheel(); break;
|
---|
354 |
|
---|
355 | case 70: /* X key */
|
---|
356 |
|
---|
357 | (*x_key)(); break;
|
---|
358 |
|
---|
359 | case 71: /* E key */
|
---|
360 |
|
---|
361 | #if DEBUGIT
|
---|
362 | if (debugsw AND debugms)
|
---|
363 | printf("msl(): -> e_key ($%lX) astat=%d ndisp=%d\n",
|
---|
364 | e_key, astat, ndisp);
|
---|
365 | #endif
|
---|
366 | (*e_key)();
|
---|
367 |
|
---|
368 | #if DEBUGIT
|
---|
369 | if (debugsw AND debugms)
|
---|
370 | printf("msl(): <- e_key ($%lX) astat=%d ndisp=%d runit=%d\n",
|
---|
371 | e_key, astat, ndisp, runit);
|
---|
372 | #endif
|
---|
373 |
|
---|
374 | break;
|
---|
375 |
|
---|
376 | case 72: /* M key */
|
---|
377 |
|
---|
378 | (*m_key)(); break;
|
---|
379 |
|
---|
380 | case 73: /* Tempo */
|
---|
381 |
|
---|
382 | if (aval > 50) /* dead band */
|
---|
383 | if (aval < 53)
|
---|
384 | aval = 50;
|
---|
385 | else
|
---|
386 | aval -= 2;
|
---|
387 |
|
---|
388 | tmpomlt = aval > 100 ? 100 : aval;
|
---|
389 | #if OLDTIME
|
---|
390 | ti = ( (tmpomlt + 50) * tmpoval) / 100;
|
---|
391 | ti = (short)( (192000L / ti) - 1);
|
---|
392 | #else
|
---|
393 | ti = (tmpomlt + 50) * tmpoval;
|
---|
394 | ti = (int16_t)( (19200000L / ti) - 1);
|
---|
395 | #endif
|
---|
396 | TIME_T2H = (uint8_t)(ti >> 8);
|
---|
397 | TIME_T2L = (uint8_t)(ti & 0x00FF);
|
---|
398 |
|
---|
399 | if (tmpomlt EQ 50) { /* 0 */
|
---|
400 |
|
---|
401 | io_leds = 0x18; /* green off */
|
---|
402 | io_leds = 0x19; /* red off */
|
---|
403 |
|
---|
404 | } else if (tmpomlt GT 50) { /* hi */
|
---|
405 |
|
---|
406 | io_leds = 0x98; /* green on */
|
---|
407 | io_leds = 0x19; /* red off */
|
---|
408 |
|
---|
409 | } else { /* lo */
|
---|
410 |
|
---|
411 | io_leds = 0x18; /* green off */
|
---|
412 | io_leds = 0x99; /* red on */
|
---|
413 | }
|
---|
414 |
|
---|
415 | break;
|
---|
416 |
|
---|
417 | case 74: /* Time */
|
---|
418 |
|
---|
419 | if (aval > 50) /* dead band */
|
---|
420 | if (aval < 53)
|
---|
421 | aval = 50;
|
---|
422 | else
|
---|
423 | aval -= 2;
|
---|
424 |
|
---|
425 | ti = aval > 100 ? 100 : aval;
|
---|
426 | timemlt = tmultab[ti];
|
---|
427 |
|
---|
428 | if (ti EQ 50) { /* 0 */
|
---|
429 |
|
---|
430 | io_leds = 0x1A; /* green off */
|
---|
431 | io_leds = 0x1B; /* red off */
|
---|
432 |
|
---|
433 | } else if (ti GT 50) { /* hi */
|
---|
434 |
|
---|
435 | io_leds = 0x9A; /* green on */
|
---|
436 | io_leds = 0x1B; /* red off */
|
---|
437 |
|
---|
438 | } else { /* lo */
|
---|
439 |
|
---|
440 | io_leds = 0x1A; /* green off */
|
---|
441 | io_leds = 0x9B; /* red on */
|
---|
442 | }
|
---|
443 |
|
---|
444 | break;
|
---|
445 |
|
---|
446 |
|
---|
447 | case 75: /* Tuning */
|
---|
448 |
|
---|
449 | if (aval > 50) /* dead band */
|
---|
450 | if (aval < 53)
|
---|
451 | aval = 50;
|
---|
452 | else
|
---|
453 | aval -= 2;
|
---|
454 |
|
---|
455 | i = (aval > 100) ? 100 : aval;
|
---|
456 | tuneval = (i - 50) << 2;
|
---|
457 | settune();
|
---|
458 |
|
---|
459 | if (i EQ 50) {
|
---|
460 |
|
---|
461 | io_leds = 0x1C; /* green off */
|
---|
462 | io_leds = 0x1D; /* red off */
|
---|
463 |
|
---|
464 | } else if (i GT 50) {
|
---|
465 |
|
---|
466 | io_leds = 0x9C; /* green on */
|
---|
467 | io_leds = 0x1D; /* red off */
|
---|
468 |
|
---|
469 | } else {
|
---|
470 |
|
---|
471 | io_leds = 0x1C; /* green off */
|
---|
472 | io_leds = 0x9D; /* red on */
|
---|
473 | }
|
---|
474 |
|
---|
475 | break;
|
---|
476 |
|
---|
477 | case 76: /* amplitude */
|
---|
478 |
|
---|
479 | aval += aval >> 2;
|
---|
480 |
|
---|
481 | if (aval > 127)
|
---|
482 | aval = 127;
|
---|
483 |
|
---|
484 | amplval = (aval << 9) ^ (int16_t)0x8000;
|
---|
485 | sendval(0, 0, amplval);
|
---|
486 | break;
|
---|
487 |
|
---|
488 | case 77: /* pedal 1 */
|
---|
489 |
|
---|
490 | val = SM_SCALE(aval);
|
---|
491 |
|
---|
492 | for (i = 0; i < 12; i++) {
|
---|
493 |
|
---|
494 | if (grp2prt[i][0] EQ LCL_PRT) {
|
---|
495 |
|
---|
496 | if (newsv(i, SM_PED1, val)) {
|
---|
497 |
|
---|
498 | if (recsw AND grpstat[i] AND
|
---|
499 | (2 EQ (ancmsw ? varmode[4][i] : grpmode[i]))) {
|
---|
500 |
|
---|
501 | if (E_NULL NE (ep = e_alc(E_SIZE2))) {
|
---|
502 |
|
---|
503 | ep->e_time = t_cur;
|
---|
504 | ep->e_type = EV_ANVL;
|
---|
505 | ep->e_data1 = (int8_t)(0x0040 | i);
|
---|
506 | ep->e_dn = (struct s_entry *)((int32_t)val << 16);
|
---|
507 | p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
508 | ctrsw = TRUE;
|
---|
509 | se_disp(ep, D_FWD, gdstbc, 1);
|
---|
510 | ctrsw = FALSE;
|
---|
511 | }
|
---|
512 |
|
---|
513 | } else if ((angroup - 1) EQ i) {
|
---|
514 |
|
---|
515 | dsanval(4);
|
---|
516 | }
|
---|
517 | }
|
---|
518 | }
|
---|
519 | }
|
---|
520 |
|
---|
521 | break;
|
---|
522 |
|
---|
523 |
|
---|
524 | case 79: /* cv 1 */
|
---|
525 |
|
---|
526 | val = SM_SCALE(aval);
|
---|
527 |
|
---|
528 | for (i = 0; i < 12; i++) {
|
---|
529 |
|
---|
530 | if (grp2prt[i][0] EQ LCL_PRT) {
|
---|
531 |
|
---|
532 | if (newsv(i, SM_CTL1, val)) {
|
---|
533 |
|
---|
534 | if (recsw AND grpstat[i] AND
|
---|
535 | (2 EQ (ancmsw ? varmode[3][i] : grpmode[i]))) {
|
---|
536 |
|
---|
537 | if (E_NULL NE (ep = e_alc(E_SIZE2))) {
|
---|
538 |
|
---|
539 | ep->e_time = t_cur;
|
---|
540 | ep->e_type = EV_ANVL;
|
---|
541 | ep->e_data1 = (int8_t)(0x0030 | i);
|
---|
542 | ep->e_dn = (struct s_entry *)((int32_t)val << 16);
|
---|
543 | p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
544 | ctrsw = TRUE;
|
---|
545 | se_disp(ep, D_FWD, gdstbc, 1);
|
---|
546 | ctrsw = FALSE;
|
---|
547 | }
|
---|
548 |
|
---|
549 | } if ((angroup - 1)EQ i) {
|
---|
550 |
|
---|
551 | dsanval(3);
|
---|
552 | }
|
---|
553 | }
|
---|
554 | }
|
---|
555 | }
|
---|
556 |
|
---|
557 | break;
|
---|
558 |
|
---|
559 | }
|
---|
560 | }
|
---|
561 | }
|
---|
562 |
|
---|
563 | #if DEBUGIT
|
---|
564 | if (debugsw AND debugms AND (NOT runit))
|
---|
565 | printf("msl(): end of asig cases -- dsp_ok = %d\n", dsp_ok);
|
---|
566 | #endif
|
---|
567 |
|
---|
568 | /* memory allocation changed ? */
|
---|
569 |
|
---|
570 | if ((ndisp EQ 2) AND se_chg AND dsp_ok) {
|
---|
571 |
|
---|
572 | dsmem(); /* display memory remaining */
|
---|
573 | se_chg = FALSE;
|
---|
574 | }
|
---|
575 |
|
---|
576 | nxtflag = FALSE; /* clear 'next score' flag */
|
---|
577 | fctemp = fc_val; /* sample the frame clock */
|
---|
578 |
|
---|
579 | if (t_cur NE fctemp) { /* see if frame clock changed */
|
---|
580 |
|
---|
581 | if (t_cur LT fctemp) { /* clock incremented */
|
---|
582 |
|
---|
583 | if (se EQ D_BAK) /* change direction ? */
|
---|
584 | chgsef();
|
---|
585 |
|
---|
586 | sc_trek(fctemp); /* track frame clock */
|
---|
587 |
|
---|
588 | } else { /* clock decremented */
|
---|
589 |
|
---|
590 | if (se EQ D_FWD) /* change direction ? */
|
---|
591 | chgseb();
|
---|
592 |
|
---|
593 | sc_trek(fctemp); /* track frame clock */
|
---|
594 | }
|
---|
595 |
|
---|
596 | /* handle display update if there's time for it */
|
---|
597 |
|
---|
598 | } else if (dsp_ok AND (t_ctr NE t_cur)) {
|
---|
599 |
|
---|
600 | if (t_ctr LT t_cur) { /* clock incremented */
|
---|
601 |
|
---|
602 | if (sd EQ D_BAK) /* change direction ? */
|
---|
603 | chgsdf();
|
---|
604 |
|
---|
605 | sc_trak(t_ctr + 1); /* track frame clock */
|
---|
606 |
|
---|
607 | } else { /* clock decremented */
|
---|
608 |
|
---|
609 | if (sd EQ D_FWD) /* change direction ? */
|
---|
610 | chgsdb();
|
---|
611 |
|
---|
612 | sc_trak(t_ctr - 1); /* track frame clock */
|
---|
613 | }
|
---|
614 | }
|
---|
615 |
|
---|
616 | #if DEBUGIT
|
---|
617 | if (debugsw AND debugms AND (NOT runit))
|
---|
618 | printf("msl(): end of clock processing -- dsp_ok = %d\n",
|
---|
619 | dsp_ok);
|
---|
620 | #endif
|
---|
621 |
|
---|
622 | /* handle 'next score' flag */
|
---|
623 |
|
---|
624 | if (nxtflag AND (sd EQ D_FWD)) { /* switch scores ? */
|
---|
625 |
|
---|
626 | oldrec = recsw;
|
---|
627 | oldclk = clkrun;
|
---|
628 |
|
---|
629 | ti = curscor + 1;
|
---|
630 |
|
---|
631 | if (ti GE N_SCORES)
|
---|
632 | ti = 0;
|
---|
633 |
|
---|
634 | for (i = 0; i < N_SCORES; i++) {
|
---|
635 |
|
---|
636 | if (E_NULL NE scores[ti]) {
|
---|
637 |
|
---|
638 | selscor(ti);
|
---|
639 | break;
|
---|
640 | }
|
---|
641 |
|
---|
642 | if (++ti GE N_SCORES)
|
---|
643 | ti = 0;
|
---|
644 | }
|
---|
645 |
|
---|
646 | clkset(oldclk); /* restore clock mode */
|
---|
647 | dsclk();
|
---|
648 | recsw = oldrec; /* restore record/play mode */
|
---|
649 | dsrpmod();
|
---|
650 | nxtflag = FALSE; /* clear 'next score' flag */
|
---|
651 | }
|
---|
652 |
|
---|
653 | #if DEBUGIT
|
---|
654 | if (debugsw AND debugms AND (NOT runit))
|
---|
655 | printf("msl(): curproc\n");
|
---|
656 | #endif
|
---|
657 |
|
---|
658 | curproc(); /* process wheel and ball */
|
---|
659 |
|
---|
660 | #if DEBUGIT
|
---|
661 | if (debugsw AND debugms AND (NOT runit))
|
---|
662 | printf("msl(): seqproc\n");
|
---|
663 | #endif
|
---|
664 |
|
---|
665 | seqproc(); /* process sequences */
|
---|
666 | }
|
---|
667 |
|
---|
668 | #if DEBUGIT
|
---|
669 | if (debugsw AND debugms)
|
---|
670 | printf("msl(): EXIT ndisp=%d\n", ndisp);
|
---|
671 | #endif
|
---|
672 | }
|
---|
673 |
|
---|