[Scummvm-cvs-logs] SF.net SVN: scummvm:[46660] scummvm/trunk/engines/sci

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Sun Dec 27 23:34:13 CET 2009


Revision: 46660
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46660&view=rev
Author:   mthreepwood
Date:     2009-12-27 22:34:12 +0000 (Sun, 27 Dec 2009)

Log Message:
-----------
Add support for external wave files used as audio resources in the ResourceManager. The GK1 CD main menu music now works.

Modified Paths:
--------------
    scummvm/trunk/engines/sci/resource.cpp
    scummvm/trunk/engines/sci/resource.h
    scummvm/trunk/engines/sci/sci.cpp

Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp	2009-12-27 20:56:10 UTC (rev 46659)
+++ scummvm/trunk/engines/sci/resource.cpp	2009-12-27 22:34:12 UTC (rev 46660)
@@ -193,7 +193,7 @@
 
 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 @@
 			switch (source->source_type) {
 			case kSourceDirectory:
 				readResourcePatches(source);
+				readWaveAudioPatches();
 				break;
 			case kSourceExtMap:
 				if (_mapVersion < kResVersionSci1Late)
@@ -943,7 +944,7 @@
 	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,7 +997,49 @@
 		}
 	}
 }
+	
+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;
 	Resource *res;

Modified: scummvm/trunk/engines/sci/resource.h
===================================================================
--- scummvm/trunk/engines/sci/resource.h	2009-12-27 20:56:10 UTC (rev 46659)
+++ scummvm/trunk/engines/sci/resource.h	2009-12-27 22:34:12 UTC (rev 46660)
@@ -405,6 +405,11 @@
 	 */
 	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).

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2009-12-27 20:56:10 UTC (rev 46659)
+++ scummvm/trunk/engines/sci/sci.cpp	2009-12-27 22:34:12 UTC (rev 46660)
@@ -94,6 +94,7 @@
 	//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() {


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