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