[Scummvm-cvs-logs] CVS: scummvm/sound imuse.cpp,1.46,1.47

Pawe? Ko?odziejski aquadran at users.sourceforge.net
Sun Aug 25 08:14:02 CEST 2002


Update of /cvsroot/scummvm/scummvm/sound
In directory usw-pr-cvs1:/tmp/cvs-serv8504/sound

Modified Files:
	imuse.cpp 
Log Message:
better SFX suport in the Dig

Index: imuse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/imuse.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- imuse.cpp	24 Aug 2002 16:13:16 -0000	1.46
+++ imuse.cpp	25 Aug 2002 15:13:44 -0000	1.47
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * $Header$
+ * $Header$ 
  */
 
 #include "stdafx.h"
@@ -39,6 +39,7 @@
 
 #define MDPG_TAG "MDpg"
 #define MDHD_TAG "MDhd"
+#define MAP_TAG "MAP "
 
 
 /* Roland to General Midi patch table. Still needs some work. */
@@ -829,8 +830,61 @@
 	if (!mdhd) {
 		mdhd = findTag(sound, MDPG_TAG, 0);
 		if (!mdhd) {
-			warning("SE::start_sound failed: Couldn't find %s", MDHD_TAG);
-			return false;
+			mdhd = findTag(sound, MAP_TAG, 0);
+			if (!mdhd) {
+				warning("SE::start_sound failed: Couldn't find %s", MDHD_TAG);
+				return false;
+			}
+			else {
+				uint32 size = 0, rate = 0, tag, chan = 0, bits = 0;
+				uint8 * ptr = g_scumm->getResourceAddress(rtSound, sound);
+				if (ptr != NULL) {
+					ptr+=16;
+					for (;;) {
+				    		tag = READ_BE_UINT32(ptr);  ptr+=4;
+						switch(tag) {
+							case MKID_BE('FRMT'):
+								size = READ_BE_UINT32(ptr); ptr+=12;
+								bits = READ_BE_UINT32(ptr); ptr+=4;
+								rate = READ_BE_UINT32(ptr); ptr+=4;
+								chan = READ_BE_UINT32(ptr); ptr+=4;
+							break;
+							case MKID_BE('TEXT'):
+							case MKID_BE('REGN'):
+							case MKID_BE('STOP'):
+							case MKID_BE('JUMP'):
+								size = READ_BE_UINT32(ptr); ptr+=size+4;
+							break;
+							case MKID_BE('DATA'):
+								size = READ_BE_UINT32(ptr); ptr+=4;
+							break;
+							default:
+								error("Unknown sfx header %c%c%c%c", tag>>24, tag>>16, tag>>8, tag);
+						}
+						if (tag == MKID_BE('DATA')) break;
+					}
+					if (bits == 8) {
+						byte * buffer = (byte*)malloc (size);
+						memcpy(buffer, ptr, size);
+						if (chan == 1) {
+							g_scumm->_mixer->playRaw(NULL, buffer, size, rate, SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_UNSIGNED);
+						}
+						else if (chan == 2) {
+							g_scumm->_mixer->playRaw(NULL, buffer, size, rate, SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_STEREO);
+						}
+					} else if (bits == 12) {
+						byte * buffer = NULL;
+						uint32 final_size = g_scumm->_sound->decode12BitsSample(ptr, &buffer, size);
+						if (chan == 1) {
+							g_scumm->_mixer->playRaw(NULL, buffer, final_size, rate, SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_16BITS);
+						}
+						else if (chan == 2) {
+							g_scumm->_mixer->playRaw(NULL, buffer, final_size, rate, SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_16BITS | SoundMixer::FLAG_STEREO);
+						}
+					}
+				}
+				return true;
+			}
 		}
 	}
 	player = allocate_player(128);





More information about the Scummvm-git-logs mailing list