aboutsummaryrefslogtreecommitdiff
path: root/engines/lastexpress
diff options
context:
space:
mode:
authorEugene Sandulenko2011-07-05 15:32:42 +0300
committerEugene Sandulenko2011-07-06 14:40:22 +0300
commitc4b2800145d3f6a2896c619165a73054677f138f (patch)
treee6fca42e706ee4b6e0288b1e26b0377787efd1c3 /engines/lastexpress
parentd4696e6a1837b5d6204d077563edf78e15775fba (diff)
downloadscummvm-rg350-c4b2800145d3f6a2896c619165a73054677f138f.tar.gz
scummvm-rg350-c4b2800145d3f6a2896c619165a73054677f138f.tar.bz2
scummvm-rg350-c4b2800145d3f6a2896c619165a73054677f138f.zip
LASTEXPRESS: implement Sound::updateQueue() and all dependent functions
Diffstat (limited to 'engines/lastexpress')
-rw-r--r--engines/lastexpress/sound/entry.cpp50
-rw-r--r--engines/lastexpress/sound/entry.h4
-rw-r--r--engines/lastexpress/sound/queue.cpp71
-rw-r--r--engines/lastexpress/sound/sound.h12
4 files changed, 133 insertions, 4 deletions
diff --git a/engines/lastexpress/sound/entry.cpp b/engines/lastexpress/sound/entry.cpp
index 1ba1862875..87d8ccdb30 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 c175b7bd40..a88b0b7210 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 b2f48cf4c1..0a6442ceed 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 797e52646e..517543f470 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