foxygit / doom Log in
commit 784e848b326a6f8b0c1377fc7a1b3c5a945cb009
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Fri Jul 28 19:13:13 2006 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Fri Jul 28 19:13:13 2006 +0000

    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
---
 src/i_sound.c | 23 ++++++-----------------
 src/mus2mid.c |  2 ++
 2 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/src/i_sound.c b/src/i_sound.c
index a2008862..131e4cca 100644
--- 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 @@ static boolean IsMid(byte *mem, int len)
     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 @@ void *I_RegisterSong(void *data, int len)
     sprintf(filename, "/tmp/doom-%i.mid", getpid());
 #endif

-    if (IsMus(data, len))
-    {
-        ConvertMus(data, len, filename);
-    }
-    else if (IsMid(data, len) && len < MAXMIDLENGTH)
+    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
diff --git a/src/mus2mid.c b/src/mus2mid.c
index ba05c4cf..e6c5a89b 100644
--- a/src/mus2mid.c
+++ b/src/mus2mid.c
@@ -385,6 +385,7 @@ int mus2mid(MEMFILE *musinput, MEMFILE *midioutput)
 		return 1;
 	}

+#ifdef CHECK_MUS_HEADER
 	// Check MUS header
 	if (musfileheader.id[0] != 'M'
 	 || musfileheader.id[1] != 'U'
@@ -393,6 +394,7 @@ int mus2mid(MEMFILE *musinput, MEMFILE *midioutput)
 	{
 		return 1;
 	}
+#endif

 	// Seek to where the data is held
 	if (mem_fseek(musinput, (long)musfileheader.scorestart, SEEK_SET) != 0)