[Scummvm-cvs-logs] CVS: scummvm/scumm akos.cpp,1.215,1.216 script_v100he.cpp,2.110,2.111 script_v72he.cpp,2.232,2.233 script_v90he.cpp,2.210,2.211 sound.cpp,1.433,1.434 sound.h,1.82,1.83 wiz_he.cpp,2.36,2.37

kirben kirben at users.sourceforge.net
Mon Apr 4 04:41:43 CEST 2005


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4047/scumm

Modified Files:
	akos.cpp script_v100he.cpp script_v72he.cpp script_v90he.cpp 
	sound.cpp sound.h wiz_he.cpp 
Log Message:

Add 8 sound channel support for HE games
-Allows sound looping to work

Added support for WAVE format musuc used in later HE100 games.


Index: akos.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/akos.cpp,v
retrieving revision 1.215
retrieving revision 1.216
diff -u -d -r1.215 -r1.216
--- akos.cpp	31 Mar 2005 21:38:29 -0000	1.215
+++ akos.cpp	4 Apr 2005 11:41:13 -0000	1.216
@@ -1676,7 +1676,7 @@
 				if (_features & GF_DIGI_IMUSE)
 					_imuseDigital->startSfx(param_1, 63);
 				else
-					_sound->addSoundToQueue(param_1);
+					_sound->addSoundToQueue(param_1, 0, -1, 0);
 			}
 			break;
 		case 4:

Index: script_v100he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v100he.cpp,v
retrieving revision 2.110
retrieving revision 2.111
diff -u -d -r2.110 -r2.111
--- script_v100he.cpp	3 Apr 2005 13:50:12 -0000	2.110
+++ script_v100he.cpp	4 Apr 2005 11:41:14 -0000	2.111
@@ -311,7 +311,7 @@
 		OPCODE(o6_isScriptRunning),
 		OPCODE(o90_sin),
 		/* D8 */
-		OPCODE(o72_getSoundElapsedTimeOfSound),
+		OPCODE(o72_getSoundElapsedTime),
 		OPCODE(o6_isSoundRunning),
 		OPCODE(o80_getSoundVar),
 		OPCODE(o100_getSpriteInfo),

Index: script_v72he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v72he.cpp,v
retrieving revision 2.232
retrieving revision 2.233
diff -u -d -r2.232 -r2.233
--- script_v72he.cpp	3 Apr 2005 02:24:28 -0000	2.232
+++ script_v72he.cpp	4 Apr 2005 11:41:15 -0000	2.233
@@ -156,7 +156,7 @@
 		/* 58 */
 		OPCODE(o72_getTimer),
 		OPCODE(o72_setTimer),
-		OPCODE(o72_getSoundElapsedTimeOfSound),
+		OPCODE(o72_getSoundElapsedTime),
 		OPCODE(o6_wordArrayDec),
 		/* 5C */
 		OPCODE(o6_if),
@@ -562,6 +562,7 @@
 			switch(chr) {
 			case 'b':
 				// byte
+				error("decodeScriptString: byte unhandled");
 				break;
 			case 'c':
 				*dst++ = args[val--];
@@ -574,6 +575,7 @@
 				break;
 			case 'x':
 				// hexadecimal
+				error("decodeScriptString: hexadecimal unhandled");
 				break;
 			default:
 				error("decodeScriptString: Unknown type %d", chr);
@@ -811,10 +813,10 @@
 	}
 }
 
-void ScummEngine_v72he::o72_getSoundElapsedTimeOfSound() {
+void ScummEngine_v72he::o72_getSoundElapsedTime() {
 	int snd = pop();
-	push(_mixer->getSoundElapsedTimeOfSoundID(snd) * 10);
-	debug(1,"o72_getSoundElapsedTimeOfSound (%d)", snd);
+	push(_sound->getSoundElapsedTime(snd) * 10);
+	debug(1,"o72_getSoundElapsedTime (%d)", snd);
 }
 
 void ScummEngine_v72he::o72_startScript() {

Index: script_v90he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v90he.cpp,v
retrieving revision 2.210
retrieving revision 2.211
diff -u -d -r2.210 -r2.211
--- script_v90he.cpp	3 Apr 2005 02:24:28 -0000	2.210
+++ script_v90he.cpp	4 Apr 2005 11:41:15 -0000	2.211
@@ -153,7 +153,7 @@
 		/* 58 */
 		OPCODE(o72_getTimer),
 		OPCODE(o72_setTimer),
-		OPCODE(o72_getSoundElapsedTimeOfSound),
+		OPCODE(o72_getSoundElapsedTime),
 		OPCODE(o6_wordArrayDec),
 		/* 5C */
 		OPCODE(o6_if),
@@ -746,7 +746,7 @@
 	byte subOp = fetchScriptByte();
 	subOp -= 30;
 
-	debug(0,"o90_getSpriteInfo (%d)", subOp);
+	debug(1,"o90_getSpriteInfo (%d)", subOp);
 	switch (subOp) {
 	case 0:
 		spriteId = pop();
@@ -1001,7 +1001,7 @@
 	byte subOp = fetchScriptByte();
 	subOp -= 34;
 
-	debug(0,"o90_setSpriteInfo (%d)", subOp);
+	debug(1,"o90_setSpriteInfo (%d)", subOp);
 	switch (subOp) {
 	case 0:
 		args[0] = pop();
@@ -1332,7 +1332,7 @@
 
 	byte subOp = fetchScriptByte();
 
-	debug(0,"o90_getSpriteGroupInfo (%d)", subOp);
+	debug(1,"o90_getSpriteGroupInfo (%d)", subOp);
 	switch (subOp) {
 	case 8: // HE 99+
 		spriteGroupId = pop();
@@ -1414,7 +1414,7 @@
 	byte subOp = fetchScriptByte();
 	subOp -= 37;
 
-	debug(0,"o90_setSpriteGroupInfo (%d)", subOp);
+	debug(1,"o90_setSpriteGroupInfo (%d)", subOp);
 	switch (subOp) {
 	case 0:
 		type = pop() - 1;

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.433
retrieving revision 1.434
diff -u -d -r1.433 -r1.434
--- sound.cpp	31 Mar 2005 21:39:06 -0000	1.433
+++ sound.cpp	4 Apr 2005 11:41:16 -0000	1.434
@@ -33,12 +33,14 @@
 #include "common/util.h"
 
 #include "sound/audiocd.h"
+#include "sound/flac.h"
 #include "sound/mididrv.h"
 #include "sound/mixer.h"
 #include "sound/mp3.h"
 #include "sound/voc.h"
 #include "sound/vorbis.h"
-#include "sound/flac.h"
+#include "sound/wave.h"
+
 
 
 namespace Scumm {
@@ -159,6 +161,7 @@
 }
 
 void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) {
+	debug(5,"playSound: soundID %d heOffset %d heChannel %d heFlags %d\n", soundID, heOffset, heChannel, heFlags);
 	byte *mallocedPtr = NULL;
 	byte *ptr;
 	char *sound;
@@ -166,6 +169,9 @@
 	int rate;
 	byte flags = SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE;
 
+	if (heChannel == -1) {
+		heChannel = 1;
+	}
 	if (_vm->_heversion >= 70 && soundID > _vm->_numSounds) {
 		debug(1, "playSound #%d", soundID);
 
@@ -218,9 +224,7 @@
 		size = musicFile.readUint32LE();
 
 		if (music_offs > total_size || (size + music_offs > total_size) || size < 0) {
-			warning("playSound: Invalid music offset (%d) in music %d", soundID);
-			musicFile.close();
-			return;
+			error("playSound: Invalid music offset (%d) in music %d", soundID);
 		}
 
 		musicFile.seek(music_offs, SEEK_SET);
@@ -231,7 +235,7 @@
 		_vm->_mixer->stopID(_currentMusic);
 		_currentMusic = soundID;
 		if (_vm->_heversion == 70) {
-			_vm->_mixer->playRaw(NULL, ptr, size, 11025, flags, soundID);
+			_vm->_mixer->playRaw(&_heSoundChannels[heChannel], ptr, size, 11025, flags, soundID);
 			return;
 		}
 
@@ -266,7 +270,18 @@
 	}
 	// Support for later Backyard sports games sounds
 	else if (READ_UINT32(ptr) == MKID('RIFF')) {
-		// TODO: Play WAV, with set sound ID
+		size = READ_BE_UINT32(ptr + 4);
+		Common::MemoryReadStream stream(ptr, size);
+
+		if (!loadWAVFromStream(stream, size, rate, flags)) {
+			warning("playSound: Not a valid WAV file");
+			return;
+		}
+
+		// Allocate a sound buffer, copy the data into it, and play
+		sound = (char *)malloc(size);
+		memcpy(sound, ptr + stream.pos(), size);
+		_vm->_mixer->playRaw(&_heSoundChannels[heChannel], sound, size, rate, flags, soundID);
 	}
 	// Support for Putt-Putt sounds - very hackish, too 8-)
 	else if (READ_UINT32(ptr) == MKID('DIGI') || READ_UINT32(ptr) == MKID('TALK') || READ_UINT32(ptr) == MKID('HSHD')) {
@@ -280,14 +295,9 @@
 
 		if (READ_UINT32(ptr) == MKID('SBNG')) {
 			ptr += READ_BE_UINT32(ptr + 4);
-			debug(2, "playSound: Skipped SBNG block");
-		}
-
-		if (READ_UINT32(ptr) != MKID('SDAT')) {
-			warning("playSound: Invalid sound %d", soundID);
-			return;	// abort
 		}
 
+		assert(READ_UINT32(ptr) == MKID('SDAT'));
 		size = READ_BE_UINT32(ptr+4) - 8;
 		if (heOffset < 0 || heOffset > size) {
 			warning("playSound: Invalid sound offset (%d) in sound %d", heOffset, soundID);
@@ -301,13 +311,15 @@
 			_overrideFreq = 0;
 		}
 
-		// TODO: Set sound channel based on heChannel
-		//       Set sound looping based on heFlags
+		if (heFlags & 1) {
+			_vm->_mixer->stopHandle(_heSoundChannels[heChannel]);
+			flags |= SoundMixer::FLAG_LOOP;
+		}
 
 		// Allocate a sound buffer, copy the data into it, and play
 		sound = (char *)malloc(size);
 		memcpy(sound, ptr + heOffset + 8, size);
-		_vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID);
+		_vm->_mixer->playRaw(&_heSoundChannels[heChannel], sound, size, rate, flags, soundID);
 	}
 	else if (READ_UINT32(ptr) == MKID('MRAW')) {
 		// pcm music in 3DO humongous games
@@ -666,26 +678,26 @@
 		}
 
 		if (_vm->_features & GF_HUMONGOUS) {
-			int extra = 0;
 			_sfxMode |= mode;
 
 			// Skip the TALK (8) and HSHD (24) chunks
 			_sfxFile->seek(offset + 32, SEEK_SET);
 
 			if (_sfxFile->readUint32LE() == TO_LE_32(MKID('SBNG'))) {
-				debug(2, "startTalkSound: Skipped SBNG block");
 				// Skip the SBNG, so we end up at the SDAT chunk
-				extra = _sfxFile->readUint32BE();
-				_sfxFile->seek(extra - 4, SEEK_CUR);
-				size = _sfxFile->readUint32BE() - 8;
-			} else {
-				_sfxFile->seek(+4, SEEK_CUR);
-				size = b - 40;
+				size = _sfxFile->readUint32BE() - 4;
+				_sfxFile->seek(size, SEEK_CUR);
 			}
-
+			size = _sfxFile->readUint32BE() - 8;
 			sound = (byte *)malloc(size);
 			_sfxFile->read(sound, size);
-			_vm->_mixer->playRaw(handle, sound, size, 11000, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
+
+			if (_vm->_heversion >= 70) {
+				int channel = _vm->VAR(_vm->VAR_SOUND_CHANNEL);
+				_vm->_mixer->playRaw(&_heSoundChannels[channel], sound, size, 11000, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE, 1);
+			} else {
+				_vm->_mixer->playRaw(handle, sound, size, 11000, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
+			}
 			return;
 		}
 
@@ -780,7 +792,9 @@
 void Sound::stopTalkSound() {
 	if (_sfxMode & 2) {
 		if (_vm->_imuseDigital) {
-			_vm->_imuseDigital->stopSound(kTalkSoundID);
+			_vm->_mixer->stopID(kTalkSoundID);
+		} else if (_vm->_heversion >= 70) {
+			_vm->_imuseDigital->stopSound(1);
 		} else {
 			_vm->_mixer->stopHandle(_talkChannelHandle);
 		}
@@ -806,6 +820,15 @@
 }
 
 
+int Sound::getSoundElapsedTime(int sound) const {
+	if (sound >= 10000) {
+		int channel = sound - 10000;
+		return _vm->_mixer->getSoundElapsedTime(_heSoundChannels[channel]);
+	} else {
+		return _vm->_mixer->getSoundElapsedTimeOfSoundID(sound);
+	}
+}
+
 int Sound::isSoundRunning(int sound) const {
 	if (_vm->_imuseDigital)
 		return (_vm->_imuseDigital->getSoundStatus(sound) != 0);
@@ -824,12 +847,9 @@
 			else if (_vm->_imuse)
 				return (_vm->_imuse->getSoundStatus(sound));
 		} else if (sound >= 10000) {
-			// TODO report sound ID on channel
-			// channel = sound - 10000
-			if (sound == 10000)
-				return (_vm->_mixer->isSoundIDActive(_currentMusic) ? _currentMusic : 0);
-			else if (sound == 10001)
-				return _vm->_mixer->isSoundHandleActive(_talkChannelHandle);
+			int channel = sound - 10000;
+			if (_vm->_mixer->isSoundHandleActive(_heSoundChannels[channel]))
+				return _vm->_mixer->getActiveChannelSoundID(_heSoundChannels[channel]);
 			else
 				return 0;
 		}
@@ -915,10 +935,8 @@
 			else if (_vm->_imuse)
 				_vm->_imuse->stopSound(_vm->_imuse->getSoundStatus(-1));
 		} else if ( sound >= 10000) {
-			// TODO: Stop sound channel
-			// channel = sound - 10000
-			if (sound == 10000)
-				_vm->_mixer->stopID(_currentMusic);
+			int channel = sound - 10000;
+			_vm->_mixer->stopHandle(_heSoundChannels[channel]);
 		}
 	}
 

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.h,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- sound.h	12 Mar 2005 18:55:43 -0000	1.82
+++ sound.h	4 Apr 2005 11:41:17 -0000	1.83
@@ -85,6 +85,7 @@
 	int16 _currentMusic;
 public:
 	SoundHandle _talkChannelHandle;	// Handle of mixer channel actor is talking on
+	SoundHandle _heSoundChannels[8];
 
 	bool _soundsPaused;
 	byte _sfxMode;
@@ -100,6 +101,7 @@
 	void startTalkSound(uint32 offset, uint32 b, int mode, SoundHandle *handle = NULL);
 	void stopTalkSound();
 	bool isMouthSyncOff(uint pos);
+	int getSoundElapsedTime(int sound) const;
 	int isSoundRunning(int sound) const;
 	bool isSoundInUse(int sound) const;
 	void stopSound(int sound);

Index: wiz_he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/wiz_he.cpp,v
retrieving revision 2.36
retrieving revision 2.37
diff -u -d -r2.36 -r2.37
--- wiz_he.cpp	2 Apr 2005 14:24:43 -0000	2.36
+++ wiz_he.cpp	4 Apr 2005 11:41:17 -0000	2.37
@@ -916,12 +916,13 @@
 			cw = width;
 			ch = height;
 		} else {
+			VirtScreen *pvs = &virtscr[kMainVirtScreen];
 			if (dstPtr) {
 				cw  = READ_LE_UINT32(dstPtr + 0x4);
 				ch = READ_LE_UINT32(dstPtr + 0x8);
+				assert(cw <= pvs->w  && ch <= pvs->h);
 				dst = dstPtr;
 			} else {
-				VirtScreen *pvs = &virtscr[kMainVirtScreen];
 				if (flags & kWIFMarkBufferDirty) {
 					dst = pvs->getPixels(0, pvs->topline);
 				} else {





More information about the Scummvm-git-logs mailing list