diff options
author | Matthew Hoops | 2009-12-27 22:34:12 +0000 |
---|---|---|
committer | Matthew Hoops | 2009-12-27 22:34:12 +0000 |
commit | 420ab4306604db8c6ffe69d28b929c3b23a6ad30 (patch) | |
tree | 4802824aa5cae61c5d085d6cb8f9521b8492dca5 | |
parent | 9511b474dcba3447120f0eda7f4eda2a954b7d2d (diff) | |
download | scummvm-rg350-420ab4306604db8c6ffe69d28b929c3b23a6ad30.tar.gz scummvm-rg350-420ab4306604db8c6ffe69d28b929c3b23a6ad30.tar.bz2 scummvm-rg350-420ab4306604db8c6ffe69d28b929c3b23a6ad30.zip |
Add support for external wave files used as audio resources in the ResourceManager. The GK1 CD main menu music now works.
svn-id: r46660
-rw-r--r-- | engines/sci/resource.cpp | 47 | ||||
-rw-r--r-- | engines/sci/resource.h | 5 | ||||
-rw-r--r-- | engines/sci/sci.cpp | 1 |
3 files changed, 51 insertions, 2 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index 8799138ac9..58a51d3463 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -193,7 +193,7 @@ ResourceSource *ResourceManager::getVolume(ResourceSource *map, int volume_nr) { bool ResourceManager::loadPatch(Resource *res, Common::File &file) { // We assume that the resource type matches res->type - file.seek(res->file_offset + 2, SEEK_SET); + file.seek(res->file_offset, SEEK_SET); res->data = new byte[res->size]; @@ -458,6 +458,7 @@ void ResourceManager::scanNewSources() { switch (source->source_type) { case kSourceDirectory: readResourcePatches(source); + readWaveAudioPatches(); break; case kSourceExtMap: if (_mapVersion < kResVersionSci1Late) @@ -943,7 +944,7 @@ void ResourceManager::processPatch(ResourceSource *source, ResourceType restype, newrsc->source = source; newrsc->size = fsize - patch_data_offset - 2; newrsc->headerSize = patch_data_offset; - newrsc->file_offset = 0; + newrsc->file_offset = 2; debugC(1, kDebugLevelResMan, "Patching %s - OK", source->location_name.c_str()); } @@ -996,6 +997,48 @@ void ResourceManager::readResourcePatches(ResourceSource *source) { } } } + +void ResourceManager::readWaveAudioPatches() { + // Here we do check for SCI1.1+ so we can patch wav files in as audio resources + Common::ArchiveMemberList files; + SearchMan.listMatchingMembers(files, "*.wav"); + + for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); x++) { + Common::String name = (*x)->getName(); + + if (isdigit(name[0])) { + int number = atoi(name.c_str()); + ResourceSource *psrcPatch = new ResourceSource; + psrcPatch->source_type = kSourcePatch; + psrcPatch->location_name = name; + + ResourceId resId = ResourceId(kResourceTypeAudio, number); + + Resource *newrsc = NULL; + + // Prepare destination, if neccessary + if (_resMap.contains(resId) == false) { + newrsc = new Resource; + _resMap.setVal(resId, newrsc); + } else + newrsc = _resMap.getVal(resId); + + // Get the size of the file + Common::SeekableReadStream *stream = (*x)->createReadStream(); + uint32 fileSize = stream->size(); + delete stream; + + // Overwrite everything, because we're patching + newrsc->id = resId; + newrsc->status = kResStatusNoMalloc; + newrsc->source = psrcPatch; + newrsc->size = fileSize; + newrsc->headerSize = 0; + newrsc->file_offset = 0; // No patch header + debugC(1, kDebugLevelResMan, "Patching %s - OK", psrcPatch->location_name.c_str()); + } + } +} int ResourceManager::readResourceMapSCI0(ResourceSource *map) { Common::File file; diff --git a/engines/sci/resource.h b/engines/sci/resource.h index 5a652a8466..abcf6210af 100644 --- a/engines/sci/resource.h +++ b/engines/sci/resource.h @@ -405,6 +405,11 @@ protected: */ void readResourcePatches(ResourceSource *source); void processPatch(ResourceSource *source, ResourceType restype, int resnumber); + + /** + * Process wave files as patches for Audio resources + */ + void readWaveAudioPatches(); /** * Applies to all versions before 0.000.395 (i.e. KQ4 old, XMAS 1988 and LSL2). diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index baf2be0edd..dd085fe9aa 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -94,6 +94,7 @@ SciEngine::SciEngine(OSystem *syst, const ADGameDescription *desc) //SearchMan.addSubDirectoryMatching(_gameDataDir, "patches"); // resource patches SearchMan.addSubDirectoryMatching(_gameDataDir, "seq"); // SEQ movie files for DOS versions SearchMan.addSubDirectoryMatching(_gameDataDir, "wav"); // speech files in WAV format + SearchMan.addSubDirectoryMatching(_gameDataDir, "sfx"); // music/sound files in WAV format } SciEngine::~SciEngine() { |