Diffstat (limited to 'core/multimedia/opieplayer/modplug/load_mdl.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/modplug/load_mdl.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/multimedia/opieplayer/modplug/load_mdl.cpp b/core/multimedia/opieplayer/modplug/load_mdl.cpp index 806b68b..e1f78d5 100644 --- a/core/multimedia/opieplayer/modplug/load_mdl.cpp +++ b/core/multimedia/opieplayer/modplug/load_mdl.cpp | |||
@@ -200,97 +200,97 @@ BOOL CSoundFile::ReadMDL(const BYTE *lpStream, DWORD dwMemLength) | |||
200 | if ((pmsh->id != 0x4C444D44) || ((pmsh->version & 0xF0) > 0x10)) return FALSE; | 200 | if ((pmsh->id != 0x4C444D44) || ((pmsh->version & 0xF0) > 0x10)) return FALSE; |
201 | memset(patterntracks, 0, sizeof(patterntracks)); | 201 | memset(patterntracks, 0, sizeof(patterntracks)); |
202 | memset(smpinfo, 0, sizeof(smpinfo)); | 202 | memset(smpinfo, 0, sizeof(smpinfo)); |
203 | memset(insvolenv, 0, sizeof(insvolenv)); | 203 | memset(insvolenv, 0, sizeof(insvolenv)); |
204 | memset(inspanenv, 0, sizeof(inspanenv)); | 204 | memset(inspanenv, 0, sizeof(inspanenv)); |
205 | dwMemPos = 5; | 205 | dwMemPos = 5; |
206 | dwTrackPos = 0; | 206 | dwTrackPos = 0; |
207 | pvolenv = ppanenv = ppitchenv = NULL; | 207 | pvolenv = ppanenv = ppitchenv = NULL; |
208 | nvolenv = npanenv = npitchenv = 0; | 208 | nvolenv = npanenv = npitchenv = 0; |
209 | m_nSamples = m_nInstruments = 0; | 209 | m_nSamples = m_nInstruments = 0; |
210 | while (dwMemPos+6 < dwMemLength) | 210 | while (dwMemPos+6 < dwMemLength) |
211 | { | 211 | { |
212 | block = *((WORD *)(lpStream+dwMemPos)); | 212 | block = *((WORD *)(lpStream+dwMemPos)); |
213 | blocklen = *((DWORD *)(lpStream+dwMemPos+2)); | 213 | blocklen = *((DWORD *)(lpStream+dwMemPos+2)); |
214 | dwMemPos += 6; | 214 | dwMemPos += 6; |
215 | if (dwMemPos + blocklen > dwMemLength) | 215 | if (dwMemPos + blocklen > dwMemLength) |
216 | { | 216 | { |
217 | if (dwMemPos == 11) return FALSE; | 217 | if (dwMemPos == 11) return FALSE; |
218 | break; | 218 | break; |
219 | } | 219 | } |
220 | switch(block) | 220 | switch(block) |
221 | { | 221 | { |
222 | // IN: infoblock | 222 | // IN: infoblock |
223 | case 0x4E49: | 223 | case 0x4E49: |
224 | pmib = (MDLINFOBLOCK *)(lpStream+dwMemPos); | 224 | pmib = (MDLINFOBLOCK *)(lpStream+dwMemPos); |
225 | memcpy(m_szNames[0], pmib->songname, 32); | 225 | memcpy(m_szNames[0], pmib->songname, 32); |
226 | norders = pmib->norders; | 226 | norders = pmib->norders; |
227 | if (norders > MAX_ORDERS) norders = MAX_ORDERS; | 227 | if (norders > MAX_ORDERS) norders = MAX_ORDERS; |
228 | m_nRestartPos = pmib->repeatpos; | 228 | m_nRestartPos = pmib->repeatpos; |
229 | m_nDefaultGlobalVolume = pmib->globalvol; | 229 | m_nDefaultGlobalVolume = pmib->globalvol; |
230 | m_nDefaultTempo = pmib->tempo; | 230 | m_nDefaultTempo = pmib->tempo; |
231 | m_nDefaultSpeed = pmib->speed; | 231 | m_nDefaultSpeed = pmib->speed; |
232 | m_nChannels = 4; | 232 | m_nChannels = 4; |
233 | for (i=0; i<32; i++) | 233 | for (i=0; i<32; i++) |
234 | { | 234 | { |
235 | ChnSettings[i].nVolume = 64; | 235 | ChnSettings[i].nVolume = 64; |
236 | ChnSettings[i].nPan = (pmib->channelinfo[i] & 0x7F) << 1; | 236 | ChnSettings[i].nPan = (pmib->channelinfo[i] & 0x7F) << 1; |
237 | if (pmib->channelinfo[i] & 0x80) | 237 | if (pmib->channelinfo[i] & 0x80) |
238 | ChnSettings[i].dwFlags |= CHN_MUTE; | 238 | ChnSettings[i].dwFlags |= CHN_MUTE; |
239 | else | 239 | else |
240 | m_nChannels = i+1; | 240 | m_nChannels = i+1; |
241 | } | 241 | } |
242 | for (j=0; j<norders; j++) Order[j] = pmib->seq[j]; | 242 | for (j=0; j<norders; j++) Order[j] = pmib->seq[j]; |
243 | break; | 243 | break; |
244 | // ME: song message | 244 | // ME: song message |
245 | case 0x454D: | 245 | case 0x454D: |
246 | if (blocklen) | 246 | if (blocklen) |
247 | { | 247 | { |
248 | if (m_lpszSongComments) delete m_lpszSongComments; | 248 | if (m_lpszSongComments) delete [] m_lpszSongComments; |
249 | m_lpszSongComments = new char[blocklen]; | 249 | m_lpszSongComments = new char[blocklen]; |
250 | if (m_lpszSongComments) | 250 | if (m_lpszSongComments) |
251 | { | 251 | { |
252 | memcpy(m_lpszSongComments, lpStream+dwMemPos, blocklen); | 252 | memcpy(m_lpszSongComments, lpStream+dwMemPos, blocklen); |
253 | m_lpszSongComments[blocklen-1] = 0; | 253 | m_lpszSongComments[blocklen-1] = 0; |
254 | } | 254 | } |
255 | } | 255 | } |
256 | break; | 256 | break; |
257 | // PA: Pattern Data | 257 | // PA: Pattern Data |
258 | case 0x4150: | 258 | case 0x4150: |
259 | npatterns = lpStream[dwMemPos]; | 259 | npatterns = lpStream[dwMemPos]; |
260 | if (npatterns > MAX_PATTERNS) npatterns = MAX_PATTERNS; | 260 | if (npatterns > MAX_PATTERNS) npatterns = MAX_PATTERNS; |
261 | dwPos = dwMemPos + 1; | 261 | dwPos = dwMemPos + 1; |
262 | for (i=0; i<npatterns; i++) | 262 | for (i=0; i<npatterns; i++) |
263 | { | 263 | { |
264 | if (dwPos+18 >= dwMemLength) break; | 264 | if (dwPos+18 >= dwMemLength) break; |
265 | pmpd = (MDLPATTERNDATA *)(lpStream + dwPos); | 265 | pmpd = (MDLPATTERNDATA *)(lpStream + dwPos); |
266 | if (pmpd->channels > 32) break; | 266 | if (pmpd->channels > 32) break; |
267 | PatternSize[i] = pmpd->lastrow+1; | 267 | PatternSize[i] = pmpd->lastrow+1; |
268 | if (m_nChannels < pmpd->channels) m_nChannels = pmpd->channels; | 268 | if (m_nChannels < pmpd->channels) m_nChannels = pmpd->channels; |
269 | dwPos += 18 + 2*pmpd->channels; | 269 | dwPos += 18 + 2*pmpd->channels; |
270 | for (j=0; j<pmpd->channels; j++) | 270 | for (j=0; j<pmpd->channels; j++) |
271 | { | 271 | { |
272 | patterntracks[i*32+j] = pmpd->data[j]; | 272 | patterntracks[i*32+j] = pmpd->data[j]; |
273 | } | 273 | } |
274 | } | 274 | } |
275 | break; | 275 | break; |
276 | // TR: Track Data | 276 | // TR: Track Data |
277 | case 0x5254: | 277 | case 0x5254: |
278 | if (dwTrackPos) break; | 278 | if (dwTrackPos) break; |
279 | ntracks = *((WORD *)(lpStream+dwMemPos)); | 279 | ntracks = *((WORD *)(lpStream+dwMemPos)); |
280 | dwTrackPos = dwMemPos+2; | 280 | dwTrackPos = dwMemPos+2; |
281 | break; | 281 | break; |
282 | // II: Instruments | 282 | // II: Instruments |
283 | case 0x4949: | 283 | case 0x4949: |
284 | ninstruments = lpStream[dwMemPos]; | 284 | ninstruments = lpStream[dwMemPos]; |
285 | dwPos = dwMemPos+1; | 285 | dwPos = dwMemPos+1; |
286 | for (i=0; i<ninstruments; i++) | 286 | for (i=0; i<ninstruments; i++) |
287 | { | 287 | { |
288 | UINT nins = lpStream[dwPos]; | 288 | UINT nins = lpStream[dwPos]; |
289 | if ((nins >= MAX_INSTRUMENTS) || (!nins)) break; | 289 | if ((nins >= MAX_INSTRUMENTS) || (!nins)) break; |
290 | if (m_nInstruments < nins) m_nInstruments = nins; | 290 | if (m_nInstruments < nins) m_nInstruments = nins; |
291 | if (!Headers[nins]) | 291 | if (!Headers[nins]) |
292 | { | 292 | { |
293 | UINT note = 12; | 293 | UINT note = 12; |
294 | if ((Headers[nins] = new INSTRUMENTHEADER) == NULL) break; | 294 | if ((Headers[nins] = new INSTRUMENTHEADER) == NULL) break; |
295 | INSTRUMENTHEADER *penv = Headers[nins]; | 295 | INSTRUMENTHEADER *penv = Headers[nins]; |
296 | memset(penv, 0, sizeof(INSTRUMENTHEADER)); | 296 | memset(penv, 0, sizeof(INSTRUMENTHEADER)); |