shithub: choc

Download patch

ref: 784e848b326a6f8b0c1377fc7a1b3c5a945cb009
parent: 0f7a31d483e6faeb9e4c4c15d711f7ca2341e480
author: Simon Howard <[email protected]>
date: Fri Jul 28 15:13:13 EDT 2006

Try to convert MUS even if the MUS header is not present. The new code
plays the deca.wad titlescreen music properly!

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 568

--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: i_sound.c 566 2006-07-22 16:43:12Z fraggle $
+// $Id: i_sound.c 568 2006-07-28 19:13:13Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -128,7 +128,7 @@
 //-----------------------------------------------------------------------------
 
 static const char
-rcsid[] = "$Id: i_sound.c 566 2006-07-22 16:43:12Z fraggle $";
+rcsid[] = "$Id: i_sound.c 568 2006-07-28 19:13:13Z fraggle $";
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -679,13 +679,6 @@
     return len > 4 && !memcmp(mem, "MThd", 4);
 }
 
-// Determine whether memory block is a .mus file
-
-static boolean IsMus(byte *mem, int len)
-{
-    return len > 3 && !memcmp(mem, "MUS", 3);
-}
-
 static boolean ConvertMus(byte *musdata, int len, char *filename)
 {
     MEMFILE *instream;
@@ -729,19 +722,15 @@
     sprintf(filename, "/tmp/doom-%i.mid", getpid());
 #endif
 
-    if (IsMus(data, len))
+    if (IsMid(data, len) && len < MAXMIDLENGTH)
     {
-        ConvertMus(data, len, filename);
-    }
-    else if (IsMid(data, len) && len < MAXMIDLENGTH)
-    {
         M_WriteFile(filename, data, len);
     }
-    else
+    else 
     {
-        // Unrecognised: unable to load
+	// Assume a MUS file and try to convert
 
-        return NULL;
+        ConvertMus(data, len, filename);
     }
 
     // Load the MIDI
--- a/src/mus2mid.c
+++ b/src/mus2mid.c
@@ -385,6 +385,7 @@
 		return 1;
 	}
 
+#ifdef CHECK_MUS_HEADER
 	// Check MUS header
 	if (musfileheader.id[0] != 'M' 
 	 || musfileheader.id[1] != 'U' 
@@ -393,6 +394,7 @@
 	{
 		return 1;
 	}
+#endif
 
 	// Seek to where the data is held
 	if (mem_fseek(musinput, (long)musfileheader.scorestart, SEEK_SET) != 0)