[Scummvm-cvs-logs] SF.net SVN: scummvm: [31666] scummvm/trunk/engines/made

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Apr 23 19:21:50 CEST 2008


Revision: 31666
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31666&view=rev
Author:   thebluegr
Date:     2008-04-23 10:21:49 -0700 (Wed, 23 Apr 2008)

Log Message:
-----------
In-game sound effects and voices should be working correctly now.

Implemented the following opcodes:
- o1_PLAYSND
- o1_ISSND
- o1_STOPSND
- o1_PLAYVOICE
- o1_SOUNDRATE
- o1_SETVOLUME

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

Modified: scummvm/trunk/engines/made/made.h
===================================================================
--- scummvm/trunk/engines/made/made.h	2008-04-23 17:08:34 UTC (rev 31665)
+++ scummvm/trunk/engines/made/made.h	2008-04-23 17:21:49 UTC (rev 31666)
@@ -92,6 +92,7 @@
 	ScriptInterpreter *_script;
 
 	int _eventMouseX, _eventMouseY;
+	int _soundRate;
 	uint16 _eventKey;
 
 	int32 _timers[50];

Modified: scummvm/trunk/engines/made/resource.cpp
===================================================================
--- scummvm/trunk/engines/made/resource.cpp	2008-04-23 17:08:34 UTC (rev 31665)
+++ scummvm/trunk/engines/made/resource.cpp	2008-04-23 17:21:49 UTC (rev 31666)
@@ -24,6 +24,7 @@
  */
 
 #include "common/endian.h"
+#include "sound/mixer.h"
 
 #include "made/resource.h"
 #include "made/graphics.h"
@@ -161,12 +162,15 @@
 	_soundSize = chunkCount * chunkSize;
 	_soundData = new byte[_soundSize];
 
-	decompressSound(source + 14, _soundData, chunkSize, chunkCount);
-	
+	decompressSound(source + 14, _soundData, chunkSize, chunkCount);	
 }
 
-Audio::AudioStream *SoundResource::getAudioStream() {
-	return Audio::makeLinearInputStream(_soundData, _soundSize, 22050, 0, 0, 0);
+Audio::AudioStream *SoundResource::getAudioStream(int soundRate, bool loop) {
+	byte flags = Audio::Mixer::FLAG_UNSIGNED;
+	if (loop) 
+		flags |= Audio::Mixer::FLAG_LOOP;
+
+	return Audio::makeLinearInputStream(_soundData, _soundSize, soundRate, flags, 0, 0);
 }
 
 /* MenuResource */

Modified: scummvm/trunk/engines/made/resource.h
===================================================================
--- scummvm/trunk/engines/made/resource.h	2008-04-23 17:08:34 UTC (rev 31665)
+++ scummvm/trunk/engines/made/resource.h	2008-04-23 17:21:49 UTC (rev 31666)
@@ -91,7 +91,7 @@
 	SoundResource();
 	~SoundResource();
 	void load(byte *source, int size);
-	Audio::AudioStream *getAudioStream();
+	Audio::AudioStream *getAudioStream(int soundRate, bool loop = false);
 protected:
 	byte *_soundData;
 	int _soundSize;

Modified: scummvm/trunk/engines/made/scriptfuncs.cpp
===================================================================
--- scummvm/trunk/engines/made/scriptfuncs.cpp	2008-04-23 17:08:34 UTC (rev 31665)
+++ scummvm/trunk/engines/made/scriptfuncs.cpp	2008-04-23 17:21:49 UTC (rev 31666)
@@ -276,11 +276,19 @@
 }
 
 int16 ScriptFunctionsRtz::o1_PLAYSND(int16 argc, int16 *argv) {
-	/*
-	Audio::SoundHandle audioStreamHandle;
-	_vm->_mixer->playInputStream(Audio::Mixer::kPlainSoundType, &audioStreamHandle, 
-								 _vm->_res->getSound(argv[0])->getAudioStream());
-	*/
+	int soundId = (argc == 1) ? argv[0] : argv[1];
+	bool loop = false;
+	if (argc > 1) {
+		loop = (argv[0] == 1);
+	}
+
+	if (argv[0] > 0) {
+		if (!_vm->_mixer->isSoundHandleActive(_audioStreamHandle)) {
+			_vm->_mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_audioStreamHandle, 
+										 _vm->_res->getSound(soundId)->getAudioStream(_vm->_soundRate, loop));
+		}
+	}
+
 	return 0;
 }
 
@@ -452,14 +460,24 @@
 }
 
 int16 ScriptFunctionsRtz::o1_ISSND(int16 argc, int16 *argv) {
-	return 0;
+	if (_vm->_mixer->isSoundHandleActive(_audioStreamHandle))
+		return 1;
+	else
+		return 0;
 }
 
 int16 ScriptFunctionsRtz::o1_STOPSND(int16 argc, int16 *argv) {
+	_vm->_mixer->stopHandle(_audioStreamHandle);
 	return 0;
 }
 
 int16 ScriptFunctionsRtz::o1_PLAYVOICE(int16 argc, int16 *argv) {
+	if (argv[0] > 0) {
+		if (!_vm->_mixer->isSoundHandleActive(_voiceStreamHandle)) {
+			_vm->_mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_voiceStreamHandle, 
+										 _vm->_res->getSound(argv[0])->getAudioStream(_vm->_soundRate, false));
+		}
+	}
 	return 0;
 }
 
@@ -643,7 +661,7 @@
 }
 
 int16 ScriptFunctionsRtz::o1_SOUNDRATE(int16 argc, int16 *argv) {
-	//g_system->delayMillis(5000);
+	_vm->_soundRate = argv[0];
 	return 1;
 }
 
@@ -714,7 +732,8 @@
 }
 
 int16 ScriptFunctionsRtz::o1_SETVOLUME(int16 argc, int16 *argv) {
-	//!! g_system->delayMillis(5000);
+	_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, argv[0] * 25);
+	_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, argv[0] * 25);
 	return 0;
 }
 

Modified: scummvm/trunk/engines/made/scriptfuncs.h
===================================================================
--- scummvm/trunk/engines/made/scriptfuncs.h	2008-04-23 17:08:34 UTC (rev 31665)
+++ scummvm/trunk/engines/made/scriptfuncs.h	2008-04-23 17:21:49 UTC (rev 31666)
@@ -45,6 +45,8 @@
 	virtual void setupExternalsTable() = 0;
 protected:
 	MadeEngine *_vm;
+	Audio::SoundHandle _audioStreamHandle;
+	Audio::SoundHandle _voiceStreamHandle;
 
 	Common::Array<const ExternalFunc*> _externalFuncs;
 


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