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