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