annotate src/modplug/load_it.cxx @ 2921:296fd6e83edb

we have both output and effect plugin, so report both
author Andrew O. Shadoura <bugzilla@tut.by>
date Wed, 20 Aug 2008 01:47:00 +0300
parents 107c1fed3d92
children 5fe8ac99a33d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1 /*
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
2 * This source code is public domain.
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
3 *
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
4 * Authors: Olivier Lapicque <olivierl@jps.net>,
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
5 * Adam Goode <adam@evdebs.org> (endian and char fixes for PPC)
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
6 */
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
7
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
8 #include "stdafx.h"
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
9 #include "sndfile.h"
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
10 #include "it_defs.h"
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
11
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
12 /* blah, -mrsb.
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
13 this is a schism header */
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
14 #include "midi.h"
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
15
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
16 #ifdef MSC_VER
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
17 #pragma warning(disable:4244)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
18 #endif
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
19
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
20 BYTE autovibit2xm[8] =
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
21 { 0, 3, 1, 4, 2, 0, 0, 0 };
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
22
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
23 BYTE autovibxm2it[8] =
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
24 { 0, 2, 4, 1, 3, 0, 0, 0 };
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
25
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
26 //////////////////////////////////////////////////////////
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
27 // Impulse Tracker IT file support (import only)
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
28
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
29
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
30 static inline UINT ConvertVolParam(UINT value)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
31 //--------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
32 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
33 return (value > 9) ? 9 : value;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
34 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
35
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
36
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
37 BOOL CSoundFile::ITInstrToMPT(const void *p, INSTRUMENTHEADER *penv, UINT trkvers)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
38 //--------------------------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
39 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
40 if (trkvers < 0x0200)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
41 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
42 const ITOLDINSTRUMENT *pis = (const ITOLDINSTRUMENT *)p;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
43 memcpy(penv->name, pis->name, 26);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
44 memcpy(penv->filename, pis->filename, 12);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
45 penv->nFadeOut = bswapLE16(pis->fadeout) << 6;
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
46 penv->nGlobalVol = 128;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
47 for (UINT j=0; j<120; j++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
48 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
49 UINT note = pis->keyboard[j*2];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
50 UINT ins = pis->keyboard[j*2+1];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
51 if (ins < MAX_SAMPLES) penv->Keyboard[j] = ins;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
52 if (note < 128) penv->NoteMap[j] = note+1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
53 else if (note >= 0xFE) penv->NoteMap[j] = note;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
54 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
55 if (pis->flags & 0x01) penv->dwFlags |= ENV_VOLUME;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
56 if (pis->flags & 0x02) penv->dwFlags |= ENV_VOLLOOP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
57 if (pis->flags & 0x04) penv->dwFlags |= ENV_VOLSUSTAIN;
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
58 penv->VolEnv.nLoopStart = pis->vls;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
59 penv->VolEnv.nLoopEnd = pis->vle;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
60 penv->VolEnv.nSustainStart = pis->sls;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
61 penv->VolEnv.nSustainEnd = pis->sle;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
62 penv->VolEnv.nNodes = 25;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
63 for (UINT ev=0; ev<25; ev++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
64 {
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
65 if ((penv->VolEnv.Ticks[ev] = pis->nodes[ev*2]) == 0xFF)
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
66 {
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
67 penv->VolEnv.nNodes = ev;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
68 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
69 }
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
70 penv->VolEnv.Values[ev] = pis->nodes[ev*2+1];
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
71 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
72 penv->nNNA = pis->nna;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
73 penv->nDCT = pis->dnc;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
74 penv->nPan = 0x80;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
75 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
76 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
77 const ITINSTRUMENT *pis = (const ITINSTRUMENT *)p;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
78 memcpy(penv->name, pis->name, 26);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
79 memcpy(penv->filename, pis->filename, 12);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
80 penv->nMidiProgram = pis->mpr;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
81 penv->nMidiChannel = pis->mch;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
82 penv->wMidiBank = bswapLE16(pis->mbank);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
83 penv->nFadeOut = bswapLE16(pis->fadeout) << 5;
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
84 penv->nGlobalVol = pis->gbv;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
85 if (penv->nGlobalVol > 128) penv->nGlobalVol = 128;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
86 for (UINT j=0; j<120; j++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
87 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
88 UINT note = pis->keyboard[j*2];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
89 UINT ins = pis->keyboard[j*2+1];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
90 if (ins < MAX_SAMPLES) penv->Keyboard[j] = ins;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
91 if (note < 128) penv->NoteMap[j] = note+1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
92 else if (note >= 0xFE) penv->NoteMap[j] = note;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
93 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
94 // Volume Envelope
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
95 if (pis->volenv.flags & 1) penv->dwFlags |= ENV_VOLUME;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
96 if (pis->volenv.flags & 2) penv->dwFlags |= ENV_VOLLOOP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
97 if (pis->volenv.flags & 4) penv->dwFlags |= ENV_VOLSUSTAIN;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
98 if (pis->volenv.flags & 8) penv->dwFlags |= ENV_VOLCARRY;
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
99 penv->VolEnv.nNodes = pis->volenv.num;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
100 if (penv->VolEnv.nNodes > 25) penv->VolEnv.nNodes = 25;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
101
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
102 penv->VolEnv.nLoopStart = pis->volenv.lpb;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
103 penv->VolEnv.nLoopEnd = pis->volenv.lpe;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
104 penv->VolEnv.nSustainStart = pis->volenv.slb;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
105 penv->VolEnv.nSustainEnd = pis->volenv.sle;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
106 // Panning Envelope
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
107 if (pis->panenv.flags & 1) penv->dwFlags |= ENV_PANNING;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
108 if (pis->panenv.flags & 2) penv->dwFlags |= ENV_PANLOOP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
109 if (pis->panenv.flags & 4) penv->dwFlags |= ENV_PANSUSTAIN;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
110 if (pis->panenv.flags & 8) penv->dwFlags |= ENV_PANCARRY;
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
111 penv->PanEnv.nNodes = pis->panenv.num;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
112 if (penv->PanEnv.nNodes > 25) penv->PanEnv.nNodes = 25;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
113 penv->PanEnv.nLoopStart = pis->panenv.lpb;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
114 penv->PanEnv.nLoopEnd = pis->panenv.lpe;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
115 penv->PanEnv.nSustainStart = pis->panenv.slb;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
116 penv->PanEnv.nSustainEnd = pis->panenv.sle;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
117 // Pitch Envelope
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
118 if (pis->pitchenv.flags & 1) penv->dwFlags |= ENV_PITCH;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
119 if (pis->pitchenv.flags & 2) penv->dwFlags |= ENV_PITCHLOOP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
120 if (pis->pitchenv.flags & 4) penv->dwFlags |= ENV_PITCHSUSTAIN;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
121 if (pis->pitchenv.flags & 8) penv->dwFlags |= ENV_PITCHCARRY;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
122 if (pis->pitchenv.flags & 0x80) penv->dwFlags |= ENV_FILTER;
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
123 penv->PitchEnv.nNodes = pis->pitchenv.num;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
124 if (penv->PitchEnv.nNodes > 25) penv->PitchEnv.nNodes = 25;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
125 penv->PitchEnv.nLoopStart = pis->pitchenv.lpb;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
126 penv->PitchEnv.nLoopEnd = pis->pitchenv.lpe;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
127 penv->PitchEnv.nSustainStart = pis->pitchenv.slb;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
128 penv->PitchEnv.nSustainEnd = pis->pitchenv.sle;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
129 // Envelopes Data
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
130 for (UINT ev=0; ev<25; ev++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
131 {
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
132 penv->VolEnv.Values[ev] = pis->volenv.data[ev*3];
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
133 penv->VolEnv.Ticks[ev] = (pis->volenv.data[ev*3+2] << 8) | (pis->volenv.data[ev*3+1]);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
134 penv->PanEnv.Values[ev] = pis->panenv.data[ev*3] + 32;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
135 penv->PanEnv.Ticks[ev] = (pis->panenv.data[ev*3+2] << 8) | (pis->panenv.data[ev*3+1]);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
136 penv->PitchEnv.Values[ev] = pis->pitchenv.data[ev*3] + 32;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
137 penv->PitchEnv.Ticks[ev] = (pis->pitchenv.data[ev*3+2] << 8) | (pis->pitchenv.data[ev*3+1]);
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
138 }
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
139 penv->nNNA = pis->nna % 4;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
140 penv->nDCT = pis->dct % 4;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
141 penv->nDNA = pis->dca % 3;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
142 penv->nPPS = pis->pps;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
143 penv->nPPC = pis->ppc;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
144 penv->nIFC = pis->ifc;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
145 penv->nIFR = pis->ifr;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
146 penv->nVolSwing = pis->rv;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
147 penv->nPanSwing = pis->rp;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
148 penv->nPan = (pis->dfp & 0x7F) << 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
149 if (penv->nPan > 256) penv->nPan = 128;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
150 if (pis->dfp < 0x80) penv->dwFlags |= ENV_SETPANNING;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
151 }
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
152 if ((penv->VolEnv.nLoopStart >= 25) || (penv->VolEnv.nLoopEnd >= 25)) penv->dwFlags &= ~ENV_VOLLOOP;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
153 if ((penv->VolEnv.nSustainStart >= 25) || (penv->VolEnv.nSustainEnd >= 25)) penv->dwFlags &= ~ENV_VOLSUSTAIN;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
154 return TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
155 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
156
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
157
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
158 BOOL CSoundFile::ReadIT(const BYTE *lpStream, DWORD dwMemLength)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
159 //--------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
160 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
161 ITFILEHEADER pifh = *(ITFILEHEADER *)lpStream;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
162 DWORD dwMemPos = sizeof(ITFILEHEADER);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
163 DWORD inspos[MAX_INSTRUMENTS];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
164 DWORD smppos[MAX_SAMPLES];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
165 DWORD patpos[MAX_PATTERNS];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
166 BYTE chnmask[64], channels_used[64];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
167 MODCOMMAND lastvalue[64];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
168
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
169 if ((!lpStream) || (dwMemLength < 0xc2)) return FALSE;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
170
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
171 pifh.id = bswapLE32(pifh.id);
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
172 if (pifh.id == 0x49504D49) {
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
173 if (dwMemLength < 554) return FALSE;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
174
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
175 WORD tv;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
176 INSTRUMENTHEADER *zenv = new INSTRUMENTHEADER;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
177 if (!zenv) return FALSE;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
178 memset(zenv, 0, sizeof(INSTRUMENTHEADER));
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
179 memcpy(&tv, lpStream+0x1C, 2); /* trkvers */
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
180 if (!ITInstrToMPT(lpStream, zenv, tv)) {
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
181 delete zenv;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
182 return FALSE;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
183 }
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
184
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
185 /* okay, we need samples now */
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
186 unsigned int q = 554;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
187 BYTE expect_samples = lpStream[0x1E];
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
188
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
189 m_nType = MOD_TYPE_IT;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
190 m_nInstruments = 1;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
191 m_nSamples = expect_samples;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
192 m_dwSongFlags = SONG_INSTRUMENTMODE | SONG_LINEARSLIDES /* eh? */;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
193
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
194 memcpy(m_szNames[0], lpStream + 0x20, 26);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
195 m_szNames[0][26] = 0;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
196
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
197 if (q+(80*expect_samples) >= dwMemLength) {
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
198 delete zenv;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
199 return FALSE;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
200 }
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
201
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
202 for (UINT nsmp = 0; nsmp < expect_samples; nsmp++) {
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
203
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
204 ITSAMPLESTRUCT pis = *(ITSAMPLESTRUCT *)(lpStream+q);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
205 q += 80; /* length of ITS header */
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
206
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
207 pis.id = bswapLE32(pis.id);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
208 pis.length = bswapLE32(pis.length);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
209 pis.loopbegin = bswapLE32(pis.loopbegin);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
210 pis.loopend = bswapLE32(pis.loopend);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
211 pis.C5Speed = bswapLE32(pis.C5Speed);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
212 pis.susloopbegin = bswapLE32(pis.susloopbegin);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
213 pis.susloopend = bswapLE32(pis.susloopend);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
214 pis.samplepointer = bswapLE32(pis.samplepointer);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
215
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
216 if (pis.id == 0x53504D49)
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
217 {
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
218 MODINSTRUMENT *pins = &Ins[nsmp+1];
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
219 memcpy(pins->name, pis.filename, 12);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
220 pins->uFlags = 0;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
221 pins->nLength = 0;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
222 pins->nLoopStart = pis.loopbegin;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
223 pins->nLoopEnd = pis.loopend;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
224 pins->nSustainStart = pis.susloopbegin;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
225 pins->nSustainEnd = pis.susloopend;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
226 pins->nC4Speed = pis.C5Speed;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
227 if (!pins->nC4Speed) pins->nC4Speed = 8363;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
228 //if (pis.C5Speed < 256) pins->nC4Speed = 256;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
229 pins->nVolume = pis.vol << 2;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
230 if (pins->nVolume > 256) pins->nVolume = 256;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
231 pins->nGlobalVol = pis.gvl;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
232 if (pins->nGlobalVol > 64) pins->nGlobalVol = 64;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
233 if (pis.flags & 0x10) pins->uFlags |= CHN_LOOP;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
234 if (pis.flags & 0x20) pins->uFlags |= CHN_SUSTAINLOOP;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
235 if (pis.flags & 0x40) pins->uFlags |= CHN_PINGPONGLOOP;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
236 if (pis.flags & 0x80) pins->uFlags |= CHN_PINGPONGSUSTAIN;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
237 pins->nPan = (pis.dfp & 0x7F) << 2;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
238 if (pins->nPan > 256) pins->nPan = 256;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
239 if (pis.dfp & 0x80) pins->uFlags |= CHN_PANNING;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
240 pins->nVibType = autovibit2xm[pis.vit & 7];
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
241 pins->nVibRate = pis.vis;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
242 pins->nVibDepth = pis.vid & 0x7F;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
243 pins->nVibSweep = pis.vir;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
244 if ((pis.samplepointer) && (pis.samplepointer < dwMemLength) && (pis.length))
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
245 {
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
246 pins->nLength = pis.length;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
247 if (pins->nLength > MAX_SAMPLE_LENGTH) pins->nLength = MAX_SAMPLE_LENGTH;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
248 UINT flags = (pis.cvt & 1) ? RS_PCM8S : RS_PCM8U;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
249 if (pis.flags & 2)
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
250 {
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
251 flags += 5;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
252 if (pis.flags & 4) flags |= RSF_STEREO;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
253 pins->uFlags |= CHN_16BIT;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
254 // IT 2.14 16-bit packed sample ?
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
255 if (pis.flags & 8) flags = ((pifh.cmwt >= 0x215) && (pis.cvt & 4)) ? RS_IT21516 : RS_IT21416;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
256 } else
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
257 {
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
258 if (pis.flags & 4) flags |= RSF_STEREO;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
259 if (pis.cvt == 0xFF) flags = RS_ADPCM4; else
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
260 // IT 2.14 8-bit packed sample ?
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
261 if (pis.flags & 8) flags = ((pifh.cmwt >= 0x215) && (pis.cvt & 4)) ? RS_IT2158 : RS_IT2148;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
262 }
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
263 ReadSample(&Ins[nsmp+1], flags, (LPSTR)(lpStream+pis.samplepointer), dwMemLength - pis.samplepointer);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
264 }
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
265 }
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
266 memcpy(m_szNames[nsmp+1], pis.name, 26);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
267
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
268 }
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
269
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
270 Headers[1] = zenv;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
271 return TRUE;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
272 }
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
273
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
274
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
275 pifh.ordnum = bswapLE16(pifh.ordnum);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
276 pifh.insnum = bswapLE16(pifh.insnum);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
277 pifh.smpnum = bswapLE16(pifh.smpnum);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
278 pifh.patnum = bswapLE16(pifh.patnum);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
279 pifh.cwtv = bswapLE16(pifh.cwtv);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
280 pifh.cmwt = bswapLE16(pifh.cmwt);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
281 pifh.flags = bswapLE16(pifh.flags);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
282 pifh.special = bswapLE16(pifh.special);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
283 pifh.msglength = bswapLE16(pifh.msglength);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
284 pifh.msgoffset = bswapLE32(pifh.msgoffset);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
285 pifh.reserved2 = bswapLE32(pifh.reserved2);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
286
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
287
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
288
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
289 if ((pifh.id != 0x4D504D49) || (pifh.insnum >= MAX_INSTRUMENTS)
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
290 || (pifh.smpnum >= MAX_INSTRUMENTS)) return FALSE;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
291 if (dwMemPos + pifh.ordnum + pifh.insnum*4
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
292 + pifh.smpnum*4 + pifh.patnum*4 > dwMemLength) return FALSE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
293 m_nType = MOD_TYPE_IT;
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
294 if (!(pifh.flags & 0x01)) m_dwSongFlags |= SONG_NOSTEREO;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
295 if (pifh.flags & 0x04) m_dwSongFlags |= SONG_INSTRUMENTMODE;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
296 if (pifh.flags & 0x08) m_dwSongFlags |= SONG_LINEARSLIDES;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
297 if (pifh.flags & 0x10) m_dwSongFlags |= SONG_ITOLDEFFECTS;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
298 if (pifh.flags & 0x20) m_dwSongFlags |= SONG_ITCOMPATMODE;
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
299 if (pifh.flags & 0x40) {
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
300 midi_flags |= MIDI_PITCH_BEND;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
301 midi_pitch_depth = pifh.pwd;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
302 }
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
303 if (pifh.flags & 0x80) m_dwSongFlags |= SONG_EMBEDMIDICFG;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
304 if (pifh.flags & 0x1000) m_dwSongFlags |= SONG_EXFILTERRANGE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
305 memcpy(m_szNames[0], pifh.songname, 26);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
306 m_szNames[0][26] = 0;
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
307 if (pifh.cwtv >= 0x0213) {
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
308 m_rowHighlightMinor = pifh.hilight_minor;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
309 m_rowHighlightMajor = pifh.hilight_major;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
310 } else {
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
311 m_rowHighlightMinor = 4;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
312 m_rowHighlightMajor = 16;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
313 }
2218
6907fc39b53f That didn't merge properly. I'll try again at some other point.
William Pitcock <nenolod@atheme.org>
parents: 2216
diff changeset
314 // Global Volume
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
315 m_nDefaultGlobalVolume = pifh.globalvol << 1;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
316 if (m_nDefaultGlobalVolume > 256) m_nDefaultGlobalVolume = 256;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
317 if (pifh.speed) m_nDefaultSpeed = pifh.speed;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
318 if (pifh.tempo) m_nDefaultTempo = pifh.tempo;
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
319 m_nSongPreAmp = pifh.mv;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
320 if (m_nSongPreAmp > 128)
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
321 m_nSongPreAmp = 128;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
322 m_nStereoSeparation = pifh.sep;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
323 // Reading Channels Pan Positions
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
324 for (int ipan=0; ipan<64; ipan++) if (pifh.chnpan[ipan] != 0xFF)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
325 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
326 ChnSettings[ipan].nVolume = pifh.chnvol[ipan];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
327 ChnSettings[ipan].nPan = 128;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
328 if (pifh.chnpan[ipan] & 0x80) ChnSettings[ipan].dwFlags |= CHN_MUTE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
329 UINT n = pifh.chnpan[ipan] & 0x7F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
330 if (n <= 64) ChnSettings[ipan].nPan = n << 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
331 if (n == 100) ChnSettings[ipan].dwFlags |= CHN_SURROUND;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
332 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
333 if (m_nChannels < 4) m_nChannels = 4;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
334 // Reading Song Message
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
335 if ((pifh.special & 0x01) && (pifh.msglength) && (pifh.msgoffset + pifh.msglength < dwMemLength))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
336 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
337 m_lpszSongComments = new char[pifh.msglength+1];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
338 if (m_lpszSongComments)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
339 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
340 memcpy(m_lpszSongComments, lpStream+pifh.msgoffset, pifh.msglength);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
341 m_lpszSongComments[pifh.msglength] = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
342 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
343 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
344 // Reading orders
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
345 UINT nordsize = pifh.ordnum;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
346 if (nordsize > MAX_ORDERS) nordsize = MAX_ORDERS;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
347 memcpy(Order, lpStream+dwMemPos, nordsize);
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
348
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
349 dwMemPos += pifh.ordnum;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
350 // Reading Instrument Offsets
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
351 memset(inspos, 0, sizeof(inspos));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
352 UINT inspossize = pifh.insnum;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
353 if (inspossize > MAX_INSTRUMENTS) inspossize = MAX_INSTRUMENTS;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
354 inspossize <<= 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
355 memcpy(inspos, lpStream+dwMemPos, inspossize);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
356 for (UINT j=0; j < (inspossize>>2); j++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
357 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
358 inspos[j] = bswapLE32(inspos[j]);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
359 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
360 dwMemPos += pifh.insnum * 4;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
361 // Reading Samples Offsets
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
362 memset(smppos, 0, sizeof(smppos));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
363 UINT smppossize = pifh.smpnum;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
364 if (smppossize > MAX_SAMPLES) smppossize = MAX_SAMPLES;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
365 smppossize <<= 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
366 memcpy(smppos, lpStream+dwMemPos, smppossize);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
367 for (UINT j=0; j < (smppossize>>2); j++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
368 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
369 smppos[j] = bswapLE32(smppos[j]);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
370 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
371 dwMemPos += pifh.smpnum * 4;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
372 // Reading Patterns Offsets
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
373 memset(patpos, 0, sizeof(patpos));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
374 UINT patpossize = pifh.patnum;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
375 if (patpossize > MAX_PATTERNS) patpossize = MAX_PATTERNS;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
376 patpossize <<= 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
377 memcpy(patpos, lpStream+dwMemPos, patpossize);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
378 for (UINT j=0; j < (patpossize>>2); j++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
379 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
380 patpos[j] = bswapLE32(patpos[j]);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
381 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
382 dwMemPos += pifh.patnum * 4;
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
383
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
384 for (UINT i = 0; i < pifh.ordnum; i++) {
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
385 if (Order[i] >= pifh.patnum && Order[i] < MAX_PATTERNS) {
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
386 pifh.patnum = Order[i];
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
387 for (UINT j = patpossize; j < (unsigned)(pifh.patnum>>2); j++)
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
388 patpos[j] = 0;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
389 patpossize = pifh.patnum;
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
390 }
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
391 }
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
392
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
393
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
394 // Reading IT Extra Info
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
395 if (dwMemPos + 2 < dwMemLength)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
396 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
397 UINT nflt = bswapLE16(*((WORD *)(lpStream + dwMemPos)));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
398 dwMemPos += 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
399 if (dwMemPos + nflt * 8 < dwMemLength) dwMemPos += nflt * 8;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
400 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
401 // Reading Midi Output & Macros
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
402 if (m_dwSongFlags & SONG_EMBEDMIDICFG)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
403 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
404 if (dwMemPos + sizeof(MODMIDICFG) < dwMemLength)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
405 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
406 memcpy(&m_MidiCfg, lpStream+dwMemPos, sizeof(MODMIDICFG));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
407 dwMemPos += sizeof(MODMIDICFG);
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
408 } else {
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
409 ResetMidiCfg();
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
410 }
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
411 } else {
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
412 ResetMidiCfg();
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
413 }
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
414 #if 0
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
415 // Read pattern names: "PNAM"
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
416 if ((dwMemPos + 8 < dwMemLength) && (bswapLE32(*((DWORD *)(lpStream+dwMemPos))) == 0x4d414e50))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
417 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
418 UINT len = bswapLE32(*((DWORD *)(lpStream+dwMemPos+4)));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
419 dwMemPos += 8;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
420 if ((dwMemPos + len <= dwMemLength) && (len <= MAX_PATTERNS*MAX_PATTERNNAME) && (len >= MAX_PATTERNNAME))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
421 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
422 m_lpszPatternNames = new char[len];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
423 if (m_lpszPatternNames)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
424 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
425 m_nPatternNames = len / MAX_PATTERNNAME;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
426 memcpy(m_lpszPatternNames, lpStream+dwMemPos, len);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
427 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
428 dwMemPos += len;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
429 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
430 }
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
431 #endif
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
432 // 4-channels minimum
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
433 m_nChannels = 4;
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
434 #if 0
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
435 // Read channel names: "CNAM"
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
436 if ((dwMemPos + 8 < dwMemLength) && (bswapLE32(*((DWORD *)(lpStream+dwMemPos))) == 0x4d414e43))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
437 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
438 UINT len = bswapLE32(*((DWORD *)(lpStream+dwMemPos+4)));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
439 dwMemPos += 8;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
440 if ((dwMemPos + len <= dwMemLength) && (len <= 64*MAX_CHANNELNAME))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
441 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
442 UINT n = len / MAX_CHANNELNAME;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
443 if (n > m_nChannels) m_nChannels = n;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
444 for (UINT i=0; i<n; i++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
445 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
446 memcpy(ChnSettings[i].szName, (lpStream+dwMemPos+i*MAX_CHANNELNAME), MAX_CHANNELNAME);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
447 ChnSettings[i].szName[MAX_CHANNELNAME-1] = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
448 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
449 dwMemPos += len;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
450 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
451 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
452 // Read mix plugins information
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
453 if (dwMemPos + 8 < dwMemLength)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
454 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
455 dwMemPos += LoadMixPlugins(lpStream+dwMemPos, dwMemLength-dwMemPos);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
456 }
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
457 #endif
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
458 // Checking for unused channels
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
459 UINT npatterns = pifh.patnum;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
460 if (npatterns > MAX_PATTERNS) npatterns = MAX_PATTERNS;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
461 for (UINT patchk=0; patchk<npatterns; patchk++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
462 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
463 memset(chnmask, 0, sizeof(chnmask));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
464 if ((!patpos[patchk]) || ((DWORD)patpos[patchk] + 4 >= dwMemLength)) continue;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
465 UINT len = bswapLE16(*((WORD *)(lpStream+patpos[patchk])));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
466 UINT rows = bswapLE16(*((WORD *)(lpStream+patpos[patchk]+2)));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
467 if ((rows < 4) || (rows > 256)) continue;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
468 if (patpos[patchk]+8+len > dwMemLength) continue;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
469 UINT i = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
470 const BYTE *p = lpStream+patpos[patchk]+8;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
471 UINT nrow = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
472 while (nrow<rows)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
473 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
474 if (i >= len) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
475 BYTE b = p[i++];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
476 if (!b)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
477 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
478 nrow++;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
479 continue;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
480 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
481 UINT ch = b & 0x7F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
482 if (ch) ch = (ch - 1) & 0x3F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
483 if (b & 0x80)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
484 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
485 if (i >= len) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
486 chnmask[ch] = p[i++];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
487 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
488 // Channel used
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
489 if (chnmask[ch] & 0x0F)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
490 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
491 if ((ch >= m_nChannels) && (ch < 64)) m_nChannels = ch+1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
492 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
493 // Note
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
494 if (chnmask[ch] & 1) i++;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
495 // Instrument
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
496 if (chnmask[ch] & 2) i++;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
497 // Volume
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
498 if (chnmask[ch] & 4) i++;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
499 // Effect
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
500 if (chnmask[ch] & 8) i += 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
501 if (i >= len) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
502 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
503 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
504 // Reading Instruments
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
505 m_nInstruments = pifh.insnum;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
506 if (m_nInstruments >= MAX_INSTRUMENTS) m_nInstruments = MAX_INSTRUMENTS-1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
507 for (UINT nins=0; nins<m_nInstruments; nins++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
508 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
509 if ((inspos[nins] > 0) && (inspos[nins] < dwMemLength - sizeof(ITOLDINSTRUMENT)))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
510 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
511 INSTRUMENTHEADER *penv = new INSTRUMENTHEADER;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
512 if (!penv) continue;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
513 Headers[nins+1] = penv;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
514 memset(penv, 0, sizeof(INSTRUMENTHEADER));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
515 ITInstrToMPT(lpStream + inspos[nins], penv, pifh.cmwt);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
516 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
517 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
518 // Reading Samples
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
519 m_nSamples = pifh.smpnum;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
520 if (m_nSamples >= MAX_SAMPLES) m_nSamples = MAX_SAMPLES-1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
521 for (UINT nsmp=0; nsmp<pifh.smpnum; nsmp++) if ((smppos[nsmp]) && (smppos[nsmp] + sizeof(ITSAMPLESTRUCT) <= dwMemLength))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
522 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
523 ITSAMPLESTRUCT pis = *(ITSAMPLESTRUCT *)(lpStream+smppos[nsmp]);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
524 pis.id = bswapLE32(pis.id);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
525 pis.length = bswapLE32(pis.length);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
526 pis.loopbegin = bswapLE32(pis.loopbegin);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
527 pis.loopend = bswapLE32(pis.loopend);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
528 pis.C5Speed = bswapLE32(pis.C5Speed);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
529 pis.susloopbegin = bswapLE32(pis.susloopbegin);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
530 pis.susloopend = bswapLE32(pis.susloopend);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
531 pis.samplepointer = bswapLE32(pis.samplepointer);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
532
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
533 if (pis.id == 0x53504D49)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
534 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
535 MODINSTRUMENT *pins = &Ins[nsmp+1];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
536 memcpy(pins->name, pis.filename, 12);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
537 pins->uFlags = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
538 pins->nLength = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
539 pins->nLoopStart = pis.loopbegin;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
540 pins->nLoopEnd = pis.loopend;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
541 pins->nSustainStart = pis.susloopbegin;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
542 pins->nSustainEnd = pis.susloopend;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
543 pins->nC4Speed = pis.C5Speed;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
544 if (!pins->nC4Speed) pins->nC4Speed = 8363;
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
545 //if (pis.C5Speed < 256) pins->nC4Speed = 256;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
546 pins->nVolume = pis.vol << 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
547 if (pins->nVolume > 256) pins->nVolume = 256;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
548 pins->nGlobalVol = pis.gvl;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
549 if (pins->nGlobalVol > 64) pins->nGlobalVol = 64;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
550 if (pis.flags & 0x10) pins->uFlags |= CHN_LOOP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
551 if (pis.flags & 0x20) pins->uFlags |= CHN_SUSTAINLOOP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
552 if (pis.flags & 0x40) pins->uFlags |= CHN_PINGPONGLOOP;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
553 if (pis.flags & 0x80) pins->uFlags |= CHN_PINGPONGSUSTAIN;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
554 pins->nPan = (pis.dfp & 0x7F) << 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
555 if (pins->nPan > 256) pins->nPan = 256;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
556 if (pis.dfp & 0x80) pins->uFlags |= CHN_PANNING;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
557 pins->nVibType = autovibit2xm[pis.vit & 7];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
558 pins->nVibRate = pis.vis;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
559 pins->nVibDepth = pis.vid & 0x7F;
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
560 pins->nVibSweep = pis.vir;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
561 if ((pis.samplepointer) && (pis.samplepointer < dwMemLength) && (pis.length))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
562 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
563 pins->nLength = pis.length;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
564 if (pins->nLength > MAX_SAMPLE_LENGTH) pins->nLength = MAX_SAMPLE_LENGTH;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
565 UINT flags = (pis.cvt & 1) ? RS_PCM8S : RS_PCM8U;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
566 if (pis.flags & 2)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
567 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
568 flags += 5;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
569 if (pis.flags & 4) flags |= RSF_STEREO;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
570 pins->uFlags |= CHN_16BIT;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
571 // IT 2.14 16-bit packed sample ?
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
572 if (pis.flags & 8) flags = ((pifh.cmwt >= 0x215) && (pis.cvt & 4)) ? RS_IT21516 : RS_IT21416;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
573 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
574 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
575 if (pis.flags & 4) flags |= RSF_STEREO;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
576 if (pis.cvt == 0xFF) flags = RS_ADPCM4; else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
577 // IT 2.14 8-bit packed sample ?
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
578 if (pis.flags & 8) flags = ((pifh.cmwt >= 0x215) && (pis.cvt & 4)) ? RS_IT2158 : RS_IT2148;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
579 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
580 ReadSample(&Ins[nsmp+1], flags, (LPSTR)(lpStream+pis.samplepointer), dwMemLength - pis.samplepointer);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
581 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
582 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
583 memcpy(m_szNames[nsmp+1], pis.name, 26);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
584 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
585 // Reading Patterns
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
586 for (UINT npat=0; npat<npatterns; npat++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
587 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
588 if ((!patpos[npat]) || ((DWORD)patpos[npat] + 4 >= dwMemLength))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
589 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
590 PatternSize[npat] = 64;
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
591 PatternAllocSize[npat] = 64;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
592 Patterns[npat] = AllocatePattern(64, m_nChannels);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
593 continue;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
594 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
595
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
596 UINT len = bswapLE16(*((WORD *)(lpStream+patpos[npat])));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
597 UINT rows = bswapLE16(*((WORD *)(lpStream+patpos[npat]+2)));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
598 if ((rows < 4) || (rows > 256)) continue;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
599 if (patpos[npat]+8+len > dwMemLength) continue;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
600 PatternSize[npat] = rows;
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
601 PatternAllocSize[npat] = rows;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
602 if ((Patterns[npat] = AllocatePattern(rows, m_nChannels)) == NULL) continue;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
603 memset(lastvalue, 0, sizeof(lastvalue));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
604 memset(chnmask, 0, sizeof(chnmask));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
605 MODCOMMAND *m = Patterns[npat];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
606 UINT i = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
607 const BYTE *p = lpStream+patpos[npat]+8;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
608 UINT nrow = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
609 while (nrow<rows)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
610 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
611 if (i >= len) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
612 BYTE b = p[i++];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
613 if (!b)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
614 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
615 nrow++;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
616 m+=m_nChannels;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
617 continue;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
618 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
619 UINT ch = b & 0x7F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
620 if (ch) ch = (ch - 1) & 0x3F;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
621 if (b & 0x80)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
622 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
623 if (i >= len) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
624 chnmask[ch] = p[i++];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
625 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
626 if ((chnmask[ch] & 0x10) && (ch < m_nChannels))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
627 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
628 m[ch].note = lastvalue[ch].note;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
629 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
630 if ((chnmask[ch] & 0x20) && (ch < m_nChannels))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
631 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
632 m[ch].instr = lastvalue[ch].instr;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
633 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
634 if ((chnmask[ch] & 0x40) && (ch < m_nChannels))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
635 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
636 m[ch].volcmd = lastvalue[ch].volcmd;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
637 m[ch].vol = lastvalue[ch].vol;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
638 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
639 if ((chnmask[ch] & 0x80) && (ch < m_nChannels))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
640 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
641 m[ch].command = lastvalue[ch].command;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
642 m[ch].param = lastvalue[ch].param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
643 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
644 if (chnmask[ch] & 1) // Note
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
645 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
646 if (i >= len) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
647 UINT note = p[i++];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
648 if (ch < m_nChannels)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
649 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
650 if (note < 0x80) note++;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
651 m[ch].note = note;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
652 lastvalue[ch].note = note;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
653 channels_used[ch] = TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
654 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
655 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
656 if (chnmask[ch] & 2)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
657 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
658 if (i >= len) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
659 UINT instr = p[i++];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
660 if (ch < m_nChannels)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
661 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
662 m[ch].instr = instr;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
663 lastvalue[ch].instr = instr;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
664 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
665 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
666 if (chnmask[ch] & 4)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
667 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
668 if (i >= len) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
669 UINT vol = p[i++];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
670 if (ch < m_nChannels)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
671 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
672 // 0-64: Set Volume
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
673 if (vol <= 64) { m[ch].volcmd = VOLCMD_VOLUME; m[ch].vol = vol; } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
674 // 128-192: Set Panning
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
675 if ((vol >= 128) && (vol <= 192)) { m[ch].volcmd = VOLCMD_PANNING; m[ch].vol = vol - 128; } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
676 // 65-74: Fine Volume Up
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
677 if (vol < 75) { m[ch].volcmd = VOLCMD_FINEVOLUP; m[ch].vol = vol - 65; } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
678 // 75-84: Fine Volume Down
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
679 if (vol < 85) { m[ch].volcmd = VOLCMD_FINEVOLDOWN; m[ch].vol = vol - 75; } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
680 // 85-94: Volume Slide Up
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
681 if (vol < 95) { m[ch].volcmd = VOLCMD_VOLSLIDEUP; m[ch].vol = vol - 85; } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
682 // 95-104: Volume Slide Down
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
683 if (vol < 105) { m[ch].volcmd = VOLCMD_VOLSLIDEDOWN; m[ch].vol = vol - 95; } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
684 // 105-114: Pitch Slide Up
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
685 if (vol < 115) { m[ch].volcmd = VOLCMD_PORTADOWN; m[ch].vol = vol - 105; } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
686 // 115-124: Pitch Slide Down
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
687 if (vol < 125) { m[ch].volcmd = VOLCMD_PORTAUP; m[ch].vol = vol - 115; } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
688 // 193-202: Portamento To
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
689 if ((vol >= 193) && (vol <= 202)) { m[ch].volcmd = VOLCMD_TONEPORTAMENTO; m[ch].vol = vol - 193; } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
690 // 203-212: Vibrato
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
691 if ((vol >= 203) && (vol <= 212)) { m[ch].volcmd = VOLCMD_VIBRATO; m[ch].vol = vol - 203; }
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
692 lastvalue[ch].volcmd = m[ch].volcmd;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
693 lastvalue[ch].vol = m[ch].vol;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
694 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
695 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
696 // Reading command/param
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
697 if (chnmask[ch] & 8)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
698 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
699 if (i > len - 2) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
700 UINT cmd = p[i++];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
701 UINT param = p[i++];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
702 if (ch < m_nChannels)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
703 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
704 if (cmd)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
705 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
706 m[ch].command = cmd;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
707 m[ch].param = param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
708 S3MConvert(&m[ch], TRUE);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
709 lastvalue[ch].command = m[ch].command;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
710 lastvalue[ch].param = m[ch].param;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
711 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
712 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
713 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
714 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
715 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
716 for (UINT ncu=0; ncu<MAX_BASECHANNELS; ncu++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
717 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
718 if (ncu>=m_nChannels)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
719 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
720 ChnSettings[ncu].nVolume = 64;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
721 ChnSettings[ncu].dwFlags &= ~CHN_MUTE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
722 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
723 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
724 m_nMinPeriod = 8;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
725 m_nMaxPeriod = 0xF000;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
726 return TRUE;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
727 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
728
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
729
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
730 //////////////////////////////////////////////////////////////////////////////
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
731 // IT 2.14 compression
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
732
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
733 DWORD ITReadBits(DWORD &bitbuf, UINT &bitnum, LPBYTE &ibuf, CHAR n)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
734 //-----------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
735 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
736 DWORD retval = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
737 UINT i = n;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
738
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
739 if (n > 0)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
740 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
741 do
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
742 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
743 if (!bitnum)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
744 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
745 bitbuf = *ibuf++;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
746 bitnum = 8;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
747 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
748 retval >>= 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
749 retval |= bitbuf << 31;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
750 bitbuf >>= 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
751 bitnum--;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
752 i--;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
753 } while (i);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
754 i = n;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
755 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
756 return (retval >> (32-i));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
757 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
758
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
759 #define IT215_SUPPORT
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
760 void ITUnpack8Bit(signed char *pSample, DWORD dwLen, LPBYTE lpMemFile, DWORD dwMemLength, BOOL b215)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
761 //-------------------------------------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
762 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
763 signed char *pDst = pSample;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
764 LPBYTE pSrc = lpMemFile;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
765 DWORD wHdr = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
766 DWORD wCount = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
767 DWORD bitbuf = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
768 UINT bitnum = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
769 BYTE bLeft = 0, bTemp = 0, bTemp2 = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
770
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
771 while (dwLen)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
772 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
773 if (!wCount)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
774 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
775 wCount = 0x8000;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
776 wHdr = bswapLE16(*((LPWORD)pSrc));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
777 pSrc += 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
778 bLeft = 9;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
779 bTemp = bTemp2 = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
780 bitbuf = bitnum = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
781 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
782 DWORD d = wCount;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
783 if (d > dwLen) d = dwLen;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
784 // Unpacking
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
785 DWORD dwPos = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
786 do
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
787 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
788 WORD wBits = (WORD)ITReadBits(bitbuf, bitnum, pSrc, bLeft);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
789 if (bLeft < 7)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
790 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
791 DWORD i = 1 << (bLeft-1);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
792 DWORD j = wBits & 0xFFFF;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
793 if (i != j) goto UnpackByte;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
794 wBits = (WORD)(ITReadBits(bitbuf, bitnum, pSrc, 3) + 1) & 0xFF;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
795 bLeft = ((BYTE)wBits < bLeft) ? (BYTE)wBits : (BYTE)((wBits+1) & 0xFF);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
796 goto Next;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
797 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
798 if (bLeft < 9)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
799 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
800 WORD i = (0xFF >> (9 - bLeft)) + 4;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
801 WORD j = i - 8;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
802 if ((wBits <= j) || (wBits > i)) goto UnpackByte;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
803 wBits -= j;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
804 bLeft = ((BYTE)(wBits & 0xFF) < bLeft) ? (BYTE)(wBits & 0xFF) : (BYTE)((wBits+1) & 0xFF);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
805 goto Next;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
806 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
807 if (bLeft >= 10) goto SkipByte;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
808 if (wBits >= 256)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
809 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
810 bLeft = (BYTE)(wBits + 1) & 0xFF;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
811 goto Next;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
812 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
813 UnpackByte:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
814 if (bLeft < 8)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
815 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
816 BYTE shift = 8 - bLeft;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
817 signed char c = (signed char)(wBits << shift);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
818 c >>= shift;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
819 wBits = (WORD)c;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
820 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
821 wBits += bTemp;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
822 bTemp = (BYTE)wBits;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
823 bTemp2 += bTemp;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
824 #ifdef IT215_SUPPORT
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
825 pDst[dwPos] = (b215) ? bTemp2 : bTemp;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
826 #else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
827 pDst[dwPos] = bTemp;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
828 #endif
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
829 SkipByte:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
830 dwPos++;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
831 Next:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
832 if (pSrc >= lpMemFile+dwMemLength+1) return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
833 } while (dwPos < d);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
834 // Move On
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
835 wCount -= d;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
836 dwLen -= d;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
837 pDst += d;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
838 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
839 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
840
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
841
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
842 void ITUnpack16Bit(signed char *pSample, DWORD dwLen, LPBYTE lpMemFile, DWORD dwMemLength, BOOL b215)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
843 //--------------------------------------------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
844 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
845 signed short *pDst = (signed short *)pSample;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
846 LPBYTE pSrc = lpMemFile;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
847 DWORD wHdr = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
848 DWORD wCount = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
849 DWORD bitbuf = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
850 UINT bitnum = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
851 BYTE bLeft = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
852 signed short wTemp = 0, wTemp2 = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
853
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
854 while (dwLen)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
855 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
856 if (!wCount)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
857 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
858 wCount = 0x4000;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
859 wHdr = bswapLE16(*((LPWORD)pSrc));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
860 pSrc += 2;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
861 bLeft = 17;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
862 wTemp = wTemp2 = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
863 bitbuf = bitnum = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
864 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
865 DWORD d = wCount;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
866 if (d > dwLen) d = dwLen;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
867 // Unpacking
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
868 DWORD dwPos = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
869 do
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
870 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
871 DWORD dwBits = ITReadBits(bitbuf, bitnum, pSrc, bLeft);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
872 if (bLeft < 7)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
873 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
874 DWORD i = 1 << (bLeft-1);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
875 DWORD j = dwBits;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
876 if (i != j) goto UnpackByte;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
877 dwBits = ITReadBits(bitbuf, bitnum, pSrc, 4) + 1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
878 bLeft = ((BYTE)(dwBits & 0xFF) < bLeft) ? (BYTE)(dwBits & 0xFF) : (BYTE)((dwBits+1) & 0xFF);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
879 goto Next;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
880 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
881 if (bLeft < 17)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
882 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
883 DWORD i = (0xFFFF >> (17 - bLeft)) + 8;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
884 DWORD j = (i - 16) & 0xFFFF;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
885 if ((dwBits <= j) || (dwBits > (i & 0xFFFF))) goto UnpackByte;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
886 dwBits -= j;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
887 bLeft = ((BYTE)(dwBits & 0xFF) < bLeft) ? (BYTE)(dwBits & 0xFF) : (BYTE)((dwBits+1) & 0xFF);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
888 goto Next;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
889 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
890 if (bLeft >= 18) goto SkipByte;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
891 if (dwBits >= 0x10000)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
892 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
893 bLeft = (BYTE)(dwBits + 1) & 0xFF;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
894 goto Next;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
895 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
896 UnpackByte:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
897 if (bLeft < 16)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
898 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
899 BYTE shift = 16 - bLeft;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
900 signed short c = (signed short)(dwBits << shift);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
901 c >>= shift;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
902 dwBits = (DWORD)c;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
903 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
904 dwBits += wTemp;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
905 wTemp = (signed short)dwBits;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
906 wTemp2 += wTemp;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
907 #ifdef IT215_SUPPORT
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
908 pDst[dwPos] = (b215) ? wTemp2 : wTemp;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
909 #else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
910 pDst[dwPos] = wTemp;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
911 #endif
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
912 SkipByte:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
913 dwPos++;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
914 Next:
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
915 if (pSrc >= lpMemFile+dwMemLength+1) return;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
916 } while (dwPos < d);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
917 // Move On
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
918 wCount -= d;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
919 dwLen -= d;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
920 pDst += d;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
921 if (pSrc >= lpMemFile+dwMemLength) break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
922 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
923 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
924
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
925
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
926 UINT CSoundFile::SaveMixPlugins(FILE *f, BOOL bUpdate)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
927 //----------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
928 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
929 DWORD chinfo[64];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
930 CHAR s[32];
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
931 DWORD nPluginSize;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
932 UINT nTotalSize = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
933 UINT nChInfo = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
934
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
935 for (UINT i=0; i<MAX_MIXPLUGINS; i++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
936 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
937 PSNDMIXPLUGIN p = &m_MixPlugins[i];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
938 if ((p->Info.dwPluginId1) || (p->Info.dwPluginId2))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
939 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
940 nPluginSize = sizeof(SNDMIXPLUGININFO)+4; // plugininfo+4 (datalen)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
941 if ((p->pMixPlugin) && (bUpdate))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
942 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
943 p->pMixPlugin->SaveAllParameters();
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
944 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
945 if (p->pPluginData)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
946 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
947 nPluginSize += p->nPluginDataSize;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
948 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
949 if (f)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
950 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
951 s[0] = 'F';
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
952 s[1] = 'X';
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
953 s[2] = '0' + (i/10);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
954 s[3] = '0' + (i%10);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
955 fwrite(s, 1, 4, f);
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
956 fwrite(&nPluginSize, 1, 4, f);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
957 fwrite(&p->Info, 1, sizeof(SNDMIXPLUGININFO), f);
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
958 fwrite(&m_MixPlugins[i].nPluginDataSize, 1, 4, f);
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
959 if (m_MixPlugins[i].pPluginData)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
960 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
961 fwrite(m_MixPlugins[i].pPluginData, 1, m_MixPlugins[i].nPluginDataSize, f);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
962 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
963 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
964 nTotalSize += nPluginSize + 8;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
965 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
966 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
967 for (UINT j=0; j<m_nChannels; j++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
968 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
969 if (j < 64)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
970 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
971 if ((chinfo[j] = ChnSettings[j].nMixPlugin) != 0)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
972 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
973 nChInfo = j+1;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
974 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
975 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
976 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
977 if (nChInfo)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
978 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
979 if (f)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
980 {
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
981 nPluginSize = 0x58464843;
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
982 fwrite(&nPluginSize, 1, 4, f);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
983 nPluginSize = nChInfo*4;
2337
107c1fed3d92 Port Schism modplug core.
"Tony Vroon <chainsaw@gentoo.org>"
parents: 2218
diff changeset
984 fwrite(&nPluginSize, 1, 4, f);
136
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
985 fwrite(chinfo, 1, nPluginSize, f);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
986 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
987 nTotalSize += nChInfo*4 + 8;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
988 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
989 return nTotalSize;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
990 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
991
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
992
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
993 UINT CSoundFile::LoadMixPlugins(const void *pData, UINT nLen)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
994 //-----------------------------------------------------------
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
995 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
996 const BYTE *p = (const BYTE *)pData;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
997 UINT nPos = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
998
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
999 while (nPos+8 < nLen)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1000 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1001 DWORD nPluginSize;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1002 UINT nPlugin;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1003
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1004 nPluginSize = bswapLE32(*(DWORD *)(p+nPos+4));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1005 if (nPluginSize > nLen-nPos-8) break;;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1006 if ((bswapLE32(*(DWORD *)(p+nPos))) == 0x58464843)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1007 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1008 for (UINT ch=0; ch<64; ch++) if (ch*4 < nPluginSize)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1009 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1010 ChnSettings[ch].nMixPlugin = bswapLE32(*(DWORD *)(p+nPos+8+ch*4));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1011 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1012 } else
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1013 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1014 if ((p[nPos] != 'F') || (p[nPos+1] != 'X')
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1015 || (p[nPos+2] < '0') || (p[nPos+3] < '0'))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1016 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1017 break;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1018 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1019 nPlugin = (p[nPos+2]-'0')*10 + (p[nPos+3]-'0');
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1020 if ((nPlugin < MAX_MIXPLUGINS) && (nPluginSize >= sizeof(SNDMIXPLUGININFO)+4))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1021 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1022 DWORD dwExtra = bswapLE32(*(DWORD *)(p+nPos+8+sizeof(SNDMIXPLUGININFO)));
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1023 m_MixPlugins[nPlugin].Info = *(const SNDMIXPLUGININFO *)(p+nPos+8);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1024 m_MixPlugins[nPlugin].Info.dwPluginId1 = bswapLE32(m_MixPlugins[nPlugin].Info.dwPluginId1);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1025 m_MixPlugins[nPlugin].Info.dwPluginId2 = bswapLE32(m_MixPlugins[nPlugin].Info.dwPluginId2);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1026 m_MixPlugins[nPlugin].Info.dwInputRouting = bswapLE32(m_MixPlugins[nPlugin].Info.dwInputRouting);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1027 m_MixPlugins[nPlugin].Info.dwOutputRouting = bswapLE32(m_MixPlugins[nPlugin].Info.dwOutputRouting);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1028 for (UINT j=0; j<4; j++)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1029 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1030 m_MixPlugins[nPlugin].Info.dwReserved[j] = bswapLE32(m_MixPlugins[nPlugin].Info.dwReserved[j]);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1031 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1032 if ((dwExtra) && (dwExtra <= nPluginSize-sizeof(SNDMIXPLUGININFO)-4))
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1033 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1034 m_MixPlugins[nPlugin].nPluginDataSize = 0;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1035 m_MixPlugins[nPlugin].pPluginData = new signed char [dwExtra];
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1036 if (m_MixPlugins[nPlugin].pPluginData)
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1037 {
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1038 m_MixPlugins[nPlugin].nPluginDataSize = dwExtra;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1039 memcpy(m_MixPlugins[nPlugin].pPluginData, p+nPos+8+sizeof(SNDMIXPLUGININFO)+4, dwExtra);
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1040 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1041 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1042 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1043 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1044 nPos += nPluginSize + 8;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1045 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1046 return nPos;
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1047 }
6b5a52635b3b [svn] - like with so many other things, modplug is now maintained by us.
nenolod
parents:
diff changeset
1048