diff src/modplug/load_669.cxx @ 2337:107c1fed3d92

Port Schism modplug core.
author "Tony Vroon <chainsaw@gentoo.org>"
date Thu, 24 Jan 2008 12:05:59 +0000
parents 6907fc39b53f
children
line wrap: on
line diff
--- a/src/modplug/load_669.cxx	Wed Jan 23 19:37:05 2008 +0100
+++ b/src/modplug/load_669.cxx	Thu Jan 24 12:05:59 2008 +0000
@@ -51,12 +51,9 @@
 	 || (!pfh->patterns) || (pfh->patterns > 128)) return FALSE;
 	DWORD dontfuckwithme = 0x1F1 + pfh->samples * sizeof(SAMPLE669) + pfh->patterns * 0x600;
 	if (dontfuckwithme > dwMemLength) return FALSE;
-	for (UINT ichk=0; ichk<pfh->samples; ichk++)
-	{
-		DWORD len = bswapLE32(*((DWORD *)(&psmp[ichk].length)));
-		dontfuckwithme += len;
-	}
-	if (dontfuckwithme > dwMemLength) return FALSE;
+        for (int n = 0; n < 128; n++)
+                if (pfh->breaks[n] > 0x3f)
+                        return false;
 	// That should be enough checking: this must be a 669 module.
 	m_nType = MOD_TYPE_669;
 	m_dwSongFlags |= SONG_LINEARSLIDES;
@@ -65,7 +62,8 @@
 	m_nDefaultTempo = 125;
 	m_nDefaultSpeed = 6;
 	m_nChannels = 8;
-	memcpy(m_szNames[0], pfh->songmessage, 16);
+	memcpy(m_szNames[0], pfh->songmessage, 31);
+	m_szNames[0][31] = 0;
 	m_nSamples = pfh->samples;
 	for (UINT nins=1; nins<=m_nSamples; nins++, psmp++)
 	{
@@ -86,9 +84,15 @@
 		Ins[nins].nPan = 128;
 	}
 	// Song Message
-	m_lpszSongComments = new char[109];
-	memcpy(m_lpszSongComments, pfh->songmessage, 108);
-	m_lpszSongComments[108] = 0;
+	m_lpszSongComments = new char[114];
+	memcpy(m_lpszSongComments, pfh->songmessage, 36);
+	m_lpszSongComments[36] = '\015';
+	m_lpszSongComments[37] = '\012';
+	memcpy(m_lpszSongComments + 38, pfh->songmessage + 36, 36);
+	m_lpszSongComments[74] = '\015';
+	m_lpszSongComments[75] = '\012';
+	memcpy(m_lpszSongComments + 76, pfh->songmessage + 72, 36);
+	m_lpszSongComments[112] = 0;
 	// Reading Orders
 	memcpy(Order, pfh->orders, 128);
 	m_nRestartPos = pfh->restartpos;
@@ -106,6 +110,7 @@
 		Patterns[npat] = AllocatePattern(64, m_nChannels);
 		if (!Patterns[npat]) break;
 		PatternSize[npat] = 64;
+		PatternAllocSize[npat] = 64;
 		MODCOMMAND *m = Patterns[npat];
 		const BYTE *p = lpStream + dwMemPos;
 		for (UINT row=0; row<64; row++)