[Scummvm-cvs-logs] SF.net SVN: scummvm:[35724] scummvm/trunk/engines/saga

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sun Jan 4 15:38:03 CET 2009


Revision: 35724
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35724&view=rev
Author:   thebluegr
Date:     2009-01-04 14:38:03 +0000 (Sun, 04 Jan 2009)

Log Message:
-----------
Improved handling of sound resources

Modified Paths:
--------------
    scummvm/trunk/engines/saga/detection.cpp
    scummvm/trunk/engines/saga/detection_tables.h
    scummvm/trunk/engines/saga/music.cpp
    scummvm/trunk/engines/saga/resource.cpp
    scummvm/trunk/engines/saga/resource.h
    scummvm/trunk/engines/saga/saga.cpp
    scummvm/trunk/engines/saga/saga.h
    scummvm/trunk/engines/saga/sndres.cpp
    scummvm/trunk/engines/saga/sound.cpp
    scummvm/trunk/engines/saga/sound.h

Modified: scummvm/trunk/engines/saga/detection.cpp
===================================================================
--- scummvm/trunk/engines/saga/detection.cpp	2009-01-04 14:23:20 UTC (rev 35723)
+++ scummvm/trunk/engines/saga/detection.cpp	2009-01-04 14:38:03 UTC (rev 35724)
@@ -84,9 +84,6 @@
 	if (_gf_wyrmkeep)
 		result |= GF_WYRMKEEP;
 
-	if (_gf_compressed_sounds)
-		result |= GF_COMPRESSED_SOUNDS;
-
 	return result;
 }
 

Modified: scummvm/trunk/engines/saga/detection_tables.h
===================================================================
--- scummvm/trunk/engines/saga/detection_tables.h	2009-01-04 14:23:20 UTC (rev 35723)
+++ scummvm/trunk/engines/saga/detection_tables.h	2009-01-04 14:38:03 UTC (rev 35724)
@@ -229,7 +229,7 @@
 			Common::ADGF_DEMO
 		},
 		GID_ITE,
-		GF_WYRMKEEP | GF_SCENE_SUBSTITUTES | GF_MONO_MUSIC,
+		GF_WYRMKEEP | GF_SCENE_SUBSTITUTES | GF_MONO_MUSIC | GF_LE_VOICES,
 		ITE_DEFAULT_SCENE,
 		&ITE_Resources,
 		ARRAYSIZE(ITEWINDEMO_GameFonts),
@@ -256,7 +256,7 @@
 			Common::ADGF_DEMO
 		},
 		GID_ITE,
-		GF_WYRMKEEP | GF_NON_INTERACTIVE,
+		GF_WYRMKEEP | GF_NON_INTERACTIVE | GF_LE_VOICES,
 		ITE_DEFAULT_SCENE,
 		&ITE_Resources,
 		ARRAYSIZE(ITEWINDEMO_GameFonts),

Modified: scummvm/trunk/engines/saga/music.cpp
===================================================================
--- scummvm/trunk/engines/saga/music.cpp	2009-01-04 14:23:20 UTC (rev 35723)
+++ scummvm/trunk/engines/saga/music.cpp	2009-01-04 14:38:03 UTC (rev 35724)
@@ -96,12 +96,7 @@
 
 	_compressedStream = NULL;
 
-	// FIXME: It is a bad idea to use the File::getName() method to distinguish
-	// files here (note that it is for debugging purposes only, though that was
-	// not correctly documented in the past).
-	// A better way is to keep track of this via some flag, which indicates
-	// whether the music file contains compressed data.
-	if (scumm_stricmp(_file->getName(), "music.cmp") == 0 || scumm_stricmp(_file->getName(), "musicd.cmp") == 0) {
+	if (context->isCompressed) {
 		// Read compressed header to determine compression type
 		_file->seek((long)resourceData->offset, SEEK_SET);
 		_file->read(compressedHeader, 9);

Modified: scummvm/trunk/engines/saga/resource.cpp
===================================================================
--- scummvm/trunk/engines/saga/resource.cpp	2009-01-04 14:23:20 UTC (rev 35723)
+++ scummvm/trunk/engines/saga/resource.cpp	2009-01-04 14:38:03 UTC (rev 35724)
@@ -205,6 +205,8 @@
 	bool soundFileInArray = false;
 	bool multipleVoices = false;
 	bool censoredVersion = false;
+	bool compressedSounds = false;
+	bool compressedMusic = false;
 	uint16 voiceFileType = GAME_VOICEFILE;
 	bool fileFound = false;
 	int maxFile = 0;
@@ -284,7 +286,7 @@
 				_contextsCount++;
 				soundFileIndex = _contextsCount - 1;
 				strcpy(soundFileName, curSoundfiles[i].fileName);
-				_vm->_gf_compressed_sounds = curSoundfiles[i].isCompressed;
+				compressedSounds = curSoundfiles[i].isCompressed;
 				fileFound = true;
 				break;
 			}
@@ -358,7 +360,7 @@
 			_contextsCount++;
 			voicesFileIndex = _contextsCount - 1;
 			strcpy(_voicesFileName[0], curSoundfiles[i].fileName);
-			_vm->_gf_compressed_sounds = curSoundfiles[i].isCompressed;
+			compressedSounds = curSoundfiles[i].isCompressed;
 			fileFound = true;
 
 			// Special cases
@@ -406,11 +408,10 @@
 	}
 
 	//// Detect and add ITE music files /////////////////////////////////////////
-	// We don't set the compressed flag here
 	SoundFileInfo musicFilesITE[] = {
-		{	"music.rsc",	true	},
+		{	"music.rsc",	false	},
 		{	"music.cmp",	true	},
-		{	"musicd.rsc",	true	},
+		{	"musicd.rsc",	false	},
 		{	"musicd.cmp",	true	},
 	};
 
@@ -422,6 +423,7 @@
 			if (Common::File::exists(musicFilesITE[i].fileName)) {
 				_contextsCount++;
 				digitalMusic = true;
+				compressedMusic = musicFilesITE[i].isCompressed;
 				fileFound = true;
 				strcpy(musicFileName, musicFilesITE[i].fileName);
 				break;
@@ -445,27 +447,32 @@
 		if (_vm->getGameId() == GID_ITE && digitalMusic && i == _contextsCount - 1) {
 			context->fileName = musicFileName;
 			context->fileType = GAME_MUSICFILE;
+			context->isCompressed = compressedMusic;
 		} else if (!soundFileInArray && i == soundFileIndex) {
 			context->fileName = soundFileName;
 			context->fileType = GAME_SOUNDFILE;
+			context->isCompressed = compressedSounds;
 		} else if (_vm->_voiceFilesExist && i == voicesFileIndex && !(_vm->getGameId() == GID_IHNM && _vm->isMacResources())) {
 			context->fileName = _voicesFileName[0];
 			// can be GAME_VOICEFILE or GAME_SOUNDFILE | GAME_VOICEFILE or GAME_VOICEFILE | GAME_SWAPENDIAN
 			context->fileType = voiceFileType;
+			context->isCompressed = compressedSounds;
 		} else {
 			if (!(_vm->_voiceFilesExist && multipleVoices && (i > voicesFileIndex))) {
 				context->fileName = _vm->getFilesDescriptions()[i].fileName;
 				context->fileType = _vm->getFilesDescriptions()[i].fileType;
+				context->isCompressed = compressedSounds;
 			} else {
 				int token = (censoredVersion && (i - voicesFileIndex >= 4)) ? 1 : 0;	// censored versions don't have voice4
 
-				if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS)
+				if (compressedSounds)
 					sprintf(_voicesFileName[i - voicesFileIndex + token], "voices%i.cmp", i - voicesFileIndex + token);
 				else
 					sprintf(_voicesFileName[i - voicesFileIndex + token], "voices%i.res", i - voicesFileIndex + token);
 
 				context->fileName = _voicesFileName[i - voicesFileIndex + token];
 				context->fileType = GAME_VOICEFILE;
+				context->isCompressed = compressedSounds;
 
 				// IHNM has several different voice files, so we need to allow
 				// multiple resource contexts of the same type. We tell them

Modified: scummvm/trunk/engines/saga/resource.h
===================================================================
--- scummvm/trunk/engines/saga/resource.h	2009-01-04 14:23:20 UTC (rev 35723)
+++ scummvm/trunk/engines/saga/resource.h	2009-01-04 14:38:03 UTC (rev 35724)
@@ -71,6 +71,7 @@
 	Common::File *file;
 	int serial;			// IHNM speech files
 
+	bool isCompressed;
 	bool isBigEndian;
 	ResourceData *table;
 	size_t count;

Modified: scummvm/trunk/engines/saga/saga.cpp
===================================================================
--- scummvm/trunk/engines/saga/saga.cpp	2009-01-04 14:23:20 UTC (rev 35723)
+++ scummvm/trunk/engines/saga/saga.cpp	2009-01-04 14:38:03 UTC (rev 35724)
@@ -157,7 +157,6 @@
 	_readingSpeed = getTalkspeed();
 	_copyProtection = ConfMan.getBool("copy_protection");
 	_gf_wyrmkeep = false;
-	_gf_compressed_sounds = false;
 	_musicWasPlaying = false;
 
 	if (_readingSpeed > 3)

Modified: scummvm/trunk/engines/saga/saga.h
===================================================================
--- scummvm/trunk/engines/saga/saga.h	2009-01-04 14:23:20 UTC (rev 35723)
+++ scummvm/trunk/engines/saga/saga.h	2009-01-04 14:38:03 UTC (rev 35724)
@@ -118,12 +118,12 @@
 	GF_WYRMKEEP          = 1 << 0,
 	GF_ITE_FLOPPY        = 1 << 1,
 	GF_SCENE_SUBSTITUTES = 1 << 2,
-	GF_COMPRESSED_SOUNDS = 1 << 3,
-	GF_NON_INTERACTIVE   = 1 << 4,
-	GF_OLD_ITE_DOS       = 1 << 5,
-	GF_MONO_MUSIC		 = 1 << 6,
-	GF_EXTRA_ITE_CREDITS = 1 << 7,
-	GF_IHNM_DEMO         = 1 << 8
+	GF_NON_INTERACTIVE   = 1 << 3,
+	GF_OLD_ITE_DOS       = 1 << 4,
+	GF_MONO_MUSIC        = 1 << 5,
+	GF_EXTRA_ITE_CREDITS = 1 << 6,
+	GF_IHNM_DEMO         = 1 << 7,
+	GF_LE_VOICES         = 1 << 8
 };
 
 enum VerbTypeIds {
@@ -495,7 +495,6 @@
 
 	bool _copyProtection;
 	bool _gf_wyrmkeep;
-	bool _gf_compressed_sounds;
 	bool _musicWasPlaying;
 
 	SndRes *_sndRes;

Modified: scummvm/trunk/engines/saga/sndres.cpp
===================================================================
--- scummvm/trunk/engines/saga/sndres.cpp	2009-01-04 14:23:20 UTC (rev 35723)
+++ scummvm/trunk/engines/saga/sndres.cpp	2009-01-04 14:38:03 UTC (rev 35724)
@@ -130,6 +130,8 @@
 		_voiceContext->fileType = GAME_VOICEFILE;
 		_voiceContext->count = 0;
 		_voiceContext->serial = 0;
+		_voiceContext->isBigEndian = true;
+		_voiceContext->isCompressed = false;
 		return;
 	}
 #endif
@@ -219,6 +221,7 @@
 
 		file->open(soundFileName);
 		soundResourceLength = file->size();
+		context->isBigEndian = true;
 	} else 
 #endif
 	{
@@ -231,7 +234,7 @@
 
 	Common::SeekableReadStream& readS = *file;
 
-	if ((context->fileType & GAME_VOICEFILE) != 0) {
+	if (context->fileType & GAME_VOICEFILE) {
 		soundInfo = _vm->getVoiceInfo();
 	} else {
 		soundInfo = _vm->getSfxInfo();
@@ -265,7 +268,7 @@
 		if (_vm->getGameId() == GID_IHNM && (context->fileType & GAME_SOUNDFILE))
 			uncompressedSound = true;
 
-		if ((_vm->getFeatures() & GF_COMPRESSED_SOUNDS) && !uncompressedSound) {
+		if (context->isCompressed && !uncompressedSound) {
 			if (header[0] == char(0)) {
 				resourceType = kSoundMP3;
 			} else if (header[0] == char(1)) {
@@ -277,7 +280,10 @@
 
 	}
 
-	buffer.isBigEndian = _vm->isMacResources();
+	buffer.isBigEndian = context->isBigEndian;
+	if ((context->fileType & GAME_VOICEFILE) && (_vm->getFeatures() & GF_LE_VOICES))
+		buffer.isBigEndian = false;
+	buffer.isCompressed = context->isCompressed;
 	buffer.soundType = resourceType;
 	buffer.originalSize = 0;
 	buffer.stereo = false;
@@ -398,7 +404,7 @@
 		return -1;
 	}
 
-	if (!(_vm->getFeatures() & GF_COMPRESSED_SOUNDS) || buffer.originalSize == 0)
+	if (!_voiceContext->isCompressed || buffer.originalSize == 0)
 		msDouble = (double)buffer.size;
 	else
 		msDouble = (double)buffer.originalSize;

Modified: scummvm/trunk/engines/saga/sound.cpp
===================================================================
--- scummvm/trunk/engines/saga/sound.cpp	2009-01-04 14:23:20 UTC (rev 35723)
+++ scummvm/trunk/engines/saga/sound.cpp	2009-01-04 14:38:03 UTC (rev 35724)
@@ -83,7 +83,7 @@
 	if (!buffer.isSigned)
 		flags |= Audio::Mixer::FLAG_UNSIGNED;
 
-	if (!(_vm->getFeatures() & GF_COMPRESSED_SOUNDS)) {
+	if (!buffer.isCompressed) {
 		if (handleType == kVoiceHandle)
 			_mixer->playRaw(Audio::Mixer::kSpeechSoundType, handle, buffer.buffer,
 					buffer.size, buffer.frequency, flags, -1, volume);

Modified: scummvm/trunk/engines/saga/sound.h
===================================================================
--- scummvm/trunk/engines/saga/sound.h	2009-01-04 14:23:20 UTC (rev 35723)
+++ scummvm/trunk/engines/saga/sound.h	2009-01-04 14:38:03 UTC (rev 35724)
@@ -47,6 +47,7 @@
 	int sampleBits;
 	bool stereo;
 	bool isSigned;
+	bool isCompressed;
 
 	byte *buffer;
 	size_t size;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list