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

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

No more pointer-int conversions.

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