changeset 1599:6764c35e16a6

Detect Fast Tracker (and others) xCHN and xxCH MOD module signatures properly.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 05 Sep 2007 07:37:53 +0300
parents 15c07b4cc459
children 49fe2225d236
files src/modplug/modplugbmp.cxx src/modplug/modplugbmp.h
diffstat 2 files changed, 18 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/modplug/modplugbmp.cxx	Wed Sep 05 04:00:46 2007 +0300
+++ b/src/modplug/modplugbmp.cxx	Wed Sep 05 07:37:53 2007 +0300
@@ -110,13 +110,13 @@
 {
 	string lExt;
 	uint32 lPos;
+	const int magicSize = 32;
+	char magic[magicSize];
 
-	gchar magic[4];
-
-	vfs_fread(magic, 1, 4, file);
+	vfs_fread(magic, 1, magicSize, file);
 	if (!memcmp(magic, UMX_MAGIC, 4))
 		return true;
-	if (!memcmp(magic, XM_MAGIC, 4))
+	if (!memcmp(magic, "Extended Module:", 16))
 		return true;
 	if (!memcmp(magic, M669_MAGIC, 2))
 		return true;
@@ -131,12 +131,22 @@
 	vfs_fread(magic, 1, 4, file);
 	if (!memcmp(magic, S3M_MAGIC, 4))
 		return true;
+
 	vfs_fseek(file, 1080, SEEK_SET);
 	vfs_fread(magic, 1, 4, file);
-	if (!memcmp(magic, MOD_MAGIC_FASTTRACKER6, 4))
-		return true;
-	if (!memcmp(magic, MOD_MAGIC_FASTTRACKER8, 4))
-		return true;
+	
+	// Check for Fast Tracker multichannel modules (xCHN, xxCH)
+	if (magic[1] == 'C' && magic[2] == 'H' && magic[3] == 'N') {
+		if (magic[0] == '6' || magic[0] == '8')
+			return true;
+	}
+	if (magic[2] == 'C' && magic[3] == 'H' && isdigit(magic[0]) && isdigit(magic[1])) {
+		int nch = (magic[0] - '0') * 10 + (magic[1] - '0');
+		if ((nch % 2 == 0) && nch >= 10)
+			return true;
+	}
+	
+	// Check for Amiga MOD module formats
 	if(mModProps.mGrabAmigaMOD) {
 	if (!memcmp(magic, MOD_MAGIC_PROTRACKER4, 4))
 		return true;
--- a/src/modplug/modplugbmp.h	Wed Sep 05 04:00:46 2007 +0300
+++ b/src/modplug/modplugbmp.h	Wed Sep 05 07:37:53 2007 +0300
@@ -29,8 +29,6 @@
 #define MOD_MAGIC_STARTRACKER4X	(unsigned char [4]) { 0x45, 0x58, 0x30, 0x34 }  // "EX04" - Startracker 4 channel (Startrekker/AudioSculpture)
 #define MOD_MAGIC_STARTRACKER8X	(unsigned char [4]) { 0x45, 0x58, 0x30, 0x38 }  // "EX08" - Startracker 8 channel (Startrekker/AudioSculpture) 
 #define MOD_MAGIC_FASTTRACKER4	(unsigned char [4]) { 0x34, 0x43, 0x48, 0x4E }  // "4CHN" - Fasttracker 4 channel
-#define MOD_MAGIC_FASTTRACKER6	(unsigned char [4]) { 0x36, 0x43, 0x48, 0x4E }  // "6CHN" - Fasttracker 6 channel
-#define MOD_MAGIC_FASTTRACKER8	(unsigned char [4]) { 0x38, 0x43, 0x48, 0x4E }  // "8CHN" - Fasttracker 8 channel
 #define MOD_MAGIC_OKTALYZER8	(unsigned char [4]) { 0x43, 0x44, 0x38, 0x31 }  // "CD81" - Atari oktalyzer 8 channel
 #define MOD_MAGIC_OKTALYZER8X	(unsigned char [4]) { 0x4F, 0x4B, 0x54, 0x41 }  // "OKTA" - Atari oktalyzer 8 channel
 #define MOD_MAGIC_TAKETRACKER16	(unsigned char [4]) { 0x31, 0x36, 0x43, 0x4E }  // "16CN" - Taketracker 16 channel