source: buchla-68k/ram/sedump.c@ e225e77

Last change on this file since e225e77 was e225e77, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Added missing includes and declarations.

  • Property mode set to 100644
File size: 15.8 KB
Line 
1/*
2 =============================================================================
3 sedump.c -- dump various kinds of MIDAS-VII data in readable format
4 Version 42 -- 1988-08-24 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "graphdef.h"
9#include "hwdefs.h"
10#include "stddefs.h"
11#include "score.h"
12#include "scfns.h"
13#include "slice.h"
14#include "secdefs.h"
15#include "vsdd.h"
16
17#include "midas.h"
18#include "instdsp.h"
19
20#include "stdio.h"
21
22extern int16_t Pcheck(struct s_entry *ptr, int8_t *msg);
23extern void mdump(int8_t *begin, int8_t *end, int32_t start);
24extern void xtrap15(void);
25
26extern uint16_t scrl;
27
28extern int16_t curfunc;
29extern int16_t curvce;
30extern int16_t sbase;
31extern int16_t sd;
32extern int16_t se;
33extern int16_t soffset;
34extern int16_t subj;
35
36extern int16_t varmode[][16];
37
38extern struct gdsel *gdstbc[NGDSEL];
39extern struct gdsel *gdstbn[NGDSEL];
40extern struct gdsel *gdstbp[NGDSEL];
41
42extern struct gdsel *gdfsep;
43extern struct gdsel gdfsl[MAXFSL];
44
45extern struct instdef vbufs[];
46
47extern int8_t *idbxlbl[];
48extern int8_t *osclbl[];
49
50/*
51
52*/
53
54int8_t *A6PTR = 0L; /* traceback a6 starting address */
55int8_t *A7PTR = 0L; /* traceback a7 starting address */
56int8_t *A7TOP = 0x000FFFFFL; /* traceback stack top */
57
58int16_t SCnumv = 0; /* voice for SCvoice() to dump (0..11) */
59int16_t SL_Flag; /* ROMP trap disable flag */
60int16_t x_unrec; /* unrecognized event type or size flag */
61
62int32_t SCdlim = MAX_SE; /* score dump limit */
63
64int8_t *evkinds[N_ETYPES] = { /* event types (must match score.h) */
65
66 "00: EV_NULL null event ", "01: EV_SCORE score begin ",
67 "02: EV_SBGN section begin", "03: EV_SEND section end ",
68 "04: EV_INST instr. change", "05: EV_NBEG note begin ",
69 "06: EV_NEND note end ", "07: EV_STOP stop ",
70 "08: EV_INTP interpolate ", "09: EV_TMPO tempo ",
71 "0A: EV_TUNE tuning ", "0B: EV_GRP group status ",
72 "0C: EV_LOCN location ", "0D: EV_DYN dynamics ",
73 "0E: EV_ANVL analog value ", "0F: EV_ANRS analog res. ",
74 "10: EV_ASGN I/O assign ", "11: EV_TRNS transposition",
75 "12: EV_REPT repeat ", "13: EV_PNCH punch in/out ",
76 "14: EV_PRES poly pressure", "15: EV_FINI score end ",
77 "16: EV_CPRS chan pressure", "17: EV_BAR bar marker "
78};
79
80int8_t *hpname[N_TYPES] = { /* header type names (must match score.h) */
81
82 "EH_INST", "EH_GRP ", "EH_LOCN", "EH_DYN ",
83 "EH_ANRS", "EH_TRNS", "EH_INTP", "EH_TMPO",
84 "EH_TUNE", "EH_ASGN", "EH_SBGN", "EH_SEND"
85};
86
87int8_t *var_lbl[6] = { /* variable names */
88
89 "Pch/Hor", "Mod/Vrt", "Brth/LP", "GPC/CV1",
90 "Pedal 1", "Key Prs"
91};
92
93int8_t *srcname[] = { /* source names (must match smdefs.h) */
94
95 "NONE", "RAND", "CTL1", "?03?", "?04?", "PTCH", "KPRS", "KVEL",
96 "PED1", "?09?", "FREQ", "HTPW", "VTMW", "LPBR"
97};
98
99int8_t *actname[] = { /* function action names */
100
101 "NULL", "SUST", "ENBL", "JUMP", "LOOP", "KYUP", "KYDN", "HERE"
102};
103
104/*
105
106*/
107
108/*
109 =============================================================================
110 ev_kind(sep) -- returns a pointer to a string describing the event
111 at 'sep', or a NULL pointer if the event is unrecognized.
112 Sets x_unrec according to the result.
113 =============================================================================
114*/
115
116int8_t *ev_kind(struct s_entry *sep)
117{
118 if ((sep->e_type & 0x00FF) GE N_ETYPES) {
119
120 x_unrec = TRUE;
121 return(NULL);
122 }
123
124 x_unrec = FALSE;
125
126 return(evkinds[sep->e_type]);
127}
128
129/*
130
131*/
132
133/*
134 =============================================================================
135 SEctrl() -- print current score pointers and times
136 =============================================================================
137*/
138
139void SEctrl(void)
140{
141 printf("curscor: %d \"%-16.16s\" cursect: %d scp: $%08lX\n\n",
142 curscor, scname[curscor], cursect, scp);
143
144
145 printf(" fc_val: %8ld fc_sw: %d\n\n",
146 fc_val, fc_sw);
147
148
149 printf(" t_bak: %8ld t_cur: %8ld t_ctr: %8ld t_fwd: %8ld\n",
150 t_bak, t_cur, t_ctr, t_fwd);
151
152 printf(" p_bak: $%08lX p_cur: $%08lX p_ctr: $%08lX p_fwd: $%08lX\n\n",
153 p_bak, p_cur, p_ctr, p_fwd);
154
155}
156
157/*
158 =============================================================================
159 SEsnap() -- snap dump critical score storage variables
160 =============================================================================
161*/
162
163void SEsnap(void)
164{
165 register int16_t i, j;
166
167 printf("\n");
168
169 printf("evleft: %ld spcount: %ld frags: %ld\n",
170 evleft(), spcount, frags);
171
172 printf(" se1_cnt=%ld se2_cnt=%ld se3_cnt=%ld\n",
173 se1_cnt, se2_cnt, se3_cnt);
174
175 printf(" pspool=$%08lX size1=$%08lX size2=$%08lX size3=$%08lX\n",
176 pspool, size1, size2, size3);
177
178 SEctrl();
179
180 for (i = 0; i < N_SCORES; i++)
181 printf("%2d: \"%-16.16s\" $%08lX %s\n",
182 i + 1, scname[i], scores[i],
183 (i EQ curscor) ? "<--- curscor" : "");
184
185 printf("\n\n");
186
187 printf("Variable modes for each group:\n\n");
188
189 printf("V# VarName 01 02 03 04 05 06 07 08 09 10 11 12\n");
190 printf("-- ------- -- -- -- -- -- -- -- -- -- -- -- --\n");
191
192 for (i = 0; i < 6; i++) {
193
194 printf("%02d %s ", i, var_lbl[i]);
195
196 for (j = 0; j < 12; j++)
197 printf(" %d ", varmode[i][j]);
198
199 printf("\n");
200 }
201
202 printf("\n");
203}
204
205/*
206
207*/
208
209/*
210 =============================================================================
211 SEdump(sep) -- dumps the event at 'sep' in readable format.
212 Returns 'sep'. Sets x_unrec TRUE if the event is unrecognized,
213 FALSE if the event is recognized.
214 =============================================================================
215*/
216
217struct s_entry *SEdump(struct s_entry *sep)
218{
219 int8_t *et;
220
221 x_unrec = TRUE;
222
223 switch (sep->e_size) {
224
225 case E_SIZE1:
226 case E_SIZE2:
227 case E_SIZE3:
228
229 break;
230
231 default:
232
233 printf("[%08lX]: ** Bad event size: $%02.2X **\n",
234 sep, sep->e_size);
235
236 return(sep);
237 }
238
239 if (NULL EQ (et = ev_kind(sep))) {
240
241 printf("[%08lX]: ** Bad event type: $%02.2X **\n",
242 sep, sep->e_type);
243
244 return(sep);
245 }
246
247 x_unrec = FALSE;
248
249 printf("$%08lX: t=%10ld F:$%08lX B:$%08lX * %s\n",
250 sep, sep->e_time, sep->e_fwd, sep->e_bak, et);
251
252 printf(" data = $%02.2X $%02.2X",
253 0x00FF & sep->e_data1, 0x00FF & sep->e_data2);
254
255 if (sep->e_size EQ E_SIZE1)
256 printf(" $%04.4X $%04.4X",
257 ((struct n_entry *)sep)->e_vel,
258 ((struct n_entry *)sep)->e_data4);
259
260 printf("\n");
261
262 if (sep->e_size GT E_SIZE1)
263 printf(" up: $%08lX dn: $%08lX",
264 sep->e_up, sep->e_dn);
265 else
266 return(sep);
267
268 if (sep->e_size GT E_SIZE2)
269 printf(" lft: $%08lX rgt: $%08lX",
270 sep->e_lft, sep->e_rgt);
271
272 printf("\n");
273
274 return(sep);
275}
276
277/*
278
279*/
280
281/*
282 =============================================================================
283 SEchase() -- print up to 'n' events or to the end of the score,
284 starting with event 'ep'.
285 =============================================================================
286*/
287
288struct s_entry *SEchase(struct s_entry *ep, int32_t n)
289{
290 register int32_t i;
291 register struct s_entry *np;
292
293 printf("\n");
294
295 if (ep EQ E_NULL) {
296
297 printf("NULL pointer\n");
298 return(scp);
299 }
300
301 if (Pcheck(ep, "ep - SEchase()"))
302 return(scp);
303
304 for (i = 0; i < n; i++) {
305
306 SEdump(ep);
307
308 if ((ep->e_type EQ EV_FINI) OR x_unrec)
309 return(scp);
310
311 np = ep->e_fwd;
312
313 if (Pcheck(np, "e_fwd - SEchase()"))
314 return(scp);
315
316 if (Pcheck(ep->e_bak, "e_bak - SEchase()"))
317 return(scp);
318
319 ep = np;
320 }
321
322 printf("\n");
323
324 return(ep);
325}
326
327/*
328
329*/
330
331/*
332 =============================================================================
333 SLdump() -- print slice control data
334 =============================================================================
335*/
336
337void SLdump(void)
338{
339 register int16_t i;
340 register struct gdsel *gp;
341
342 printf("\n");
343
344 printf("sd = %s se = %s sbase = %d soffset = %d scrl = $%04.4X\n",
345 sd ? "BAK" : "FWD", se ? "BAK" : "FWD", sbase, soffset, scrl);
346
347 printf("gdfsep = $%08lX\n\n", gdfsep);
348
349 printf("gr $ gdstbp $ gdstbc $ gdstbn\n");
350 printf(" %08lX %08lX %08lX\n", gdstbp, gdstbc, gdstbn);
351 printf("-- -------- -------- --------\n");
352
353 for (i = 0; i < NGDSEL; i++) {
354
355 printf("%2d %08lX %08lX %08lX\n",
356 i + 1, gdstbp[i], gdstbc[i], gdstbn[i]);
357
358 if (i EQ 11)
359 printf("\n");
360 }
361
362 printf("\n");
363
364 if (SL_Flag EQ FALSE)
365 xtrap15();
366
367 SL_Flag = FALSE;
368}
369
370/*
371
372*/
373
374/*
375 =============================================================================
376 SECdump() -- dump section variables and hplist
377 =============================================================================
378*/
379
380void SECdump(void)
381{
382 register int16_t i;
383
384 printf("p_sbgn = $%08lX p_send = $%08lX\n",
385 p_sbgn, p_send);
386
387 printf("t_sbgn = %8ld t_send = %8ld t_sect = %8ld\n\n",
388 t_sbgn, t_send, t_sect);
389
390
391 printf("p_cbgn = $%08lX p_cend = $%08lX\n",
392 p_cbgn, p_cend);
393
394 printf("t_cbgn = %8ld t_cend = %8ld\n\n",
395 t_cbgn, t_cend);
396
397
398 printf("seclist[curscor][]\n");
399 printf("------------------\n\n");
400
401 printf("Sec Addr_____ Sec Addr_____ Sec Addr_____ Sec Addr_____ Sec Addr_____ \n");
402
403 for (i = 0; i < N_SECTS; i += 5) {
404
405 printf("%2d $%08lX ", i + 1, seclist[curscor][i]);
406
407 if ((i + 1) < N_SECTS)
408 printf("%2d $%08lX ", i + 2, seclist[curscor][i + 1]);
409
410 if ((i + 2) < N_SECTS)
411 printf("%2d $%08lX ", i + 3, seclist[curscor][i + 2]);
412
413 if ((i + 3) < N_SECTS)
414 printf("%2d $%08lX ", i + 4, seclist[curscor][i + 3]);
415
416 if ((i + 4) < N_SECTS)
417 printf("%2d $%08lX ", i + 5, seclist[curscor][i + 4]);
418
419 printf("\n");
420 }
421
422 printf("\n");
423
424 printf("hplist[curscor][]\n");
425 printf("-----------------\n");
426 printf("Type___ Addr_____\n");
427
428 for (i = 0; i < N_TYPES; i++)
429 printf("%s $%08lX\n", hpname[i], hplist[curscor][i]);
430
431 printf("\n");
432}
433
434/*
435
436*/
437
438/*
439 =============================================================================
440 DOA() -- do a simple stack traceback
441 =============================================================================
442*/
443
444void DOA(void)
445{
446 register int32_t *olda6, *cura6;
447 register int16_t n, *prptr;
448
449 if (A6PTR AND A7PTR) {
450
451 printf("Stack dump: $%08lX to $%08lX\n\n", A7PTR, A7TOP);
452 mdump(A7PTR, A7TOP, A7PTR);
453 printf("\n\n");
454 printf("Stack traceback: from A6 = $%08lX\n\n", A6PTR);
455 printf("A6 Old A6 Return\n");
456
457 } else {
458
459 printf("Set A6PTR ($%08lX) and A7PTR ($%08lX) first\n",
460 &A6PTR, &A7PTR);
461
462 xtrap15();
463 }
464
465 cura6 = A6PTR;
466
467 while (cura6) {
468
469 olda6 = *cura6;
470
471 printf("$%08lX: $%08lX $%08lX\n",
472 cura6, olda6, *(cura6 + 4L));
473
474 prptr = cura6 + 8L;
475 n = 8;
476
477 while (prptr < olda6) {
478
479 printf(" +%-4d [$%08lX]: $%04.4X\n",
480 n, prptr, *prptr);
481
482 n += 2;
483 ++prptr;
484 }
485
486 cura6 = olda6;
487 }
488
489 xtrap15();
490}
491
492/*
493
494*/
495
496/*
497 =============================================================================
498 SCPanic() -- print the score control variables
499 =============================================================================
500*/
501
502void SCPanic(void)
503{
504 SEsnap(); /* control data */
505 xtrap15();
506}
507
508/*
509 =============================================================================
510 SCdump() -- print the score control variables and the current score
511 =============================================================================
512*/
513
514void SCdump(void)
515{
516 SEsnap(); /* control data */
517 SECdump(); /* section variables */
518 SEchase(scp, SCdlim); /* current score */
519 xtrap15();
520}
521
522/*
523 =============================================================================
524 SCcrash() -- print all of the score related data and the current score
525 =============================================================================
526*/
527
528void SCcrash(void)
529{
530 SL_Flag = TRUE;
531 SLdump(); /* slice data */
532 SCdump(); /* control data and current score */
533}
534
535/*
536 =============================================================================
537 SCtimes() -- print the score times and pointers
538 =============================================================================
539*/
540
541void SCtimes(void)
542{
543 SEctrl();
544 xtrap15();
545}
546
547/*
548
549*/
550
551/*
552 =============================================================================
553 SCslice() -- print details of the slices
554 =============================================================================
555*/
556
557void SCslice(void)
558{
559 register int16_t i, s;
560 register struct gdsel *gp;
561
562 /* print details of gdstbp */
563
564 s = FALSE;
565
566 for (i = 0; i < NGDSEL; i++) {
567
568 if ((struct gdsel *)NULL NE (gp = gdstbp[i])) {
569
570 if (NOT s) {
571
572 printf("gdstbp:");
573 s = TRUE;
574 }
575
576 while (gp) {
577
578 printf(" %02d:%02d:%d",
579 i + 1, gp->note, gp->code);
580
581 gp = gp->next;
582 }
583 }
584 }
585
586 if (s)
587 printf("\n");
588
589/*
590
591*/
592 /* print details of gdstbc */
593
594 s = FALSE;
595
596 for (i = 0; i < NGDSEL; i++) {
597
598 if ((struct gdsel *)NULL NE (gp = gdstbc[i])) {
599
600 if (NOT s) {
601
602 printf("gdstbc:");
603 s = TRUE;
604 }
605
606 while (gp) {
607
608 printf(" %02d:%02d:%d",
609 i + 1, gp->note, gp->code);
610
611 gp = gp->next;
612 }
613 }
614 }
615
616 if (s)
617 printf("\n");
618/*
619
620*/
621 /* print details of gdstbn */
622
623 s = FALSE;
624
625 for (i = 0; i < NGDSEL; i++) {
626
627 if ((struct gdsel *)NULL NE (gp = gdstbn[i])) {
628
629 if (NOT s) {
630
631 printf("gdstbn:");
632 s = TRUE;
633 }
634
635 while (gp) {
636
637 printf(" %02d:%02d:%d",
638 i + 1, gp->note, gp->code);
639
640 gp = gp->next;
641 }
642 }
643 }
644
645 if (s)
646 printf("\n");
647
648}
649
650/*
651
652*/
653
654/*
655 =============================================================================
656 SCvce() -- dump voice buffer instrument definition
657 =============================================================================
658*/
659
660void SCvce(int16_t n)
661{
662 register int16_t i, j, pif, pt1;
663 register struct instdef *ip;
664 register struct idfnhdr *fp;
665 register struct instpnt *pp;
666
667 ip = &vbufs[n];
668
669 /* dump instrument header */
670
671 printf("VOICE %2d: %-16.16s %-16.16s %-16.16s %-16.16s\n",
672 (1 + n), ip->idhname, ip->idhcom1, ip->idhcom2, ip->idhcom3);
673
674 printf(" flag=%04.4X Cfg=%d #plft=%d WsA=%d WsB=%d\n",
675 ip->idhflag, (0x00FF & ip->idhcfg), (0x00FF & ip->idhplft),
676 (1 + (0x00FF & ip->idhwsa)), (1 + (0x00FF & ip->idhwsb)));
677
678 printf(" Osc 1:%s %c %04.4X 2:%s %c %04.4X 3:%s %c %04.4X 4:%s %c %04.4X\n",
679 osclbl[ip->idhos1c & OC_MOD],
680 ((ip->idhos1c & OC_SYN) ? 'S' : ' '),
681 ip->idhos1v,
682 osclbl[ip->idhos2c & OC_MOD],
683 ((ip->idhos2c & OC_SYN) ? 'S' : ' '),
684 ip->idhos2v,
685 osclbl[ip->idhos3c & OC_MOD],
686 ((ip->idhos3c & OC_SYN) ? 'S' : ' '),
687 ip->idhos3v,
688 osclbl[ip->idhos4c & OC_MOD],
689 ((ip->idhos4c & OC_SYN) ? 'S' : ' '),
690 ip->idhos4v);
691
692 /* dump function headers */
693
694 printf("\nFunction headers\n");
695
696 printf(" Fn Pch Mult Sr Pif Pt1 Cpt Md Pr Trg \n");
697 printf(" -- ---- ---- -- --- --- --- -- -- ----\n");
698
699 for (i = 0; i < NFINST; i++) {
700
701 fp = &ip->idhfnc[i];
702
703 printf(" %2d %04.4X %04.4X %02X %3d %3d %3d %02x %02x %04.4x %s\n",
704 i, fp->idfpch, fp->idfmlt, (0x00FF & fp->idfsrc),
705 (0x00FF & fp->idfpif), (0x00FF & fp->idfpt1),
706 (0x00FF & fp->idfcpt), (0x00FF & fp->idftmd),
707 (0x00FF & fp->idfprm), fp->idftrg, idbxlbl[i]);
708
709 }
710
711 /* dump occupied points for each function */
712
713 printf("\nOccupied points\n");
714 printf(" Fn Fpt Ipt Time Val Mult Src Act P1 P2 P3 Pd\n");
715 printf(" -- --- --- ---- ---- ---- ---- ---- -- -- -- --\n");
716
717 for (i = 0; i < NFINST; i++) {
718
719 fp = &ip->idhfnc[i];
720 pif = 0x00FF & fp->idfpif;
721 pt1 = 0x00FF & fp->idfpt1;
722
723 for (j = 0; j < pif; j++) {
724
725 pp = &ip->idhpnt[pt1 + j];
726
727 printf(" %2d %3d %3d %04.4X %04.4X %04.4X %4s %4s %2X %2X %2X %2X\n",
728 i, j, (pt1 + j), pp->iptim, pp->ipval, pp->ipvmlt,
729 srcname[0x00FF & pp->ipvsrc],
730 actname[0x00FF & pp->ipact],
731 (0x00FF & pp->ippar1), (0x00FF & pp->ippar2),
732 (0x00FF & pp->ippar3), (0x00FF & pp->ippad));
733 }
734 }
735
736 printf("\n");
737}
738
739/*
740
741*/
742
743/*
744 =============================================================================
745 SCvces() -- dump voice buffer instrument definitions
746 =============================================================================
747*/
748
749void SCvces(void)
750{
751 register int16_t i;
752
753 for (i = 0; i < 12; i++)
754 SCvce(i);
755
756 xtrap15();
757}
758
759/*
760 =============================================================================
761 SCvoice() -- dump voice buffer instrument definition
762 =============================================================================
763*/
764
765void SCvoice(void)
766{
767 SCvce(SCnumv);
768 xtrap15();
769}
Note: See TracBrowser for help on using the repository browser.