[Scummvm-cvs-logs] SF.net SVN: scummvm:[50614] scummvm/trunk/engines/draci

spalek at users.sourceforge.net spalek at users.sourceforge.net
Sat Jul 3 05:48:26 CEST 2010


Revision: 50614
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50614&view=rev
Author:   spalek
Date:     2010-07-03 03:48:26 +0000 (Sat, 03 Jul 2010)

Log Message:
-----------
Dragon History tries uses compressed dubbing when available

Timing of speaking is not fixed yet.

Modified Paths:
--------------
    scummvm/trunk/engines/draci/barchive.cpp
    scummvm/trunk/engines/draci/draci.cpp
    scummvm/trunk/engines/draci/sound.cpp

Modified: scummvm/trunk/engines/draci/barchive.cpp
===================================================================
--- scummvm/trunk/engines/draci/barchive.cpp	2010-07-03 03:47:39 UTC (rev 50613)
+++ scummvm/trunk/engines/draci/barchive.cpp	2010-07-03 03:48:26 UTC (rev 50614)
@@ -283,8 +283,7 @@
 		tmp ^= _files[i]._data[j];
 	}
 
-	debugC(3, kDraciArchiverDebugLevel, "Cached file %d from archive %s",
-		i, _path.c_str());
+	debugC(2, kDraciArchiverDebugLevel, "Read %d bytes", _files[i]._length);
 	assert(tmp == _files[i]._crc && "CRC checksum mismatch");
 
 	return _files + i;
@@ -385,7 +384,7 @@
 
 	// Check if file has already been opened and return that
 	if (_files[i]._data) {
-		debugC(2, kDraciArchiverDebugLevel, "Success");
+		debugC(2, kDraciArchiverDebugLevel, "Cached");
 		return _files + i;
 	}
 

Modified: scummvm/trunk/engines/draci/draci.cpp
===================================================================
--- scummvm/trunk/engines/draci/draci.cpp	2010-07-03 03:47:39 UTC (rev 50613)
+++ scummvm/trunk/engines/draci/draci.cpp	2010-07-03 03:48:26 UTC (rev 50614)
@@ -71,7 +71,7 @@
 const char *musicPathMask = "HUDBA%d.MID";
 
 const uint kSoundsFrequency = 13000;
-const uint kDubbingFrequency = 22000;
+const uint kDubbingFrequency = 22050;
 
 DraciEngine::DraciEngine(OSystem *syst, const ADGameDescription *gameDesc)
  : Engine(syst) {
@@ -105,6 +105,39 @@
 		(f == kSupportsSavingDuringRuntime);
 }
 
+static SoundArchive* openAnyPossibleDubbing() {
+	debugC(1, kDraciGeneralDebugLevel, "Trying to find original dubbing");
+	LegacySoundArchive *legacy = new LegacySoundArchive(dubbingPath, kDubbingFrequency);
+	if (legacy->isOpen() && legacy->size()) {
+		debugC(1, kDraciGeneralDebugLevel, "Found original dubbing");
+		return legacy;
+	}
+	delete legacy;
+
+	// The original uncompressed dubbing cannot be found.  Try to open the
+	// newer compressed version.
+	debugC(1, kDraciGeneralDebugLevel, "Trying to find compressed dubbing");
+	ZipSoundArchive *zip = new ZipSoundArchive();
+
+	zip->openArchive("dub-raw.zzz", "buf", RAW80, kDubbingFrequency);
+	if (zip->isOpen() && zip->size()) return zip;
+#ifdef USE_FLAC
+	zip->openArchive("dub-flac.zzz", "flac", FLAC);
+	if (zip->isOpen() && zip->size()) return zip;
+#endif
+#ifdef USE_VORBIS
+	zip->openArchive("dub-ogg.zzz", "ogg", OGG);
+	if (zip->isOpen() && zip->size()) return zip;
+#endif
+#ifdef USE_MAD
+	zip->openArchive("dub-mp3.zzz", "mp3", MP3);
+	if (zip->isOpen() && zip->size()) return zip;
+#endif
+
+	// Return an empty (but initialized) archive anyway.
+	return zip;
+}
+
 int DraciEngine::init() {
 	// Initialize graphics using following:
 	initGraphics(kScreenWidth, kScreenHeight, false);
@@ -124,7 +157,7 @@
 	_stringsArchive = new BArchive(stringsPath);
 
 	_soundsArchive = new LegacySoundArchive(soundsPath, kSoundsFrequency);
-	_dubbingArchive = new LegacySoundArchive(dubbingPath, kDubbingFrequency);
+	_dubbingArchive = openAnyPossibleDubbing();
 	_sound = new Sound(_mixer);
 
 	MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB | MDT_PREFER_GM);

Modified: scummvm/trunk/engines/draci/sound.cpp
===================================================================
--- scummvm/trunk/engines/draci/sound.cpp	2010-07-03 03:47:39 UTC (rev 50613)
+++ scummvm/trunk/engines/draci/sound.cpp	2010-07-03 03:48:26 UTC (rev 50614)
@@ -48,14 +48,14 @@
 	// Close previously opened archive (if any)
 	closeArchive();
 
-	debugCN(2, kDraciArchiverDebugLevel, "Loading samples %s: ", path);
+	debugCN(1, kDraciArchiverDebugLevel, "Loading samples %s: ", path);
 
 	_f = new Common::File();
 	_f->open(path);
 	if (_f->isOpen()) {
-		debugC(2, kDraciArchiverDebugLevel, "Success");
+		debugC(1, kDraciArchiverDebugLevel, "Success");
 	} else {
-		debugC(2, kDraciArchiverDebugLevel, "Error");
+		debugC(1, kDraciArchiverDebugLevel, "Error");
 		delete _f;
 		_f = NULL;
 		return;
@@ -65,7 +65,7 @@
 	_path = path;
 
 	// Read archive header
-	debugC(2, kDraciArchiverDebugLevel, "Loading header");
+	debugC(1, kDraciArchiverDebugLevel, "Loading header");
 
 	uint totalLength = _f->readUint32LE();
 	const uint kMaxSamples = 4095;	// The no-sound file is exactly 16K bytes long, so don't fail on short reads
@@ -81,7 +81,7 @@
 			break;
 	}
 	if (_sampleCount > 0) {
-		debugC(2, kDraciArchiverDebugLevel, "Archive info: %d samples, %d total length",
+		debugC(1, kDraciArchiverDebugLevel, "Archive info: %d samples, %d total length",
 			_sampleCount, totalLength);
 		_samples = new SoundSample[_sampleCount];
 		for (uint i = 0; i < _sampleCount; ++i) {
@@ -92,14 +92,14 @@
 		if (_samples[_sampleCount-1]._offset + _samples[_sampleCount-1]._length != totalLength &&
 		    _samples[_sampleCount-1]._offset + _samples[_sampleCount-1]._length - _samples[0]._offset != totalLength) {
 			// WORKAROUND: the stored length is stored with the header for sounds and without the hader for dubbing.  Crazy.
-			debugC(2, kDraciArchiverDebugLevel, "Broken sound archive: %d != %d",
+			debugC(1, kDraciArchiverDebugLevel, "Broken sound archive: %d != %d",
 				_samples[_sampleCount-1]._offset + _samples[_sampleCount-1]._length,
 				totalLength);
 			closeArchive();
 			return;
 		}
 	} else {
-		debugC(2, kDraciArchiverDebugLevel, "Archive info: empty");
+		debugC(1, kDraciArchiverDebugLevel, "Archive info: empty");
 	}
 
 	// Indicate that the archive has been successfully opened
@@ -170,7 +170,7 @@
 		_f->seek(_samples[i]._offset);
 		_f->read(_samples[i]._data, _samples[i]._length);
 
-		debugC(3, kDraciArchiverDebugLevel, "Read sample %d from archive %s",
+		debugC(2, kDraciArchiverDebugLevel, "Read sample %d from archive %s",
 			i, _path);
 	}
 	_samples[i]._frequency = freq ? freq : _defaultFreq;
@@ -185,6 +185,7 @@
 		return;
 	}
 
+	debugCN(1, kDraciArchiverDebugLevel, "Trying to open ZIP archive %s: ", path);
 	_archive = Common::makeZipArchive(path);
 	_path = path;
 	_extension = extension;
@@ -195,6 +196,9 @@
 		Common::ArchiveMemberList files;
 		_archive->listMembers(files);
 		_sampleCount = files.size();
+		debugC(1, kDraciArchiverDebugLevel, "Capacity %d", _sampleCount);
+	} else {
+		debugC(1, kDraciArchiverDebugLevel, "Failed");
 	}
 }
 


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