aboutsummaryrefslogtreecommitdiff
path: root/engines/lastexpress
diff options
context:
space:
mode:
Diffstat (limited to 'engines/lastexpress')
-rw-r--r--engines/lastexpress/sound/queue.cpp6
-rw-r--r--engines/lastexpress/sound/sound.cpp24
-rw-r--r--engines/lastexpress/sound/sound.h16
3 files changed, 23 insertions, 23 deletions
diff --git a/engines/lastexpress/sound/queue.cpp b/engines/lastexpress/sound/queue.cpp
index 51073839d1..3a10a7a89b 100644
--- a/engines/lastexpress/sound/queue.cpp
+++ b/engines/lastexpress/sound/queue.cpp
@@ -86,9 +86,9 @@ void SoundQueue::updateQueue() {
if (!entry || getFlags()->flag_3 || (entry && entry->getTime() > getSound()->getAmbientSoundDuration())) {
getSound()->playAmbientSound(0x45);
} else {
- if (getSound()->getData1() && getSound()->getData2() >= getSound()->getData1()) {
- entry->setVolumeSmoothly((SoundFlag)getSound()->getData0());
- getSound()->setData1(0);
+ if (getSound()->needToChangeAmbientVolume()) {
+ entry->setVolumeSmoothly(getSound()->getChangedAmbientVolume());
+ getSound()->clearAmbientVolumeChange();
}
}
}
diff --git a/engines/lastexpress/sound/sound.cpp b/engines/lastexpress/sound/sound.cpp
index c28b734129..597edd3b11 100644
--- a/engines/lastexpress/sound/sound.cpp
+++ b/engines/lastexpress/sound/sound.cpp
@@ -119,10 +119,8 @@ SoundManager::SoundManager(LastExpressEngine *engine) : _engine(engine) {
memset(&_lastWarning, 0, sizeof(_lastWarning));
- // Initialize unknown data
- _data0 = 0;
- _data1 = 0;
- _data2 = 0;
+ _ambientVolumeChangeTimeMS = _ambientVolumeChangeDelayMS = 0;
+ _ambientScheduledVolume = kVolumeNone;
}
SoundManager::~SoundManager() {
@@ -181,6 +179,10 @@ bool SoundManager::playSoundWithSubtitles(Common::String filename, uint32 flag,
return (entry->getTag() != kSoundTagNone);
}
+bool SoundManager::needToChangeAmbientVolume() {
+ return _ambientScheduledVolume && _engine->_system->getMillis() - _ambientVolumeChangeTimeMS >= _ambientVolumeChangeDelayMS;
+}
+
void SoundManager::playSoundEvent(EntityIndex entity, byte action, byte activateDelay) {
int values[5];
@@ -195,18 +197,20 @@ void SoundManager::playSoundEvent(EntityIndex entity, byte action, byte activate
switch (action) {
case 36: {
- int _param3 = (flag <= 9) ? flag + 7 : 16;
+ uint newVolume = (flag <= kVolumeFull - 7) ? flag + 7 : kVolumeFull;
- if (_param3 > 7) {
- _data0 = (uint)_param3;
- _data1 = _data2 + 2 * activateDelay;
+ if (newVolume > kVolume7) {
+ _ambientScheduledVolume = (SoundFlag)newVolume;
+ _ambientVolumeChangeTimeMS = _engine->_system->getMillis();
+ _ambientVolumeChangeDelayMS = activateDelay * 1000 / 15;
}
break;
}
case 37:
- _data0 = 7;
- _data1 = _data2 + 2 * activateDelay;
+ _ambientScheduledVolume = kVolume7;
+ _ambientVolumeChangeTimeMS = _engine->_system->getMillis();
+ _ambientVolumeChangeDelayMS = activateDelay * 1000 / 15;
break;
case 150:
diff --git a/engines/lastexpress/sound/sound.h b/engines/lastexpress/sound/sound.h
index f832574ba5..e4ffbd95e2 100644
--- a/engines/lastexpress/sound/sound.h
+++ b/engines/lastexpress/sound/sound.h
@@ -65,13 +65,12 @@ public:
// Accessors
SoundQueue *getQueue() { return _queue; }
- uint32 getData0() { return _data0; }
- int32 getData1() { return _data1; }
- int32 getData2() { return _data2; }
uint32 getAmbientSoundDuration() { return _ambientSoundDuration; }
+ bool needToChangeAmbientVolume();
+ SoundFlag getChangedAmbientVolume() { return _ambientScheduledVolume; }
// Setters
- void setData1(int32 data) { _data1 = data; }
+ void clearAmbientVolumeChange() { _ambientScheduledVolume = kVolumeNone; }
private:
LastExpressEngine *_engine;
@@ -80,13 +79,10 @@ private:
// Compartment warnings by Mertens or Coudert
uint32 _lastWarning[12];
- // Looping sound
+ // Ambient sound
int _ambientSoundDuration;
-
- // Unknown data
- uint32 _data0;
- int32 _data1;
- int32 _data2;
+ uint32 _ambientVolumeChangeTimeMS, _ambientVolumeChangeDelayMS;
+ SoundFlag _ambientScheduledVolume;
};
} // End of namespace LastExpress