[Scummvm-cvs-logs] scummvm master -> c4b2800145d3f6a2896c619165a73054677f138f

sev- sev at scummvm.org
Wed Jul 6 15:54:58 CEST 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c4b2800145 LASTEXPRESS: implement Sound::updateQueue() and all dependent functions


Commit: c4b2800145d3f6a2896c619165a73054677f138f
    https://github.com/scummvm/scummvm/commit/c4b2800145d3f6a2896c619165a73054677f138f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2011-07-06T04:40:22-07:00

Commit Message:
LASTEXPRESS: implement Sound::updateQueue() and all dependent functions

Changed paths:
    engines/lastexpress/sound/entry.cpp
    engines/lastexpress/sound/entry.h
    engines/lastexpress/sound/queue.cpp
    engines/lastexpress/sound/sound.h



diff --git a/engines/lastexpress/sound/entry.cpp b/engines/lastexpress/sound/entry.cpp
index 1ba1862..87d8ccd 100644
--- a/engines/lastexpress/sound/entry.cpp
+++ b/engines/lastexpress/sound/entry.cpp
@@ -262,6 +262,56 @@ void SoundEntry::update(uint val) {
 	}
 }
 
+bool SoundEntry::updateSound() {
+	bool result;
+	char sub[16];
+
+	if (_status.status2 & 4) {
+		result = false;
+	} else {
+		if (_status.status2 & 0x80) {
+			if (_field_48 <= getSound()->getData2()) {
+				_status.status |= 0x20;
+				_status.status &= ~0x8000;
+				strcpy(sub, _name2.c_str());
+
+				int l = strlen(sub) + 1;
+				if (l - 1 > 4)
+					sub[l - 1 - 4] = 0;
+				showSubtitle(sub);
+			}
+		} else {
+			if (!(getSoundQueue()->getFlag() & 0x20)) {
+				if (!(_status.status3 & 8)) {
+					if (_entity) {
+						if (_entity < 0x80) {
+							updateEntryFlag(getSound()->getSoundFlag(_entity));
+						}
+					}
+				}
+			}
+			//if (status.status2 & 0x40 && !((uint32)_status.status & 0x180) && v1->soundBuffer) 
+			//	Sound_FillSoundBuffer(v1);
+		}
+		result = true;
+	}
+
+	return result;
+}
+
+void SoundEntry::updateEntryFlag(SoundFlag flag) {
+	if (flag) {
+		if (getSoundQueue()->getFlag() & 0x20 && _type != kSoundType9 && _type != kSoundType7)
+			update(flag);
+		else
+			_status.status = flag + (_status.status & ~0x1F);
+	} else {
+		_variant = 0;
+		_status.status |= 0x80u;
+		_status.status &= ~0x10001F;
+	}
+}
+
 void SoundEntry::updateState() {
 	if (getSoundQueue()->getFlag() & 32) {
 		if (_type != kSoundType9 && _type != kSoundType7 && _type != kSoundType5) {
diff --git a/engines/lastexpress/sound/entry.h b/engines/lastexpress/sound/entry.h
index c175b7b..a88b0b7 100644
--- a/engines/lastexpress/sound/entry.h
+++ b/engines/lastexpress/sound/entry.h
@@ -102,7 +102,9 @@ public:
 	void reset();
 	bool isFinished();
 	void update(uint val);
+	bool updateSound();
 	void updateState();
+	void updateEntryFlag(SoundFlag flag);
 
 	// Subtitles
 	void showSubtitle(Common::String filename);
@@ -140,7 +142,7 @@ private:
 	//int _size;
 	//int _field_28;
 	Common::SeekableReadStream *_stream;    // The file stream
-	//int _field_30;
+	//int _archive;
 	int _field_34;
 	int _field_38;
 	int _field_3C;
diff --git a/engines/lastexpress/sound/queue.cpp b/engines/lastexpress/sound/queue.cpp
index b2f48cf..0a6442c 100644
--- a/engines/lastexpress/sound/queue.cpp
+++ b/engines/lastexpress/sound/queue.cpp
@@ -105,6 +105,77 @@ void SoundQueue::updateQueue() {
 	//Common::StackLock locker(_mutex);
 
 	//warning("[Sound::updateQueue] Not implemented");
+
+	int maxPriority = 0;
+	Common::List<SoundEntry *>::iterator lsnd;
+	SoundEntry *msnd;
+
+	bool loopedPlaying;
+
+	loopedPlaying = 0;
+	//++g_sound_flag;
+
+	for (lsnd = _soundList.begin(); lsnd != _soundList.end(); ++lsnd) {
+		if ((*lsnd)->getType() == kSoundType1)
+			break;
+	}
+
+	if (getSoundState() & 1) {
+		if (!(*lsnd) || getFlags()->flag_3 || (*lsnd && (*lsnd)->getTime() > getSound()->getLoopingSoundDuration())) {
+			getSound()->playLoopingSound(0x45);
+		} else {
+			if (getSound()->getData1() && getSound()->getData2() >= getSound()->getData1()) {
+				(*lsnd)->update(getSound()->getData0());
+				getSound()->setData1(0);
+			}
+		}
+	}
+
+	msnd = NULL;
+
+	for (lsnd = _soundList.begin(); lsnd != _soundList.end(); ++lsnd) {
+		if ((*lsnd)->getStatus().status2 & 0x1) { // Sound is stopped
+			// original code
+			//if ((*lsnd)->soundBuffer)
+			//	Sound_RemoveSoundDataFromCache(*lsnd);
+			//if ((*lsnd)->archive) {
+			//	Archive_SetStatusNotLoaded((*lsnd)->archive);
+			//	(*lsnd)->archive = 0;
+			//	(*lsnd)->field_28 = 3;
+			//}
+
+			if (_soundList.size() < 6) {
+				if ((*lsnd)->getStatus().status1 & 0x1F) {
+					int pri = (*lsnd)->getPriority() + ((*lsnd)->getStatus().status1 & 0x1F);
+
+					if (pri > maxPriority) {
+						msnd = *lsnd;
+						maxPriority = pri;
+					}
+				}
+			}
+		}
+
+		if (!(*lsnd)->updateSound() && !((*lsnd)->getStatus().status3 & 0x8)) {
+			if (msnd == *lsnd) {
+				maxPriority = 0;
+				msnd = 0;
+			}
+			if (*lsnd) {
+				(*lsnd)->close();
+				SAFE_DELETE(*lsnd);
+				lsnd = _soundList.reverse_erase(lsnd);
+			}
+		}
+	}
+
+	
+	// We don't need this
+	//if (msnd)
+	//	msnd->updateEntryInternal();
+
+	getFlags()->flag_3 = 0;
+	//--g_sound_flag;
 }
 
 void SoundQueue::resetQueue() {
diff --git a/engines/lastexpress/sound/sound.h b/engines/lastexpress/sound/sound.h
index 797e526..517543f 100644
--- a/engines/lastexpress/sound/sound.h
+++ b/engines/lastexpress/sound/sound.h
@@ -64,7 +64,13 @@ public:
 
 	// Accessors
 	SoundQueue *getQueue() { return _queue; }
-	uint32 getData2() { return _data2; }
+	uint32 getData0() { return _data0; }
+	int32 getData1() { return _data1; }
+	int32 getData2() { return _data2; }
+	uint32 getLoopingSoundDuration() { return _loopingSoundDuration; }
+
+	// Setters
+	void setData1(int32 data) { _data1 = data; }
 
 private:
 	LastExpressEngine *_engine;
@@ -78,8 +84,8 @@ private:
 
 	// Unknown data
 	uint32 _data0;
-	uint32 _data1;
-	uint32 _data2;
+	int32 _data1;
+	int32 _data2;
 };
 
 } // End of namespace LastExpress






More information about the Scummvm-git-logs mailing list