diff options
| author | Travis Howell | 2006-10-14 01:15:28 +0000 | 
|---|---|---|
| committer | Travis Howell | 2006-10-14 01:15:28 +0000 | 
| commit | ca620f02f327b95f8764d2b093c147a61b7c0814 (patch) | |
| tree | 6f79ed760d8787fce6282f5de049e3c59fc65dca | |
| parent | e87ff48e053b621dc5df63d42b561d69d0643bce (diff) | |
| download | scummvm-rg350-ca620f02f327b95f8764d2b093c147a61b7c0814.tar.gz scummvm-rg350-ca620f02f327b95f8764d2b093c147a61b7c0814.tar.bz2 scummvm-rg350-ca620f02f327b95f8764d2b093c147a61b7c0814.zip | |
Add sound effects support for early games
svn-id: r24300
| -rw-r--r-- | engines/agos/agos.cpp | 7 | ||||
| -rw-r--r-- | engines/agos/agos.h | 2 | ||||
| -rw-r--r-- | engines/agos/res.cpp | 71 | ||||
| -rw-r--r-- | engines/agos/sound.cpp | 8 | ||||
| -rw-r--r-- | engines/agos/sound.h | 3 | ||||
| -rw-r--r-- | engines/agos/vga.cpp | 71 | 
6 files changed, 114 insertions, 48 deletions
| diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index d97d14270f..0768b7e854 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -1523,9 +1523,10 @@ void AGOSEngine::loadZone(uint zoneNum) {  	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; +		}  	}  } diff --git a/engines/agos/agos.h b/engines/agos/agos.h index 4b5c195992..9f08142992 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -1275,7 +1275,7 @@ protected:  	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(); diff --git a/engines/agos/res.cpp b/engines/agos/res.cpp index d511e40fdc..18b305617c 100644 --- a/engines/agos/res.cpp +++ b/engines/agos/res.cpp @@ -631,7 +631,7 @@ void AGOSEngine::loadSimonVGAFile(uint id) {  	}  } -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 @@ void AGOSEngine::loadVGAFile(uint id, uint type) {  		}  		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); +			} +			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 if (type != 3) { -			error("loadVGAFile: Can't load %s", filename);  		} +		in.close();  	} else {  		id = id * 2 + (type - 1);  		offs = _gameOffsetsPtr[id]; @@ -728,6 +733,8 @@ void AGOSEngine::loadVGAFile(uint id, uint type) {  		dst = allocBlock(dstSize + extraBuffer);  		readGameFile(dst, offs, dstSize);  	} + +	return true;  }  static const char *dimpSoundList[32] = { diff --git a/engines/agos/sound.cpp b/engines/agos/sound.cpp index e9484ca994..6cdd5347d7 100644 --- a/engines/agos/sound.cpp +++ b/engines/agos/sound.cpp @@ -624,6 +624,14 @@ void Sound::ambientPause(bool b) {  	}  } +// 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) diff --git a/engines/agos/sound.h b/engines/agos/sound.h index 606dad5b59..a10458534e 100644 --- a/engines/agos/sound.h +++ b/engines/agos/sound.h @@ -75,6 +75,9 @@ public:  	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); diff --git a/engines/agos/vga.cpp b/engines/agos/vga.cpp index 2f28944617..82191a61a2 100644 --- a/engines/agos/vga.cpp +++ b/engines/agos/vga.cpp @@ -1983,12 +1983,37 @@ void AGOSEngine::vc27_resetSprite() {  }  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 @@ void AGOSEngine::vc56_fullScreen() {  	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 @@ void AGOSEngine::vc56_fullScreen() {  	}  	_system->setPalette(palette, 0, 256); -	memcpy(dst, src, _screenHeight * _screenWidth);  }  void AGOSEngine::vc56_delayLong() { @@ -2588,30 +2615,50 @@ void AGOSEngine::vc60_stopAnimation() {  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() { | 
