annotate jssplr.c @ 224:81f3993412ae

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