[Scummvm-cvs-logs] SF.net SVN: scummvm: [24388] scummvm/trunk/engines/agos

kirben at users.sourceforge.net kirben at users.sourceforge.net
Thu Oct 19 13:13:35 CEST 2006


Revision: 24388
          http://svn.sourceforge.net/scummvm/?rev=24388&view=rev
Author:   kirben
Date:     2006-10-19 04:13:28 -0700 (Thu, 19 Oct 2006)

Log Message:
-----------
Add support for sound effects in PC version of Elvira 1

Modified Paths:
--------------
    scummvm/trunk/engines/agos/agos.cpp
    scummvm/trunk/engines/agos/agos.h
    scummvm/trunk/engines/agos/res.cpp
    scummvm/trunk/engines/agos/script.cpp

Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp	2006-10-19 05:37:22 UTC (rev 24387)
+++ scummvm/trunk/engines/agos/agos.cpp	2006-10-19 11:13:28 UTC (rev 24388)
@@ -1331,7 +1331,7 @@
 	}
 }
 
-void AGOSEngine::hitarea_stuff() {
+void AGOSEngine::waitForInput() {
 	HitArea *ha;
 	uint id;
 
@@ -1588,17 +1588,17 @@
 	// Loading order is important
 	// due to resource managment
 
-	loadVGAFile(zoneNum, 2);
+	loadVGAVideoFile(zoneNum, 2);
 	vpe->vgaFile2 = _block;
 	vpe->vgaFile2End = _blockEnd;
 
-	loadVGAFile(zoneNum, 1);
+	loadVGAVideoFile(zoneNum, 1);
 	vpe->vgaFile1 = _block;
 	vpe->vgaFile1End = _blockEnd;
 
 	vpe->sfxFile = NULL;
 	if (!(getFeatures() & GF_ZLIBCOMP)) {
-		if (loadVGAFile(zoneNum, 3)) {
+		if (loadVGASoundFile(zoneNum, 3)) {
 			vpe->sfxFile = _block;
 			vpe->sfxFileEnd = _blockEnd;
 		}
@@ -2409,7 +2409,7 @@
 	permitInput();
 
 	while (1) {
-		hitarea_stuff();
+		waitForInput();
 		handleVerbClicked(_verbHitArea);
 		delay(100);
 	}

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2006-10-19 05:37:22 UTC (rev 24387)
+++ scummvm/trunk/engines/agos/agos.h	2006-10-19 11:13:28 UTC (rev 24388)
@@ -730,7 +730,7 @@
 	void displayName(HitArea * ha);
 	void resetNameWindow();
 	void displayBoxStars();
-	void hitarea_stuff();
+	void waitForInput();
 	void invertBox_FF(HitArea *ha, bool state);
 	void invertBox(HitArea * ha, byte a, byte b, byte c, byte d);
 
@@ -1292,8 +1292,9 @@
 
 	void convertAmiga(byte *srcBuf, int32 fileSize);
 	bool decrunchFile(byte *src, byte *dst, uint32 size);
-	bool loadVGAFile(uint id, uint type);
-	void loadSimonVGAFile(uint id);
+	void loadVGABeardFile(uint id);
+	void loadVGAVideoFile(uint id, uint type);
+	bool loadVGASoundFile(uint id, uint type);
 
 	int init();
 	int go();

Modified: scummvm/trunk/engines/agos/res.cpp
===================================================================
--- scummvm/trunk/engines/agos/res.cpp	2006-10-19 05:37:22 UTC (rev 24387)
+++ scummvm/trunk/engines/agos/res.cpp	2006-10-19 11:13:28 UTC (rev 24388)
@@ -611,7 +611,7 @@
 #undef SD_TYPE_LITERAL
 #undef SD_TYPE_MATCH
 
-void AGOSEngine::loadSimonVGAFile(uint id) {
+void AGOSEngine::loadVGABeardFile(uint id) {
 	uint32 offs, size;
 
 	if (getFeatures() & GF_OLD_BUNDLE) {
@@ -655,10 +655,10 @@
 	}
 }
 
-bool AGOSEngine::loadVGAFile(uint id, uint type) {
+void AGOSEngine::loadVGAVideoFile(uint id, uint type) {
 	File in;
 	char filename[15];
-	byte *dst = NULL;
+	byte *dst;
 	uint32 file, offs, srcSize, dstSize;
 	uint extraBuffer = 0;
 
@@ -698,15 +698,9 @@
 				else
 					sprintf(filename, "%.1d%d.out", id, type);
 			} else if (getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2) {
-				if (type == 3)
-					sprintf(filename, "%.2d%d.out", id, type);
-				else
-					sprintf(filename, "%.2d%d.pkd", id, type);
+				sprintf(filename, "%.2d%d.pkd", id, type);
 			} else {
-				if (type == 3)
-					sprintf(filename, "%.3d%d.out", id, type);
-				else
-					sprintf(filename, "%.3d%d.pkd", id, type);
+				sprintf(filename, "%.3d%d.pkd", id, type);
 			}
 		} else {
 			if (getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) {
@@ -717,21 +711,15 @@
 		}
 
 		in.open(filename);
-		if (in.isOpen() == false || in.size() == 0) {
-			// Sound VGA files don't always exist
-			if (type == 3) {
-				return false;
-			} else {
-				error("loadVGAFile: Can't load %s", filename);
-			}
+		if (in.isOpen() == false) {
+			error("loadVGAVideoFile: Can't load %s", filename);
 		}
 
 		dstSize = srcSize = in.size();
-		if ((getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) ||
-			(getFeatures() & GF_CRUNCHED && type != 3)) {
+		if (getFeatures() & GF_CRUNCHED) {
 			byte *srcBuffer = (byte *)malloc(srcSize);
 			if (in.read(srcBuffer, srcSize) != srcSize)
-				error("loadVGAFile: Read failed");
+				error("loadVGAVideoFile: Read failed");
 
 			dstSize = READ_BE_UINT32(srcBuffer + srcSize - 4);
 			if (type == 2) {
@@ -748,13 +736,13 @@
 			if (getGameId() == GID_SIMON1CD32 && type == 2) {
 				dst = (byte *)malloc(dstSize);
 				if (in.read(dst, dstSize) != dstSize)
-					error("loadVGAFile: Read failed");
+					error("loadVGAVideoFile: Read failed");
 				convertAmiga(dst, dstSize);
 				free(dst);
 			} else {
 				dst = allocBlock(dstSize + extraBuffer);
 				if (in.read(dst, dstSize) != dstSize)
-					error("loadVGAFile: Read failed");
+					error("loadVGAVideoFile: Read failed");
 			}
 		}
 		in.close();
@@ -766,7 +754,80 @@
 		dst = allocBlock(dstSize + extraBuffer);
 		readGameFile(dst, offs, dstSize);
 	}
+}
 
+static const byte elvira1_soundTable[100] = {
+	0, 2, 0, 1, 0, 0, 0, 0, 0, 3,
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, 0, 6, 4, 0, 0, 9, 0,
+	0, 2, 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 8, 0, 0, 0, 0, 0, 0, 0, 0,
+	1, 1, 0, 0, 5, 0, 6, 6, 0, 0,
+	0, 5, 0, 0, 6, 0, 0, 0, 0, 8,
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+};
+
+bool AGOSEngine::loadVGASoundFile(uint id, uint type) {
+	File in;
+	char filename[15];
+	byte *dst;
+	uint32 srcSize, dstSize;
+
+	if (getPlatform() == Common::kPlatformAmiga || getPlatform() == Common::kPlatformAtariST) {
+		if (getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) {
+			if (id == 20)
+				sprintf(filename, "D%d.out", type);
+			else if (id == 26)
+				sprintf(filename, "J%d.out", type);
+			else if (id == 27)
+				sprintf(filename, "K%d.out", type);
+			else if (id == 33)
+				sprintf(filename, "Q%d.out", type);
+			else if (id == 34)
+				sprintf(filename, "R%d.out", type);
+			else
+				sprintf(filename, "%.1d%d.out", id, type);
+		} else if (getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2) {
+			sprintf(filename, "%.2d%d.out", id, type);
+		} else {
+			sprintf(filename, "%.3d%d.out", id, type);
+		}
+	} else {
+		if (getGameType() == GType_ELVIRA1) {
+			if (elvira1_soundTable[id] == 0)
+				return false;
+
+			sprintf(filename, "%.2d.SND", elvira1_soundTable[id]);
+		} else if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) {
+			sprintf(filename, "%.2d%d.VGA", id, type);
+		} else {
+			sprintf(filename, "%.3d%d.VGA", id, type);
+		}
+	}
+
+	in.open(filename);
+	if (in.isOpen() == false || in.size() == 0) {
+		return false;
+	}
+
+	dstSize = srcSize = in.size();
+	if (getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) {
+		byte *srcBuffer = (byte *)malloc(srcSize);
+		if (in.read(srcBuffer, srcSize) != srcSize)
+			error("loadVGASoundFile: Read failed");
+
+		dstSize = READ_BE_UINT32(srcBuffer + srcSize - 4);
+		dst = allocBlock (dstSize);
+		decrunchFile(srcBuffer, dst, srcSize);
+		free(srcBuffer);
+	} else {
+		dst = allocBlock(dstSize);
+		if (in.read(dst, dstSize) != dstSize)
+			error("loadVGASoundFile: Read failed");
+	}
+	in.close();
+
 	return true;
 }
 

Modified: scummvm/trunk/engines/agos/script.cpp
===================================================================
--- scummvm/trunk/engines/agos/script.cpp	2006-10-19 05:37:22 UTC (rev 24387)
+++ scummvm/trunk/engines/agos/script.cpp	2006-10-19 11:13:28 UTC (rev 24388)
@@ -2422,7 +2422,7 @@
 	if (_beardLoaded == false) {
 		_beardLoaded = true;
 		_lockWord |= 0x8000;
-		loadSimonVGAFile(328);
+		loadVGABeardFile(328);
 		_lockWord &= ~0x8000;
 	}
 }
@@ -2432,7 +2432,7 @@
 	if (_beardLoaded == true) {
 		_beardLoaded = false;
 		_lockWord |= 0x8000;
-		loadSimonVGAFile(23);
+		loadVGABeardFile(23);
 		_lockWord &= ~0x8000;
 	}
 }


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