summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/modplug/load_umx.cpp
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/modplug/load_umx.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/modplug/load_umx.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/modplug/load_umx.cpp b/core/multimedia/opieplayer/modplug/load_umx.cpp
new file mode 100644
index 0000000..4c54fcf
--- a/dev/null
+++ b/core/multimedia/opieplayer/modplug/load_umx.cpp
@@ -0,0 +1,56 @@
1/*
2 * This program is free software; you can redistribute it and modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; either version 2 of the license or (at your
5 * option) any later version.
6 *
7 * Authors: Olivier Lapicque <olivierl@jps.net>
8*/
9
10#include "stdafx.h"
11#include "sndfile.h"
12
13 #define MODMAGIC_OFFSET(20+31*30+130)
14
15
16BOOL CSoundFile::ReadUMX(const BYTE *lpStream, DWORD dwMemLength)
17//---------------------------------------------------------------
18{
19 if ((!lpStream) || (dwMemLength < 0x800)) return FALSE;
20 // Rip Mods from UMX
21 if ((bswapLE32(*((DWORD *)(lpStream+0x20))) < dwMemLength)
22 && (bswapLE32(*((DWORD *)(lpStream+0x18))) <= dwMemLength - 0x10)
23 && (bswapLE32(*((DWORD *)(lpStream+0x18))) >= dwMemLength - 0x200))
24 {
25 for (UINT uscan=0x40; uscan<0x500; uscan++)
26 {
27 DWORD dwScan = bswapLE32(*((DWORD *)(lpStream+uscan)));
28 // IT
29 if (dwScan == 0x4D504D49)
30 {
31 DWORD dwRipOfs = uscan;
32 return ReadIT(lpStream + dwRipOfs, dwMemLength - dwRipOfs);
33 }
34 // S3M
35 if (dwScan == 0x4D524353)
36 {
37 DWORD dwRipOfs = uscan - 44;
38 return ReadS3M(lpStream + dwRipOfs, dwMemLength - dwRipOfs);
39 }
40 // XM
41 if (!strnicmp((LPCSTR)(lpStream+uscan), "Extended Module", 15))
42 {
43 DWORD dwRipOfs = uscan;
44 return ReadXM(lpStream + dwRipOfs, dwMemLength - dwRipOfs);
45 }
46 // MOD
47 if ((uscan > MODMAGIC_OFFSET) && (dwScan == 0x2e4b2e4d))
48 {
49 DWORD dwRipOfs = uscan - MODMAGIC_OFFSET;
50 return ReadMod(lpStream+dwRipOfs, dwMemLength-dwRipOfs);
51 }
52 }
53 }
54 return FALSE;
55}
56