[Scummvm-cvs-logs] SF.net SVN: scummvm: [22115] scummvm/trunk/engines/scumm

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Apr 23 11:53:13 CEST 2006


Revision: 22115
Author:   fingolfin
Date:     2006-04-23 11:52:39 -0700 (Sun, 23 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22115&view=rev

Log Message:
-----------
Move HE specific stuff from class Sound to its new subclass SoundHE

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/actor.cpp
    scummvm/trunk/engines/scumm/he/resource_he.cpp
    scummvm/trunk/engines/scumm/he/script_v100he.cpp
    scummvm/trunk/engines/scumm/he/script_v60he.cpp
    scummvm/trunk/engines/scumm/he/script_v70he.cpp
    scummvm/trunk/engines/scumm/he/script_v72he.cpp
    scummvm/trunk/engines/scumm/he/script_v80he.cpp
    scummvm/trunk/engines/scumm/he/sound_he.cpp
    scummvm/trunk/engines/scumm/scumm.cpp
    scummvm/trunk/engines/scumm/sound.cpp
    scummvm/trunk/engines/scumm/sound.h
    scummvm/trunk/engines/scumm/string.cpp

Added Paths:
-----------
    scummvm/trunk/engines/scumm/he/sound_he.h
Modified: scummvm/trunk/engines/scumm/actor.cpp
===================================================================
--- scummvm/trunk/engines/scumm/actor.cpp	2006-04-23 17:58:52 UTC (rev 22114)
+++ scummvm/trunk/engines/scumm/actor.cpp	2006-04-23 18:52:39 UTC (rev 22115)
@@ -33,7 +33,7 @@
 #include "scumm/object.h"
 #include "scumm/resource.h"
 #include "scumm/saveload.h"
-#include "scumm/sound.h"
+#include "scumm/he/sound_he.h"
 #include "scumm/he/sprite_he.h"
 #include "scumm/usage_bits.h"
 #include "scumm/util.h"
@@ -1154,8 +1154,8 @@
 		if (_vm->getTalkingActor() == _number && !_vm->_string[0].no_talk_anim) {
 			int talkState = 0;
 
-			if (_vm->_sound->isSoundCodeUsed(1))
-				talkState = _vm->_sound->getSoundVar(1, 19);
+			if (((SoundHE *)_vm->_sound)->isSoundCodeUsed(1))
+				talkState = ((SoundHE *)_vm->_sound)->getSoundVar(1, 19);
 			if (talkState == 0)
 				talkState = _vm->_rnd.getRandomNumberRng(1, 10);
 

Modified: scummvm/trunk/engines/scumm/he/resource_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/resource_he.cpp	2006-04-23 17:58:52 UTC (rev 22114)
+++ scummvm/trunk/engines/scumm/he/resource_he.cpp	2006-04-23 18:52:39 UTC (rev 22115)
@@ -30,7 +30,7 @@
 #include "scumm/he/intern_he.h"
 #include "scumm/resource.h"
 #include "scumm/he/resource_he.h"
-#include "scumm/sound.h"
+#include "scumm/he/sound_he.h"
 
 #include "sound/wave.h"
 
@@ -1762,7 +1762,7 @@
 	int offs, size;
 
 	if (id > _numSounds) {
-		if (!_sound->getHEMusicDetails(id, offs, size)) {
+		if (!((SoundHE *)_sound)->getHEMusicDetails(id, offs, size)) {
 			debug(0, "getSoundResourceSize: musicID %d not found", id);
 			return 0;
 		}

Modified: scummvm/trunk/engines/scumm/he/script_v100he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v100he.cpp	2006-04-23 17:58:52 UTC (rev 22114)
+++ scummvm/trunk/engines/scumm/he/script_v100he.cpp	2006-04-23 18:52:39 UTC (rev 22115)
@@ -32,7 +32,7 @@
 #include "scumm/resource.h"
 #include "scumm/he/resource_he.h"
 #include "scumm/scumm.h"
-#include "scumm/sound.h"
+#include "scumm/he/sound_he.h"
 #include "scumm/he/sprite_he.h"
 #include "scumm/util.h"
 
@@ -1714,7 +1714,7 @@
 		value = pop();
 		var = pop();
 		_heSndSoundId = pop();
-		_sound->setSoundVar(_heSndSoundId, var, value);
+		((SoundHE *)_sound)->setSoundVar(_heSndSoundId, var, value);
 		break;
 	case 92:
 		_sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags);

Modified: scummvm/trunk/engines/scumm/he/script_v60he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v60he.cpp	2006-04-23 17:58:52 UTC (rev 22114)
+++ scummvm/trunk/engines/scumm/he/script_v60he.cpp	2006-04-23 18:52:39 UTC (rev 22115)
@@ -31,7 +31,7 @@
 #include "scumm/object.h"
 #include "scumm/resource.h"
 #include "scumm/scumm.h"
-#include "scumm/sound.h"
+#include "scumm/he/sound_he.h"
 #include "scumm/usage_bits.h"
 #include "scumm/util.h"
 #include "scumm/verbs.h"
@@ -1151,7 +1151,7 @@
 		// Fatty Bear's Birthday surprise uses this when playing the
 		// piano, but only when using one of the digitized instruments.
 		// See also o6_startSound().
-		_sound->setOverrideFreq(arg);
+		((SoundHE *)_sound)->setOverrideFreq(arg);
 		break;
 	default:
 		error("o60_soundOps: default case 0x%x", subOp);

Modified: scummvm/trunk/engines/scumm/he/script_v70he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v70he.cpp	2006-04-23 17:58:52 UTC (rev 22114)
+++ scummvm/trunk/engines/scumm/he/script_v70he.cpp	2006-04-23 18:52:39 UTC (rev 22115)
@@ -33,7 +33,7 @@
 #include "scumm/resource.h"
 #include "scumm/he/resource_he.h"
 #include "scumm/scumm.h"
-#include "scumm/sound.h"
+#include "scumm/he/sound_he.h"
 #include "scumm/verbs.h"
 
 namespace Scumm {
@@ -438,7 +438,7 @@
 		value = pop();
 		var = pop();
 		_heSndSoundId = pop();
-		_sound->setSoundVar(_heSndSoundId, var, value);
+		((SoundHE *)_sound)->setSoundVar(_heSndSoundId, var, value);
 		break;
 	case 25:
 		value = pop();

Modified: scummvm/trunk/engines/scumm/he/script_v72he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v72he.cpp	2006-04-23 17:58:52 UTC (rev 22114)
+++ scummvm/trunk/engines/scumm/he/script_v72he.cpp	2006-04-23 18:52:39 UTC (rev 22115)
@@ -35,7 +35,7 @@
 #include "scumm/resource.h"
 #include "scumm/he/resource_he.h"
 #include "scumm/scumm.h"
-#include "scumm/sound.h"
+#include "scumm/he/sound_he.h"
 #include "scumm/util.h"
 #include "scumm/verbs.h"
 
@@ -847,7 +847,7 @@
 
 void ScummEngine_v72he::o72_getSoundPosition() {
 	int snd = pop();
-	push(_sound->getSoundPos(snd));
+	push(((SoundHE *)_sound)->getSoundPos(snd));
 }
 
 void ScummEngine_v72he::o72_startScript() {

Modified: scummvm/trunk/engines/scumm/he/script_v80he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v80he.cpp	2006-04-23 17:58:52 UTC (rev 22114)
+++ scummvm/trunk/engines/scumm/he/script_v80he.cpp	2006-04-23 18:52:39 UTC (rev 22115)
@@ -34,7 +34,7 @@
 #include "scumm/resource.h"
 #include "scumm/he/resource_he.h"
 #include "scumm/scumm.h"
-#include "scumm/sound.h"
+#include "scumm/he/sound_he.h"
 
 namespace Scumm {
 
@@ -432,7 +432,7 @@
 void ScummEngine_v80he::o80_getSoundVar() {
 	int var = pop();
 	int snd = pop();
-	push(_sound->getSoundVar(snd, var));
+	push(((SoundHE *)_sound)->getSoundVar(snd, var));
 }
 
 void ScummEngine_v80he::o80_localizeArrayToRoom() {

Modified: scummvm/trunk/engines/scumm/he/sound_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/sound_he.cpp	2006-04-23 17:58:52 UTC (rev 22114)
+++ scummvm/trunk/engines/scumm/he/sound_he.cpp	2006-04-23 18:52:39 UTC (rev 22115)
@@ -26,7 +26,7 @@
 #include "scumm/file.h"
 #include "scumm/imuse/imuse.h"
 #include "scumm/scumm.h"
-#include "scumm/sound.h"
+#include "scumm/he/sound_he.h"
 #include "scumm/util.h"
 
 #include "common/config-manager.h"
@@ -45,7 +45,125 @@
 
 namespace Scumm {
 
-void Sound::stopSoundChannel(int chan) {
+SoundHE::SoundHE(ScummEngine *parent)
+	:
+	Sound(parent),
+	_heMusic(0),
+	_heMusicTracks(0) {
+
+	memset(_heChannel, 0, sizeof(_heChannel));
+}	
+
+SoundHE::~SoundHE() {
+	free(_heMusic);
+}
+
+void SoundHE::addSoundToQueue(int sound, int heOffset, int heChannel, int heFlags) {
+	if (_vm->VAR_LAST_SOUND != 0xFF)
+		_vm->VAR(_vm->VAR_LAST_SOUND) = sound;
+
+	if (heFlags & 16) {
+		playHESound(sound, heOffset, heChannel, heFlags);
+		return;
+	}
+
+	Sound::addSoundToQueue(sound, heOffset, heChannel, heFlags);
+}
+
+void SoundHE::addSoundToQueue2(int sound, int heOffset, int heChannel, int heFlags) {
+	int i = _soundQue2Pos;
+	while (i--) {
+		if (_soundQue2[i].sound == sound && !(heFlags & 2))
+			return;
+	}
+	
+	Sound::addSoundToQueue2(sound, heOffset, heChannel, heFlags);
+}
+
+void SoundHE::processSoundQueues() {
+	int snd, heOffset, heChannel, heFlags;
+
+	if (_vm->_game.heversion >= 72) {
+		for (int i = 0; i <_soundQue2Pos; i++) {
+			snd = _soundQue2[i].sound;
+			heOffset = _soundQue2[i].offset;
+			heChannel = _soundQue2[i].channel;
+			heFlags = _soundQue2[i].flags;
+			if (snd)
+				playHESound(snd, heOffset, heChannel, heFlags);
+		}
+		_soundQue2Pos = 0;
+	} else {
+		while (_soundQue2Pos) {
+			_soundQue2Pos--;
+			snd = _soundQue2[_soundQue2Pos].sound;
+			heOffset = _soundQue2[_soundQue2Pos].offset;
+			heChannel = _soundQue2[_soundQue2Pos].channel;
+			heFlags = _soundQue2[_soundQue2Pos].flags;
+			if (snd)
+				playHESound(snd, heOffset, heChannel, heFlags);
+		}
+	}
+
+	Sound::processSoundQueues();
+}
+
+int SoundHE::isSoundRunning(int sound) const {
+	if (_vm->_game.heversion >= 70) {
+		if (sound >= 10000) {
+			return _vm->_mixer->getSoundID(_heSoundChannels[sound - 10000]);
+		}
+	} else if (_vm->_game.heversion >= 60) {
+		if (sound == -2) {
+			sound = _heChannel[0].sound;
+		} else if (sound == -1) {
+			sound = _currentMusic;
+		}
+	}
+
+	return Sound::isSoundRunning(sound);
+}
+
+void SoundHE::stopSound(int sound) {
+	if (_vm->_game.heversion >= 70) {
+		if ( sound >= 10000) {
+			stopSoundChannel(sound - 10000);
+		}
+	} else if (_vm->_game.heversion >= 60) {
+		if (sound == -2) {
+			sound = _heChannel[0].sound;
+		} else if (sound == -1) {
+			sound = _currentMusic;
+		}
+	}
+
+	Sound::stopSound(sound);
+
+	for (int i = 0; i < ARRAYSIZE(_heChannel); i++) {
+		if (_heChannel[i].sound == sound) {
+			_heChannel[i].sound = 0;
+			_heChannel[i].priority = 0;
+			_heChannel[i].sbngBlock = 0;
+			_heChannel[i].codeOffs = 0;
+			memset(_heChannel[i].soundVars, 0, sizeof(_heChannel[i].soundVars));
+		}
+	}
+
+	if (_vm->_game.heversion >= 70 && sound == 1) {
+		_vm->_haveMsg = 3;
+		_vm->_talkDelay = 0;
+	}
+}
+
+void SoundHE::setupSound() {
+	Sound::setupSound();
+
+	if (_vm->_game.heversion >= 70) {
+		setupHEMusicFile();
+	}
+}
+
+void SoundHE::stopSoundChannel(int chan) {
 	if (_heChannel[chan].sound == 1) {
 		_vm->_haveMsg = 3;
 		_vm->_talkDelay = 0;
@@ -69,7 +187,7 @@
 	}
 }
 
-int Sound::findFreeSoundChannel() {
+int SoundHE::findFreeSoundChannel() {
 	int chan, min;
 
 	min = _vm->VAR(_vm->VAR_RESERVED_SOUND_CHANNELS);
@@ -90,7 +208,7 @@
 	return min;
 }
 
-int Sound::isSoundCodeUsed(int sound) {
+int SoundHE::isSoundCodeUsed(int sound) {
 	int chan = -1;
 	for (int i = 0; i < ARRAYSIZE(_heChannel); i ++) {
 		if (_heChannel[i].sound == sound)
@@ -104,7 +222,7 @@
 	}
 }
 
-int Sound::getSoundPos(int sound) {
+int SoundHE::getSoundPos(int sound) {
 	int chan = -1;
 	for (int i = 0; i < ARRAYSIZE(_heChannel); i ++) {
 		if (_heChannel[i].sound == sound)
@@ -119,7 +237,7 @@
 	}
 }
 
-int Sound::getSoundVar(int sound, int var) {
+int SoundHE::getSoundVar(int sound, int var) {
 	if (_vm->_game.heversion >= 90 && var == 26) {
 		return isSoundCodeUsed(sound);
 	}
@@ -140,7 +258,7 @@
 	}
 }
 
-void Sound::setSoundVar(int sound, int var, int val) {
+void SoundHE::setSoundVar(int sound, int var, int val) {
 	checkRange(25, 0, var, "Illegal sound variable %d");
 
 	int chan = -1;
@@ -155,11 +273,11 @@
 	}
 }
 
-void Sound::setOverrideFreq(int freq) {
+void SoundHE::setOverrideFreq(int freq) {
 	_overrideFreq = freq;
 }
 
-void Sound::setupHEMusicFile() {
+void SoundHE::setupHEMusicFile() {
 	int i, total_size;
 	Common::File musicFile;
 	Common::String buf(_vm->generateFilename(4));
@@ -191,7 +309,7 @@
 	}
 }
 
-bool Sound::getHEMusicDetails(int id, int &musicOffs, int &musicSize) {
+bool SoundHE::getHEMusicDetails(int id, int &musicOffs, int &musicSize) {
 	int i;
 
 	for (i = 0; i < _heMusicTracks; i++) {
@@ -205,7 +323,7 @@
 	return 0;
 }
 
-void Sound::processSoundCode() {
+void SoundHE::processSoundCode() {
 	byte *codePtr;
 	int chan, tmr, size, time;
 
@@ -252,7 +370,7 @@
 	}
 }
 
-void Sound::processSoundOpcodes(int sound, byte *codePtr, int *soundVars) {
+void SoundHE::processSoundOpcodes(int sound, byte *codePtr, int *soundVars) {
 	int arg, opcode, var, val;
 
 	while(READ_LE_UINT16(codePtr) != 0) {
@@ -329,7 +447,7 @@
 	}
 }
 
-void Sound::playHESound(int soundID, int heOffset, int heChannel, int heFlags) {
+void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags) {
 	byte *ptr, *spoolPtr;
 	int size = -1;
 	int priority, rate;
@@ -507,7 +625,7 @@
 	}
 }
 
-void Sound::startHETalkSound(uint32 offset) {
+void SoundHE::startHETalkSound(uint32 offset) {
 	byte *ptr;
 	int32 size;
 

Added: scummvm/trunk/engines/scumm/he/sound_he.h
===================================================================
--- scummvm/trunk/engines/scumm/he/sound_he.h	                        (rev 0)
+++ scummvm/trunk/engines/scumm/he/sound_he.h	2006-04-23 18:52:39 UTC (rev 22115)
@@ -0,0 +1,74 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2002-2006 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#ifndef SCUMM_HE_SOUND_HE_H
+#define SCUMM_HE_SOUND_HE_H
+
+#include "common/scummsys.h"
+#include "scumm/sound.h"
+
+namespace Scumm {
+
+class SoundHE : public Sound {
+protected:
+	struct HEMusic{
+		int32 id;
+		int32 offset;
+		int32 size;
+	};
+	HEMusic *_heMusic;
+	int16 _heMusicTracks;
+
+	Audio::SoundHandle _heSoundChannels[8];
+
+public:
+	SoundHE(ScummEngine *parent);
+	~SoundHE();
+	
+	virtual void addSoundToQueue(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
+	virtual void addSoundToQueue2(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
+
+	virtual int isSoundRunning(int sound) const;
+	virtual void stopSound(int sound);
+	virtual void setupSound();
+
+	bool getHEMusicDetails(int id, int &musicOffs, int &musicSize);
+	int findFreeSoundChannel();
+	int isSoundCodeUsed(int sound);
+	int getSoundPos(int sound);
+	int getSoundVar(int sound, int var);
+	void setSoundVar(int sound, int var, int val);
+	void playHESound(int soundID, int heOffset, int heChannel, int heFlags);
+	void processSoundCode();
+	void processSoundOpcodes(int sound, byte *codePtr, int *soundVars);
+	void setOverrideFreq(int freq);
+	void setupHEMusicFile();
+	void startHETalkSound(uint32 offset);
+	void stopSoundChannel(int chan);
+
+protected:
+	virtual void processSoundQueues();
+};
+
+
+} // End of namespace Scumm
+
+#endif


Property changes on: scummvm/trunk/engines/scumm/he/sound_he.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/trunk/engines/scumm/scumm.cpp
===================================================================
--- scummvm/trunk/engines/scumm/scumm.cpp	2006-04-23 17:58:52 UTC (rev 22114)
+++ scummvm/trunk/engines/scumm/scumm.cpp	2006-04-23 18:52:39 UTC (rev 22115)
@@ -45,6 +45,7 @@
 #include "scumm/intern.h"
 #include "scumm/he/intern_he.h"
 #include "scumm/he/logic_he.h"
+#include "scumm/he/sound_he.h"
 #include "scumm/player_nes.h"
 #include "scumm/player_v1.h"
 #include "scumm/player_v2.h"
@@ -944,7 +945,10 @@
 		_system->openCD(cd_num);
 
 	// Create the sound manager
-	_sound = new Sound(this);
+	if (_game.heversion > 0)
+		_sound = new SoundHE(this);
+	else
+		_sound = new Sound(this);
 
 	// Setup the music engine
 	setupMusic(_game.midi);
@@ -1762,7 +1766,7 @@
 	}
 
 	if (_game.heversion >= 80) {
-		_sound->processSoundCode();
+		((SoundHE *)_sound)->processSoundCode();
 	}
 	runAllScripts();
 	checkExecVerbs();

Modified: scummvm/trunk/engines/scumm/sound.cpp
===================================================================
--- scummvm/trunk/engines/scumm/sound.cpp	2006-04-23 17:58:52 UTC (rev 22114)
+++ scummvm/trunk/engines/scumm/sound.cpp	2006-04-23 18:52:39 UTC (rev 22115)
@@ -78,11 +78,8 @@
 	_currentCDSound(0),
 	_currentMusic(0),
 	_soundsPaused(false),
-	_sfxMode(0),
-	_heMusic(0),
-	_heMusicTracks(0) {
+	_sfxMode(0) {
 
-	memset(_heChannel, 0, sizeof(_heChannel));
 	memset(_soundQue, 0, sizeof(_soundQue));
 	memset(_soundQue2, 0, sizeof(_soundQue2));
 	memset(_mouthSyncTimes, 0, sizeof(_mouthSyncTimes));
@@ -91,20 +88,12 @@
 Sound::~Sound() {
 	stopCDTimer();
 	delete _sfxFile;
-
-	// HE Specific
-	free(_heMusic);
 }
 
 void Sound::addSoundToQueue(int sound, int heOffset, int heChannel, int heFlags) {
 	if (_vm->VAR_LAST_SOUND != 0xFF)
 		_vm->VAR(_vm->VAR_LAST_SOUND) = sound;
 
-	if (heFlags & 16) {
-		playHESound(sound, heOffset, heChannel, heFlags);
-		return;
-	}
-
 	// HE music resources are in separate file
 	if (sound <= _vm->_numSounds)
 		_vm->ensureResourceLoaded(rtSound, sound);
@@ -113,14 +102,6 @@
 }
 
 void Sound::addSoundToQueue2(int sound, int heOffset, int heChannel, int heFlags) {
-	if (_vm->_game.heversion >= 60 && _soundQue2Pos) {
-		int i = _soundQue2Pos;
-		while (i--) {
-			if (_soundQue2[i].sound == sound && !(heFlags & 2))
-				return;
-		}
-	}
-
 	assert(_soundQue2Pos < ARRAYSIZE(_soundQue2));
 	_soundQue2[_soundQue2Pos].sound = sound;
 	_soundQue2[_soundQue2Pos].offset = heOffset;
@@ -144,37 +125,14 @@
 
 void Sound::processSoundQueues() {
 	int i = 0, num;
-	int snd, heOffset, heChannel, heFlags;
+	int snd;
 	int data[16];
 
-	if (_vm->_game.heversion >= 72) {
-		for (i = 0; i <_soundQue2Pos; i++) {
-			snd = _soundQue2[i].sound;
-			heOffset = _soundQue2[i].offset;
-			heChannel = _soundQue2[i].channel;
-			heFlags = _soundQue2[i].flags;
-			if (snd) {
-				if (_vm->_game.heversion>= 60)
-					playHESound(snd, heOffset, heChannel, heFlags);
-				else
-					playSound(snd);
-			}
-		}
-		_soundQue2Pos = 0;
-	} else {
-		while (_soundQue2Pos) {
-			_soundQue2Pos--;
-			snd = _soundQue2[_soundQue2Pos].sound;
-			heOffset = _soundQue2[_soundQue2Pos].offset;
-			heChannel = _soundQue2[_soundQue2Pos].channel;
-			heFlags = _soundQue2[_soundQue2Pos].flags;
-			if (snd) {
-				if (_vm->_game.heversion>= 60)
-					playHESound(snd, heOffset, heChannel, heFlags);
-				else
-					playSound(snd);
-			}
-		}
+	while (_soundQue2Pos) {
+		_soundQue2Pos--;
+		snd = _soundQue2[_soundQue2Pos].sound;
+		if (snd)
+			playSound(snd);
 	}
 
 	while (i < _soundQuePos) {
@@ -726,18 +684,6 @@
 	if (sound == _currentCDSound)
 		return pollCD();
 
-	if (_vm->_game.heversion >= 70) {
-		if (sound >= 10000) {
-			return _vm->_mixer->getSoundID(_heSoundChannels[sound - 10000]);
-		}
-	} else if (_vm->_game.heversion >= 60) {
-		if (sound == -2) {
-			sound = _heChannel[0].sound;
-		} else if (sound == -1) {
-			sound = _currentMusic;
-		}
-	}
-
 	if (_vm->_mixer->isSoundIDActive(sound))
 		return 1;
 
@@ -814,18 +760,6 @@
 void Sound::stopSound(int sound) {
 	int i;
 
-	if (_vm->_game.heversion >= 70) {
-		if ( sound >= 10000) {
-			stopSoundChannel(sound - 10000);
-		}
-	} else if (_vm->_game.heversion >= 60) {
-		if (sound == -2) {
-			sound = _heChannel[0].sound;
-		} else if (sound == -1) {
-			sound = _currentMusic;
-		}
-	}
-
 	if (sound != 0 && sound == _currentCDSound) {
 		_currentCDSound = 0;
 		stopCD();
@@ -838,16 +772,6 @@
 	if (_vm->_musicEngine)
 		_vm->_musicEngine->stopSound(sound);
 
-	for (i = 0; i < ARRAYSIZE(_heChannel); i++) {
-		if (_heChannel[i].sound == sound) {
-			_heChannel[i].sound = 0;
-			_heChannel[i].priority = 0;
-			_heChannel[i].sbngBlock = 0;
-			_heChannel[i].codeOffs = 0;
-			memset(_heChannel[i].soundVars, 0, sizeof(_heChannel[i].soundVars));
-		}
-	}
-
 	for (i = 0; i < ARRAYSIZE(_soundQue2); i++) {
 		if (_soundQue2[i].sound == sound) {
 			_soundQue2[i].sound = 0;
@@ -856,12 +780,6 @@
 			_soundQue2[i].flags = 0;
 		}
 	}
-
-	if (_vm->_game.heversion >= 70 && sound == 1) {
-		_vm->_haveMsg = 3;
-		_vm->_talkDelay = 0;
-	}
-
 }
 
 void Sound::stopAllSounds() {
@@ -938,10 +856,6 @@
 
 	_sfxFile = openSfxFile();
 
-	if (_vm->_game.heversion >= 70) {
-		setupHEMusicFile();
-	}
-
 	if (_vm->_game.id == GID_FT) {
 		_vm->VAR(_vm->VAR_VOICE_BUNDLE_LOADED) = _sfxFile->isOpen();
 	}

Modified: scummvm/trunk/engines/scumm/sound.h
===================================================================
--- scummvm/trunk/engines/scumm/sound.h	2006-04-23 17:58:52 UTC (rev 22114)
+++ scummvm/trunk/engines/scumm/sound.h	2006-04-23 18:52:39 UTC (rev 22115)
@@ -19,8 +19,8 @@
  * $Id$
  */
 
-#ifndef SOUND_H
-#define SOUND_H
+#ifndef SCUMM_SOUND_H
+#define SCUMM_SOUND_H
 
 #include "common/scummsys.h"
 #include "sound/audiostream.h"
@@ -43,12 +43,10 @@
 	kTalkSoundID = 10000
 };
 
+// TODO: Consider splitting Sound into even more subclasses.
+// E.g. for v1-v4, v5, v6+, ...
 class Sound : public Serializable {
-#ifdef PALMOS_MODE
 public:
-#else
-protected:
-#endif
 	enum SoundMode {
 		kVOCMode,
 		kMP3Mode,
@@ -56,9 +54,7 @@
 		kFlacMode
 	};
 
-#ifdef PALMOS_MODE
 protected:
-#endif
 	ScummEngine *_vm;
 
 	int16 _soundQuePos, _soundQue[0x100];
@@ -88,14 +84,6 @@
 	int16 _currentCDSound;
 	int16 _currentMusic;
 
-	struct HEMusic{
-		int32 id;
-		int32 offset;
-		int32 size;
-	};
-	HEMusic *_heMusic;
-	int16 _heMusicTracks;
-
 public: // Used by createSound()
 	struct {
 		int sound;
@@ -107,30 +95,28 @@
 
 public:
 	Audio::SoundHandle _talkChannelHandle;	// Handle of mixer channel actor is talking on
-	Audio::SoundHandle _heSoundChannels[8];
 
 	bool _soundsPaused;
 	byte _sfxMode;
 
 public:
 	Sound(ScummEngine *parent);
-	~Sound();
-	void addSoundToQueue(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
-	void addSoundToQueue2(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
+	virtual ~Sound();
+	virtual void addSoundToQueue(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
+	virtual void addSoundToQueue2(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
 	void processSound();
-	void processSoundQueues();
 
 	void playSound(int soundID);
 	void startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle *handle = NULL);
 	void stopTalkSound();
 	bool isMouthSyncOff(uint pos);
-	int isSoundRunning(int sound) const;
+	virtual int isSoundRunning(int sound) const;
 	bool isSoundInUse(int sound) const;
-	void stopSound(int sound);
+	virtual void stopSound(int sound);
 	void stopAllSounds();
 	void soundKludge(int *list, int num);
 	void talkSound(uint32 a, uint32 b, int mode, int channel = 0);
-	void setupSound();
+	virtual void setupSound();
 	void pauseSounds(bool pause);
 
 	void startCDTimer();
@@ -142,21 +128,6 @@
 	void updateCD();
 	int getCurrentCDSound() const { return _currentCDSound; }
 
-	// HE specific
-	bool getHEMusicDetails(int id, int &musicOffs, int &musicSize);
-	int findFreeSoundChannel();
-	int isSoundCodeUsed(int sound);
-	int getSoundPos(int sound);
-	int getSoundVar(int sound, int var);
-	void setSoundVar(int sound, int var, int val);
-	void playHESound(int soundID, int heOffset, int heChannel, int heFlags);
-	void processSoundCode();
-	void processSoundOpcodes(int sound, byte *codePtr, int *soundVars);
-	void setOverrideFreq(int freq);
-	void setupHEMusicFile();
-	void startHETalkSound(uint32 offset);
-	void stopSoundChannel(int chan);
-
 	// Used by the save/load system:
 	void saveLoadWithSerializer(Serializer *ser);
 
@@ -166,6 +137,8 @@
 	void processSfxQueues();
 
 	bool isSoundInQueue(int sound) const;
+
+	virtual void processSoundQueues();
 };
 
 /**

Modified: scummvm/trunk/engines/scumm/string.cpp
===================================================================
--- scummvm/trunk/engines/scumm/string.cpp	2006-04-23 17:58:52 UTC (rev 22114)
+++ scummvm/trunk/engines/scumm/string.cpp	2006-04-23 18:52:39 UTC (rev 22115)
@@ -36,7 +36,7 @@
 #include "scumm/he/intern_he.h"
 #endif
 #include "scumm/verbs.h"
-#include "scumm/sound.h"
+#include "scumm/he/sound_he.h"
 
 namespace Scumm {
 
@@ -288,7 +288,7 @@
 			talk_sound_b = buffer[8] | (buffer[9] << 8) | (buffer[12] << 16) | (buffer[13] << 24);
 			buffer += 14;
 			if (_game.heversion >= 60) {
-				_sound->startHETalkSound(talk_sound_a);
+				((SoundHE *)_sound)->startHETalkSound(talk_sound_a);
 			} else {
 				_sound->talkSound(talk_sound_a, talk_sound_b, 2);
 			}
@@ -358,7 +358,7 @@
 			}
 			value[i] = 0;
 			talk_sound_b = atoi(value);
-			_sound->startHETalkSound(talk_sound_a);
+			((SoundHE *)_sound)->startHETalkSound(talk_sound_a);
 			break;
 		case 104:
 			_haveMsg = 0;
@@ -381,7 +381,7 @@
 			value[i] = 0;
 			talk_sound_a = atoi(value);
 			talk_sound_b = 0;
-			_sound->startHETalkSound(talk_sound_a);
+			((SoundHE *)_sound)->startHETalkSound(talk_sound_a);
 			break;
 		case 119:
 			_haveMsg = 0xFF;


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