annotate jssplr.c @ 271:6d9a3577741b

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