diff options
-rw-r--r-- | engines/draci/barchive.cpp | 5 | ||||
-rw-r--r-- | engines/draci/draci.cpp | 37 | ||||
-rw-r--r-- | engines/draci/sound.cpp | 20 |
3 files changed, 49 insertions, 13 deletions
diff --git a/engines/draci/barchive.cpp b/engines/draci/barchive.cpp index 2ed2a9b591..8f9e836ba3 100644 --- a/engines/draci/barchive.cpp +++ b/engines/draci/barchive.cpp @@ -283,8 +283,7 @@ BAFile *BArchive::loadFileBAR(uint i) { 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 @@ const BAFile *BArchive::getFile(uint i) { // 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; } diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp index 202bf6d187..cd3920b30d 100644 --- a/engines/draci/draci.cpp +++ b/engines/draci/draci.cpp @@ -71,7 +71,7 @@ const char *dubbingPath = "CD.SAM"; 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 @@ bool DraciEngine::hasFeature(EngineFeature f) const { (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 @@ int DraciEngine::init() { _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); diff --git a/engines/draci/sound.cpp b/engines/draci/sound.cpp index aa696832bb..5000ceac74 100644 --- a/engines/draci/sound.cpp +++ b/engines/draci/sound.cpp @@ -48,14 +48,14 @@ void LegacySoundArchive::openArchive(const char *path) { // 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 @@ void LegacySoundArchive::openArchive(const char *path) { _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 @@ void LegacySoundArchive::openArchive(const char *path) { 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 @@ void LegacySoundArchive::openArchive(const char *path) { 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 @@ SoundSample *LegacySoundArchive::getSample(int i, uint freq) { _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 @@ void ZipSoundArchive::openArchive(const char *path, const char *extension, Sound return; } + debugCN(1, kDraciArchiverDebugLevel, "Trying to open ZIP archive %s: ", path); _archive = Common::makeZipArchive(path); _path = path; _extension = extension; @@ -195,6 +196,9 @@ void ZipSoundArchive::openArchive(const char *path, const char *extension, Sound Common::ArchiveMemberList files; _archive->listMembers(files); _sampleCount = files.size(); + debugC(1, kDraciArchiverDebugLevel, "Capacity %d", _sampleCount); + } else { + debugC(1, kDraciArchiverDebugLevel, "Failed"); } } |