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