Mercurial > hg > dmlib
annotate jssplr.c @ 172:cfb087000db3
Clear player channel data as well in here.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 06 Oct 2012 09:37:34 +0300 |
parents | 2023c2d8d6e7 |
children | 520c18f581c7 |
rev | line source |
---|---|
0 | 1 /* |
2 * miniJSS - Module playing routines | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
142 | 4 * (C) Copyright 2006-2012 Tecnic Software productions (TNSP) |
0 | 5 */ |
6 #include "jssplr.h" | |
7 #include <string.h> | |
8 #include <stdlib.h> | |
9 | |
10 // FIXME!! FIX ME! | |
11 #include <math.h> | |
12 | |
13 /* Miscellaneous tables | |
14 */ | |
15 #define jmpNSineTable (256) | |
16 static int *jmpSineTable = NULL; | |
17 | |
18 | |
19 static const Sint16 jmpXMAmigaPeriodTab[13 * 8] = { | |
20 907, 900, 894, 887, 881, 875, 868, 862, 856, 850, 844, 838, | |
21 832, 826, 820, 814, 808, 802, 796, 791, 785, 779, 774, 768, | |
22 762, 757, 752, 746, 741, 736, 730, 725, 720, 715, 709, 704, | |
23 699, 694, 689, 684, 678, 675, 670, 665, 660, 655, 651, 646, | |
24 640, 636, 632, 628, 623, 619, 614, 610, 604, 601, 597, 592, | |
25 588, 584, 580, 575, 570, 567, 563, 559, 555, 551, 547, 543, | |
26 538, 535, 532, 528, 524, 520, 516, 513, 508, 505, 502, 498, | |
27 494, 491, 487, 484, 480, 477, 474, 470, 467, 463, 460, 457, | |
28 | |
29 453, 450, 447, 443, 440, 437, 434, 431 | |
30 }; | |
31 | |
32 | |
33 #define jmpNMODEffectTable (36) | |
34 static const char jmpMODEffectTable[jmpNMODEffectTable] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
35 | |
36 | |
37 /* Helper functions | |
38 */ | |
136 | 39 static int jmpNoteToAmigaPeriod(int note, int finetune) |
0 | 40 { |
154 | 41 int tmp = dmClamp(note + finetune + 8, 0, 103); |
0 | 42 return jmpXMAmigaPeriodTab[tmp]; |
43 } | |
44 | |
45 | |
46 static int jmpGetPeriodFromNote(JSSPlayer *mp, int note, int finetune) | |
47 { | |
48 int res; | |
49 | |
50 if (JMPGETMODFLAGS(mp, jmdfAmigaPeriods)) | |
51 { | |
52 int mfinetune = finetune / 16, | |
53 mnote = (note % 12) * 8, | |
54 moctave = note / 12, | |
55 period1, period2; | |
56 | |
57 period1 = jmpNoteToAmigaPeriod(mnote, mfinetune); | |
58 | |
59 if (finetune < 0) | |
60 { | |
61 mfinetune--; | |
62 finetune = -finetune; | |
63 } else | |
64 mfinetune++; | |
65 | |
66 period2 = jmpNoteToAmigaPeriod(mnote, mfinetune); | |
67 | |
68 mfinetune = finetune & 15; | |
69 period1 *= (16 - mfinetune); | |
70 period2 *= mfinetune; | |
71 | |
72 res = ((period1 + period2) * 2) >> moctave; | |
73 | |
74 //fprintf(stderr, "jmpGetAmigaPeriod(%d, %d) = %d\n", note, finetune, res); | |
75 } | |
76 else | |
77 { | |
78 //fprintf(stderr, "jmpGetLinearPeriod(%d, %d) = %d\n", note, finetune, res); | |
79 //res = ((120 - note) << 6) - (finetune / 2); | |
80 res = 7680 - (note * 64) - (finetune / 2); | |
81 if (res < 1) res = 1; | |
82 } | |
83 | |
84 return res; | |
85 } | |
86 | |
87 | |
88 static void jmpCSetPitch(JSSPlayer *mp, int channel, int value) | |
89 { | |
90 assert(mp != NULL); | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
91 assert(mp->device != NULL); |
0 | 92 |
93 if (value > 0) | |
94 { | |
95 if (JMPGETMODFLAGS(mp, jmdfAmigaPeriods)) | |
96 { | |
97 // Frequency = 8363*1712 / Period | |
98 //fprintf(stderr, "jmpCSetPitch::AMIGA(%d, %d)\n", channel, value); | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
99 jvmSetFreq(mp->device, channel, 14317456.0f / (double) value); |
0 | 100 } |
101 else | |
102 { | |
103 // Frequency = Frequency = 8363*2^((6*12*16*4 - Period) / (12*16*4)) | |
104 //fprintf(stderr, "jmpCSetPitch::Linear(%d, %d)\n", channel, value); | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
105 jvmSetFreq(mp->device, channel, |
0 | 106 8363.0f * pow(2.0f, (4608.0f - (double) value) / 768.0f)); |
107 } | |
108 } | |
109 } | |
110 | |
111 | |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
112 static void jmpCSetVolume(JSSPlayer * mp, JSSPlayerChannel *chn, int channel, int volume, int init) |
0 | 113 { |
114 assert(mp != NULL); | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
115 assert(mp->device != NULL); |
0 | 116 |
154 | 117 volume = dmClamp(volume, mpMinVol, mpMaxVol); |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
118 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
119 //fprintf(stderr, "chn %d: vol=%d, fad=%d, env=%d\n", channel, volume, chn->iCFadeOutVol, chn->iCVolEnv); |
157 | 120 |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
121 if (mp->future == NULL) |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
122 { |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
123 jvmSetVolume(mp->device, channel, |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
124 (chn->iCFadeOutVol * chn->iCVolEnv * volume) / (16 * 65536)); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
125 } |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
126 else |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
127 if (init) |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
128 { |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
129 jvmSetVolumeRamp(mp->device, channel, |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
130 0, |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
131 jvmGetVolume(mp->future->device, channel), 5); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
132 } |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
133 else |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
134 { |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
135 jvmSetVolumeRamp(mp->device, channel, |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
136 (chn->iCFadeOutVol * chn->iCVolEnv * volume) / (16 * 65536), |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
137 jvmGetVolume(mp->future->device, channel), 0); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
138 } |
0 | 139 } |
140 | |
141 | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
142 static void jmpCSetPanning(JSSPlayer * mp, JSSPlayerChannel *chn, int channel, int panning) |
0 | 143 { |
144 assert(mp != NULL); | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
145 assert(mp->device != NULL); |
0 | 146 |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
147 if (mp->future == NULL) |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
148 { |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
149 jvmSetPan(mp->device, channel, |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
150 panning + (((chn->iCPanEnv - 32) * (128 - abs(panning - 128))) / 32)); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
151 } |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
152 else |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
153 { |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
154 jvmSetPanRamp(mp->device, channel, |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
155 panning + (((chn->iCPanEnv - 32) * (128 - abs(panning - 128))) / 32), |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
156 jvmGetPan(mp->future->device, channel), 0); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
157 } |
0 | 158 } |
159 | |
160 | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
161 static int jmpFindEnvPoint(JSSEnvelope * env, const int pos) |
0 | 162 { |
163 int i; | |
164 | |
165 for (i = 0; i < env->npoints - 1; i++) | |
166 { | |
167 if (env->points[i].frame <= pos && | |
168 env->points[i + 1].frame >= pos) | |
169 return i; | |
170 } | |
171 | |
172 return -1; | |
173 } | |
174 | |
175 | |
176 static void jmpExecEnvelope(JSSEnvelope * env, BOOL keyOff, int * frames, BOOL * doExec, int * result) | |
177 { | |
178 int currPoint, delta; | |
179 JSSEnvelopePoint *ipf1, *ipf2; | |
180 | |
181 // OK, find the current point based on frame | |
182 currPoint = jmpFindEnvPoint(env, *frames); | |
183 | |
184 // Check if the envelope has ended | |
185 if (currPoint < 0 && (env->flags & jenvfLooped) == 0) | |
186 { | |
187 *doExec = FALSE; | |
188 return; | |
189 } | |
190 | |
191 // Do the envelope looping here, if needed | |
192 if ((env->flags & jenvfLooped) && *frames >= env->points[env->loopE].frame) | |
193 { | |
194 currPoint = env->loopS; | |
195 *frames = env->points[currPoint].frame; | |
196 } | |
197 | |
198 // If the current point is OK, then process the envelope | |
199 if (currPoint >= 0) | |
200 { | |
201 // Linearly interpolate the value for given frame | |
202 ipf1 = &env->points[currPoint]; | |
203 ipf2 = &env->points[currPoint + 1]; | |
204 | |
205 delta = (ipf2->frame - ipf1->frame); | |
206 if (delta > 0) | |
207 *result = ipf1->value + ((ipf2->value - ipf1->value) * (*frames - ipf1->frame)) / delta; | |
208 else | |
209 *result = ipf1->value; | |
210 } | |
211 | |
212 // The frame counter IS processed even if the envelope is not! | |
213 if ((env->flags & jenvfSustain) && currPoint == env->sustain && | |
214 env->points[currPoint].frame == env->points[env->sustain].frame) { | |
215 if (keyOff) (*frames)++; | |
216 } else | |
217 (*frames)++; | |
218 } | |
219 | |
220 | |
61
a33e47232161
Silence some "unused parameter" warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
221 static void jmpProcessExtInstrument(JSSPlayerChannel *chn, int channel) |
0 | 222 { |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
223 JSSExtInstrument *inst = chn->iCExtInstrument; |
61
a33e47232161
Silence some "unused parameter" warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
224 (void) channel; |
0 | 225 |
226 // Get the instrument for envelope data | |
227 if (!inst) return; | |
228 | |
229 // Process the autovibrato | |
230 /* | |
231 FIXME fix me FIX me!!! todo. | |
232 */ | |
233 | |
234 // Process the volume envelope | |
235 if (inst->volumeEnv.flags & jenvfUsed) | |
236 { | |
169
13f27b9882bc
Backed out changeset 21f54947eb18. No, it isn't. :(
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
237 // Process the instrument volume fadeout |
13f27b9882bc
Backed out changeset 21f54947eb18. No, it isn't. :(
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
238 if (chn->iCKeyOff && chn->iCFadeOutVol > 0 && inst->fadeOut > 0) |
13f27b9882bc
Backed out changeset 21f54947eb18. No, it isn't. :(
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
239 { |
13f27b9882bc
Backed out changeset 21f54947eb18. No, it isn't. :(
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
240 int tmp = chn->iCFadeOutVol - inst->fadeOut; |
13f27b9882bc
Backed out changeset 21f54947eb18. No, it isn't. :(
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
241 if (tmp < 0) tmp = 0; |
13f27b9882bc
Backed out changeset 21f54947eb18. No, it isn't. :(
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
242 chn->iCFadeOutVol = tmp; |
13f27b9882bc
Backed out changeset 21f54947eb18. No, it isn't. :(
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
243 |
13f27b9882bc
Backed out changeset 21f54947eb18. No, it isn't. :(
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
244 JMPSETNDFLAGS(cdfNewVolume); |
13f27b9882bc
Backed out changeset 21f54947eb18. No, it isn't. :(
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
245 } |
13f27b9882bc
Backed out changeset 21f54947eb18. No, it isn't. :(
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
246 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
247 if (chn->iCVolEnv_Exec) |
0 | 248 { |
249 // Execute the volume envelope | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
250 jmpExecEnvelope(&(inst->volumeEnv), |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
251 chn->iCKeyOff, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
252 &(chn->iCVolEnv_Frames), &(chn->iCVolEnv_Exec), |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
253 &(chn->iCVolEnv)); |
0 | 254 |
255 JMPSETNDFLAGS(cdfNewVolume); | |
256 } | |
257 } | |
258 else | |
259 { | |
260 // If the envelope is not used, set max volume | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
261 if (chn->iCVolEnv != mpMaxVol) |
0 | 262 { |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
263 chn->iCVolEnv = mpMaxVol; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
264 chn->iCFadeOutVol = mpMaxFadeoutVol; |
0 | 265 JMPSETNDFLAGS(cdfNewVolume); |
266 } | |
267 } | |
268 | |
269 // Process the panning envelope | |
270 if (inst->panningEnv.flags & jenvfUsed) | |
271 { | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
272 if (chn->iCPanEnv_Exec) |
0 | 273 { |
274 // Execute the panning envelope | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
275 jmpExecEnvelope(&(inst->panningEnv), chn->iCKeyOff, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
276 &(chn->iCPanEnv_Frames), &(chn->iCPanEnv_Exec), |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
277 &(chn->iCPanEnv)); |
0 | 278 |
279 JMPSETNDFLAGS(cdfNewPanPos); | |
280 } | |
281 } | |
282 else | |
283 { | |
284 // If the envelope is not used, set center panning | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
285 if (chn->iCPanEnv != mpPanCenter) |
0 | 286 { |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
287 chn->iCPanEnv = mpPanCenter; |
0 | 288 JMPSETNDFLAGS(cdfNewPanPos); |
289 } | |
290 } | |
291 } | |
292 | |
293 | |
294 /* | |
295 * The player | |
296 */ | |
297 JSSPlayer *jmpInit(JSSMixer *pDevice) | |
298 { | |
299 JSSPlayer *mp; | |
300 | |
301 // Initialize global tables | |
302 if (jmpSineTable == NULL) | |
303 { | |
304 int i; | |
305 if ((jmpSineTable = dmMalloc(jmpNSineTable * sizeof(int))) == NULL) | |
306 JSSERROR(DMERR_MALLOC, NULL, "Could not allocate memory for sinus table.\n"); | |
307 | |
308 for (i = 0; i < 256; i++) | |
309 { | |
310 float f = ((float) i * M_PI * 2.0f) / 256.0f; | |
311 jmpSineTable[i] = (int) (sin(f) * 2048.0f); | |
312 } | |
313 } | |
314 | |
315 // Allocate a player structure | |
316 mp = dmMalloc0(sizeof(JSSPlayer)); | |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
317 if (mp == NULL) |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
318 JSSERROR(DMERR_MALLOC, NULL, "Could not allocate memory for player structure.\n"); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
319 |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
320 mp->future = dmMalloc0(sizeof(JSSPlayer)); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
321 if (mp->future == NULL) |
0 | 322 JSSERROR(DMERR_MALLOC, NULL, "Could not allocate memory for player structure.\n"); |
323 | |
324 // Set variables | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
325 mp->device = pDevice; |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
326 mp->future->device = jvmInit(pDevice->outFormat, pDevice->outChannels, pDevice->outFreq, JMIX_AUTO); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
327 if (mp->future->device == NULL) |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
328 JSSERROR(DMERR_INIT_FAIL, NULL, "Could not initialize shadow mixing device.\n"); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
329 |
0 | 330 #ifdef JSS_SUP_THREADS |
331 mp->mutex = dmCreateMutex(); | |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
332 mp->future->mutex = dmCreateMutex(); |
0 | 333 #endif |
334 | |
335 return mp; | |
336 } | |
337 | |
338 | |
339 int jmpClose(JSSPlayer * mp) | |
340 { | |
341 if (mp == NULL) | |
342 return DMERR_NULLPTR; | |
343 | |
344 // Stop player | |
345 jmpStop(mp); | |
346 | |
347 // Deallocate resources | |
348 #ifdef JSS_SUP_THREADS | |
349 dmDestroyMutex(mp->mutex); | |
350 #endif | |
351 | |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
352 if (mp->future != NULL) |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
353 { |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
354 #ifdef JSS_SUP_THREADS |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
355 dmDestroyMutex(mp->future->mutex); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
356 #endif |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
357 jvmClose(mp->future->device); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
358 dmFree(mp->future); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
359 } |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
360 |
0 | 361 // Clear structure |
362 memset(mp, 0, sizeof(JSSPlayer)); | |
363 dmFree(mp); | |
364 | |
365 return DMERR_OK; | |
366 } | |
367 | |
368 | |
369 /* Reset the envelopes for given channel. | |
370 */ | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
371 static void jmpResetEnvelopes(JSSPlayerChannel *chn) |
0 | 372 { |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
373 chn->iCPanEnv_Frames = chn->iCVolEnv_Frames = 0; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
374 chn->iCPanEnv_Exec = chn->iCVolEnv_Exec = TRUE; |
0 | 375 } |
376 | |
377 | |
378 /* Clear module player structure | |
379 */ | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
380 void jmpClearChannel(JSSPlayerChannel *chn) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
381 { |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
382 memset(chn, 0, sizeof(JSSPlayerChannel)); |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
383 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
384 chn->iCNote = jsetNotSet; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
385 chn->iCInstrumentN = jsetNotSet; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
386 chn->iCExtInstrumentN = jsetNotSet; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
387 chn->iCPanning = mpPanCenter; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
388 chn->iCPanEnv = mpPanCenter; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
389 } |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
390 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
391 |
0 | 392 void jmpClearPlayer(JSSPlayer * mp) |
393 { | |
394 int i; | |
395 assert(mp != NULL); | |
396 JSS_LOCK(mp); | |
397 | |
398 // Initialize general variables | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
399 mp->patternDelay = 0; |
170 | 400 mp->newRowSet = FALSE; |
401 mp->newOrderSet = FALSE; | |
402 mp->tick = jsetNotSet; | |
403 mp->row = 0; | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
404 mp->lastPatLoopRow = 0; |
0 | 405 |
406 // Initialize channel data | |
407 for (i = 0; i < jsetNChannels; i++) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
408 jmpClearChannel(&mp->channels[i]); |
0 | 409 |
410 JSS_UNLOCK(mp); | |
411 } | |
412 | |
413 | |
414 /* Set module | |
415 */ | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
416 void jmpSetModule(JSSPlayer * mp, JSSModule * module) |
0 | 417 { |
418 assert(mp != NULL); | |
419 JSS_LOCK(mp); | |
420 | |
421 jmpStop(mp); | |
422 jmpClearPlayer(mp); | |
423 | |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
424 mp->future->module = mp->module = module; |
0 | 425 |
426 JSS_UNLOCK(mp); | |
427 } | |
428 | |
429 | |
430 /* Stop playing | |
431 */ | |
432 void jmpStop(JSSPlayer * mp) | |
433 { | |
434 assert(mp != NULL); | |
435 JSS_LOCK(mp); | |
436 | |
437 if (mp->isPlaying) | |
438 { | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
439 jvmRemoveCallback(mp->device); |
0 | 440 mp->isPlaying = FALSE; |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
441 |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
442 if (mp->future != NULL) |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
443 jmpStop(mp->future); |
0 | 444 } |
445 | |
446 JSS_UNLOCK(mp); | |
447 } | |
448 | |
449 | |
450 /* Resume playing | |
451 */ | |
452 void jmpResume(JSSPlayer * mp) | |
453 { | |
454 assert(mp != NULL); | |
455 JSS_LOCK(mp); | |
456 | |
457 if (!mp->isPlaying) | |
458 { | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
459 int result = jvmSetCallback(mp->device, jmpExec, (void *) mp); |
0 | 460 if (result != DMERR_OK) |
461 JSSERROR(result,, "Could not initialize callback for player.\n"); | |
462 | |
463 mp->isPlaying = TRUE; | |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
464 if (mp->future != NULL) |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
465 jmpResume(mp->future); |
0 | 466 } |
467 | |
468 JSS_UNLOCK(mp); | |
469 } | |
470 | |
471 | |
472 /* Sets new order using given value as reference. | |
473 * Jumps over skip-points and invalid values, loops | |
474 * to first order if enabled. | |
475 */ | |
476 static void jmpSetNewOrder(JSSPlayer * mp, int order) | |
477 { | |
478 BOOL orderOK; | |
479 int pattern; | |
480 | |
481 pattern = jsetOrderEnd; | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
482 mp->order = jsetNotSet; |
0 | 483 orderOK = FALSE; |
484 | |
485 while (!orderOK) | |
486 { | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
487 if (order < 0 || order >= mp->module->norders) |
0 | 488 { |
489 jmpStop(mp); | |
490 orderOK = TRUE; | |
491 } | |
492 else | |
493 { | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
494 pattern = mp->module->orderList[order]; |
0 | 495 if (pattern == jsetOrderSkip) |
496 { | |
497 order++; | |
498 } | |
499 else | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
500 if (pattern >= mp->module->npatterns || pattern == jsetOrderEnd) |
0 | 501 { |
502 jmpStop(mp); | |
503 orderOK = TRUE; | |
504 } | |
505 else | |
506 { | |
507 // All OK | |
508 orderOK = TRUE; | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
509 mp->pattern = mp->module->patterns[pattern]; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
510 mp->npattern = pattern; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
511 mp->order = order; |
0 | 512 } |
513 } | |
514 } | |
515 } | |
516 | |
517 | |
518 /* Set new tempo-value of the player. | |
519 */ | |
136 | 520 static void jmpSetTempo(JSSPlayer * mp, int tempo) |
0 | 521 { |
522 assert(mp != NULL); | |
523 JSS_LOCK(mp); | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
524 assert(mp->device != NULL); |
0 | 525 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
526 mp->tempo = tempo; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
527 jvmSetCallbackFreq(mp->device, (tempo * 2) / 5); |
0 | 528 JSS_UNLOCK(mp); |
529 } | |
530 | |
531 | |
136 | 532 static void jmpClearChannels(JSSPlayer * mp) |
0 | 533 { |
534 int i; | |
535 assert(mp != NULL); | |
536 JSS_LOCK(mp); | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
537 assert(mp->device != NULL); |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
538 assert(mp->module != NULL); |
0 | 539 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
540 for (i = 0; i < mp->module->nchannels; i++) |
0 | 541 { |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
542 jvmStop(mp->device, i); |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
543 jvmClear(mp->device, i); |
0 | 544 } |
545 | |
172
cfb087000db3
Clear player channel data as well in here.
Matti Hamalainen <ccr@tnsp.org>
parents:
171
diff
changeset
|
546 // Initialize channel data |
cfb087000db3
Clear player channel data as well in here.
Matti Hamalainen <ccr@tnsp.org>
parents:
171
diff
changeset
|
547 for (i = 0; i < jsetNChannels; i++) |
cfb087000db3
Clear player channel data as well in here.
Matti Hamalainen <ccr@tnsp.org>
parents:
171
diff
changeset
|
548 jmpClearChannel(&mp->channels[i]); |
cfb087000db3
Clear player channel data as well in here.
Matti Hamalainen <ccr@tnsp.org>
parents:
171
diff
changeset
|
549 |
0 | 550 JSS_UNLOCK(mp); |
551 } | |
552 | |
553 | |
554 /* Starts playing module from a given ORDER. | |
555 */ | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
556 int jmpPlayOrder(JSSPlayer * mp, int order) |
0 | 557 { |
558 int result; | |
559 assert(mp != NULL); | |
560 | |
561 JSS_LOCK(mp); | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
562 assert(mp->module != NULL); |
0 | 563 |
564 // Stop if already playing | |
565 jmpStop(mp); | |
566 jmpClearChannels(mp); | |
567 | |
568 // Check starting order | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
569 if (order < 0 || order >= mp->module->norders) |
0 | 570 { |
571 JSS_UNLOCK(mp); | |
572 JSSERROR(DMERR_INVALID_ARGS, DMERR_INVALID_ARGS, "Invalid playing startorder given.\n"); | |
573 } | |
574 | |
575 // Initialize playing | |
576 jmpClearPlayer(mp); | |
577 | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
578 jmpSetNewOrder(mp, order); |
0 | 579 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
580 if (mp->order == jsetNotSet) |
0 | 581 { |
582 JSS_UNLOCK(mp); | |
583 JSSERROR(DMERR_NOT_SUPPORTED, DMERR_NOT_SUPPORTED, | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
584 "Could not start playing from given order #%i\n", order); |
0 | 585 } |
586 | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
587 mp->speed = mp->module->defSpeed; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
588 jmpSetTempo(mp, mp->module->defTempo); |
0 | 589 |
590 // Set callback | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
591 result = jvmSetCallback(mp->device, jmpExec, (void *) mp); |
0 | 592 if (result != DMERR_OK) |
593 { | |
594 JSS_UNLOCK(mp); | |
595 JSSERROR(result, result, "Could not initialize callback for player.\n"); | |
596 } | |
597 | |
598 mp->isPlaying = TRUE; | |
599 | |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
600 if (mp->future != NULL) |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
601 { |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
602 jmpPlayOrder(mp->future, order); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
603 jmpExec(mp->future->device, mp->future); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
604 } |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
605 |
0 | 606 JSS_UNLOCK(mp); |
607 return 0; | |
608 } | |
609 | |
610 | |
611 /* Play given pattern | |
612 */ | |
613 int jmpPlayPattern(JSSPlayer * mp, int pattern) | |
614 { | |
615 int result; | |
616 assert(mp != NULL); | |
617 JSS_LOCK(mp); | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
618 assert(mp->module != NULL); |
0 | 619 |
620 // Stop if already playing | |
621 jmpStop(mp); | |
622 jmpClearChannels(mp); | |
623 | |
624 // Initialize playing | |
625 jmpClearPlayer(mp); | |
626 | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
627 mp->npattern = pattern; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
628 mp->speed = mp->module->defSpeed; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
629 jmpSetTempo(mp, mp->module->defTempo); |
0 | 630 |
631 // Set callback | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
632 result = jvmSetCallback(mp->device, jmpExec, (void *) mp); |
0 | 633 if (result != DMERR_OK) |
634 { | |
635 JSS_UNLOCK(mp); | |
636 JSSERROR(result, result, "Could not initialize callback for player.\n"); | |
637 } | |
638 | |
639 mp->isPlaying = TRUE; | |
640 | |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
641 if (mp->future != NULL) |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
642 { |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
643 jmpPlayPattern(mp->future, pattern); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
644 jmpExec(mp->future->device, mp->future); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
645 } |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
646 |
0 | 647 JSS_UNLOCK(mp); |
648 return 0; | |
649 } | |
650 | |
651 | |
652 /* Set volume for given module channel. | |
653 */ | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
654 static void jmpSetVolume(JSSPlayerChannel * chn, int channel, int volume) |
0 | 655 { |
61
a33e47232161
Silence some "unused parameter" warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
656 (void) channel; |
a33e47232161
Silence some "unused parameter" warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
657 |
154 | 658 chn->iCVolume = dmClamp(volume, mpMinVol, mpMaxVol); |
0 | 659 JMPSETNDFLAGS(cdfNewVolume); |
660 } | |
661 | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
662 #define jmpChangeVolume(Q, Z, X) jmpSetVolume(Q, Z, chn->iCVolume + (X)) |
0 | 663 |
664 | |
665 /* Change the pitch of given channel by ADelta. | |
666 */ | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
667 static void jmpChangePitch(JSSPlayerChannel *chn, int channel, int delta) |
0 | 668 { |
669 int value; | |
61
a33e47232161
Silence some "unused parameter" warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
670 (void) channel; |
0 | 671 |
672 // Calculate new pitch and check it | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
673 value = chn->iCPitch + delta; |
0 | 674 if (value < 0) |
675 value = 0; | |
676 | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
677 chn->iCPitch = value; |
0 | 678 JMPSETNDFLAGS(cdfNewPitch); |
679 } | |
680 | |
681 | |
682 /* Do a note portamento (pitch slide) effect for given module channel. | |
683 */ | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
684 static void jmpDoPortamento(JSSPlayerChannel * chn, int channel) |
0 | 685 { |
61
a33e47232161
Silence some "unused parameter" warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
686 (void) channel; |
a33e47232161
Silence some "unused parameter" warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
687 |
0 | 688 // Check for zero parameter |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
689 if (chn->iLastPortaToNoteParam == 0) |
0 | 690 { |
691 JMPSETNDFLAGS(cdfNewPitch); | |
692 return; | |
693 } | |
694 | |
695 /* Slide the pitch of channel to the destination value | |
696 * with speed of iLastPortaToNoteParam[] * 4 and stop when it equals. | |
697 */ | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
698 if (chn->iCPitch != chn->iLastPortaToNotePitch) |
0 | 699 { |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
700 if (chn->iCPitch < chn->iLastPortaToNotePitch) |
0 | 701 { |
702 // Increase pitch UP | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
703 jmpChangePitch(chn, channel, chn->iLastPortaToNoteParam * 4); |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
704 if (chn->iCPitch > chn->iLastPortaToNotePitch) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
705 chn->iCPitch = chn->iLastPortaToNotePitch; |
0 | 706 } |
707 else | |
708 { | |
709 // Decrease pitch DOWN | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
710 jmpChangePitch(chn, channel, -(chn->iLastPortaToNoteParam * 4)); |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
711 if (chn->iCPitch < chn->iLastPortaToNotePitch) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
712 chn->iCPitch = chn->iLastPortaToNotePitch; |
0 | 713 } |
714 } | |
715 } | |
716 | |
717 | |
718 /* Do a tremolo effect for given module channel. | |
719 */ | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
720 static void jmpDoTremolo(JSSPlayer * mp, JSSPlayerChannel *chn, int channel) |
0 | 721 { |
722 int delta, pos, depth; | |
723 | |
724 // Check settings | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
725 if (chn->iTremoloDepth == 0 || chn->iTremoloSpeed == 0) |
0 | 726 return; |
727 | |
728 // Get position of tremolo waveform | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
729 pos = chn->iTremoloPos & 255; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
730 depth = chn->iTremoloDepth; |
0 | 731 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
732 switch (chn->iTremoloWC & 3) |
0 | 733 { |
734 case 0: // Sine-wave | |
735 delta = (jmpSineTable[pos] * depth) / 2048; | |
736 break; | |
737 | |
738 case 1: // Ramp down | |
739 delta = ((pos - 128) * depth) / 128; | |
740 break; | |
741 | |
742 case 2: // Square | |
743 delta = (((pos & 128) - 64) * depth) / 64; | |
744 break; | |
745 | |
746 default: | |
747 return; | |
748 } | |
749 | |
750 // Set the new volume | |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
751 jmpCSetVolume(mp, chn, channel, chn->iCVolume + delta, FALSE); |
0 | 752 |
753 // Advance tremolo waveform position | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
754 chn->iTremoloPos += chn->iTremoloSpeed; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
755 if (chn->iTremoloPos > 255) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
756 chn->iTremoloPos = 0; |
0 | 757 } |
758 | |
759 | |
760 /* Do a vibrato effect for given module channel. | |
761 */ | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
762 static void jmpDoVibrato(JSSPlayer * mp, JSSPlayerChannel *chn, int channel) |
0 | 763 { |
764 int delta, pos, depth; | |
765 | |
766 // Check settings | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
767 if (chn->iVibratoDepth == 0 || chn->iVibratoSpeed == 0) |
0 | 768 return; |
769 | |
770 // Get position of vibrato waveform | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
771 pos = chn->iVibratoPos & 255; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
772 depth = chn->iVibratoDepth; |
0 | 773 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
774 switch (chn->iVibratoWC & 3) |
0 | 775 { |
776 case 0: // Sine-wave | |
777 delta = (jmpSineTable[pos] * depth) / 2048; | |
778 break; | |
779 | |
780 case 1: // Ramp down | |
781 delta = ((pos - 128) * depth) / 16; | |
782 break; | |
783 | |
784 case 2: // Square | |
785 delta = (((pos & 128) - 64) * depth) / 8; | |
786 break; | |
787 | |
788 default: | |
789 return; | |
790 } | |
791 | |
792 // Set the new frequency | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
793 jmpCSetPitch(mp, channel, chn->iCPitch + delta); |
0 | 794 |
795 // Advance vibrato waveform position | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
796 chn->iVibratoPos += chn->iVibratoSpeed; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
797 if (chn->iVibratoPos > 255) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
798 chn->iVibratoPos = 0; |
0 | 799 } |
800 | |
801 | |
802 /* Do a volume slide effect for given module channel. | |
803 */ | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
804 static void jmpDoVolumeSlide(JSSPlayerChannel * chn, int channel, int param) |
0 | 805 { |
806 int paramX, paramY; | |
807 | |
808 JMPMAKEPARAM(param, paramX, paramY) | |
809 | |
810 if (paramY == 0) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
811 jmpChangeVolume(chn, channel, paramX); |
0 | 812 if (paramX == 0) |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
813 jmpChangeVolume(chn, channel, -paramY); |
0 | 814 } |
815 | |
816 | |
817 /* Execute a pattern loop effect/command for given module channel. | |
818 * | |
819 * This routine works for most of the supported formats, as they | |
820 * use the 'standard' implementation ascending from MOD. However, | |
821 * here is included also a slightly kludgy implementation of the | |
822 * FT2 patloop bug. | |
823 */ | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
824 static void jmpDoPatternLoop(JSSPlayer * mp, JSSPlayerChannel *chn, int channel, int paramY) |
0 | 825 { |
61
a33e47232161
Silence some "unused parameter" warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
826 (void) channel; |
a33e47232161
Silence some "unused parameter" warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
827 |
0 | 828 // Check what we need to do |
829 if (paramY > 0) | |
830 { | |
831 // SBx/E6x loops 'x' times | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
832 if (chn->iPatLoopCount == 1) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
833 chn->iPatLoopCount = 0; |
0 | 834 else |
835 { | |
836 // Check if we need to set the count | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
837 if (chn->iPatLoopCount == 0) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
838 chn->iPatLoopCount = (paramY + 1); |
0 | 839 |
840 // Loop to specified row | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
841 chn->iPatLoopCount--; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
842 mp->newRow = chn->iPatLoopRow; |
0 | 843 mp->newRowSet = TRUE; |
844 } | |
845 } | |
846 else | |
847 { | |
848 // SB0/E60 sets the loop start point | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
849 chn->iPatLoopRow = mp->row; |
0 | 850 |
851 // This is here because of the infamous FT2 patloop bug | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
852 mp->lastPatLoopRow = mp->row; |
0 | 853 } |
854 } | |
855 | |
856 | |
857 /* Do arpeggio effect | |
858 */ | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
859 static void jmpDoArpeggio(JSSPlayer * mp, JSSPlayerChannel *chn, int channel, int paramY, int paramX) |
0 | 860 { |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
861 JSSInstrument *tempInst = chn->iCInstrument; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
862 |
0 | 863 if (tempInst) |
864 { | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
865 int tmp = chn->iCNote; |
0 | 866 if (tmp == jsetNotSet || tmp == jsetNoteOff) return; |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
867 switch (mp->tick & 3) |
0 | 868 { |
869 case 1: | |
870 tmp += paramX; | |
871 break; | |
872 case 2: | |
873 tmp += paramY; | |
874 break; | |
875 } | |
876 jmpCSetPitch(mp, channel, jmpGetPeriodFromNote(mp, tmp + tempInst->ERelNote, tempInst->EFineTune)); | |
877 } | |
878 } | |
879 | |
880 | |
881 /* | |
882 * Process pattern effects | |
883 */ | |
884 static void jmpProcessRowEffect(JSSPlayer * mp, int channel, JSSNote * currNote) | |
885 { | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
886 JSSPlayerChannel *chn = &(mp->channels[channel]); |
0 | 887 int param, paramX, paramY; |
888 char effect; | |
889 | |
890 param = currNote->param; | |
891 JMPMAKEPARAM(param, paramX, paramY); | |
892 JMPGETEFFECT(effect, currNote->effect); | |
893 | |
894 switch (effect) | |
895 { | |
896 case '0': // 0xy = Arpeggio | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
897 jmpDoArpeggio(mp, chn, channel, paramX, paramY); |
0 | 898 break; |
899 | |
900 case 'W': // Used widely in demo-music as MIDAS Sound System sync-command | |
901 case 'Q': // SoundTracker/OpenCP: Qxx = Set LP filter resonance | |
902 case 'Z': // SoundTracker/OpenCP: Zxx = Set LP filter cutoff freq | |
903 break; | |
904 | |
905 case '1': | |
906 case '2': // 1xy = Portamento Up, 2xy = Portamento Down : IMPL.VERIFIED | |
907 if (param) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
908 chn->iLastPortaParam = param; |
0 | 909 break; |
910 | |
911 case '3': // 3xy = Porta To Note | |
912 if (param) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
913 chn->iLastPortaToNoteParam = param; |
0 | 914 |
170 | 915 if (currNote->note != jsetNotSet && currNote->note != jsetNoteOff) |
916 { | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
917 chn->iLastPortaToNotePitch = chn->iCPitch; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
918 chn->iCPitch = chn->iCOldPitch; |
0 | 919 JMPUNSETNDFLAGS(cdfNewPitch | cdfNewInstr | cdfNewPanPos); |
920 } | |
921 break; | |
922 | |
923 case '4': // 4xy = Vibrato : IMPL.VERIFIED | |
924 if (paramX) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
925 chn->iVibratoSpeed = paramX; |
0 | 926 |
927 if (paramY) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
928 chn->iVibratoDepth = paramY; |
0 | 929 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
930 if ((chn->iVibratoWC & 4) == 0) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
931 chn->iVibratoPos = 0; |
0 | 932 break; |
933 | |
934 case '5': // 5xy = Portamento + Volume Slide | |
935 case '6': // 6xy = Vibrato + Volume slide | |
936 if (param) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
937 chn->iLastVolSlideParam = param; |
0 | 938 break; |
939 | |
940 case '7': // 7xy = Tremolo | |
941 if (paramX) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
942 chn->iTremoloSpeed = paramX; |
0 | 943 |
944 if (paramY) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
945 chn->iTremoloDepth = paramY; |
0 | 946 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
947 if ((chn->iTremoloWC & 4) == 0) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
948 chn->iTremoloPos = 0; |
0 | 949 break; |
950 | |
951 case '8': // 8xx = Set Panning | |
952 JMPDEBUG("Set Panning used, UNIMPLEMENTED"); | |
953 break; | |
954 | |
955 case '9': // 9xx = Set Sample Offset : IMPL.VERIFIED | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
956 if (chn->iCNewDataFlags & cdfNewPitch) |
30 | 957 { |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
958 chn->iCPosition = param * 0x100; |
0 | 959 JMPSETNDFLAGS(cdfNewPos); |
960 } | |
961 break; | |
962 | |
963 case 'A': // Axy = Volume Slide : IMPL.VERIFIED | |
964 if (param) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
965 chn->iLastVolSlideParam = param; |
0 | 966 break; |
967 | |
968 case 'B': // Bxx = Pattern Jump : IMPL.VERIFIED | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
969 mp->newOrder = param; |
0 | 970 mp->newOrderSet = TRUE; |
971 mp->jumpFlag = TRUE; | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
972 mp->lastPatLoopRow = 0; |
0 | 973 break; |
974 | |
975 case 'C': // Cxx = Set Volume : IMPL.VERIFIED | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
976 jmpSetVolume(chn, channel, param); |
0 | 977 break; |
978 | |
979 case 'D': // Dxx = Pattern Break : IMPL.VERIFIED | |
980 // Compute the new row | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
981 mp->newRow = (paramX * 10) + paramY; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
982 if (mp->newRow >= mp->pattern->nrows) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
983 mp->newRow = 0; |
0 | 984 |
985 mp->newRowSet = TRUE; | |
986 | |
987 // Now we do some tricky tests | |
988 if (!mp->breakFlag && !mp->jumpFlag) { | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
989 mp->newOrder = mp->order + 1; |
0 | 990 mp->newOrderSet = TRUE; |
991 } | |
992 | |
993 mp->breakFlag = TRUE; | |
994 break; | |
995 | |
996 case 'E': // Exy = Special Effects | |
997 switch (paramX) { | |
998 case 0x00: // E0x - Set filter (NOT SUPPORTED) | |
999 JMPDEBUG("Set Filter used, UNSUPPORTED"); | |
1000 break; | |
1001 | |
1002 case 0x01: // E1x - Fine Portamento Up | |
1003 if (paramY) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1004 chn->iCLastFinePortamentoUpParam = paramY; |
0 | 1005 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1006 jmpChangePitch(chn, channel, -(chn->iCLastFinePortamentoUpParam * 4)); |
0 | 1007 break; |
1008 | |
1009 case 0x02: // E2x - Fine Portamento Down | |
1010 if (paramY) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1011 chn->iCLastFinePortamentoDownParam = paramY; |
0 | 1012 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1013 jmpChangePitch(chn, channel, (chn->iCLastFinePortamentoDownParam * 4)); |
0 | 1014 break; |
1015 | |
1016 case 0x03: // E3x - Glissando Control (NOT SUPPORTED) | |
1017 break; | |
1018 | |
1019 case 0x04: // E4x - Set Vibrato waveform | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1020 chn->iVibratoWC = paramY; |
0 | 1021 break; |
1022 | |
1023 case 0x05: // E5x - Set Finetune | |
1024 JMPDEBUG("Set Finetune used, UNIMPLEMENTED"); | |
1025 break; | |
1026 | |
1027 case 0x06: // E6x - Set Pattern Loop | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1028 jmpDoPatternLoop(mp, chn, channel, paramY); |
0 | 1029 break; |
1030 | |
1031 case 0x07: // E7x - Set Tremolo waveform | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1032 chn->iTremoloWC = paramY; |
0 | 1033 break; |
1034 | |
1035 case 0x08: // E8x - Set Pan Position | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1036 chn->iCPanning = (paramY * 16); |
0 | 1037 JMPSETNDFLAGS(cdfNewPanPos); |
1038 break; | |
1039 | |
1040 case 0x09: // E9x - Retrig note | |
1041 JMPDEBUG("Retrig Note used, UNIMPLEMENTED"); | |
1042 break; | |
1043 | |
1044 case 0x0a: // EAx - Fine Volumeslide Up | |
1045 if (paramY) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1046 chn->iCLastFineVolumeslideUpParam = paramY; |
0 | 1047 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1048 jmpChangeVolume(chn, channel, chn->iCLastFineVolumeslideUpParam); |
0 | 1049 break; |
1050 | |
1051 case 0x0b: // EBx - Fine Volumeslide Down | |
1052 if (paramY) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1053 chn->iCLastFineVolumeslideDownParam = paramY; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1054 jmpChangeVolume(chn, channel, -(chn->iCLastFineVolumeslideDownParam)); |
0 | 1055 break; |
1056 | |
1057 case 0x0c: // ECx - Set Note Cut (NOT PROCESSED IN TICK0) | |
1058 break; | |
1059 | |
1060 case 0x0d: // EDx - Set Note Delay : IMPL.VERIFIED | |
1061 if (paramY > 0) | |
1062 { | |
1063 // Save the ND-flags, then clear | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1064 chn->iSaveNDFlags = chn->iCNewDataFlags; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1065 chn->iCNewDataFlags = 0; |
0 | 1066 // TODO .. does this only affect NOTE or also instrument? |
1067 } | |
1068 break; | |
1069 | |
1070 case 0x0e: // EEx - Set Pattern Delay : IMPL.VERIFIED | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1071 mp->patternDelay = paramY; |
0 | 1072 break; |
1073 | |
1074 case 0x0f: // EFx - Invert Loop (NOT SUPPORTED) | |
1075 JMPDEBUG("Invert Loop used, UNSUPPORTED"); | |
1076 break; | |
1077 | |
1078 default: | |
1079 JMPDEBUG("Unsupported special command used"); | |
1080 } | |
1081 break; | |
1082 | |
1083 case 'F': // Fxy = Set Speed / Tempo : IMPL.VERIFIED | |
1084 if (param > 0) | |
1085 { | |
1086 if (param < 0x20) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1087 mp->speed = param; |
0 | 1088 else |
1089 jmpSetTempo(mp, param); | |
1090 } | |
1091 break; | |
1092 | |
1093 case 'G': // Gxx = Global Volume | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1094 mp->globalVol = param; |
0 | 1095 JMPSETNDFLAGS(cdfNewGlobalVol); |
1096 break; | |
1097 | |
1098 | |
1099 case 'H': // Hxx = Global Volume Slide | |
1100 JMPDEBUG("Global Volume Slide used, UNIMPLEMENTED"); | |
1101 break; | |
1102 | |
1103 case 'K': // Kxx = Key-off (Same as key-off note) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1104 chn->iCKeyOff = TRUE; |
0 | 1105 break; |
1106 | |
1107 case 'L': // Lxx = Set Envelope Position | |
1108 JMPDEBUG("Set Envelope Position used, NOT verified with FT2"); | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1109 chn->iCPanEnv_Frames = param; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1110 chn->iCVolEnv_Frames = param; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1111 chn->iCPanEnv_Exec = TRUE; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1112 chn->iCVolEnv_Exec = TRUE; |
0 | 1113 break; |
1114 | |
1115 case 'R': // Rxy = Multi Retrig note | |
1116 JMPDEBUG("Multi Retrig Note used, UNIMPLEMENTED"); | |
1117 break; | |
1118 | |
1119 case 'T': // Txy = Tremor | |
1120 if (param) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1121 chn->iLastTremorParam = param; |
0 | 1122 break; |
1123 | |
1124 case 'X': // Xxy = Extra Fine Portamento | |
1125 switch (paramX) | |
1126 { | |
1127 case 0x01: // X1y - Extra Fine Portamento Up | |
1128 if (paramY) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1129 chn->iCLastExtraFinePortamentoUpParam = paramY; |
0 | 1130 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1131 jmpChangePitch(chn, channel, - chn->iCLastExtraFinePortamentoUpParam); |
0 | 1132 break; |
1133 | |
1134 case 0x02: // X2y - Extra Fine Portamento Down | |
1135 if (paramY) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1136 chn->iCLastExtraFinePortamentoDownParam = paramY; |
0 | 1137 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1138 jmpChangePitch(chn, channel, chn->iCLastExtraFinePortamentoUpParam); |
0 | 1139 break; |
1140 | |
1141 default: | |
1142 JMPDEBUG("Unsupported value in Extra Fine Portamento command!"); | |
1143 break; | |
1144 } | |
1145 break; | |
1146 | |
1147 default: | |
1148 JMPDEBUG("Unsupported effect"); | |
1149 break; | |
1150 } | |
1151 } | |
1152 | |
1153 | |
1154 static void jmpProcessNewRow(JSSPlayer * mp, int channel) | |
1155 { | |
1156 JSSNote *currNote; | |
1157 JSSExtInstrument *extInst = NULL; | |
1158 JSSInstrument *inst = NULL; | |
1159 BOOL newNote = FALSE; | |
1160 int tmp, paramX, paramY; | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1161 JSSPlayerChannel *chn = &(mp->channels[channel]); |
0 | 1162 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1163 JMPGETNOTE(currNote, mp->row, channel); |
0 | 1164 |
1165 // Check for a new note/keyoff here | |
1166 if (currNote->note == jsetNoteOff) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1167 chn->iCKeyOff = TRUE; |
0 | 1168 else |
1169 if (currNote->note >= 0 && currNote->note <= 96) | |
1170 { | |
1171 // New note was set | |
1172 newNote = TRUE; | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1173 chn->iCNote = currNote->note; |
0 | 1174 } |
1175 | |
1176 // Check for new instrument | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1177 if (currNote->instrument != jsetNotSet) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1178 { |
0 | 1179 /* Envelopes and ext.instrument fadeout are initialized always if |
1180 * new instrument is set, even if the instrument does not exist. | |
1181 */ | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1182 jmpResetEnvelopes(chn); |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1183 chn->iCKeyOff = FALSE; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1184 chn->iCFadeOutVol = mpMaxFadeoutVol; |
0 | 1185 |
1186 // We save the instrument number here for later use | |
145 | 1187 if (currNote->instrument >= 0 && |
1188 currNote->instrument < mp->module->nextInstruments) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1189 chn->iCExtInstrumentN = currNote->instrument; |
0 | 1190 } |
1191 | |
1192 /* ONLY if newNote was SET NOW and ExtInstrument HAS BEEN set, we can | |
1193 * set new pitches, and other things... | |
1194 */ | |
1195 if (newNote) | |
1196 { | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1197 if (chn->iCExtInstrumentN != jsetNotSet) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1198 extInst = mp->module->extInstruments[chn->iCExtInstrumentN]; |
0 | 1199 else |
1200 extInst = NULL; | |
1201 | |
1202 if (extInst) | |
1203 { | |
1204 // Set instrument | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1205 int note = chn->iCNote; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1206 chn->iCExtInstrument = extInst; |
0 | 1207 |
1208 // We set new Instrument ONLY if NEW NOTE has been set | |
1209 if (note != jsetNotSet) | |
1210 { | |
1211 // Get instrument number | |
1212 tmp = extInst->sNumForNotes[note]; | |
1213 | |
145 | 1214 if (tmp >= 0 && tmp < mp->module->ninstruments) |
1215 { | |
0 | 1216 // Set the new instrument |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1217 inst = mp->module->instruments[tmp]; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1218 chn->iCInstrumentN = tmp; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1219 chn->iCInstrument = inst; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1220 chn->iCVolume = inst->volume; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1221 chn->iCPanning = inst->EPanning; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1222 chn->iCPosition = 0; |
0 | 1223 |
1224 // Set NDFlags | |
1225 JMPSETNDFLAGS(cdfNewInstr | cdfNewPos | cdfNewPanPos | cdfNewVolume); | |
1226 } | |
1227 } | |
1228 } | |
1229 } | |
1230 | |
1231 if (inst) | |
1232 { | |
1233 // Save old pitch for later use | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1234 chn->iCOldPitch = chn->iCPitch; |
0 | 1235 |
1236 // Compute new pitch | |
154 | 1237 tmp = dmClamp(chn->iCNote + inst->ERelNote, 0, 119); |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1238 //fprintf(stderr, "HEH: %d + %d = %d\n", chn->iCNote, inst->ERelNote, tmp); |
0 | 1239 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1240 chn->iCPitch = jmpGetPeriodFromNote(mp, tmp, inst->EFineTune); |
0 | 1241 JMPSETNDFLAGS(cdfNewPitch); |
1242 } | |
1243 | |
1244 // Process the volume column | |
1245 JMPMAKEPARAM(currNote->volume, paramX, paramY); | |
1246 | |
1247 switch (paramX) | |
1248 { | |
1249 case 0x00: | |
1250 case 0x01: | |
1251 case 0x02: | |
1252 case 0x03: | |
1253 case 0x04: | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1254 jmpSetVolume(chn, channel, currNote->volume); |
0 | 1255 break; |
1256 | |
1257 case 0x07: // Dx = Fine Volumeslide Down : IMPL.VERIFIED | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1258 jmpChangeVolume(chn, channel, -paramY); |
0 | 1259 break; |
1260 | |
1261 case 0x08: // Ux = Fine Volumeslide Up : IMPL.VERIFIED | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1262 jmpChangeVolume(chn, channel, paramY); |
0 | 1263 break; |
1264 | |
1265 case 0x09: // Sx = Set vibrato speed : IMPL.VERIFIED | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1266 chn->iVibratoSpeed = paramY; |
0 | 1267 break; |
1268 | |
1269 case 0x0a: // Vx = Vibrato : IMPL.VERIFIED | |
1270 if (paramY) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1271 chn->iVibratoDepth = paramY; |
0 | 1272 break; |
1273 | |
1274 case 0x0e: // Mx = Porta To Note : IMPL.VERIFIED | |
1275 if (paramY) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1276 chn->iLastPortaToNoteParam = paramY; |
0 | 1277 |
1278 if (currNote->note != jsetNotSet && currNote->note != jsetNoteOff) { | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1279 chn->iLastPortaToNotePitch = chn->iCPitch; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1280 chn->iCPitch = chn->iCOldPitch; |
0 | 1281 JMPUNSETNDFLAGS(cdfNewPitch | cdfNewInstr | cdfNewPanPos); |
1282 } | |
1283 break; | |
1284 } | |
1285 | |
1286 // ...And finally process the Normal effects | |
1287 if (currNote->effect != jsetNotSet) | |
1288 jmpProcessRowEffect(mp, channel, currNote); | |
1289 } | |
1290 | |
1291 | |
1292 static void jmpProcessEffects(JSSPlayer * mp, int channel) | |
1293 { | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1294 JSSPlayerChannel *chn = &(mp->channels[channel]); |
0 | 1295 JSSNote *currNote; |
1296 int param, paramX, paramY, tmp; | |
1297 char effect; | |
1298 | |
1299 // Process the volume column effects | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1300 JMPGETNOTE(currNote, mp->row, channel); |
0 | 1301 JMPMAKEPARAM(currNote->volume, paramX, paramY); |
1302 | |
1303 switch (paramX) | |
1304 { | |
1305 case 0x05: // -x = Volumeslide Down : IMPL.VERIFIED | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1306 jmpChangeVolume(chn, channel, -paramY); |
0 | 1307 break; |
1308 | |
1309 case 0x06: // +x = Volumeslide Down : IMPL.VERIFIED | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1310 jmpChangeVolume(chn, channel, paramY); |
0 | 1311 break; |
1312 | |
1313 case 0x0a: // Vx = Vibrato : IMPL.VERIFIED | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1314 jmpDoVibrato(mp, chn, channel); |
0 | 1315 break; |
1316 | |
1317 case 0x0e: // Mx = Porta To Note : IMPL.VERIFIED | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1318 jmpDoPortamento(chn, channel); |
0 | 1319 break; |
1320 } | |
1321 | |
1322 // ...And finally process the Normal effects | |
1323 if (currNote->effect == jsetNotSet) | |
1324 return; | |
1325 | |
1326 param = currNote->param; | |
1327 JMPMAKEPARAM(param, paramX, paramY); | |
1328 JMPGETEFFECT(effect, currNote->effect); | |
1329 | |
1330 switch (effect) | |
1331 { | |
1332 case '0': // 0xy = Arpeggio | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1333 jmpDoArpeggio(mp, chn, channel, paramX, paramY); |
0 | 1334 break; |
1335 | |
1336 case '1': // 1xy = Portamento Up | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1337 if (chn->iLastPortaParam > 0) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1338 jmpChangePitch(chn, channel, -(chn->iLastPortaParam * 4)); |
0 | 1339 break; |
1340 | |
1341 case '2': // 2xy = Portamento Down | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1342 if (chn->iLastPortaParam > 0) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1343 jmpChangePitch(chn, channel, (chn->iLastPortaParam * 4)); |
0 | 1344 break; |
1345 | |
1346 case '3': // 3xy = Porta To Note | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1347 jmpDoPortamento(chn, channel); |
0 | 1348 break; |
1349 | |
1350 case '4': // 4xy = Vibrato | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1351 jmpDoVibrato(mp, chn, channel); |
0 | 1352 break; |
1353 | |
1354 case '5': // 5xy = Portamento + Volume Slide | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1355 jmpDoPortamento(chn, channel); |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1356 jmpDoVolumeSlide(chn, channel, chn->iLastVolSlideParam); |
0 | 1357 break; |
1358 | |
1359 case '6': // 6xy = Vibrato + Volume Slide | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1360 jmpDoVibrato(mp, chn, channel); |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1361 jmpDoVolumeSlide(chn, channel, chn->iLastVolSlideParam); |
0 | 1362 break; |
1363 | |
1364 case '7': // 7xy = Tremolo | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1365 jmpDoTremolo(mp, chn, channel); |
0 | 1366 break; |
1367 | |
1368 case 'A': // Axy = Volume slide | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1369 jmpDoVolumeSlide(chn, channel, chn->iLastVolSlideParam); |
0 | 1370 break; |
1371 | |
1372 case 'E': // Exy = Special Effects | |
1373 switch (paramX) | |
1374 { | |
1375 case 0x0c: // ECx - Set Note Cut | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1376 if (mp->tick == paramY) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1377 jmpSetVolume(chn, channel, jsetMinVol); |
0 | 1378 break; |
1379 | |
1380 case 0x0d: // EDx - Set Note Delay | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1381 if (mp->tick == paramY) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1382 chn->iCNewDataFlags = chn->iSaveNDFlags; |
0 | 1383 break; |
1384 } | |
1385 break; | |
1386 | |
1387 case 'T': // Txy = Tremor | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1388 JMPMAKEPARAM(chn->iLastTremorParam, paramX, paramY) |
0 | 1389 paramX++; |
1390 paramY++; | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1391 tmp = (chn->iTremorCount % (paramX + paramY)); |
0 | 1392 if (tmp < paramX) |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1393 jmpCSetVolume(mp, chn, channel, chn->iCVolume, FALSE); |
0 | 1394 else |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1395 jmpCSetVolume(mp, chn, channel, jsetMinVol, FALSE); |
0 | 1396 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1397 chn->iTremorCount = (tmp + 1); |
0 | 1398 break; |
1399 } | |
1400 } | |
1401 | |
1402 | |
1403 /* This is the main processing callback-loop of a module player. | |
1404 * It processes the ticks, calling the needed jmpProcessNewRow() | |
1405 * and jmpProcessEffects() methods for processing the module playing. | |
1406 */ | |
1407 void jmpExec(void *pDEV, void *pMP) | |
1408 { | |
1409 JSSPlayer *mp; | |
1410 JSSMixer *dev; | |
146
3226778033fd
Move variable a bit further into the block where it is actually used.
Matti Hamalainen <ccr@tnsp.org>
parents:
145
diff
changeset
|
1411 int channel; |
0 | 1412 |
1413 // Check some things via assert() | |
1414 mp = (JSSPlayer *) pMP; | |
1415 JSS_LOCK(mp); | |
1416 | |
1417 dev = (JSSMixer *) pDEV; | |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1418 |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1419 // Futures |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1420 if (mp->future != NULL) |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1421 { |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1422 jmpExec(mp->future->device, mp->future); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1423 } |
0 | 1424 |
1425 // Check if we are playing | |
1426 if (!mp->isPlaying) | |
1427 goto out; | |
1428 | |
1429 // Clear channel new data flags | |
1430 mp->jumpFlag = FALSE; | |
1431 mp->breakFlag = FALSE; | |
1432 | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1433 for (channel = 0; channel < jsetNChannels; channel++) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1434 mp->channels[channel].iCNewDataFlags = 0; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1435 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1436 //fprintf(stderr, "1: tick=%d, order=%d, iPattern=%d, row=%d\n", mp->tick, mp->order, mp->npattern, mp->row); |
0 | 1437 |
1438 // Check for init-tick | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1439 if (mp->tick < 0) |
0 | 1440 { |
1441 // Initialize pattern | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1442 if (mp->order != jsetNotSet) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1443 jmpSetNewOrder(mp, mp->order); |
0 | 1444 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1445 mp->newRow = 0; |
0 | 1446 mp->newRowSet = TRUE; |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1447 mp->tick = mp->speed; |
0 | 1448 } |
1449 | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1450 //fprintf(stderr, "2: tick=%d, order=%d, iPattern=%d, row=%d\n", mp->tick, mp->order, mp->npattern, mp->row); |
0 | 1451 |
1452 // Check if we are playing | |
1453 if (!mp->isPlaying) | |
1454 goto out; | |
1455 | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1456 assert(mp->pattern); |
0 | 1457 |
1458 // Update the tick | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1459 mp->tick++; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1460 if (mp->tick >= mp->speed) |
0 | 1461 { |
1462 // Re-init tick counter | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1463 mp->tick = 0; |
0 | 1464 |
1465 // Check pattern delay | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1466 if (mp->patternDelay > 0) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1467 mp->patternDelay--; |
0 | 1468 else |
1469 { | |
1470 // New pattern row | |
1471 if (mp->newRowSet) | |
1472 { | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1473 mp->row = mp->newRow; |
0 | 1474 mp->newRowSet = FALSE; |
1475 } else | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1476 mp->row++; |
0 | 1477 |
1478 // Check for end of pattern | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1479 if (mp->row >= mp->pattern->nrows) |
0 | 1480 { |
1481 // Go to next order | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1482 if (mp->order != jsetNotSet) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1483 jmpSetNewOrder(mp, mp->order + 1); |
0 | 1484 else |
1485 mp->isPlaying = FALSE; | |
1486 | |
1487 // Check for FT2 quirks | |
1488 if (JMPGETMODFLAGS(mp, jmdfFT2Replay)) | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1489 mp->row = mp->lastPatLoopRow; |
0 | 1490 else |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1491 mp->row = 0; |
0 | 1492 } |
1493 | |
1494 if (!mp->isPlaying) | |
1495 goto out; | |
1496 | |
1497 // Check current order | |
1498 if (mp->newOrderSet) | |
1499 { | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1500 jmpSetNewOrder(mp, mp->newOrder); |
0 | 1501 mp->newOrderSet = FALSE; |
1502 } | |
1503 | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1504 //fprintf(stderr, "3: tick=%d, order=%d, iPattern=%d, row=%d\n", mp->tick, mp->order, mp->npattern, mp->row); |
0 | 1505 |
1506 if (!mp->isPlaying) | |
1507 goto out; | |
1508 | |
1509 // TICK #0: Process new row | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1510 for (channel = 0; channel < mp->module->nchannels; channel++) |
0 | 1511 jmpProcessNewRow(mp, channel); |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1512 } // patternDelay |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1513 } // tick |
0 | 1514 else |
1515 { | |
1516 // Implement FT2's pattern delay-effect: don't update effects while on patdelay | |
1517 if (!JMPGETMODFLAGS(mp, jmdfFT2Replay) || | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1518 (JMPGETMODFLAGS(mp, jmdfFT2Replay) && mp->patternDelay <= 0)) |
0 | 1519 { |
1520 // TICK n: Process the effects | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1521 for (channel = 0; channel < mp->module->nchannels; channel++) |
0 | 1522 jmpProcessEffects(mp, channel); |
1523 } | |
1524 } | |
1525 | |
1526 // Check if playing has stopped | |
1527 if (!mp->isPlaying) | |
1528 goto out; | |
1529 | |
1530 // Update player data to audio device/mixer | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1531 for (channel = 0; channel < mp->module->nchannels; channel++) |
0 | 1532 { |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1533 JSSPlayerChannel *chn = &mp->channels[channel]; |
146
3226778033fd
Move variable a bit further into the block where it is actually used.
Matti Hamalainen <ccr@tnsp.org>
parents:
145
diff
changeset
|
1534 int flags; |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1535 |
0 | 1536 // Process extended instruments |
61
a33e47232161
Silence some "unused parameter" warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
1537 jmpProcessExtInstrument(chn, channel); |
0 | 1538 |
1539 // Check NDFlags and update channel data | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1540 flags = chn->iCNewDataFlags; |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1541 if (!flags) |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1542 continue; |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1543 |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1544 // Check if we stop? |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1545 if (flags & cdfStop) |
0 | 1546 { |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1547 jvmStop(mp->device, channel); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1548 } |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1549 else |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1550 { |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1551 // No, handle other flags |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1552 if (flags & cdfNewInstr) |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
1553 { |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1554 JSSInstrument *instr = chn->iCInstrument; |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1555 if (instr != NULL) |
0 | 1556 { |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1557 jvmSetSample(mp->device, channel, |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1558 instr->data, instr->size, |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1559 instr->loopS, instr->loopE, |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1560 instr->flags); |
0 | 1561 } |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1562 jvmPlay(mp->device, channel); |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1563 } |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1564 |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1565 if (flags & cdfNewPitch) |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1566 jmpCSetPitch(mp, channel, chn->iCPitch); |
0 | 1567 |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1568 if (flags & cdfNewPos) |
171 | 1569 jvmSetPos(mp->device, channel, chn->iCPosition); |
0 | 1570 |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1571 if (flags & cdfNewVolume) |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1572 jmpCSetVolume(mp, chn, channel, chn->iCVolume, flags & cdfNewInstr); |
0 | 1573 |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1574 if (flags & cdfNewPanPos) |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1575 jmpCSetPanning(mp, chn, channel, chn->iCPanning); |
0 | 1576 |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1577 if (flags & cdfNewGlobalVol) |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
1578 jvmSetGlobalVol(mp->device, mp->globalVol); |
0 | 1579 } |
1580 } | |
1581 | |
1582 out: | |
1583 JSS_UNLOCK(mp); | |
1584 } |