aboutsummaryrefslogtreecommitdiff
path: root/engines/lastexpress/sound
diff options
context:
space:
mode:
authorEvgeny Grechnikov2018-10-14 20:05:54 +0300
committerEvgeny Grechnikov2018-10-14 20:08:32 +0300
commit53cd6616c958e4a50644254688aea222177f2ae2 (patch)
treeb0373918c84cf577268056ef0fe65a97f19f7e58 /engines/lastexpress/sound
parent46fe0aafd6996841ee9969da7a8988497baf51b6 (diff)
downloadscummvm-rg350-53cd6616c958e4a50644254688aea222177f2ae2.tar.gz
scummvm-rg350-53cd6616c958e4a50644254688aea222177f2ae2.tar.bz2
scummvm-rg350-53cd6616c958e4a50644254688aea222177f2ae2.zip
LASTEXPRESS: refactor sound flags
Merge SoundFlag and SoundStatus into a single enum; SoundEntry::setupStatus just casts one to another. Keep only definitions of bits in SoundFlag; drop compound flags like kFlagSteam = kSoundTypeAmbient | kSoundFlagLooped | kVolume7, use ORed simple flags in calls; change the signature of SoundManager::playSoundWithSubtitles to use uint32 instead of SoundFlag to avoid excess casting. Add meaningful names to flags; add some comments. Get rid of endian-unsafe SoundStatusUnion. Fixes an issue with big-endian hosts. No changes in behaviour on little-endian hosts.
Diffstat (limited to 'engines/lastexpress/sound')
-rw-r--r--engines/lastexpress/sound/entry.cpp105
-rw-r--r--engines/lastexpress/sound/entry.h28
-rw-r--r--engines/lastexpress/sound/queue.cpp14
-rw-r--r--engines/lastexpress/sound/sound.cpp114
-rw-r--r--engines/lastexpress/sound/sound.h6
5 files changed, 128 insertions, 139 deletions
diff --git a/engines/lastexpress/sound/entry.cpp b/engines/lastexpress/sound/entry.cpp
index a8c9b22cd4..945fc2318b 100644
--- a/engines/lastexpress/sound/entry.cpp
+++ b/engines/lastexpress/sound/entry.cpp
@@ -42,6 +42,7 @@ namespace LastExpress {
// SoundEntry
//////////////////////////////////////////////////////////////////////////
SoundEntry::SoundEntry(LastExpressEngine *engine) : _engine(engine) {
+ _status = 0;
_type = kSoundTypeNone;
_currentDataPtr = NULL;
@@ -90,10 +91,10 @@ void SoundEntry::open(Common::String name, SoundFlag flag, int priority) {
}
void SoundEntry::close() {
- _status.status |= kSoundStatusClosed;
+ _status |= kSoundFlagCloseRequested;
// Loop until ready
- //while (!(_status.b.status1 & 4) && !(getSoundQueue()->getFlag() & 8) && (getSoundQueue()->getFlag() & 1))
+ //while (!(_status & kSoundFlagClosed) && !(getSoundQueue()->getFlag() & 8) && (getSoundQueue()->getFlag() & 1))
// ; // empty loop body
// The original game remove the entry from the cache here,
@@ -123,7 +124,7 @@ void SoundEntry::play() {
_soundStream = new StreamedSound();
// Compute current filter id
- int32 filterId = _status.status & kSoundStatusFilter;
+ int32 filterId = _status & kSoundVolumeMask;
// TODO adjust status (based on stepIndex)
if (_queued) {
@@ -150,14 +151,14 @@ bool SoundEntry::isFinished() {
}
void SoundEntry::setType(SoundFlag flag) {
- switch (flag & kFlagType9) {
+ switch (flag & kSoundTypeMask) {
default:
- case kFlagNone:
+ case kSoundTypeNormal:
_type = getSoundQueue()->getCurrentType();
getSoundQueue()->setCurrentType((SoundType)(_type + 1));
break;
- case kFlagType1_2: {
+ case kSoundTypeAmbient: {
SoundEntry *previous2 = getSoundQueue()->getEntry(kSoundType2);
if (previous2)
previous2->update(0);
@@ -172,7 +173,7 @@ void SoundEntry::setType(SoundFlag flag) {
}
break;
- case kFlagType3: {
+ case kSoundTypeWalla: {
SoundEntry *previous = getSoundQueue()->getEntry(kSoundType3);
if (previous) {
previous->setType(kSoundType4);
@@ -183,7 +184,7 @@ void SoundEntry::setType(SoundFlag flag) {
}
break;
- case kFlagType7: {
+ case kSoundTypeLink: {
SoundEntry *previous = getSoundQueue()->getEntry(kSoundType7);
if (previous)
previous->setType(kSoundType8);
@@ -192,7 +193,7 @@ void SoundEntry::setType(SoundFlag flag) {
}
break;
- case kFlagType9: {
+ case kSoundTypeNIS: {
SoundEntry *previous = getSoundQueue()->getEntry(kSoundType9);
if (previous)
previous->setType(kSoundType10);
@@ -201,7 +202,7 @@ void SoundEntry::setType(SoundFlag flag) {
}
break;
- case kFlagType11: {
+ case kSoundTypeIntro: {
SoundEntry *previous = getSoundQueue()->getEntry(kSoundType11);
if (previous)
previous->setType(kSoundType14);
@@ -210,7 +211,7 @@ void SoundEntry::setType(SoundFlag flag) {
}
break;
- case kFlagType13: {
+ case kSoundTypeMenu: {
SoundEntry *previous = getSoundQueue()->getEntry(kSoundType13);
if (previous)
previous->setType(kSoundType14);
@@ -222,14 +223,12 @@ void SoundEntry::setType(SoundFlag flag) {
}
void SoundEntry::setupStatus(SoundFlag flag) {
- SoundStatus statusFlag = (SoundStatus)flag;
- if (!((statusFlag & 0xFF) & kSoundStatusFilter))
- statusFlag = (SoundStatus)(statusFlag | kSoundStatusCached);
-
- if (((statusFlag & 0xFF00) >> 8) & kSoundStatusClear0)
- _status.status = (uint32)statusFlag;
- else
- _status.status = (statusFlag | kSoundStatusClear4);
+ _status = flag;
+ if ((_status & kSoundVolumeMask) == kVolumeNone)
+ _status |= kSoundFlagMuteRequested;
+
+ if (!(_status & kSoundFlagLooped))
+ _status |= kSoundFlagCloseOnDataEnd;
}
void SoundEntry::loadStream(Common::String name) {
@@ -242,26 +241,27 @@ void SoundEntry::loadStream(Common::String name) {
_stream = getArchive("DEFAULT.SND");
if (!_stream)
- _status.status = kSoundStatusClosed;
+ _status = kSoundFlagCloseRequested;
}
void SoundEntry::update(uint val) {
- if (!(_status.b.status3 & 64)) {
- int value2 = val;
+ if (_status & kSoundFlagFading)
+ return;
- _status.status |= kSoundStatus_100000;
+ int value2 = val;
- if (val) {
- if (getSoundQueue()->getFlag() & 32) {
- _variant = val;
- value2 = val * 2 + 1;
- }
+ _status |= kSoundFlagVolumeChanging;
- _field_3C = value2;
- } else {
- _field_3C = 0;
- _status.status |= kSoundStatus_40000000;
+ if (val) {
+ if (getSoundQueue()->getFlag() & 32) {
+ _variant = val;
+ value2 = val * 2 + 1;
}
+
+ _field_3C = value2;
+ } else {
+ _field_3C = 0;
+ _status |= kSoundFlagFading;
}
}
@@ -271,13 +271,13 @@ bool SoundEntry::updateSound() {
bool result;
char sub[16];
- if (_status.b.status2 & 4) {
+ if (_status & kSoundFlagClosed) {
result = false;
} else {
- if (_status.b.status2 & 0x80) {
+ if (_status & kSoundFlagDelayedActivate) {
if (_field_48 <= getSound()->getData2()) {
- _status.status |= 0x20;
- _status.status &= ~0x8000;
+ _status |= kSoundFlagPlayRequested;
+ _status &= ~kSoundFlagDelayedActivate;
strcpy(sub, _name2.c_str());
// FIXME: Rewrite and document expected behavior
@@ -288,7 +288,7 @@ bool SoundEntry::updateSound() {
}
} else {
if (!(getSoundQueue()->getFlag() & 0x20)) {
- if (!(_status.b.status3 & 8)) {
+ if (!(_status & kSoundFlagFixedVolume)) {
if (_entity) {
if (_entity < 0x80) {
updateEntryFlag(getSound()->getSoundFlag(_entity));
@@ -296,7 +296,7 @@ bool SoundEntry::updateSound() {
}
}
}
- //if (status.b.status2 & 0x40 && !((uint32)_status.status & 0x180) && v1->soundBuffer)
+ //if (_status & kSoundFlagHasUnreadData && !(_status & kSoundFlagMute) && v1->soundBuffer)
// Sound_FillSoundBuffer(v1);
}
result = true;
@@ -310,31 +310,31 @@ void SoundEntry::updateEntryFlag(SoundFlag flag) {
if (getSoundQueue()->getFlag() & 0x20 && _type != kSoundType9 && _type != kSoundType7)
update(flag);
else
- _status.status = flag + (_status.status & ~0x1F);
+ _status = flag + (_status & ~kSoundVolumeMask);
} else {
_variant = 0;
- _status.status |= 0x80u;
- _status.status &= ~0x10001F;
+ _status |= kSoundFlagMuteRequested;
+ _status &= ~(kSoundFlagVolumeChanging | kSoundVolumeMask);
}
}
void SoundEntry::updateState() {
if (getSoundQueue()->getFlag() & 32) {
if (_type != kSoundType9 && _type != kSoundType7 && _type != kSoundType5) {
- uint32 variant = _status.status & kSoundStatusFilter;
+ uint32 variant = _status & kSoundVolumeMask;
- _status.status &= kSoundStatusClearAll;
+ _status &= ~kSoundVolumeMask;
_variant = variant;
- _status.status |= variant * 2 + 1;
+ _status |= variant * 2 + 1;
}
}
- _status.status |= kSoundStatus_20;
+ _status |= kSoundFlagPlayRequested;
}
void SoundEntry::reset() {
- _status.status |= kSoundStatusClosed;
+ _status |= kSoundFlagCloseRequested;
_entity = kEntityPlayer;
if (_stream) {
@@ -354,11 +354,11 @@ void SoundEntry::showSubtitle(Common::String filename) {
_subtitle = new SubtitleEntry(_engine);
_subtitle->load(filename, this);
- if (_subtitle->getStatus().b.status2 & 4) {
+ if (_subtitle->getStatus() & 0x400) {
_subtitle->draw();
SAFE_DELETE(_subtitle);
} else {
- _status.status |= kSoundStatus_20000;
+ _status |= kSoundFlagHasSubtitles;
}
}
@@ -366,8 +366,8 @@ void SoundEntry::saveLoadWithSerializer(Common::Serializer &s) {
assert(_name1.size() <= 16);
assert(_name2.size() <= 16);
- if (_name2.matchString("NISSND?") && ((_status.status & kFlagType9) != kFlagType13)) {
- s.syncAsUint32LE(_status.status);
+ if (_name2.matchString("NISSND?") && ((_status & kSoundTypeMask) != kSoundTypeMenu)) {
+ s.syncAsUint32LE(_status);
s.syncAsUint32LE(_type);
s.syncAsUint32LE(_blockCount); // field_8;
s.syncAsUint32LE(_time);
@@ -396,6 +396,7 @@ void SoundEntry::saveLoadWithSerializer(Common::Serializer &s) {
// SubtitleEntry
//////////////////////////////////////////////////////////////////////////
SubtitleEntry::SubtitleEntry(LastExpressEngine *engine) : _engine(engine) {
+ _status = 0;
_sound = NULL;
_data = NULL;
}
@@ -423,7 +424,7 @@ void SubtitleEntry::load(Common::String filename, SoundEntry *soundEntry) {
loadData();
} else {
- _status.status = kSoundStatus_400;
+ _status = kSoundFlagClosed;
}
}
@@ -445,7 +446,7 @@ void SubtitleEntry::setupAndDraw() {
}
if (_data->getMaxTime() > _sound->getTime()) {
- _status.status = kSoundStatus_400;
+ _status = kSoundFlagClosed;
} else {
_data->setTime((uint16)_sound->getTime());
diff --git a/engines/lastexpress/sound/entry.h b/engines/lastexpress/sound/entry.h
index 0ebe550a02..4769d83d47 100644
--- a/engines/lastexpress/sound/entry.h
+++ b/engines/lastexpress/sound/entry.h
@@ -76,21 +76,6 @@ namespace LastExpress {
class LastExpressEngine;
class SubtitleEntry;
-// TODO: this union assumes little-endian machine
-union SoundStatusUnion {
- uint32 status;
- struct {
- byte status1;
- byte status2;
- byte status3;
- byte status4;
- } b;
-
- SoundStatusUnion() {
- status = 0;
- }
-};
-
//////////////////////////////////////////////////////////////////////////
// SoundEntry
//////////////////////////////////////////////////////////////////////////
@@ -116,12 +101,12 @@ public:
void saveLoadWithSerializer(Common::Serializer &ser);
// Accessors
- void setStatus(int status) { _status.status = status; }
+ void setStatus(uint32 status) { _status = status; }
void setType(SoundType type) { _type = type; }
void setEntity(EntityIndex entity) { _entity = entity; }
void setField48(int val) { _field_48 = val; }
- SoundStatusUnion getStatus() { return _status; }
+ uint32 getStatus() { return _status; }
SoundType getType() { return _type; }
uint32 getTime() { return _time; }
EntityIndex getEntity() { return _entity; }
@@ -134,7 +119,10 @@ public:
private:
LastExpressEngine *_engine;
- SoundStatusUnion _status;
+ // _status field is a combination of bits from SoundFlag; writing
+ // _status = (SoundFlag)(_status | kSoundFlagXxx) instead of _status |= kSoundFlagXxx
+ // is irksome, so let's keep the type as uint32
+ uint32 _status;
SoundType _type; // int
//int _data;
//int _endOffset;
@@ -182,14 +170,14 @@ public:
void drawOnScreen();
// Accessors
- SoundStatusUnion getStatus() { return _status; }
+ uint32 getStatus() { return _status; }
SoundEntry *getSoundEntry() { return _sound; }
private:
LastExpressEngine *_engine;
Common::String _filename;
- SoundStatusUnion _status;
+ uint32 _status;
SoundEntry *_sound;
SubtitleManager *_data;
};
diff --git a/engines/lastexpress/sound/queue.cpp b/engines/lastexpress/sound/queue.cpp
index a088da319f..84b6e69c18 100644
--- a/engines/lastexpress/sound/queue.cpp
+++ b/engines/lastexpress/sound/queue.cpp
@@ -132,7 +132,7 @@ void SoundQueue::updateQueue() {
// and if the sound data buffer is not full, loads a new entry to be played based on
// its priority and filter id
- if (!entry->updateSound() && !(entry->getStatus().b.status3 & 0x8)) {
+ if (!entry->updateSound() && !(entry->getStatus() & kSoundFlagKeepAfterFinish)) {
entry->close();
SAFE_DELETE(entry);
it = _soundList.reverse_erase(it);
@@ -203,7 +203,7 @@ void SoundQueue::clearStatus() {
Common::StackLock locker(_mutex);
for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i)
- (*i)->setStatus((*i)->getStatus().status | kSoundStatusClosed);
+ (*i)->setStatus((*i)->getStatus() | kSoundFlagCloseRequested);
}
//////////////////////////////////////////////////////////////////////////
@@ -321,16 +321,16 @@ void SoundQueue::updateSubtitles() {
for (Common::List<SubtitleEntry *>::iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) {
uint32 current_index = 0;
SoundEntry *soundEntry = (*i)->getSoundEntry();
- SoundStatus status = (SoundStatus)soundEntry->getStatus().status;
+ SoundFlag status = (SoundFlag)soundEntry->getStatus();
- if (!(status & kSoundStatus_40)
- || status & kSoundStatus_180
+ if (!(status & kSoundFlagPlaying)
+ || status & kSoundFlagMute
|| soundEntry->getTime() == 0
- || (status & kSoundStatusFilter) < 6
+ || (status & kSoundVolumeMask) < kVolume6
|| ((getFlags()->nis & 0x8000) && soundEntry->getPriority() < 90)) {
current_index = 0;
} else {
- current_index = soundEntry->getPriority() + (status & kSoundStatusFilter);
+ current_index = soundEntry->getPriority() + (status & kSoundVolumeMask);
if (_currentSubtitle == (*i))
current_index += 4;
diff --git a/engines/lastexpress/sound/sound.cpp b/engines/lastexpress/sound/sound.cpp
index ca79915c66..a226250956 100644
--- a/engines/lastexpress/sound/sound.cpp
+++ b/engines/lastexpress/sound/sound.cpp
@@ -96,20 +96,20 @@ static const char *const locomotiveSounds[5] = {
};
static const SoundFlag soundFlags[32] = {
- kFlagDefault,
- kFlag15,
- kFlag14,
- kFlag13,
- kFlag12,
- kFlag11, kFlag11,
- kFlag10, kFlag10,
- kFlag9, kFlag9,
- kFlag8, kFlag8,
- kFlag7, kFlag7, kFlag7,
- kFlag6, kFlag6, kFlag6,
- kFlag5, kFlag5, kFlag5, kFlag5,
- kFlag4, kFlag4, kFlag4, kFlag4,
- kFlag3, kFlag3, kFlag3, kFlag3, kFlag3
+ kVolumeFull,
+ kVolume15,
+ kVolume14,
+ kVolume13,
+ kVolume12,
+ kVolume11, kVolume11,
+ kVolume10, kVolume10,
+ kVolume9, kVolume9,
+ kVolume8, kVolume8,
+ kVolume7, kVolume7, kVolume7,
+ kVolume6, kVolume6, kVolume6,
+ kVolume5, kVolume5, kVolume5, kVolume5,
+ kVolume4, kVolume4, kVolume4, kVolume4,
+ kVolume3, kVolume3, kVolume3, kVolume3, kVolume3
};
SoundManager::SoundManager(LastExpressEngine *engine) : _engine(engine) {
@@ -150,15 +150,15 @@ void SoundManager::playSound(EntityIndex entity, Common::String filename, SoundF
getSavePoints()->push(kEntityPlayer, entity, kActionEndSound);
}
-bool SoundManager::playSoundWithSubtitles(Common::String filename, SoundFlag flag, EntityIndex entity, byte a4) {
+bool SoundManager::playSoundWithSubtitles(Common::String filename, uint32 flag, EntityIndex entity, byte a4) {
SoundEntry *entry = new SoundEntry(_engine);
- entry->open(filename, flag, 30);
+ entry->open(filename, (SoundFlag)flag, 30);
entry->setEntity(entity);
if (a4) {
entry->setField48(_data2 + 2 * a4);
- entry->setStatus(entry->getStatus().status | kSoundStatus_8000);
+ entry->setStatus(entry->getStatus() | kSoundFlagDelayedActivate);
} else {
// Get subtitles name
uint32 size = filename.size();
@@ -308,7 +308,7 @@ void SoundManager::playSteam(CityIndex index) {
_queue->resetState(kSoundState2);
if (!_queue->getEntry(kSoundType1))
- playSoundWithSubtitles("STEAM.SND", kFlagSteam, kEntitySteam);
+ playSoundWithSubtitles("STEAM.SND", kSoundTypeAmbient | kSoundFlagLooped | kVolume7, kEntitySteam);
// Get the new sound entry and show subtitles
SoundEntry *entry = _queue->getEntry(kSoundType1);
@@ -357,7 +357,7 @@ void SoundManager::playFightSound(byte action, byte a4) {
}
if (_action)
- playSound(kEntityTrain, Common::String::format("LIB%03d.SND", _action), kFlagDefault, a4);
+ playSound(kEntityTrain, Common::String::format("LIB%03d.SND", _action), kVolumeFull, a4);
}
void SoundManager::playDialog(EntityIndex entity, EntityIndex entityDialog, SoundFlag flag, byte a4) {
@@ -691,7 +691,7 @@ void SoundManager::readText(int id) {
if (_queue->isBuffered(text))
_queue->removeFromQueue(text);
- playSound(kEntityTables4, text, kFlagDefault);
+ playSound(kEntityTables4, text, kVolumeFull);
}
//////////////////////////////////////////////////////////////////////////
@@ -702,14 +702,14 @@ void SoundManager::playWarningCompartment(EntityIndex entity, ObjectIndex compar
#define PLAY_WARNING(index, sound1, sound2, sound3, sound4, sound5, sound6) { \
if (_lastWarning[index] + 450 >= getState()->timeTicks) { \
if (rnd(2)) \
- playSound(kEntityMertens, sound1, kFlagDefault); \
+ playSound(kEntityMertens, sound1, kVolumeFull); \
else \
- playSound(kEntityMertens, rnd(2) ? sound2 : sound3, kFlagDefault); \
+ playSound(kEntityMertens, rnd(2) ? sound2 : sound3, kVolumeFull); \
} else { \
if (rnd(2)) \
- playSound(kEntityMertens, sound4, kFlagDefault); \
+ playSound(kEntityMertens, sound4, kVolumeFull); \
else \
- playSound(kEntityMertens, rnd(2) ? sound5 : sound6, kFlagDefault); \
+ playSound(kEntityMertens, rnd(2) ? sound5 : sound6, kVolumeFull); \
} \
_lastWarning[index] = getState()->timeTicks; \
}
@@ -748,15 +748,15 @@ void SoundManager::playWarningCompartment(EntityIndex entity, ObjectIndex compar
break;
case 1:
- getSound()->playSound(kEntityMertens, "Con1503C", kFlagDefault);
+ getSound()->playSound(kEntityMertens, "Con1503C", kVolumeFull);
break;
case 2:
- getSound()->playSound(kEntityMertens, rnd(2) ? "Con1503E" : "Con1503A", kFlagDefault);
+ getSound()->playSound(kEntityMertens, rnd(2) ? "Con1503E" : "Con1503A", kVolumeFull);
break;
case 3:
- getSound()->playSound(kEntityMertens, rnd(2) ? "Con1503B" : "Con1503D", kFlagDefault);
+ getSound()->playSound(kEntityMertens, rnd(2) ? "Con1503B" : "Con1503D", kVolumeFull);
_lastWarning[3] = 0;
break;
}
@@ -773,83 +773,83 @@ void SoundManager::playWarningCompartment(EntityIndex entity, ObjectIndex compar
case kObjectCompartmentA:
if (_lastWarning[4] + 450 >= getState()->timeTicks) {
- getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kVolumeFull);
break;
}
- getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1508" : "Jac1508A", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1508" : "Jac1508A", kVolumeFull);
break;
case kObjectCompartmentB:
if (_lastWarning[5] + 450 >= getState()->timeTicks) {
- getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kVolumeFull);
break;
}
if (getProgress().field_40 || (getState()->time > kTimeCityLinz && getState()->time < kTime2133000))
- getSound()->playSound(kEntityCoudert, "Jac1507A", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, "Jac1507A", kVolumeFull);
else
- getSound()->playSound(kEntityCoudert, "Jac1507", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, "Jac1507", kVolumeFull);
break;
case kObjectCompartmentC:
if (_lastWarning[6] + 450 >= getState()->timeTicks) {
- getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kVolumeFull);
break;
}
if (getProgress().chapter < kChapter3)
- getSound()->playSound(kEntityCoudert, "Jac1506", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, "Jac1506", kVolumeFull);
else
- getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1506A" : "Jac1506B", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1506A" : "Jac1506B", kVolumeFull);
break;
case kObjectCompartmentD:
if (_lastWarning[7] + 450 >= getState()->timeTicks) {
- getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kVolumeFull);
break;
}
- getSound()->playSound(kEntityCoudert, "Jac1505", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, "Jac1505", kVolumeFull);
break;
case kObjectCompartmentE:
if (_lastWarning[8] + 450 >= getState()->timeTicks) {
- getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kVolumeFull);
break;
}
if (getProgress().field_40 || (getState()->time > kTime2115000 && getState()->time < kTime2133000)) {
- getSound()->playSound(kEntityCoudert, "Jac1504B", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, "Jac1504B", kVolumeFull);
break;
}
if (getEntities()->isInsideCompartment(kEntityRebecca, kCarRedSleeping, kPosition_4840))
- getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kVolumeFull);
else
- getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1504" : "Jac1504A", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1504" : "Jac1504A", kVolumeFull);
break;
case kObjectCompartmentF:
if (_lastWarning[9] + 450 >= getState()->timeTicks) {
- getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kVolumeFull);
break;
}
if (getProgress().field_40 || (getState()->time > kTime2083500 && getState()->time < kTime2133000)) {
- getSound()->playSound(kEntityCoudert, "Jac1503B", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, "Jac1503B", kVolumeFull);
break;
}
if (rnd(2) || getEntities()->isInsideCompartment(kEntityAnna, kCarRedSleeping, kPosition_4070))
- getSound()->playSound(kEntityCoudert, "Jac1503A", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, "Jac1503A", kVolumeFull);
else
- getSound()->playSound(kEntityCoudert, "Jac1503", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, "Jac1503", kVolumeFull);
break;
case kObjectCompartmentG:
if (_lastWarning[10] + 450 >= getState()->timeTicks) {
- getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kVolumeFull);
break;
}
@@ -858,21 +858,21 @@ void SoundManager::playWarningCompartment(EntityIndex entity, ObjectIndex compar
// Jac1502 is a generic response,
// so Coudert only says "Milos is not in" when Milos is actually in.
if (rnd(2) || getEntities()->isInsideCompartment(kEntityMilos, kCarRedSleeping, kPosition_3050))
- getSound()->playSound(kEntityCoudert, "Jac1502", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, "Jac1502", kVolumeFull);
else
- getSound()->playSound(kEntityCoudert, "Jac1502A", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, "Jac1502A", kVolumeFull);
break;
case kObjectCompartmentH:
if (_lastWarning[11] + 450 >= getState()->timeTicks) {
- getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kVolumeFull);
break;
}
if (getEntities()->isInsideCompartment(kEntityIvo, kCarRedSleeping, kPosition_2740))
- getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, rnd(2) ? "Jac1500" : "Jac1500A", kVolumeFull);
else
- getSound()->playSound(kEntityCoudert, "Jac1501", kFlagDefault);
+ getSound()->playSound(kEntityCoudert, "Jac1501", kVolumeFull);
break;
}
@@ -890,7 +890,7 @@ void SoundManager::excuseMe(EntityIndex entity, EntityIndex entity2, SoundFlag f
if (entity == kEntityFrancois && getEntityData(kEntityFrancois)->field_4A3 != 30)
return;
- if (flag == kFlagNone)
+ if (flag == kVolumeNone)
flag = getSoundFlag(entity);
switch (entity) {
@@ -1232,13 +1232,13 @@ const char *SoundManager::justAMinuteCath() const {
//////////////////////////////////////////////////////////////////////////
SoundFlag SoundManager::getSoundFlag(EntityIndex entity) const {
if (entity == kEntityPlayer)
- return kFlagDefault;
+ return kVolumeFull;
if (getEntityData(entity)->car != getEntityData(kEntityPlayer)->car)
- return kFlagNone;
+ return kVolumeNone;
// Compute sound value
- SoundFlag ret = kFlag2;
+ SoundFlag ret = kVolume2;
// Get default value if valid
int index = ABS(getEntityData(entity)->entityPosition - getEntityData(kEntityPlayer)->entityPosition) / 230;
@@ -1249,7 +1249,7 @@ SoundFlag SoundManager::getSoundFlag(EntityIndex entity) const {
if (getEntityData(kEntityPlayer)->car != kCarKronos
&& !getEntities()->isOutsideAlexeiWindow()
&& !getEntities()->isOutsideAnnaWindow())
- return kFlagNone;
+ return kVolumeNone;
return (SoundFlag)(ret / 6);
}
@@ -1371,7 +1371,7 @@ void SoundManager::playLoopingSound(int param) {
_loopingSoundDuration = _engine->getRandom().getRandomNumber(319) + 260;
if (partNumber != 99) {
- playSoundWithSubtitles(tmp, kFlagLoopedSound, kEntitySteam);
+ playSoundWithSubtitles(tmp, kSoundTypeAmbient | kSoundFlagLooped | kVolume1, kEntitySteam);
if (entry)
entry->update(0);
diff --git a/engines/lastexpress/sound/sound.h b/engines/lastexpress/sound/sound.h
index 81f1529286..f8e826a333 100644
--- a/engines/lastexpress/sound/sound.h
+++ b/engines/lastexpress/sound/sound.h
@@ -38,8 +38,8 @@ public:
~SoundManager();
// Sound playing
- void playSound(EntityIndex entity, Common::String filename, SoundFlag flag = kFlagInvalid, byte a4 = 0);
- bool playSoundWithSubtitles(Common::String filename, SoundFlag flag, EntityIndex entity, byte a4 = 0);
+ void playSound(EntityIndex entity, Common::String filename, SoundFlag flag = kSoundVolumeEntityDefault, byte a4 = 0);
+ bool playSoundWithSubtitles(Common::String filename, uint32 flag, EntityIndex entity, byte a4 = 0);
void playSoundEvent(EntityIndex entity, byte action, byte a3 = 0);
void playDialog(EntityIndex entity, EntityIndex entityDialog, SoundFlag flag, byte a4);
void playSteam(CityIndex index);
@@ -53,7 +53,7 @@ public:
const char *getDialogName(EntityIndex entity) const;
// Sound bites
- void excuseMe(EntityIndex entity, EntityIndex entity2 = kEntityPlayer, SoundFlag flag = kFlagNone);
+ void excuseMe(EntityIndex entity, EntityIndex entity2 = kEntityPlayer, SoundFlag flag = kVolumeNone);
void excuseMeCath();
const char *justCheckingCath() const;
const char *wrongDoorCath() const;