annotate minijss/jssplr.c @ 1403:6aa0897265e8

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