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

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

Added include files for global functions and variables.

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