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