comparison tests/plrtest.c @ 1603:2d7511e61403

Cleanup plrtest.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 14 May 2018 10:34:36 +0300
parents 0d173edbabe2
children 93d1050eac99
comparison
equal deleted inserted replaced
1602:096767827bb8 1603:2d7511e61403
18 18
19 #define jmpNMODEffectTable (36) 19 #define jmpNMODEffectTable (36)
20 static const char jmpMODEffectTable[jmpNMODEffectTable] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 20 static const char jmpMODEffectTable[jmpNMODEffectTable] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
21 21
22 22
23 void printRow(FILE * f, JSSPattern * p, int row) 23 void printRow(FILE * fh, const JSSPattern * pat, const int row)
24 { 24 {
25 int j, k; 25 const JSSNote *note = &(pat->data[pat->nchannels * row]);
26 char c; 26 int width = pat->nchannels < 5 ? pat->nchannels : 5;
27 JSSNote *n; 27
28 28 fprintf(fh, "%.2x: ", row);
29 if (!p) 29
30 return; 30 for (int channel = 0; channel < width; channel++)
31 31 {
32 n = &(p->data[p->nchannels * row]); 32 switch (note->note)
33
34 fprintf(f, "%.2x: ", row);
35
36 k = p->nchannels < 5 ? p->nchannels : 5;
37
38 for (j = 0; j < k; j++)
39 {
40 switch (n->note)
41 { 33 {
42 case jsetNotSet: 34 case jsetNotSet:
43 fprintf(f, "... "); 35 fprintf(fh, "... ");
44 break; 36 break;
45 case jsetNoteOff: 37 case jsetNoteOff:
46 fprintf(f, "=== "); 38 fprintf(fh, "=== ");
47 break; 39 break;
48 default: 40 default:
49 fprintf(f, "%s%i ", patNoteTable[n->note % 12], n->note / 12); 41 fprintf(fh, "%s%d ",
42 patNoteTable[note->note % 12],
43 note->note / 12);
50 break; 44 break;
51 } 45 }
52 46
53 if (n->instrument != jsetNotSet) 47 if (note->instrument != jsetNotSet)
54 fprintf(f, "%.2x ", n->instrument + 1); 48 fprintf(fh, "%.2x ", note->instrument + 1);
55 else 49 else
56 fprintf(f, ".. "); 50 fprintf(fh, ".. ");
57 51
58 if (n->volume == jsetNotSet) 52 if (note->volume == jsetNotSet)
59 fprintf(f, ".. "); 53 fprintf(fh, ".. ");
60 else if (n->volume >= 0x00 && n->volume <= 0x40) 54 else
61 fprintf(f, "%.2x ", n->volume); 55 if (note->volume >= 0x00 && note->volume <= 0x40)
62 else 56 fprintf(fh, "%.2x ", note->volume);
63 { 57 else
64 switch (n->volume & 0xf0) 58 {
59 char ch;
60 switch (note->volume & 0xf0)
65 { 61 {
66 case 0x50: c = '-'; break; 62 case 0x50: ch = '-'; break;
67 case 0x60: c = '+'; break; 63 case 0x60: ch = '+'; break;
68 case 0x70: c = '/'; break; 64 case 0x70: ch = '/'; break;
69 case 0x80: c = '\\'; break; 65 case 0x80: ch = '\\'; break;
70 case 0x90: c = 'S'; break; 66 case 0x90: ch = 'S'; break;
71 case 0xa0: c = 'V'; break; 67 case 0xa0: ch = 'V'; break;
72 case 0xb0: c = 'P'; break; 68 case 0xb0: ch = 'P'; break;
73 case 0xc0: c = '<'; break; 69 case 0xc0: ch = '<'; break;
74 case 0xd0: c = '>'; break; 70 case 0xd0: ch = '>'; break;
75 case 0xe0: c = 'M'; break; 71 case 0xe0: ch = 'M'; break;
76 default: c = '?'; break; 72 default: ch = '?'; break;
77 } 73 }
78 fprintf(f, "%c%x ", c, (n->volume & 0x0f)); 74 fprintf(fh, "%c%x ",
79 } 75 ch, note->volume & 0x0f);
80 76 }
81 if (n->effect >= 0 && n->effect < jmpNMODEffectTable) 77
82 fprintf(f, "%c", jmpMODEffectTable[n->effect]); 78 if (note->effect >= 0 && note->effect < jmpNMODEffectTable)
83 else if (n->effect == jsetNotSet) 79 fprintf(fh, "%c", jmpMODEffectTable[note->effect]);
84 fprintf(f, "."); 80 else
85 else 81 fprintf(fh, "%c", note->effect == jsetNotSet ? '.' : '?');
86 fprintf(f, "?"); 82
87 83 if (note->param != jsetNotSet)
88 if (n->param != jsetNotSet) 84 fprintf(fh, "%.2x|", note->param);
89 fprintf(f, "%.2x|", n->param); 85 else
90 else 86 fprintf(fh, "..|");
91 fprintf(f, "..|"); 87
92 88 note++;
93 n++;
94 } 89 }
95 } 90 }
96 91
97 92
98 void audioCallback(void *userdata, Uint8 *stream, int len) 93 void audioCallback(void *userdata, Uint8 *stream, int len)
219 214
220 // Initialize playing 215 // Initialize playing
221 jvmSetCallback(dev, jmpExec, plr); 216 jvmSetCallback(dev, jmpExec, plr);
222 jmpSetModule(plr, mod); 217 jmpSetModule(plr, mod);
223 jmpPlayOrder(plr, 0); 218 jmpPlayOrder(plr, 0);
224 jvmSetGlobalVol(dev, 60); 219 jvmSetGlobalVol(dev, 100);
225 220
226 // okay, main loop here ... "play" module and print out info 221 // okay, main loop here ... "play" module and print out info
227 printf("----------------------------------------------------\n"); 222 printf("----------------------------------------------------\n");
228 SDL_LockAudio(); 223 SDL_LockAudio();
229 SDL_PauseAudio(0); 224 SDL_PauseAudio(0);