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

kirben at users.sourceforge.net kirben at users.sourceforge.net
Sat Oct 14 03:15:42 CEST 2006


Revision: 24300
          http://svn.sourceforge.net/scummvm/?rev=24300&view=rev
Author:   kirben
Date:     2006-10-13 18:15:28 -0700 (Fri, 13 Oct 2006)

Log Message:
-----------
Add sound effects support for early games

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

Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp	2006-10-13 23:19:07 UTC (rev 24299)
+++ scummvm/trunk/engines/agos/agos.cpp	2006-10-14 01:15:28 UTC (rev 24300)
@@ -1523,9 +1523,10 @@
 
 	vpe->sfxFile = NULL;
 	if (!(getFeatures() & GF_ZLIBCOMP)) {
-		loadVGAFile(zoneNum, 3);
-		vpe->sfxFile = _block;
-		vpe->sfxFileEnd = _blockEnd;
+		if (loadVGAFile(zoneNum, 3)) {
+			vpe->sfxFile = _block;
+			vpe->sfxFileEnd = _blockEnd;
+		}
 	}
 }
 

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2006-10-13 23:19:07 UTC (rev 24299)
+++ scummvm/trunk/engines/agos/agos.h	2006-10-14 01:15:28 UTC (rev 24300)
@@ -1275,7 +1275,7 @@
 	byte *getScaleBuf();
 
 	void convertAmiga(byte *srcBuf, int32 fileSize);
-	void loadVGAFile(uint id, uint type);
+	bool loadVGAFile(uint id, uint type);
 	void loadSimonVGAFile(uint id);
 
 	int init();

Modified: scummvm/trunk/engines/agos/res.cpp
===================================================================
--- scummvm/trunk/engines/agos/res.cpp	2006-10-13 23:19:07 UTC (rev 24299)
+++ scummvm/trunk/engines/agos/res.cpp	2006-10-14 01:15:28 UTC (rev 24300)
@@ -631,7 +631,7 @@
 	}
 }
 
-void AGOSEngine::loadVGAFile(uint id, uint type) {
+bool AGOSEngine::loadVGAFile(uint id, uint type) {
 	File in;
 	char filename[15];
 	byte *dst = NULL;
@@ -685,41 +685,46 @@
 		}
 
 		in.open(filename);
-		if (in.isOpen() == true) {
-			dstSize = srcSize = in.size();
-			if (getFeatures() & GF_CRUNCHED) {
-				byte *srcBuffer = (byte *)malloc(srcSize);
-				if (in.read(srcBuffer, srcSize) != srcSize)
-					error("loadVGAFile: Read failed");
+		if (in.isOpen() == false) {
+			// Sound VGA files don't always exist
+			if (type == 3) {
+				return false;
+			} else {
+				error("loadVGAFile: Can't load %s", filename);
+			}
+		}
 
-				dstSize = READ_BE_UINT32(srcBuffer + srcSize - 4);
-				if (type == 2 && dstSize != 64800) {
-					dst = (byte *)malloc(dstSize);
-					decrunchFile(srcBuffer, dst, srcSize);
-					convertAmiga(dst, dstSize);
-					free(dst);
-				} else {
-					dst = allocBlock (dstSize + extraBuffer);
-					decrunchFile(srcBuffer, dst, srcSize);
-				}
-				free(srcBuffer);
+		dstSize = srcSize = in.size();
+		if (getFeatures() & GF_CRUNCHED) {
+			byte *srcBuffer = (byte *)malloc(srcSize);
+			if (in.read(srcBuffer, srcSize) != srcSize)
+			error("loadVGAFile: Read failed");
+
+			dstSize = READ_BE_UINT32(srcBuffer + srcSize - 4);
+			if (type == 2 && dstSize != 64800) {
+				dst = (byte *)malloc(dstSize);
+				decrunchFile(srcBuffer, dst, srcSize);
+				convertAmiga(dst, dstSize);
+				free(dst);
 			} else {
-				if (getGameId() == GID_SIMON1CD32 && type == 2) {
-					dst = (byte *)malloc(dstSize);
-					if (in.read(dst, dstSize) != dstSize)
-						error("loadVGAFile: Read failed");
-					convertAmiga(dst, dstSize);
-					free(dst);
-				} else {
-					dst = allocBlock(dstSize + extraBuffer);
-					if (in.read(dst, dstSize) != dstSize)
-						error("loadVGAFile: Read failed");
-				}
+				dst = allocBlock (dstSize + extraBuffer);
+				decrunchFile(srcBuffer, dst, srcSize);
 			}
-			in.close();
-		} else if (type != 3) {
-			error("loadVGAFile: Can't load %s", filename);
+			free(srcBuffer);
+		} else {
+			if (getGameId() == GID_SIMON1CD32 && type == 2) {
+				dst = (byte *)malloc(dstSize);
+				if (in.read(dst, dstSize) != dstSize)
+					error("loadVGAFile: Read failed");
+				convertAmiga(dst, dstSize);
+				free(dst);
+			} else {
+				dst = allocBlock(dstSize + extraBuffer);
+				if (in.read(dst, dstSize) != dstSize)
+					error("loadVGAFile: Read failed");
+			}
 		}
+		in.close();
 	} else {
 		id = id * 2 + (type - 1);
 		offs = _gameOffsetsPtr[id];
@@ -728,6 +733,8 @@
 		dst = allocBlock(dstSize + extraBuffer);
 		readGameFile(dst, offs, dstSize);
 	}
+
+	return true;
 }
 
 static const char *dimpSoundList[32] = {

Modified: scummvm/trunk/engines/agos/sound.cpp
===================================================================
--- scummvm/trunk/engines/agos/sound.cpp	2006-10-13 23:19:07 UTC (rev 24299)
+++ scummvm/trunk/engines/agos/sound.cpp	2006-10-14 01:15:28 UTC (rev 24300)
@@ -624,6 +624,14 @@
 	}
 }
 
+// Elvira 1/2 and Waxworks specific
+void Sound::playRawData(byte *soundData, uint sound, uint size) {
+	byte *buffer = (byte *)malloc(size);
+	memcpy(buffer, soundData, size);
+
+	_mixer->playRaw(&_effectsHandle, buffer, size, 8000, Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_AUTOFREE);
+}
+
 // Feeble Files specific
 void Sound::playAmbientData(byte *soundData, uint sound, uint pan, uint vol) {
 	if (sound == _ambientPlaying)

Modified: scummvm/trunk/engines/agos/sound.h
===================================================================
--- scummvm/trunk/engines/agos/sound.h	2006-10-13 23:19:07 UTC (rev 24299)
+++ scummvm/trunk/engines/agos/sound.h	2006-10-14 01:15:28 UTC (rev 24300)
@@ -75,6 +75,9 @@
 	void playEffects(uint sound);
 	void playAmbient(uint sound);
 
+	// Elvira 1/2 and Waxworks specific
+	void playRawData(byte *soundData, uint sound, uint size);
+
 	// Feeble Files specific
 	void playAmbientData(byte *soundData, uint sound, uint pan, uint vol);
 	void playSfxData(byte *soundData, uint sound, uint pan, uint vol);

Modified: scummvm/trunk/engines/agos/vga.cpp
===================================================================
--- scummvm/trunk/engines/agos/vga.cpp	2006-10-13 23:19:07 UTC (rev 24299)
+++ scummvm/trunk/engines/agos/vga.cpp	2006-10-14 01:15:28 UTC (rev 24300)
@@ -1983,12 +1983,37 @@
 }
 
 void AGOSEngine::vc28_playSFX() {
-	// TODO
-	uint a = vcReadNextWord();
-	uint b = vcReadNextWord();
-	uint c = vcReadNextWord();
-	uint d = vcReadNextWord();
-	debug(0, "vc28_playSFX: stub (%d, %d, %d, %d)", a, b, c, d);
+	byte *dst;
+	uint sound, channels, frequency, flags;
+	uint offs, size;
+
+	sound = vcReadNextWord();
+	channels = vcReadNextWord();
+	frequency = vcReadNextWord();
+	flags = vcReadNextWord();
+
+	debug(0, "vc28_playSFX: stub (%d, %d, %d, %d)", sound, channels, frequency, flags);
+
+	if (_curSfxFile == NULL)
+		return;
+
+	dst = _curSfxFile;
+	if (getGameType() == GType_WW) {
+		uint tmp = sound;
+		while (tmp--)
+			dst += READ_LE_UINT16(dst) + 4;
+
+		size = READ_LE_UINT16(dst);
+		offs = 4;
+	} else {
+		while (READ_BE_UINT16(dst) != sound)
+			dst += 12;
+
+		size = READ_BE_UINT16(dst + 2);
+		offs = READ_BE_UINT32(dst + 8);
+	}
+
+	_sound->playRawData(dst + offs, sound, size);
 }
 
 void AGOSEngine::vc29_stopAllSounds() {
@@ -2453,6 +2478,9 @@
 	byte *src = _curVgaFile2 + 32;
 	byte *dst = getBackBuf();
 
+	memcpy(dst, src, _screenHeight * _screenWidth);
+	//fullFade();
+
 	uint8 palette[1024];
 	for (int i = 0; i < 256; i++) {
 		palette[i * 4 + 0] = *src++ * 4;
@@ -2462,7 +2490,6 @@
 	}
 
 	_system->setPalette(palette, 0, 256);
-	memcpy(dst, src, _screenHeight * _screenWidth);
 }
 
 void AGOSEngine::vc56_delayLong() {
@@ -2588,30 +2615,50 @@
 void AGOSEngine::vc61() {
 	uint16 a = vcReadNextWord();
 	byte *src, *dst;
+	uint h, tmp;
 
 	if (a == 6) {
 		src = _curVgaFile2 + 800;
 		dst = getBackBuf();
 		memcpy(dst, src, 64000);
-		a = 4;
+		tmp = 4;
+	} else {
+		tmp = a;
 	}
 
 	src = _curVgaFile2 + 3360;
-	dst = getBackBuf() + 3840;
-
-	uint tmp = a;
 	while (tmp--) {
 		src += 1712;
-		dst += 1536;
 	}
 
 	src += 800;
 
 	if (a != 5) {
+		dst = getBackBuf() + 7448;
+		for (h = 0; h < 177; h++) {
+			memcpy(dst, src, 144);
+			src += 144;
+			dst += _screenWidth;
+		}
+
+		if (a != 6)
+			return;
+
+		src += 15344;
 	}
 
+	dst = getBackBuf() + 50296;
+	for (h = 0; h < 17; h++) {
+		memcpy(dst, src, 208);
+		src += 208;
+		dst += _screenWidth;
+	}
+
 	if (a == 6) {
+		//fullFade();
 	}
+
+	debug(0, "vc61: stub (%d)", a);
 }
 
 void AGOSEngine::vc61_setMaskImage() {


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