1 | /*
|
---|
2 | =============================================================================
|
---|
3 | sqscan.c -- scan a string and turn it into score events
|
---|
4 | Version 24 -- 1988-06-20 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #define CHEKSTOP 1 /* non-zero to trap to ROMP on error */
|
---|
9 |
|
---|
10 | #include "stddefs.h"
|
---|
11 | #include "cmeta.h"
|
---|
12 | #include "score.h"
|
---|
13 | #include "scfns.h"
|
---|
14 | #include "biosdefs.h"
|
---|
15 |
|
---|
16 | #if CHEKSTOP
|
---|
17 | short chkstop = TRUE;
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | extern short notenum, notepit, curgrp, thescore, verbose;
|
---|
21 | extern short testing;
|
---|
22 | extern short sharp, endflg;
|
---|
23 |
|
---|
24 | extern long curtime, noteon, noteoff, noteval, noteper, nrest;
|
---|
25 | extern long dvwork;
|
---|
26 |
|
---|
27 | char *nlist[] = { "a", "b", "c", "d", "e", "f", "g", NULL };
|
---|
28 |
|
---|
29 | int notetab[] = { 0, 2, 3, 5, 7, 8, 10 };
|
---|
30 | int octab[] = { 21, 33, 45, 57, 69, 81, 93, 105 };
|
---|
31 |
|
---|
32 | /* |
---|
33 |
|
---|
34 | */
|
---|
35 |
|
---|
36 | /*
|
---|
37 | =============================================================================
|
---|
38 | nospace(et) -- print error message for no space condition
|
---|
39 | =============================================================================
|
---|
40 | */
|
---|
41 |
|
---|
42 | void nospace(char *et)
|
---|
43 | {
|
---|
44 |
|
---|
45 | #if CHEKSTOP
|
---|
46 | if (chkstop) {
|
---|
47 |
|
---|
48 | printf("\n** sqscan: ERROR - no space for %s **\n\n", et);
|
---|
49 | xtrap15(); /* ERROR: trap to ROMP */
|
---|
50 |
|
---|
51 | SEsnap();
|
---|
52 | waitcr();
|
---|
53 | }
|
---|
54 | #endif
|
---|
55 | }
|
---|
56 |
|
---|
57 | /* |
---|
58 |
|
---|
59 | */
|
---|
60 |
|
---|
61 | /*
|
---|
62 | =============================================================================
|
---|
63 | Pcheck(ptr, msg) -- check 'ptr' for validity -- output msg if bad.
|
---|
64 | A pointer is invalid if it points outside the score or is null.
|
---|
65 | Returns SUCCESS for a good pointer, FAILURE for a bad one.
|
---|
66 | =============================================================================
|
---|
67 | */
|
---|
68 |
|
---|
69 | int Pcheck(struct s_entry *ptr, char *msg)
|
---|
70 | {
|
---|
71 | register struct s_entry *cval;
|
---|
72 |
|
---|
73 | if (ptr EQ E_NULL) {
|
---|
74 |
|
---|
75 | printf("** Pcheck($%08.8lx): ZERO - %s **\n", ptr, msg);
|
---|
76 |
|
---|
77 | #if CHEKSTOP
|
---|
78 | if (chkstop)
|
---|
79 | xtrap15(); /* ERROR: trap to ROMP */
|
---|
80 | #endif
|
---|
81 | return(FAILURE);
|
---|
82 | }
|
---|
83 |
|
---|
84 | cval = spool;
|
---|
85 |
|
---|
86 | if (ptr LT cval) {
|
---|
87 |
|
---|
88 | printf("** Pcheck($%08.8lx): LOW - %s **\n", ptr, msg);
|
---|
89 | #if CHEKSTOP
|
---|
90 | if (chkstop)
|
---|
91 | xtrap15(); /* ERROR: trap to ROMP */
|
---|
92 | #endif
|
---|
93 | return(FAILURE);
|
---|
94 | }
|
---|
95 |
|
---|
96 | cval = &spool[(long)MAX_SE-1];
|
---|
97 |
|
---|
98 | if (ptr GT cval) {
|
---|
99 |
|
---|
100 | printf("** Pcheck($%08.8lx): HIGH - %s **\n", ptr, msg);
|
---|
101 | #if CHEKSTOP
|
---|
102 | if (chkstop)
|
---|
103 | xtrap15(); /* ERROR: trap to ROMP */
|
---|
104 | #endif
|
---|
105 | return(FAILURE);
|
---|
106 | }
|
---|
107 |
|
---|
108 | return(SUCCESS);
|
---|
109 | }
|
---|
110 |
|
---|
111 | /* |
---|
112 |
|
---|
113 | */
|
---|
114 |
|
---|
115 | /*
|
---|
116 | =============================================================================
|
---|
117 | insnevt() -- insert a note event at t_cur/p_cur
|
---|
118 | =============================================================================
|
---|
119 | */
|
---|
120 |
|
---|
121 | struct n_entry *insnevt(struct n_entry *nsp, short nt, short grp, short note, short vel)
|
---|
122 | {
|
---|
123 | nsp->e_time = t_cur;
|
---|
124 | nsp->e_type = nt;
|
---|
125 | nsp->e_note = note;
|
---|
126 | nsp->e_group = grp;
|
---|
127 | nsp->e_vel = vel;
|
---|
128 |
|
---|
129 | return(e_ins((struct s_entry *)nsp, ep_adj(p_cur, 0, t_cur))->e_fwd);
|
---|
130 | }
|
---|
131 |
|
---|
132 | /* |
---|
133 |
|
---|
134 | */
|
---|
135 |
|
---|
136 | /*
|
---|
137 | =============================================================================
|
---|
138 | Qevent() -- 'event' syntax equation
|
---|
139 | =============================================================================
|
---|
140 | */
|
---|
141 |
|
---|
142 | int Qevent(void)
|
---|
143 | {
|
---|
144 | register int aux1, aux2, aux3, aux4, aux5;
|
---|
145 | register char *chptr;
|
---|
146 | register struct s_entry *tsp1, *tsp2;
|
---|
147 | struct s_entry *tsp3;
|
---|
148 |
|
---|
149 | if (!CM_CHR('!')) /* all commands start with ! */
|
---|
150 | CM_NOGO;
|
---|
151 |
|
---|
152 | if (CM_USTR("group")) { /* !group = n */
|
---|
153 |
|
---|
154 | if (!CM_CHR('='))
|
---|
155 | CM_NOGO;
|
---|
156 |
|
---|
157 | if (!CM_NUM)
|
---|
158 | CM_NOGO;
|
---|
159 |
|
---|
160 | curgrp = QQnum;
|
---|
161 |
|
---|
162 | if (verbose)
|
---|
163 | printf("<Current group = %d>\n", curgrp);
|
---|
164 |
|
---|
165 | CM_OK;
|
---|
166 | }
|
---|
167 |
|
---|
168 | /* |
---|
169 |
|
---|
170 | */
|
---|
171 | if (CM_USTR("status")) { /* !status = {on|off} */
|
---|
172 |
|
---|
173 | if (!CM_CHR('='))
|
---|
174 | CM_NOGO;
|
---|
175 |
|
---|
176 | if (CM_USTR("on")) {
|
---|
177 |
|
---|
178 | if (E_NULL EQ (tsp1 = e_alc(E_SIZE2))) {
|
---|
179 |
|
---|
180 | nospace("!status=on");
|
---|
181 | CM_NOGO;
|
---|
182 | }
|
---|
183 |
|
---|
184 | tsp1->e_time = t_cur;
|
---|
185 | tsp1->e_type = EV_GRP;
|
---|
186 | tsp1->e_data1 = curgrp;
|
---|
187 | tsp1->e_data2 = GS_ENBL;
|
---|
188 |
|
---|
189 | p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
190 | eh_ins(tsp1, EH_GRP);
|
---|
191 |
|
---|
192 | if (verbose)
|
---|
193 | printf("%8ld: Group %d enabled\n",
|
---|
194 | t_cur, curgrp);
|
---|
195 | CM_OK;
|
---|
196 |
|
---|
197 | } else if (CM_USTR("off")) {
|
---|
198 |
|
---|
199 | if (E_NULL EQ (tsp1 = e_alc(E_SIZE2))) {
|
---|
200 |
|
---|
201 | nospace("!status=off");
|
---|
202 | CM_NOGO;
|
---|
203 | }
|
---|
204 |
|
---|
205 | tsp1->e_time = t_cur;
|
---|
206 | tsp1->e_type = EV_GRP;
|
---|
207 | tsp1->e_data1 = curgrp;
|
---|
208 | tsp1->e_data2 = GS_DSBL;
|
---|
209 |
|
---|
210 | p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
211 | eh_ins(tsp1, EH_GRP);
|
---|
212 |
|
---|
213 | if (verbose)
|
---|
214 | printf("%8ld: Group %d disabled\n",
|
---|
215 | t_cur, curgrp);
|
---|
216 | CM_OK;
|
---|
217 |
|
---|
218 | } else
|
---|
219 | CM_NOGO;
|
---|
220 | }
|
---|
221 |
|
---|
222 | /* |
---|
223 |
|
---|
224 | */
|
---|
225 | if (CM_USTR("tempo")) { /* !tempo = n */
|
---|
226 |
|
---|
227 | if (!CM_CHR('='))
|
---|
228 | CM_NOGO;
|
---|
229 |
|
---|
230 | if (!CM_NUM)
|
---|
231 | CM_NOGO;
|
---|
232 |
|
---|
233 | aux1 = QQnum;
|
---|
234 |
|
---|
235 | if (E_NULL EQ (tsp1 = e_alc(E_SIZE2))) {
|
---|
236 |
|
---|
237 | nospace("!tempo");
|
---|
238 | CM_NOGO;
|
---|
239 | }
|
---|
240 |
|
---|
241 | tsp1->e_time = t_cur;
|
---|
242 | tsp1->e_type = EV_TMPO;
|
---|
243 | tsp1->e_data1 = aux1;
|
---|
244 |
|
---|
245 | p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
246 | eh_ins(tsp1, EH_TMPO);
|
---|
247 |
|
---|
248 | if (verbose)
|
---|
249 | printf("%8ld: Tempo = %d\n", t_cur, aux1);
|
---|
250 | CM_OK;
|
---|
251 | }
|
---|
252 | /* |
---|
253 |
|
---|
254 | */
|
---|
255 | if (CM_USTR("inst")) { /* !inst = n */
|
---|
256 |
|
---|
257 | if (!CM_CHR('='))
|
---|
258 | CM_NOGO;
|
---|
259 |
|
---|
260 | if (!CM_NUM)
|
---|
261 | CM_NOGO;
|
---|
262 |
|
---|
263 | aux1 = QQnum;
|
---|
264 |
|
---|
265 | if (E_NULL EQ (tsp1 = e_alc(E_SIZE2))) {
|
---|
266 |
|
---|
267 | nospace("!inst");
|
---|
268 | CM_NOGO;
|
---|
269 | }
|
---|
270 |
|
---|
271 | tsp1->e_time = t_cur;
|
---|
272 | tsp1->e_type = EV_INST;
|
---|
273 | tsp1->e_data1 = curgrp;
|
---|
274 | tsp1->e_data2 = aux1;
|
---|
275 |
|
---|
276 | p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
277 | eh_ins(tsp1, EH_INST);
|
---|
278 |
|
---|
279 | if (verbose)
|
---|
280 | printf("%8ld: group %d set to inst %d\n",
|
---|
281 | t_cur, curgrp, aux1);
|
---|
282 | CM_OK;
|
---|
283 | }
|
---|
284 | /* |
---|
285 |
|
---|
286 | */
|
---|
287 | if (CM_USTR("tuning")) { /* !tuning = n */
|
---|
288 |
|
---|
289 | if (!CM_CHR('='))
|
---|
290 | CM_NOGO;
|
---|
291 |
|
---|
292 | if (!CM_NUM)
|
---|
293 | CM_NOGO;
|
---|
294 |
|
---|
295 | aux1 = QQnum;
|
---|
296 |
|
---|
297 | if (E_NULL EQ (tsp1 = e_alc(E_SIZE2))) {
|
---|
298 |
|
---|
299 | nospace("!tuning");
|
---|
300 | CM_NOGO;
|
---|
301 | }
|
---|
302 |
|
---|
303 | tsp1->e_time = t_cur;
|
---|
304 | tsp1->e_type = EV_TUNE;
|
---|
305 | tsp1->e_data1 = aux1;
|
---|
306 |
|
---|
307 | p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
308 | eh_ins(tsp1, EH_TUNE);
|
---|
309 |
|
---|
310 | if (verbose)
|
---|
311 | printf("%8ld: Tuning %d selected\n", t_cur, aux1);
|
---|
312 | CM_OK;
|
---|
313 | }
|
---|
314 | /* |
---|
315 |
|
---|
316 | */
|
---|
317 | if (CM_USTR("trans")) { /* !trans = {+|-} n */
|
---|
318 |
|
---|
319 | if (!CM_CHR('='))
|
---|
320 | CM_NOGO;
|
---|
321 |
|
---|
322 | if (CM_CHR('+')) {
|
---|
323 |
|
---|
324 | } else if (CM_CHR('-')) {
|
---|
325 |
|
---|
326 | } else
|
---|
327 | CM_NOGO;
|
---|
328 |
|
---|
329 | if (!CM_NUM)
|
---|
330 | CM_NOGO;
|
---|
331 |
|
---|
332 | aux1 = QQnum;
|
---|
333 |
|
---|
334 | if (QQchr EQ '-')
|
---|
335 | aux1 = -aux1;
|
---|
336 |
|
---|
337 | if (E_NULL EQ (tsp1 = e_alc(E_SIZE2))) {
|
---|
338 |
|
---|
339 | nospace("!trans");
|
---|
340 | CM_NOGO;
|
---|
341 | }
|
---|
342 |
|
---|
343 | tsp1->e_time = t_cur;
|
---|
344 | tsp1->e_type = EV_TRNS;
|
---|
345 | tsp1->e_data1 = curgrp;
|
---|
346 | tsp1->e_lft = (struct s_entry *)aux1;
|
---|
347 |
|
---|
348 | p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
349 | eh_ins(tsp1, EH_TRNS);
|
---|
350 |
|
---|
351 | if (verbose)
|
---|
352 | printf("%8ld: Transposition set to %d\n",
|
---|
353 | t_cur, aux1);
|
---|
354 | CM_OK;
|
---|
355 | }
|
---|
356 | /* |
---|
357 |
|
---|
358 | */
|
---|
359 | if (CM_USTR("dyn")) { /* !dyn = n */
|
---|
360 |
|
---|
361 | if (!CM_CHR('='))
|
---|
362 | CM_NOGO;
|
---|
363 |
|
---|
364 | if (!CM_NUM)
|
---|
365 | CM_NOGO;
|
---|
366 |
|
---|
367 | aux1 = QQnum;
|
---|
368 |
|
---|
369 | if (E_NULL EQ (tsp1 = e_alc(E_SIZE2))) {
|
---|
370 |
|
---|
371 | nospace("!dyn");
|
---|
372 | CM_NOGO;
|
---|
373 | }
|
---|
374 |
|
---|
375 | tsp1->e_time = t_cur;
|
---|
376 | tsp1->e_type = EV_DYN;
|
---|
377 | tsp1->e_data1 = curgrp;
|
---|
378 | tsp1->e_data2 = aux1;
|
---|
379 |
|
---|
380 | p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
381 | eh_ins(tsp1, EH_DYN);
|
---|
382 |
|
---|
383 | if (verbose)
|
---|
384 | printf("%8ld: Dynamics set to %d\n", t_cur, aux1);
|
---|
385 | CM_OK;
|
---|
386 | }
|
---|
387 | /* |
---|
388 |
|
---|
389 | */
|
---|
390 | if (CM_USTR("loc")) { /* !loc = n */
|
---|
391 |
|
---|
392 | if (!CM_CHR('='))
|
---|
393 | CM_NOGO;
|
---|
394 |
|
---|
395 | if (!CM_NUM)
|
---|
396 | CM_NOGO;
|
---|
397 |
|
---|
398 | aux1 = QQnum;
|
---|
399 |
|
---|
400 | if (E_NULL EQ (tsp1 = e_alc(E_SIZE2))) {
|
---|
401 |
|
---|
402 | nospace("!loc");
|
---|
403 | CM_NOGO;
|
---|
404 | }
|
---|
405 |
|
---|
406 | tsp1->e_time = t_cur;
|
---|
407 | tsp1->e_type = EV_LOCN;
|
---|
408 | tsp1->e_data1 = curgrp;
|
---|
409 | tsp1->e_data2 = aux1;
|
---|
410 |
|
---|
411 | p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
412 | eh_ins(tsp1, EH_LOCN);
|
---|
413 |
|
---|
414 | if (verbose)
|
---|
415 | printf("%8ld: Location set to %d\n", t_cur, aux1);
|
---|
416 | CM_OK;
|
---|
417 | }
|
---|
418 | /* |
---|
419 |
|
---|
420 | */
|
---|
421 | if (CM_USTR("goto")) { /* !goto n @ n */
|
---|
422 |
|
---|
423 | if (!CM_NUM)
|
---|
424 | CM_NOGO;
|
---|
425 |
|
---|
426 | curtime = QQnum * 48;
|
---|
427 |
|
---|
428 | if (!CM_CHR('@'))
|
---|
429 | CM_NOGO;
|
---|
430 |
|
---|
431 | if (!CM_NUM)
|
---|
432 | CM_NOGO;
|
---|
433 |
|
---|
434 | sc_goto(curtime += QQnum);
|
---|
435 |
|
---|
436 | if (verbose)
|
---|
437 | printf("\n<Score time set to %ld>\n", t_cur);
|
---|
438 |
|
---|
439 | CM_OK;
|
---|
440 | }
|
---|
441 |
|
---|
442 | /* |
---|
443 |
|
---|
444 | */
|
---|
445 |
|
---|
446 | if (CM_USTR("pos")) { /* !pos = n @ n */
|
---|
447 |
|
---|
448 | if (!CM_CHR('='))
|
---|
449 | CM_NOGO;
|
---|
450 |
|
---|
451 | if (!CM_NUM)
|
---|
452 | CM_NOGO;
|
---|
453 |
|
---|
454 | curtime = QQnum * 48;
|
---|
455 |
|
---|
456 | if (!CM_CHR('@'))
|
---|
457 | CM_NOGO;
|
---|
458 |
|
---|
459 | if (!CM_NUM)
|
---|
460 | CM_NOGO;
|
---|
461 |
|
---|
462 | t_cur = (curtime += QQnum);
|
---|
463 | p_cur = frfind(t_cur, 0);
|
---|
464 |
|
---|
465 | if (verbose)
|
---|
466 | printf("\n<Score time set to %ld>\n", t_cur);
|
---|
467 |
|
---|
468 | CM_OK;
|
---|
469 | }
|
---|
470 | /* |
---|
471 |
|
---|
472 | */
|
---|
473 | if (CM_USTR("beat")) { /* !beat = n */
|
---|
474 |
|
---|
475 | if (!CM_CHR('='))
|
---|
476 | CM_NOGO;
|
---|
477 |
|
---|
478 | if (!CM_NUM)
|
---|
479 | CM_NOGO;
|
---|
480 |
|
---|
481 | t_cur = QQnum * 48;
|
---|
482 | p_cur = frfind(t_cur, 0);
|
---|
483 |
|
---|
484 | if (verbose)
|
---|
485 | printf("\n<Score time set to %ld>\n", t_cur);
|
---|
486 |
|
---|
487 | CM_OK;
|
---|
488 | }
|
---|
489 | /* |
---|
490 |
|
---|
491 | */
|
---|
492 | if (CM_USTR("frame")) { /* !frame = n */
|
---|
493 |
|
---|
494 | if (!CM_CHR('='))
|
---|
495 | CM_NOGO;
|
---|
496 |
|
---|
497 | if (!CM_NUM)
|
---|
498 | CM_NOGO;
|
---|
499 |
|
---|
500 | t_cur = QQnum;
|
---|
501 | p_cur = frfind(t_cur, 0);
|
---|
502 |
|
---|
503 | if (verbose)
|
---|
504 | printf("\n<Score time set to %ld>\n", t_cur);
|
---|
505 |
|
---|
506 | CM_OK;
|
---|
507 | }
|
---|
508 | /* |
---|
509 |
|
---|
510 | */
|
---|
511 | if (CM_USTR("score")) { /* !score = n */
|
---|
512 |
|
---|
513 | if (!CM_CHR('='))
|
---|
514 | CM_NOGO;
|
---|
515 |
|
---|
516 | if (!CM_NUM)
|
---|
517 | CM_NOGO;
|
---|
518 |
|
---|
519 | if (QQnum > 127)
|
---|
520 | CM_NOGO;
|
---|
521 |
|
---|
522 | thescore = QQnum;
|
---|
523 |
|
---|
524 | selscor(thescore);
|
---|
525 |
|
---|
526 | if (verbose)
|
---|
527 | printf("\n<Score %d selected>\n", thescore);
|
---|
528 | CM_OK;
|
---|
529 | }
|
---|
530 | /* |
---|
531 |
|
---|
532 | */
|
---|
533 | if (CM_USTR("weight")) { /* !weight = n */
|
---|
534 |
|
---|
535 | if (!CM_CHR('='))
|
---|
536 | CM_NOGO;
|
---|
537 |
|
---|
538 | if (!CM_NUM)
|
---|
539 | CM_NOGO;
|
---|
540 |
|
---|
541 | if (QQnum > 100L)
|
---|
542 | CM_NOGO;
|
---|
543 |
|
---|
544 | noteper = QQnum;
|
---|
545 |
|
---|
546 | if (verbose)
|
---|
547 | printf("<Note weight = %ld percent>\n", noteper);
|
---|
548 |
|
---|
549 | CM_OK;
|
---|
550 | }
|
---|
551 |
|
---|
552 | if (CM_USTR("snap")) { /* !snap */
|
---|
553 |
|
---|
554 | SEsnap();
|
---|
555 | CM_OK;
|
---|
556 | }
|
---|
557 |
|
---|
558 | if (CM_USTR("wait")) { /* !wait */
|
---|
559 |
|
---|
560 | waitcr();
|
---|
561 | CM_OK;
|
---|
562 | }
|
---|
563 |
|
---|
564 | if (CM_USTR("stop")) { /* !stop */
|
---|
565 |
|
---|
566 | if (E_NULL EQ (tsp1 = e_alc(E_SIZE1))) {
|
---|
567 |
|
---|
568 | nospace("!stop");
|
---|
569 | CM_NOGO;
|
---|
570 | }
|
---|
571 |
|
---|
572 | tsp1->e_time = t_cur;
|
---|
573 | tsp1->e_type = EV_STOP;
|
---|
574 |
|
---|
575 | p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
|
---|
576 |
|
---|
577 | if (verbose)
|
---|
578 | printf("%8ld: Stop entered\n", t_cur);
|
---|
579 | CM_OK;
|
---|
580 | }
|
---|
581 | /* |
---|
582 |
|
---|
583 | */
|
---|
584 | if (CM_USTR("clear")) { /* !clear {n | * | $} */
|
---|
585 |
|
---|
586 | if (CM_NUM) {
|
---|
587 |
|
---|
588 | aux1 = QQnum;
|
---|
589 | sc_clr(aux1);
|
---|
590 |
|
---|
591 | if (verbose)
|
---|
592 | printf("\n<Score %d cleared>\n", aux1);
|
---|
593 |
|
---|
594 | CM_OK;
|
---|
595 | }
|
---|
596 |
|
---|
597 | if (CM_CHR('*')) {
|
---|
598 |
|
---|
599 | scinit();
|
---|
600 |
|
---|
601 | if (verbose)
|
---|
602 | printf("\n<All scores cleared>\n");
|
---|
603 |
|
---|
604 | CM_OK;
|
---|
605 | }
|
---|
606 |
|
---|
607 | if (CM_CHR('$')) {
|
---|
608 |
|
---|
609 | sc_clr(curscor);
|
---|
610 |
|
---|
611 | if (verbose)
|
---|
612 | printf("\n<Current score (%d) cleared>\n", curscor);
|
---|
613 |
|
---|
614 | CM_OK;
|
---|
615 | }
|
---|
616 |
|
---|
617 | CM_NOGO;
|
---|
618 | }
|
---|
619 | /* |
---|
620 |
|
---|
621 | */
|
---|
622 | if (CM_USTR("show")) { /* !show {active | names | sections} */
|
---|
623 |
|
---|
624 | if (CM_USTR("active")) {
|
---|
625 |
|
---|
626 | printf("<Active scores:\n");
|
---|
627 | aux1 = aux2 = 0;
|
---|
628 |
|
---|
629 | for (aux3 = 0; aux3 < 4; aux3++) {
|
---|
630 |
|
---|
631 | printf("<");
|
---|
632 |
|
---|
633 | for (aux4 = 0; aux4 < 16; aux4++) {
|
---|
634 |
|
---|
635 | if (scores[aux1]) {
|
---|
636 |
|
---|
637 | printf("%3d ", aux1);
|
---|
638 | ++aux2;
|
---|
639 |
|
---|
640 | } else {
|
---|
641 |
|
---|
642 | printf("... ");
|
---|
643 | }
|
---|
644 |
|
---|
645 | ++aux1;
|
---|
646 | }
|
---|
647 |
|
---|
648 | printf(">\n");
|
---|
649 | }
|
---|
650 |
|
---|
651 | printf("<%d active scores, score %d is current>\n\n",
|
---|
652 | aux2, curscor);
|
---|
653 | CM_OK;
|
---|
654 | }
|
---|
655 | /* |
---|
656 |
|
---|
657 | */
|
---|
658 | if (CM_USTR("names")) {
|
---|
659 |
|
---|
660 | printf("<Active score names:>\n");
|
---|
661 | aux2 = 0;
|
---|
662 |
|
---|
663 | for (aux1 = 0; aux1 < 128; aux1++) {
|
---|
664 |
|
---|
665 | if (scores[aux1] NE E_NULL) {
|
---|
666 |
|
---|
667 | printf("<%3d: ", aux1);
|
---|
668 | chptr = scname[aux1];
|
---|
669 | printf("[$%08.8lx, $%08.8lx] ",
|
---|
670 | scores[aux1], chptr);
|
---|
671 |
|
---|
672 | for (aux3 = 0; aux3 < 16; aux3++)
|
---|
673 | printf("%c", (*chptr++ & 0xFF));
|
---|
674 |
|
---|
675 | printf(">\n");
|
---|
676 | ++aux2;
|
---|
677 | }
|
---|
678 | }
|
---|
679 |
|
---|
680 | printf("<%d active scores, %d is current>\n\n",
|
---|
681 | aux2, curscor);
|
---|
682 |
|
---|
683 | CM_OK;
|
---|
684 | }
|
---|
685 | /* |
---|
686 |
|
---|
687 | */
|
---|
688 | if (CM_USTR("sections")) {
|
---|
689 |
|
---|
690 | printf("<Active sections:>\n");
|
---|
691 | aux1 = aux2 = 0;
|
---|
692 |
|
---|
693 | for (aux3 = 0; aux3 < 5; aux3++) {
|
---|
694 |
|
---|
695 | printf("<");
|
---|
696 |
|
---|
697 | for (aux4 = 0; aux4 < 10; aux4++) {
|
---|
698 |
|
---|
699 | if (seclist[curscor][aux1]) {
|
---|
700 |
|
---|
701 | printf("%3d ", aux1);
|
---|
702 | ++aux2;
|
---|
703 |
|
---|
704 | } else {
|
---|
705 |
|
---|
706 | printf("... ");
|
---|
707 | }
|
---|
708 |
|
---|
709 | ++aux1;
|
---|
710 | }
|
---|
711 |
|
---|
712 | printf(">\n");
|
---|
713 | }
|
---|
714 |
|
---|
715 | printf("<%d active sections, %d is current>\n\n",
|
---|
716 | aux2, cursect);
|
---|
717 | CM_OK;
|
---|
718 | }
|
---|
719 |
|
---|
720 | CM_NOGO;
|
---|
721 | }
|
---|
722 | /* |
---|
723 |
|
---|
724 | */
|
---|
725 | if (CM_USTR("find")) { /* !find {l | r} n */
|
---|
726 |
|
---|
727 | if (CM_UCHR('l'))
|
---|
728 | aux1 = 1;
|
---|
729 | else if (CM_UCHR('r'))
|
---|
730 | aux1 = 0;
|
---|
731 | else
|
---|
732 | CM_NOGO;
|
---|
733 |
|
---|
734 | if (!CM_NUM)
|
---|
735 | CM_NOGO;
|
---|
736 |
|
---|
737 | tsp1 = frfind(QQnum, aux1);
|
---|
738 |
|
---|
739 | if (tsp1 NE E_NULL) {
|
---|
740 |
|
---|
741 | if (verbose)
|
---|
742 | printf("\n<FIND: Found %ld at $%08.8lx>\n\n",
|
---|
743 | QQnum, tsp1);
|
---|
744 |
|
---|
745 | p_cur = tsp1;
|
---|
746 | t_cur = QQnum;
|
---|
747 |
|
---|
748 | } else {
|
---|
749 |
|
---|
750 | if (verbose)
|
---|
751 | printf("<FIND: Found the current score empty>\n\n");
|
---|
752 |
|
---|
753 | CM_NOGO;
|
---|
754 | }
|
---|
755 |
|
---|
756 | CM_OK;
|
---|
757 | }
|
---|
758 | /* |
---|
759 |
|
---|
760 | */
|
---|
761 | if (CM_USTR("chase")) { /* !chase */
|
---|
762 |
|
---|
763 | if (E_NULL EQ (tsp1 = p_cur)) {
|
---|
764 |
|
---|
765 | printf("<CHASE: Current score not active>\n\n");
|
---|
766 | CM_NOGO;
|
---|
767 | }
|
---|
768 |
|
---|
769 | tsp2 = tsp1;
|
---|
770 |
|
---|
771 | while (tsp2) {
|
---|
772 |
|
---|
773 | tsp3 = &spool[0];
|
---|
774 |
|
---|
775 | if (tsp2 LT tsp3) {
|
---|
776 |
|
---|
777 | printf("\nCHASE: Error\n");
|
---|
778 | printf("** Bad pointer: $%08.8lx\n", tsp2);
|
---|
779 | printf("** spool: $%08.8lx, pspool: $%08.8lx\n",
|
---|
780 | &spool[0], pspool);
|
---|
781 | CM_NOGO;
|
---|
782 | }
|
---|
783 |
|
---|
784 | tsp3 = &spool[MAX_SE-1];
|
---|
785 |
|
---|
786 | if (tsp2 GT tsp3) {
|
---|
787 |
|
---|
788 | printf("\nCHASE: Error\n");
|
---|
789 | printf("** Bad pointer: $%08.8lx\n", tsp2);
|
---|
790 | printf("** spool: $%08.8lx, pspool: $%08.8lx\n",
|
---|
791 | &spool[0], pspool);
|
---|
792 | CM_NOGO;
|
---|
793 | }
|
---|
794 |
|
---|
795 | SEdump(tsp2);
|
---|
796 | tsp2 = tsp2->e_fwd;
|
---|
797 |
|
---|
798 | if ((tsp1 EQ tsp2) OR
|
---|
799 | (tsp2->e_type EQ EV_SCORE)) {
|
---|
800 |
|
---|
801 | printf("-- End of chain --\n\n");
|
---|
802 | break;
|
---|
803 | }
|
---|
804 | }
|
---|
805 |
|
---|
806 | CM_OK;
|
---|
807 | }
|
---|
808 | /* |
---|
809 |
|
---|
810 | */
|
---|
811 | if (CM_USTR("verbose")) { /* !verbose */
|
---|
812 |
|
---|
813 | verbose = TRUE;
|
---|
814 | CM_OK;
|
---|
815 | }
|
---|
816 |
|
---|
817 | if (CM_USTR("quiet")) { /* !quiet */
|
---|
818 |
|
---|
819 | verbose = FALSE;
|
---|
820 | CM_OK;
|
---|
821 | }
|
---|
822 |
|
---|
823 | if (CM_USTR("test")) { /* !test */
|
---|
824 |
|
---|
825 | testing = TRUE;
|
---|
826 | CM_OK;
|
---|
827 | }
|
---|
828 |
|
---|
829 | if (CM_USTR("normal")) { /* !normal */
|
---|
830 |
|
---|
831 | testing = FALSE;
|
---|
832 | CM_OK;
|
---|
833 | }
|
---|
834 |
|
---|
835 | if (CM_USTR("end")) { /* !end */
|
---|
836 |
|
---|
837 | if (verbose)
|
---|
838 | printf("\n<End command encountered>\n");
|
---|
839 |
|
---|
840 | endflg = TRUE;
|
---|
841 | CM_OK;
|
---|
842 | }
|
---|
843 |
|
---|
844 | CM_NOGO;
|
---|
845 | }
|
---|
846 |
|
---|
847 | /* |
---|
848 |
|
---|
849 | */
|
---|
850 |
|
---|
851 | /*
|
---|
852 | =============================================================================
|
---|
853 | Qnote() -- 'note' and rest syntax equation
|
---|
854 |
|
---|
855 | "val [#] oct [+|-|/n]" | "r n / m"
|
---|
856 | e.g.: a#0+ .. a#0- .. c3/4 , r2/1 d3 , e3
|
---|
857 | =============================================================================
|
---|
858 | */
|
---|
859 |
|
---|
860 | int Qnote(void)
|
---|
861 | {
|
---|
862 | struct n_entry *nsp1;
|
---|
863 |
|
---|
864 | if (CM_UCHR('r')) { /* try for a rest */
|
---|
865 |
|
---|
866 | if (!CM_NUM)
|
---|
867 | CM_NOGO;
|
---|
868 |
|
---|
869 | nrest = QQnum;
|
---|
870 |
|
---|
871 | if (!CM_CHR('/'))
|
---|
872 | CM_NOGO;
|
---|
873 |
|
---|
874 | if (!CM_NUM)
|
---|
875 | CM_NOGO;
|
---|
876 |
|
---|
877 | dvwork = 192L;
|
---|
878 | noteval = dvwork / QQnum;
|
---|
879 | t_cur += (noteval * nrest);
|
---|
880 | p_cur = ep_adj(p_cur, 0, t_cur);
|
---|
881 |
|
---|
882 | if (verbose)
|
---|
883 | printf("%8ld: <rest>\n", t_cur);
|
---|
884 |
|
---|
885 | CM_OK;
|
---|
886 | }
|
---|
887 | /* |
---|
888 |
|
---|
889 | */
|
---|
890 | if (!CM_ULIST(nlist)) /* try for a note */
|
---|
891 | CM_NOGO;
|
---|
892 |
|
---|
893 | notepit = QQlnum;
|
---|
894 |
|
---|
895 | if (CM_CHR('#'))
|
---|
896 | sharp = 1;
|
---|
897 | else
|
---|
898 | sharp = 0;
|
---|
899 |
|
---|
900 | if (!CM_DIG)
|
---|
901 | CM_NOGO;
|
---|
902 |
|
---|
903 | if (QQdig > '7')
|
---|
904 | CM_NOGO;
|
---|
905 |
|
---|
906 | notenum = octab[QQdig - '0'] + notetab[notepit] + sharp;
|
---|
907 |
|
---|
908 | if (CM_CHR('+')) { /* output note begin */
|
---|
909 |
|
---|
910 | if (E_NULL EQ (nsp1 = (struct n_entry *)e_alc(E_SIZE1))) {
|
---|
911 |
|
---|
912 | nospace("note event");
|
---|
913 | CM_NOGO;
|
---|
914 | }
|
---|
915 |
|
---|
916 | noteon = t_cur;
|
---|
917 | p_cur = insnevt(nsp1, EV_NBEG, curgrp, notenum, 64);
|
---|
918 |
|
---|
919 | if (verbose)
|
---|
920 | printf("%8ld: Note %3d ON\n", noteon, notenum);
|
---|
921 |
|
---|
922 | CM_OK;
|
---|
923 | }
|
---|
924 | /* |
---|
925 |
|
---|
926 | */
|
---|
927 | if (CM_CHR('-')) { /* output note end */
|
---|
928 |
|
---|
929 | if (E_NULL EQ (nsp1 = (struct n_entry *)e_alc(E_SIZE1))) {
|
---|
930 |
|
---|
931 | nospace("note event");
|
---|
932 | CM_NOGO;
|
---|
933 | }
|
---|
934 |
|
---|
935 | noteoff = t_cur;
|
---|
936 | p_cur = insnevt(nsp1, EV_NEND, curgrp, notenum, 64);
|
---|
937 |
|
---|
938 | if (verbose)
|
---|
939 | printf("%8ld: Note %3d OFF\n", noteoff, notenum);
|
---|
940 |
|
---|
941 | CM_OK;
|
---|
942 | }
|
---|
943 | /* |
---|
944 |
|
---|
945 | */
|
---|
946 | if (CM_CHR('/')) { /* output note begin and end, given value */
|
---|
947 |
|
---|
948 | if (!CM_NUM)
|
---|
949 | CM_NOGO;
|
---|
950 |
|
---|
951 | dvwork = 192L;
|
---|
952 | noteval = dvwork / QQnum;
|
---|
953 | noteon = t_cur;
|
---|
954 | dvwork = 100L;
|
---|
955 | noteoff = t_cur + ((noteper * noteval) / dvwork);
|
---|
956 |
|
---|
957 | if (E_NULL EQ (nsp1 = (struct n_entry *)e_alc(E_SIZE1))) {
|
---|
958 |
|
---|
959 | nospace("note event");
|
---|
960 | CM_NOGO;
|
---|
961 | }
|
---|
962 |
|
---|
963 | p_cur = insnevt(nsp1, EV_NBEG, curgrp, notenum, 64);
|
---|
964 |
|
---|
965 | if (E_NULL EQ (nsp1 = (struct n_entry *)e_alc(E_SIZE1))) {
|
---|
966 |
|
---|
967 | nospace("note event");
|
---|
968 | CM_NOGO;
|
---|
969 | }
|
---|
970 |
|
---|
971 | p_cur = ep_adj(p_cur, 0, (t_cur = noteoff));
|
---|
972 |
|
---|
973 | insnevt(nsp1, EV_NEND, curgrp, notenum, 64);
|
---|
974 |
|
---|
975 | p_cur = ep_adj(p_cur, 0, (t_cur = noteon));
|
---|
976 |
|
---|
977 | if (verbose)
|
---|
978 | printf("%8ld: Note %3d ON at %8ld, OFF at %8ld\n",
|
---|
979 | t_cur, notenum, noteon, noteoff);
|
---|
980 |
|
---|
981 | CM_OK;
|
---|
982 | }
|
---|
983 | /* |
---|
984 |
|
---|
985 | */
|
---|
986 | /* output note begin and end, use previous value */
|
---|
987 |
|
---|
988 | noteon = t_cur;
|
---|
989 | dvwork = 100L;
|
---|
990 | noteoff = t_cur + ((noteval * noteper) / dvwork);
|
---|
991 |
|
---|
992 | if (E_NULL EQ (nsp1 = (struct n_entry *)e_alc(E_SIZE1))) {
|
---|
993 |
|
---|
994 | nospace("note event");
|
---|
995 | CM_NOGO;
|
---|
996 | }
|
---|
997 |
|
---|
998 | p_cur = insnevt(nsp1, EV_NBEG, curgrp, notenum, 64);
|
---|
999 |
|
---|
1000 | if (E_NULL EQ (nsp1 = (struct n_entry *)e_alc(E_SIZE1))) {
|
---|
1001 |
|
---|
1002 | nospace("note event");
|
---|
1003 | CM_NOGO;
|
---|
1004 | }
|
---|
1005 |
|
---|
1006 | p_cur = ep_adj(p_cur, 0, (t_cur = noteoff));
|
---|
1007 |
|
---|
1008 | insnevt(nsp1, EV_NEND, curgrp, notenum, 64);
|
---|
1009 |
|
---|
1010 | p_cur = ep_adj(p_cur, 0, (t_cur = noteon));
|
---|
1011 |
|
---|
1012 | if (verbose)
|
---|
1013 | printf("%8ld: Note %3d ON at %8ld, OFF at %8ld\n",
|
---|
1014 | t_cur, notenum, noteon, noteoff);
|
---|
1015 | CM_OK;
|
---|
1016 | }
|
---|
1017 |
|
---|
1018 | /* |
---|
1019 |
|
---|
1020 | */
|
---|
1021 |
|
---|
1022 | /*
|
---|
1023 | =============================================================================
|
---|
1024 | Qadv() -- 'adv' syntax equation
|
---|
1025 | =============================================================================
|
---|
1026 | */
|
---|
1027 |
|
---|
1028 | int Qadv(void)
|
---|
1029 | {
|
---|
1030 | if (CM_CHR('.')) { /* advance by 1 frame */
|
---|
1031 |
|
---|
1032 | ++t_cur;
|
---|
1033 | p_cur = ep_adj(p_cur, 0, t_cur);
|
---|
1034 | CM_OK;
|
---|
1035 | }
|
---|
1036 |
|
---|
1037 | if (CM_CHR(',')) { /* advance by current note value */
|
---|
1038 |
|
---|
1039 | t_cur += noteval;
|
---|
1040 | p_cur = ep_adj(p_cur, 0, t_cur);
|
---|
1041 | CM_OK;
|
---|
1042 | }
|
---|
1043 |
|
---|
1044 | if (CM_CHR(';')) { /* avance to next beat */
|
---|
1045 |
|
---|
1046 | dvwork = 48L;
|
---|
1047 | t_cur = ((t_cur / dvwork) + 1L) * 48L;
|
---|
1048 | p_cur = ep_adj(p_cur, 0, t_cur);
|
---|
1049 | CM_OK;
|
---|
1050 | }
|
---|
1051 |
|
---|
1052 | if (CM_CHR(':')) { /* advance by one beat interval */
|
---|
1053 |
|
---|
1054 | t_cur += 48L;
|
---|
1055 | p_cur = ep_adj(p_cur, 0, t_cur);
|
---|
1056 | CM_OK;
|
---|
1057 | }
|
---|
1058 |
|
---|
1059 | CM_NOGO;
|
---|
1060 | }
|
---|
1061 |
|
---|
1062 | /* |
---|
1063 |
|
---|
1064 | */
|
---|
1065 |
|
---|
1066 | /*
|
---|
1067 | =============================================================================
|
---|
1068 | Qseq() -- 'seq' syntax equation
|
---|
1069 | =============================================================================
|
---|
1070 | */
|
---|
1071 |
|
---|
1072 | int Qseq(void)
|
---|
1073 | {
|
---|
1074 | CM_DBLK;
|
---|
1075 |
|
---|
1076 | if (!*QQip)
|
---|
1077 | CM_OK;
|
---|
1078 |
|
---|
1079 | if (Qnote() OR Qadv() OR (Qevent() AND !endflg)) {
|
---|
1080 |
|
---|
1081 | CM_DBLK;
|
---|
1082 |
|
---|
1083 | if (!*QQip)
|
---|
1084 | return(QQsw);
|
---|
1085 |
|
---|
1086 | while (QQsw AND !endflg) {
|
---|
1087 |
|
---|
1088 | if (!Qadv())
|
---|
1089 | if (!Qnote())
|
---|
1090 | Qevent();
|
---|
1091 |
|
---|
1092 | CM_DBLK;
|
---|
1093 |
|
---|
1094 | if (!*QQip)
|
---|
1095 | return(QQsw);
|
---|
1096 | }
|
---|
1097 | }
|
---|
1098 |
|
---|
1099 | return(QQsw);
|
---|
1100 | }
|
---|
1101 |
|
---|
1102 | /* |
---|
1103 |
|
---|
1104 | */
|
---|
1105 |
|
---|
1106 | /*
|
---|
1107 | =============================================================================
|
---|
1108 | sqinit() -- setup score interpreter variables
|
---|
1109 | =============================================================================
|
---|
1110 | */
|
---|
1111 |
|
---|
1112 | void sqinit(void)
|
---|
1113 | {
|
---|
1114 | verbose = FALSE;
|
---|
1115 | testing = FALSE;
|
---|
1116 | endflg = FALSE;
|
---|
1117 |
|
---|
1118 | noteval = 48L; /* default value = 1/4 note (192/48) */
|
---|
1119 | noteper = 80L; /* default weight = 80 percent */
|
---|
1120 |
|
---|
1121 | curtime = t_cur = t_ctr = 0L;
|
---|
1122 | t_bak = t_cur - TO_BAK;
|
---|
1123 | t_fwd = t_cur + TO_FWD;
|
---|
1124 |
|
---|
1125 | p_bak = p_cur = p_ctr = p_fwd = E_NULL;
|
---|
1126 |
|
---|
1127 | curgrp = 0;
|
---|
1128 | thescore = 0;
|
---|
1129 | }
|
---|
1130 |
|
---|
1131 | /* |
---|
1132 |
|
---|
1133 | */
|
---|
1134 |
|
---|
1135 | /*
|
---|
1136 | =============================================================================
|
---|
1137 | sqscan(ip) -- scans the string at 'ip' and converts the event
|
---|
1138 | descriptions therein to events in the current score. Returns
|
---|
1139 | the value of the parser switch.
|
---|
1140 | =============================================================================
|
---|
1141 | */
|
---|
1142 |
|
---|
1143 | int sqscan(char *ip)
|
---|
1144 | {
|
---|
1145 | endflg = FALSE;
|
---|
1146 | CMinit(ip);
|
---|
1147 |
|
---|
1148 | if (!Qseq())
|
---|
1149 | CMstat("Syntax error");
|
---|
1150 |
|
---|
1151 | return(QQsw);
|
---|
1152 | }
|
---|