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 |
|
---|
389 | tmpomlt = aval > 100 ? 100 : aval;
|
---|
390 | #if OLDTIME
|
---|
391 | ti = ( (tmpomlt + 50) * tmpoval) / 100;
|
---|
392 | ti = (short)( (192000L / ti) - 1);
|
---|
393 | #else
|
---|
394 | ti = (tmpomlt + 50) * tmpoval;
|
---|
395 | ti = (int16_t)( (19200000L / ti) - 1);
|
---|
396 | #endif
|
---|
397 | TIME_T2H = (uint8_t)(ti >> 8);
|
---|
398 | TIME_T2L = (uint8_t)(ti & 0x00FF);
|
---|
399 |
|
---|
400 | if (tmpomlt EQ 50) { /* 0 */
|
---|
401 |
|
---|
402 | io_leds = 0x18; /* green off */
|
---|
403 | io_leds = 0x19; /* red off */
|
---|
404 |
|
---|
405 | } else if (tmpomlt GT 50) { /* hi */
|
---|
406 |
|
---|
407 | io_leds = 0x98; /* green on */
|
---|
408 | io_leds = 0x19; /* red off */
|
---|
409 |
|
---|
410 | } else { /* lo */
|
---|
411 |
|
---|
412 | io_leds = 0x18; /* green off */
|
---|
413 | io_leds = 0x99; /* red on */
|
---|
414 | }
|
---|
415 |
|
---|
416 | break;
|
---|
417 |
|
---|
418 | case 74: /* Time */
|
---|
419 |
|
---|
420 | if (aval > 50) { /* dead band */
|
---|
421 | if (aval < 53)
|
---|
422 | aval = 50;
|
---|
423 | else
|
---|
424 | aval -= 2;
|
---|
425 | }
|
---|
426 |
|
---|
427 | ti = aval > 100 ? 100 : aval;
|
---|
428 | timemlt = tmultab[ti];
|
---|
429 |
|
---|
430 | if (ti EQ 50) { /* 0 */
|
---|
431 |
|
---|
432 | io_leds = 0x1A; /* green off */
|
---|
433 | io_leds = 0x1B; /* red off */
|
---|
434 |
|
---|
435 | } else if (ti GT 50) { /* hi */
|
---|
436 |
|
---|
437 | io_leds = 0x9A; /* green on */
|
---|
438 | io_leds = 0x1B; /* red off */
|
---|
439 |
|
---|
440 | } else { /* lo */
|
---|
441 |
|
---|
442 | io_leds = 0x1A; /* green off */
|
---|
443 | io_leds = 0x9B; /* red on */
|
---|
444 | }
|
---|
445 |
|
---|
446 | break;
|
---|
447 |
|
---|
448 |
|
---|
449 | case 75: /* Tuning */
|
---|
450 |
|
---|
451 | if (aval > 50) { /* dead band */
|
---|
452 | if (aval < 53)
|
---|
453 | aval = 50;
|
---|
454 | else
|
---|
455 | aval -= 2;
|
---|
456 | }
|
---|
457 |
|
---|
458 | i = (aval > 100) ? 100 : aval;
|
---|
459 | tuneval = (i - 50) << 2;
|
---|
460 | settune();
|
---|
461 |
|
---|
462 | if (i EQ 50) {
|
---|
463 |
|
---|
464 | io_leds = 0x1C; /* green off */
|
---|
465 | io_leds = 0x1D; /* red off */
|
---|
466 |
|
---|
467 | } else if (i GT 50) {
|
---|
468 |
|
---|
469 | io_leds = 0x9C; /* green on */
|
---|
470 | io_leds = 0x1D; /* red off */
|
---|
471 |
|
---|
472 | } else {
|
---|
473 |
|
---|
474 | io_leds = 0x1C; /* green off */
|
---|
475 | io_leds = 0x9D; /* red on */
|
---|
476 | }
|
---|
477 |
|
---|
478 | break;
|
---|
479 |
|
---|
480 | case 76: /* amplitude */
|
---|
481 |
|
---|
482 | aval += aval >> 2;
|
---|
483 |
|
---|
484 | if (aval > 127)
|
---|
485 | aval = 127;
|
---|
486 |
|
---|
487 | amplval = (aval << 9) ^ (int16_t)0x8000;
|
---|
488 | sendval(0, 0, amplval);
|
---|
489 | break;
|
---|
490 |
|
---|
491 | case 77: /* pedal 1 */
|
---|
492 |
|
---|
493 | val = SM_SCALE(aval);
|
---|
494 |
|
---|
495 | for (i = 0; i < 12; i++) {
|
---|
496 |
|
---|
497 | if (grp2prt[i][0] EQ LCL_PRT) {
|
---|
498 |
|
---|
499 | if (newsv(i, SM_PED1, val)) {
|
---|
500 |
|
---|
501 | if (recsw AND grpstat[i] AND
|
---|
502 | (2 EQ (ancmsw ? varmode[4][i] : grpmode[i]))) {
|
---|
503 |
|
---|
504 | if (E_NULL NE (ep = e_alc(E_SIZE2))) {
|
---|
505 |
|
---|
506 | ep->e_time = t_cur;
|
---|
507 | ep->e_type = EV_ANVL;
|
---|
508 | ep->e_data1 = (int8_t)(0x0040 | i);
|
---|
509 | ep->e_dn = (struct s_entry *)((int32_t)val << 16);
|
---|
510 | p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
511 | ctrsw = TRUE;
|
---|
512 | se_disp(ep, D_FWD, gdstbc, 1);
|
---|
513 | ctrsw = FALSE;
|
---|
514 | }
|
---|
515 |
|
---|
516 | } else if ((angroup - 1) EQ i) {
|
---|
517 |
|
---|
518 | dsanval(4);
|
---|
519 | }
|
---|
520 | }
|
---|
521 | }
|
---|
522 | }
|
---|
523 |
|
---|
524 | break;
|
---|
525 |
|
---|
526 |
|
---|
527 | case 79: /* cv 1 */
|
---|
528 |
|
---|
529 | val = SM_SCALE(aval);
|
---|
530 |
|
---|
531 | for (i = 0; i < 12; i++) {
|
---|
532 |
|
---|
533 | if (grp2prt[i][0] EQ LCL_PRT) {
|
---|
534 |
|
---|
535 | if (newsv(i, SM_CTL1, val)) {
|
---|
536 |
|
---|
537 | if (recsw AND grpstat[i] AND
|
---|
538 | (2 EQ (ancmsw ? varmode[3][i] : grpmode[i]))) {
|
---|
539 |
|
---|
540 | if (E_NULL NE (ep = e_alc(E_SIZE2))) {
|
---|
541 |
|
---|
542 | ep->e_time = t_cur;
|
---|
543 | ep->e_type = EV_ANVL;
|
---|
544 | ep->e_data1 = (int8_t)(0x0030 | i);
|
---|
545 | ep->e_dn = (struct s_entry *)((int32_t)val << 16);
|
---|
546 | p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
547 | ctrsw = TRUE;
|
---|
548 | se_disp(ep, D_FWD, gdstbc, 1);
|
---|
549 | ctrsw = FALSE;
|
---|
550 | }
|
---|
551 |
|
---|
552 | } if ((angroup - 1)EQ i) {
|
---|
553 |
|
---|
554 | dsanval(3);
|
---|
555 | }
|
---|
556 | }
|
---|
557 | }
|
---|
558 | }
|
---|
559 |
|
---|
560 | break;
|
---|
561 |
|
---|
562 | }
|
---|
563 | }
|
---|
564 | }
|
---|
565 |
|
---|
566 | #if DEBUGIT
|
---|
567 | if (debugsw AND debugms AND (NOT runit))
|
---|
568 | printf("msl(): end of asig cases -- dsp_ok = %d\n", dsp_ok);
|
---|
569 | #endif
|
---|
570 |
|
---|
571 | /* memory allocation changed ? */
|
---|
572 |
|
---|
573 | if ((ndisp EQ 2) AND se_chg AND dsp_ok) {
|
---|
574 |
|
---|
575 | dsmem(); /* display memory remaining */
|
---|
576 | se_chg = FALSE;
|
---|
577 | }
|
---|
578 |
|
---|
579 | nxtflag = FALSE; /* clear 'next score' flag */
|
---|
580 | fctemp = fc_val; /* sample the frame clock */
|
---|
581 |
|
---|
582 | if (t_cur NE fctemp) { /* see if frame clock changed */
|
---|
583 |
|
---|
584 | if (t_cur LT fctemp) { /* clock incremented */
|
---|
585 |
|
---|
586 | if (se EQ D_BAK) /* change direction ? */
|
---|
587 | chgsef();
|
---|
588 |
|
---|
589 | sc_trek(fctemp); /* track frame clock */
|
---|
590 |
|
---|
591 | } else { /* clock decremented */
|
---|
592 |
|
---|
593 | if (se EQ D_FWD) /* change direction ? */
|
---|
594 | chgseb();
|
---|
595 |
|
---|
596 | sc_trek(fctemp); /* track frame clock */
|
---|
597 | }
|
---|
598 |
|
---|
599 | /* handle display update if there's time for it */
|
---|
600 |
|
---|
601 | } else if (dsp_ok AND (t_ctr NE t_cur)) {
|
---|
602 |
|
---|
603 | if (t_ctr LT t_cur) { /* clock incremented */
|
---|
604 |
|
---|
605 | if (sd EQ D_BAK) /* change direction ? */
|
---|
606 | chgsdf();
|
---|
607 |
|
---|
608 | sc_trak(t_ctr + 1); /* track frame clock */
|
---|
609 |
|
---|
610 | } else { /* clock decremented */
|
---|
611 |
|
---|
612 | if (sd EQ D_FWD) /* change direction ? */
|
---|
613 | chgsdb();
|
---|
614 |
|
---|
615 | sc_trak(t_ctr - 1); /* track frame clock */
|
---|
616 | }
|
---|
617 | }
|
---|
618 |
|
---|
619 | #if DEBUGIT
|
---|
620 | if (debugsw AND debugms AND (NOT runit))
|
---|
621 | printf("msl(): end of clock processing -- dsp_ok = %d\n",
|
---|
622 | dsp_ok);
|
---|
623 | #endif
|
---|
624 |
|
---|
625 | /* handle 'next score' flag */
|
---|
626 |
|
---|
627 | if (nxtflag AND (sd EQ D_FWD)) { /* switch scores ? */
|
---|
628 |
|
---|
629 | oldrec = recsw;
|
---|
630 | oldclk = clkrun;
|
---|
631 |
|
---|
632 | ti = curscor + 1;
|
---|
633 |
|
---|
634 | if (ti GE N_SCORES)
|
---|
635 | ti = 0;
|
---|
636 |
|
---|
637 | for (i = 0; i < N_SCORES; i++) {
|
---|
638 |
|
---|
639 | if (E_NULL NE scores[ti]) {
|
---|
640 |
|
---|
641 | selscor(ti);
|
---|
642 | break;
|
---|
643 | }
|
---|
644 |
|
---|
645 | if (++ti GE N_SCORES)
|
---|
646 | ti = 0;
|
---|
647 | }
|
---|
648 |
|
---|
649 | clkset(oldclk); /* restore clock mode */
|
---|
650 | dsclk();
|
---|
651 | recsw = oldrec; /* restore record/play mode */
|
---|
652 | dsrpmod();
|
---|
653 | nxtflag = FALSE; /* clear 'next score' flag */
|
---|
654 | }
|
---|
655 |
|
---|
656 | #if DEBUGIT
|
---|
657 | if (debugsw AND debugms AND (NOT runit))
|
---|
658 | printf("msl(): curproc\n");
|
---|
659 | #endif
|
---|
660 |
|
---|
661 | curproc(); /* process wheel and ball */
|
---|
662 |
|
---|
663 | #if DEBUGIT
|
---|
664 | if (debugsw AND debugms AND (NOT runit))
|
---|
665 | printf("msl(): seqproc\n");
|
---|
666 | #endif
|
---|
667 |
|
---|
668 | seqproc(); /* process sequences */
|
---|
669 | }
|
---|
670 |
|
---|
671 | #if DEBUGIT
|
---|
672 | if (debugsw AND debugms)
|
---|
673 | printf("msl(): EXIT ndisp=%d\n", ndisp);
|
---|
674 | #endif
|
---|
675 | }
|
---|
676 |
|
---|