annotate jssplr.c @ 154:969cefb2f8c3

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