aboutsummaryrefslogtreecommitdiff
path: root/engines/lastexpress/sound
diff options
context:
space:
mode:
Diffstat (limited to 'engines/lastexpress/sound')
-rw-r--r--engines/lastexpress/sound/entry.cpp99
-rw-r--r--engines/lastexpress/sound/entry.h87
-rw-r--r--engines/lastexpress/sound/queue.cpp74
-rw-r--r--engines/lastexpress/sound/queue.h38
-rw-r--r--engines/lastexpress/sound/sound.cpp32
-rw-r--r--engines/lastexpress/sound/sound.h6
6 files changed, 166 insertions, 170 deletions
diff --git a/engines/lastexpress/sound/entry.cpp b/engines/lastexpress/sound/entry.cpp
index 0eb6077d78..8d9a496fe1 100644
--- a/engines/lastexpress/sound/entry.cpp
+++ b/engines/lastexpress/sound/entry.cpp
@@ -43,16 +43,12 @@ namespace LastExpress {
//////////////////////////////////////////////////////////////////////////
SoundEntry::SoundEntry(LastExpressEngine *engine) : _engine(engine) {
_status = 0;
- _type = kSoundTypeNone;
-
- _currentDataPtr = NULL;
+ _tag = kSoundTagNone;
_blockCount = 0;
_stream = NULL;
- _field_34 = 0;
- _field_38 = 0;
_volumeWithoutNIS = 0;
_entity = kEntityPlayer;
_initTimeMS = 0;
@@ -71,8 +67,6 @@ SoundEntry::~SoundEntry() {
SAFE_DELETE(_soundStream);
- free(_currentDataPtr);
-
_subtitle = NULL;
_stream = NULL;
@@ -82,7 +76,7 @@ SoundEntry::~SoundEntry() {
void SoundEntry::open(Common::String name, SoundFlag flag, int priority) {
_priority = priority;
- setType(flag);
+ setupTag(flag);
setupStatus(flag);
loadStream(name);
}
@@ -100,13 +94,13 @@ void SoundEntry::close() {
// removeFromCache(entry);
if (_subtitle) {
- _subtitle->draw();
+ _subtitle->close();
SAFE_DELETE(_subtitle);
}
if (_entity) {
if (_entity == kEntitySteam)
- getSound()->playLoopingSound(2);
+ getSound()->playAmbientSound(2);
else if (_entity != kEntityTrain)
getSavePoints()->push(kEntityPlayer, _entity, kActionEndSound);
}
@@ -137,73 +131,72 @@ bool SoundEntry::isFinished() {
return _soundStream->isFinished();
}
-void SoundEntry::setType(SoundFlag flag) {
+void SoundEntry::setupTag(SoundFlag flag) {
switch (flag & kSoundTypeMask) {
default:
case kSoundTypeNormal:
- _type = getSoundQueue()->getCurrentType();
- getSoundQueue()->setCurrentType((SoundType)(_type + 1));
+ _tag = getSoundQueue()->generateNextTag();
break;
case kSoundTypeAmbient: {
- SoundEntry *previous2 = getSoundQueue()->getEntry(kSoundType2);
+ SoundEntry *previous2 = getSoundQueue()->getEntry(kSoundTagOldAmbient);
if (previous2)
previous2->fade();
- SoundEntry *previous = getSoundQueue()->getEntry(kSoundType1);
+ SoundEntry *previous = getSoundQueue()->getEntry(kSoundTagAmbient);
if (previous) {
- previous->setType(kSoundType2);
+ previous->_tag = kSoundTagOldAmbient;
previous->fade();
}
- _type = kSoundType1;
+ _tag = kSoundTagAmbient;
}
break;
case kSoundTypeWalla: {
- SoundEntry *previous = getSoundQueue()->getEntry(kSoundType3);
+ SoundEntry *previous = getSoundQueue()->getEntry(kSoundTagWalla);
if (previous) {
- previous->setType(kSoundType4);
+ previous->_tag = kSoundTagOldWalla;
previous->fade();
}
- _type = kSoundType11;
+ _tag = kSoundTagIntro;
}
break;
case kSoundTypeLink: {
- SoundEntry *previous = getSoundQueue()->getEntry(kSoundType7);
+ SoundEntry *previous = getSoundQueue()->getEntry(kSoundTagLink);
if (previous)
- previous->setType(kSoundType8);
+ previous->_tag = kSoundTagOldLink;
- _type = kSoundType7;
+ _tag = kSoundTagLink;
}
break;
case kSoundTypeNIS: {
- SoundEntry *previous = getSoundQueue()->getEntry(kSoundType9);
+ SoundEntry *previous = getSoundQueue()->getEntry(kSoundTagNIS);
if (previous)
- previous->setType(kSoundType10);
+ previous->_tag = kSoundTagOldNIS;
- _type = kSoundType9;
+ _tag = kSoundTagNIS;
}
break;
case kSoundTypeIntro: {
- SoundEntry *previous = getSoundQueue()->getEntry(kSoundType11);
+ SoundEntry *previous = getSoundQueue()->getEntry(kSoundTagIntro);
if (previous)
- previous->setType(kSoundType14);
+ previous->_tag = kSoundTagOldMenu;
- _type = kSoundType11;
+ _tag = kSoundTagIntro;
}
break;
case kSoundTypeMenu: {
- SoundEntry *previous = getSoundQueue()->getEntry(kSoundType13);
+ SoundEntry *previous = getSoundQueue()->getEntry(kSoundTagMenu);
if (previous)
- previous->setType(kSoundType14);
+ previous->_tag = kSoundTagOldMenu;
- _type = kSoundType13;
+ _tag = kSoundTagMenu;
}
break;
}
@@ -219,7 +212,7 @@ void SoundEntry::setupStatus(SoundFlag flag) {
}
void SoundEntry::loadStream(Common::String name) {
- _name2 = name;
+ _name = name;
// Load sound data
_stream = getArchive(name);
@@ -252,8 +245,8 @@ void SoundEntry::setVolumeSmoothly(SoundFlag newVolume) {
_soundStream->setVolumeSmoothly(requestedVolume);
}
-bool SoundEntry::updateSound() {
- assert(_name2.size() < 16);
+bool SoundEntry::update() {
+ assert(_name.size() < 16);
bool result;
char sub[16];
@@ -268,8 +261,8 @@ bool SoundEntry::updateSound() {
play();
// drop .SND extension
- strcpy(sub, _name2.c_str());
- int l = _name2.size();
+ strcpy(sub, _name.c_str());
+ int l = _name.size();
if (l > 4)
sub[l - 4] = 0;
showSubtitle(sub);
@@ -297,7 +290,7 @@ void SoundEntry::setVolume(SoundFlag newVolume) {
assert((newVolume & kSoundVolumeMask) == newVolume);
if (newVolume) {
- if (getSoundQueue()->getFlag() & 0x20 && _type != kSoundType9 && _type != kSoundType7)
+ if (getSoundQueue()->getFlag() & 0x20 && _tag != kSoundTagNIS && _tag != kSoundTagLink)
setVolumeSmoothly(newVolume);
else
_status = newVolume + (_status & ~kSoundVolumeMask);
@@ -312,7 +305,7 @@ void SoundEntry::setVolume(SoundFlag newVolume) {
void SoundEntry::adjustVolumeIfNISPlaying() {
if (getSoundQueue()->getFlag() & 32) {
- if (_type != kSoundType9 && _type != kSoundType7 && _type != kSoundType5) {
+ if (_tag != kSoundTagNIS && _tag != kSoundTagLink && _tag != kSoundTagConcert) {
uint32 baseVolume = _status & kSoundVolumeMask;
uint32 actualVolume = baseVolume / 2 + 1;
@@ -331,7 +324,7 @@ void SoundEntry::initDelayedActivate(unsigned activateDelay) {
_status |= kSoundFlagDelayedActivate;
}
-void SoundEntry::reset() {
+void SoundEntry::kill() {
_status |= kSoundFlagClosed;
_entity = kEntityPlayer;
@@ -353,7 +346,7 @@ void SoundEntry::showSubtitle(Common::String filename) {
_subtitle->load(filename, this);
if (_subtitle->getStatus() & 0x400) {
- _subtitle->draw();
+ _subtitle->close();
SAFE_DELETE(_subtitle);
} else {
_status |= kSoundFlagHasSubtitles;
@@ -361,17 +354,17 @@ void SoundEntry::showSubtitle(Common::String filename) {
}
void SoundEntry::saveLoadWithSerializer(Common::Serializer &s) {
- assert(_name1.size() <= 16);
- assert(_name2.size() <= 16);
+ assert(_name.size() <= 16);
- if (_name2.matchString("NISSND?") && ((_status & kSoundTypeMask) != kSoundTypeMenu)) {
+ if (_name.matchString("NISSND?") && ((_status & kSoundTypeMask) != kSoundTypeMenu)) {
s.syncAsUint32LE(_status);
- s.syncAsUint32LE(_type);
+ s.syncAsUint32LE(_tag);
s.syncAsUint32LE(_blockCount); // field_8;
uint32 time = getTime();
s.syncAsUint32LE(time);
- s.syncAsUint32LE(_field_34); // field_10;
- s.syncAsUint32LE(_field_38); // field_14;
+ uint32 unused = 0;
+ s.syncAsUint32LE(unused);
+ s.syncAsUint32LE(unused);
s.syncAsUint32LE(_entity);
if (s.isLoading()) {
@@ -389,13 +382,11 @@ void SoundEntry::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsUint32LE(_priority);
- char name1[16];
- strcpy((char *)&name1, _name1.c_str());
- s.syncBytes((byte *)&name1, 16);
+ char name[16] = {0};
+ s.syncBytes((byte *)name, 16);
- char name2[16];
- strcpy((char *)&name2, _name2.c_str());
- s.syncBytes((byte *)&name2, 16);
+ strcpy((char *)name, _name.c_str());
+ s.syncBytes((byte *)name, 16);
}
}
@@ -466,7 +457,7 @@ void SubtitleEntry::setupAndDraw() {
// TODO Missing code
}
-void SubtitleEntry::draw() {
+void SubtitleEntry::close() {
// Remove ourselves from the queue
getSoundQueue()->removeSubtitle(this);
diff --git a/engines/lastexpress/sound/entry.h b/engines/lastexpress/sound/entry.h
index 48e802ed9a..cb12214d4a 100644
--- a/engines/lastexpress/sound/entry.h
+++ b/engines/lastexpress/sound/entry.h
@@ -26,32 +26,38 @@
/*
Sound entry: 68 bytes (this is what appears in savegames)
uint32 {4} - status
- uint32 {4} - type
- uint32 {4} - blockCount
- uint32 {4} - time
+ uint32 {4} - tag
+ uint32 {4} - time left (_blockCount - _time)
+ uint32 {4} - time in sound ticks (30Hz timer)
uint32 {4} - LastExpress_ADPCMStream::_volumeHoldBlocks
(useless since the target volume is not saved)
- uint32 {4} - ?? [copy of a field below with no references]
+ uint32 {4} - ?? [no references except for save/load]
uint32 {4} - entity
uint32 {4} - activate delay in sound ticks (30Hz timer)
uint32 {4} - priority
- char {16} - name 1
- char {16} - name 2
+ char {16} - name of linked-after sound
+ (always empty because only NIS entries
+ have linked-after sounds, and NIS entries are not saved)
+ char {16} - name
Sound queue entry: 120 bytes
- uint16 {2} - status
- byte {1} - type
- byte {1} - ??
- uint32 {4} - ??
- uint32 {4} - currentDataPtr
- uint32 {4} - soundData
- uint32 {4} - currentBufferPtr
- uint32 {4} - blockCount
- uint32 {4} - time
- uint32 {4} - size
- uint32 {4} - ??
+ uint32 {4} - status (combination of flags from SoundFlag)
+ uint32 {4} - tag (enum SoundTag for special sounds,
+ unique value for normal ones)
+ uint32 {4} - pointer to the beginning of the buffer for compressed sound data
+ uint32 {4} - pointer to the end of the buffer for compressed sound data
+ uint32 {4} - decoder pointer inside the buffer
+ uint32 {4} - pointer to the sound buffer [always same as the third field]
+ uint32 {4} - reader pointer inside the buffer
+ uint32 {4} - time left (_blockCount - time)
+ uint32 {4} - time in sound ticks (30Hz timer)
+ uint32 {4} - buffer size
+ uint32 {4} - union:
+ if data stream is open: position in the stream
+ if data stream is closed: close reason, purely informational
uint32 {4} - archive structure pointer
- uint32 {4} - ??
+ uint32 {4} - _linkAfter, pointer to the entry for linked-after sound
+ (xxx.LNK for sound entry corresponding to xxx.NIS)
uint32 {4} - LastExpress_ADPCMStream::_volumeHoldBlocks
(used for smooth change of volume)
uint32 {4} - ?? [no references except for save/load]
@@ -62,8 +68,8 @@
uint32 {4} - entity
uint32 {4} - activate time in sound ticks (30Hz timer)
uint32 {4} - priority
- char {16} - name 1
- char {16} - name 2
+ char {16} - name of linked-after sound, used to save/load _linkAfter
+ char {16} - name
uint32 {4} - pointer to next entry in the queue
uint32 {4} - subtitle data pointer
*/
@@ -91,13 +97,13 @@ public:
void open(Common::String name, SoundFlag flag, int priority);
void close();
void play();
- void reset();
+ void kill();
bool isFinished();
void setVolumeSmoothly(SoundFlag newVolume);
// setVolumeSmoothly() treats kVolumeNone in a special way;
// fade() terminates the stream after the transition
void fade() { setVolumeSmoothly(kVolumeNone); }
- bool updateSound();
+ bool update();
void adjustVolumeIfNISPlaying();
void setVolume(SoundFlag newVolume);
// activateDelay is measured in main ticks, 15Hz timer
@@ -111,15 +117,14 @@ public:
// Accessors
void addStatusFlag(SoundFlag flag) { _status |= flag; }
- void setType(SoundType type) { _type = type; }
void setEntity(EntityIndex entity) { _entity = entity; }
uint32 getStatus() { return _status; }
- SoundType getType() { return _type; }
+ int32 getTag() { return _tag; }
uint32 getTime() { return _soundStream ? (_soundStream->getTimeMS() * 30 / 1000) : 0; }
EntityIndex getEntity() { return _entity; }
uint32 getPriority() { return _priority; }
- Common::String getName2() { return _name2; }
+ const Common::String& getName(){ return _name; }
// Streams
SimpleSound *getSoundStream() { return _soundStream; }
@@ -131,19 +136,19 @@ private:
// _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;
- byte * _currentDataPtr;
- //int _currentBufferPtr;
- int _blockCount;
- //int _size;
- //int _field_28;
+ int32 _tag; // member of SoundTag for special sounds, unique value for normal sounds
+ //byte *_bufferStart, *_bufferEnd, *_decodePointer, *_buffer, *_readPointer;
+ // the original game uses uint32 _blocksLeft, _time instead of _totalBlocks
+ // we ask the backend for sound time
+ uint32 _blockCount;
+ //uint32 _bufferSize;
+ //union { uint32 _streamPos; enum StreamCloseReason _streamCloseReason; };
Common::SeekableReadStream *_stream; // The file stream
- //int _archive;
- int _field_34;
- int _field_38;
- int _volumeWithoutNIS;
+ //SoundEntry* _linkAfter;
+ //uint32 _volumeHoldBlocks; // the related logic is in LastExpress_ADPCMStream
+ //uint32 _unused;
+ //uint32 _smoothChangeTarget; // the related logic is in LastExpress_ADPCMStream
+ uint32 _volumeWithoutNIS;
EntityIndex _entity;
// The original game uses one variable _activateTime = _initTime + _activateDelay
// and measures everything in sound ticks (30Hz timer).
@@ -151,15 +156,15 @@ private:
// (probably paranoid, but nothing really complicated).
uint32 _initTimeMS, _activateDelayMS;
uint32 _priority;
- Common::String _name1; //char[16];
- Common::String _name2; //char[16];
+ // char _linkAfterName[16];
+ Common::String _name; //char[16];
// original has pointer to the next structure in the list (not used)
SubtitleEntry *_subtitle;
// Sound buffer & stream
StreamedSound *_soundStream; // the filtered sound stream
- void setType(SoundFlag flag);
+ void setupTag(SoundFlag flag);
void setupStatus(SoundFlag flag);
void loadStream(Common::String name);
};
@@ -174,7 +179,7 @@ public:
void load(Common::String filename, SoundEntry *soundEntry);
void loadData();
- void draw();
+ void close();
void setupAndDraw();
void drawOnScreen();
diff --git a/engines/lastexpress/sound/queue.cpp b/engines/lastexpress/sound/queue.cpp
index 8eef091f51..e162174ab2 100644
--- a/engines/lastexpress/sound/queue.cpp
+++ b/engines/lastexpress/sound/queue.cpp
@@ -34,8 +34,8 @@
namespace LastExpress {
SoundQueue::SoundQueue(LastExpressEngine *engine) : _engine(engine) {
- _state = 0;
- _currentType = kSoundType16;
+ _ambientState = 0;
+ _currentTag = kSoundTagFirstNormal;
_flag = 0;
_subtitlesFlag = 0;
@@ -66,25 +66,25 @@ void SoundQueue::addToQueue(SoundEntry *entry) {
_soundList.push_back(entry);
}
-void SoundQueue::removeFromQueue(EntityIndex entity) {
+void SoundQueue::stop(EntityIndex entity) {
SoundEntry *entry = getEntry(entity);
if (entry)
- entry->reset();
+ entry->kill();
}
-void SoundQueue::removeFromQueue(Common::String filename) {
+void SoundQueue::stop(Common::String filename) {
SoundEntry *entry = getEntry(filename);
if (entry)
- entry->reset();
+ entry->kill();
}
void SoundQueue::updateQueue() {
++_flag;
- if (getSoundState() & kSoundState1) {
- SoundEntry *entry = getEntry(kSoundType1);
- if (!entry || getFlags()->flag_3 || (entry && entry->getTime() > getSound()->getLoopingSoundDuration())) {
- getSound()->playLoopingSound(0x45);
+ if (getAmbientState() & kAmbientSoundEnabled) {
+ SoundEntry *entry = getEntry(kSoundTagAmbient);
+ 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());
@@ -102,7 +102,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() & kSoundFlagKeepAfterFinish)) {
+ if (!entry->update() && !(entry->getStatus() & kSoundFlagKeepAfterFinish)) {
entry->close();
SAFE_DELETE(entry);
it = _soundList.reverse_erase(it);
@@ -125,39 +125,39 @@ void SoundQueue::updateQueue() {
--_flag;
}
-void SoundQueue::resetQueue() {
+void SoundQueue::stopAmbient() {
for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i) {
- if ((*i)->getType() == kSoundType1) {
- (*i)->reset();
+ if ((*i)->getTag() == kSoundTagAmbient) {
+ (*i)->kill();
break;
}
}
for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i) {
- if ((*i)->getType() == kSoundType2) {
- (*i)->reset();
+ if ((*i)->getTag() == kSoundTagOldAmbient) {
+ (*i)->kill();
break;
}
}
}
-void SoundQueue::resetQueue(SoundType type1, SoundType type2) {
+void SoundQueue::stopAllExcept(SoundTag type1, SoundTag type2) {
if (!type2)
type2 = type1;
for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i) {
- if ((*i)->getType() != type1 && (*i)->getType() != type2)
- (*i)->reset();
+ if ((*i)->getTag() != type1 && (*i)->getTag() != type2)
+ (*i)->kill();
}
}
-void SoundQueue::clearQueue() {
+void SoundQueue::destroyAllSound() {
_flag |= 8;
for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i) {
SoundEntry *entry = (*i);
if (entry == NULL)
- error("[SoundQueue::clearQueue] Invalid entry found in sound queue");
+ error("[SoundQueue::destroyAllSound] Invalid entry found in sound queue");
// Delete entry
entry->close();
@@ -172,7 +172,7 @@ void SoundQueue::clearQueue() {
//////////////////////////////////////////////////////////////////////////
// State
//////////////////////////////////////////////////////////////////////////
-void SoundQueue::clearStatus() {
+void SoundQueue::stopAll() {
for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i)
(*i)->addStatusFlag(kSoundFlagClosed);
}
@@ -180,13 +180,13 @@ void SoundQueue::clearStatus() {
//////////////////////////////////////////////////////////////////////////
// Entry management
//////////////////////////////////////////////////////////////////////////
-void SoundQueue::setupEntry(SoundType type, EntityIndex index) {
- SoundEntry *entry = getEntry(type);
+void SoundQueue::assignNISLink(EntityIndex index) {
+ SoundEntry *entry = getEntry(kSoundTagLink);
if (entry)
entry->setEntity(index);
}
-void SoundQueue::processEntry(EntityIndex entity) {
+void SoundQueue::fade(EntityIndex entity) {
SoundEntry *entry = getEntry(entity);
if (entry) {
entry->fade();
@@ -194,13 +194,13 @@ void SoundQueue::processEntry(EntityIndex entity) {
}
}
-void SoundQueue::processEntry(SoundType type) {
+void SoundQueue::fade(SoundTag type) {
SoundEntry *entry = getEntry(type);
if (entry)
entry->fade();
}
-void SoundQueue::processEntry(Common::String filename) {
+void SoundQueue::fade(Common::String filename) {
SoundEntry *entry = getEntry(filename);
if (entry) {
entry->fade();
@@ -208,11 +208,11 @@ void SoundQueue::processEntry(Common::String filename) {
}
}
-void SoundQueue::processEntries() {
- _state = 0;
+void SoundQueue::endAmbient() {
+ _ambientState = 0;
- processEntry(kSoundType1);
- processEntry(kSoundType2);
+ fade(kSoundTagAmbient);
+ fade(kSoundTagOldAmbient);
}
SoundEntry *SoundQueue::getEntry(EntityIndex index) {
@@ -229,16 +229,16 @@ SoundEntry *SoundQueue::getEntry(Common::String name) {
name += ".SND";
for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i) {
- if ((*i)->getName2() == name)
+ if ((*i)->getName() == name)
return *i;
}
return NULL;
}
-SoundEntry *SoundQueue::getEntry(SoundType type) {
+SoundEntry *SoundQueue::getEntry(SoundTag type) {
for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i) {
- if ((*i)->getType() == type)
+ if ((*i)->getTag() == type)
return *i;
}
@@ -318,8 +318,8 @@ void SoundQueue::updateSubtitles() {
// Savegame
//////////////////////////////////////////////////////////////////////////
void SoundQueue::saveLoadWithSerializer(Common::Serializer &s) {
- s.syncAsUint32LE(_state);
- s.syncAsUint32LE(_currentType);
+ s.syncAsUint32LE(_ambientState);
+ s.syncAsUint32LE(_currentTag);
// Compute the number of entries to save
uint32 numEntries = count();
@@ -347,7 +347,7 @@ void SoundQueue::saveLoadWithSerializer(Common::Serializer &s) {
uint32 SoundQueue::count() {
uint32 numEntries = 0;
for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i)
- if ((*i)->getName2().matchString("NISSND?"))
+ if ((*i)->getName().matchString("NISSND?"))
++numEntries;
return numEntries;
diff --git a/engines/lastexpress/sound/queue.h b/engines/lastexpress/sound/queue.h
index 1c73f57906..df8c945ee9 100644
--- a/engines/lastexpress/sound/queue.h
+++ b/engines/lastexpress/sound/queue.h
@@ -42,26 +42,26 @@ public:
// Queue
void addToQueue(SoundEntry *entry);
- void removeFromQueue(Common::String filename);
- void removeFromQueue(EntityIndex entity);
+ void stop(Common::String filename);
+ void stop(EntityIndex entity);
void updateQueue();
- void resetQueue();
- void resetQueue(SoundType type1, SoundType type2 = kSoundTypeNone);
- void clearQueue();
+ void stopAmbient();
+ void stopAllExcept(SoundTag type1, SoundTag type2 = kSoundTagNone);
+ void destroyAllSound();
// State
- void clearStatus();
- int getSoundState() { return _state; }
- void resetState() { resetState(kSoundState1); }
- void resetState(SoundState state) { _state |= state; }
+ void stopAll();
+ int getAmbientState() { return _ambientState; }
+ void startAmbient() { _ambientState |= kAmbientSoundEnabled; }
+ void setAmbientToSteam() { _ambientState |= kAmbientSoundSteam; }
// Entries
- void setupEntry(SoundType type, EntityIndex index);
- void processEntry(EntityIndex entity);
- void processEntry(SoundType type);
- void processEntry(Common::String filename);
- void processEntries();
- SoundEntry *getEntry(SoundType type);
+ void assignNISLink(EntityIndex index);
+ void fade(EntityIndex entity);
+ void fade(SoundTag type);
+ void fade(Common::String filename);
+ void endAmbient();
+ SoundEntry *getEntry(SoundTag type);
SoundEntry *getEntry(EntityIndex index);
SoundEntry *getEntry(Common::String name);
uint32 getEntryTime(EntityIndex index);
@@ -83,8 +83,8 @@ public:
uint32 getFlag() { return _flag; }
int getSubtitleFlag() { return _subtitlesFlag; }
void setSubtitleFlag(int flag) { _subtitlesFlag = flag; }
- SoundType getCurrentType() { return _currentType; }
- void setCurrentType(SoundType type) { _currentType = type; }
+
+ int32 generateNextTag() { return _currentTag++; }
protected:
// Debug
@@ -94,8 +94,8 @@ private:
LastExpressEngine *_engine;
// State & shared data
- int _state;
- SoundType _currentType;
+ int _ambientState;
+ int32 _currentTag;
// TODO: this seems to be a synchronization flag for the sound timer
uint32 _flag;
diff --git a/engines/lastexpress/sound/sound.cpp b/engines/lastexpress/sound/sound.cpp
index b69121bbb5..c28b734129 100644
--- a/engines/lastexpress/sound/sound.cpp
+++ b/engines/lastexpress/sound/sound.cpp
@@ -113,7 +113,7 @@ static const SoundFlag soundFlags[32] = {
};
SoundManager::SoundManager(LastExpressEngine *engine) : _engine(engine) {
- _loopingSoundDuration = 0;
+ _ambientSoundDuration = 0;
_queue = new SoundQueue(engine);
@@ -137,7 +137,7 @@ SoundManager::~SoundManager() {
//////////////////////////////////////////////////////////////////////////
void SoundManager::playSound(EntityIndex entity, Common::String filename, SoundFlag flag, byte activateDelay) {
if (_queue->isBuffered(entity) && entity && entity < kEntityTrain)
- _queue->removeFromQueue(entity);
+ _queue->stop(entity);
SoundFlag currentFlag = (flag == kSoundVolumeEntityDefault) ? getSoundFlag(entity) : (SoundFlag)(flag | 0x80000);
@@ -178,7 +178,7 @@ bool SoundManager::playSoundWithSubtitles(Common::String filename, uint32 flag,
// Add entry to sound list
_queue->addToQueue(entry);
- return (entry->getType() != kSoundTypeNone);
+ return (entry->getTag() != kSoundTagNone);
}
void SoundManager::playSoundEvent(EntityIndex entity, byte action, byte activateDelay) {
@@ -311,13 +311,13 @@ void SoundManager::playSteam(CityIndex index) {
if (index >= ARRAYSIZE(cities))
error("[SoundManager::playSteam] Invalid city index (was %d, max %d)", index, ARRAYSIZE(cities));
- _queue->resetState(kSoundState2);
+ _queue->setAmbientToSteam();
- if (!_queue->getEntry(kSoundType1))
+ if (!_queue->getEntry(kSoundTagAmbient))
playSoundWithSubtitles("STEAM.SND", kSoundTypeAmbient | kSoundFlagLooped | kVolume7, kEntitySteam);
// Get the new sound entry and show subtitles
- SoundEntry *entry = _queue->getEntry(kSoundType1);
+ SoundEntry *entry = _queue->getEntry(kSoundTagAmbient);
if (entry)
entry->showSubtitle(cities[index]);
}
@@ -368,7 +368,7 @@ void SoundManager::playFightSound(byte action, byte a4) {
void SoundManager::playDialog(EntityIndex entity, EntityIndex entityDialog, SoundFlag flag, byte a4) {
if (_queue->isBuffered(getDialogName(entityDialog)))
- _queue->removeFromQueue(getDialogName(entityDialog));
+ _queue->stop(getDialogName(entityDialog));
playSound(entity, getDialogName(entityDialog), flag, a4);
}
@@ -695,7 +695,7 @@ void SoundManager::readText(int id) {
// Check if file is in cache for id [1;8]
if (id <= 8)
if (_queue->isBuffered(text))
- _queue->removeFromQueue(text);
+ _queue->stop(text);
playSound(kEntityTables4, text, kVolumeFull);
}
@@ -1293,8 +1293,8 @@ SoundFlag SoundManager::getSoundFlag(EntityIndex entity) const {
//////////////////////////////////////////////////////////////////////////
// Misc
//////////////////////////////////////////////////////////////////////////
-void SoundManager::playLoopingSound(int param) {
- SoundEntry *entry = _queue->getEntry(kSoundType1);
+void SoundManager::playAmbientSound(int param) {
+ SoundEntry *entry = _queue->getEntry(kSoundTagAmbient);
static const EntityPosition positions[8] = { kPosition_8200, kPosition_7500,
kPosition_6470, kPosition_5790,
@@ -1315,11 +1315,11 @@ void SoundManager::playLoopingSound(int param) {
int partNumber = 1;
int fnameLen = 6;
- if (_queue->getSoundState() & kSoundState1 && param >= 0x45 && param <= 0x46) {
- if (_queue->getSoundState() & kSoundState2) {
+ if (_queue->getAmbientState() & kAmbientSoundEnabled && param >= 0x45 && param <= 0x46) {
+ if (_queue->getAmbientState() & kAmbientSoundSteam) {
strcpy(tmp, "STEAM.SND");
- _loopingSoundDuration = 32767;
+ _ambientSoundDuration = 32767;
} else {
if (getEntityData(kEntityPlayer)->location == kLocationOutsideTrain) {
partNumber = 6;
@@ -1373,8 +1373,8 @@ void SoundManager::playLoopingSound(int param) {
if (getFlags()->flag_3)
fnameLen = 5;
- if (!entry || scumm_strnicmp(entry->getName2().c_str(), tmp, (uint)fnameLen)) {
- _loopingSoundDuration = _engine->getRandom().getRandomNumber(319) + 260;
+ if (!entry || scumm_strnicmp(entry->getName().c_str(), tmp, (uint)fnameLen)) {
+ _ambientSoundDuration = _engine->getRandom().getRandomNumber(319) + 260;
if (partNumber != 99) {
playSoundWithSubtitles(tmp, kSoundTypeAmbient | kSoundFlagLooped | kVolume1, kEntitySteam);
@@ -1382,7 +1382,7 @@ void SoundManager::playLoopingSound(int param) {
if (entry)
entry->fade();
- SoundEntry *entry1 = _queue->getEntry(kSoundType1);
+ SoundEntry *entry1 = _queue->getEntry(kSoundTagAmbient);
if (entry1)
entry1->setVolumeSmoothly(kVolume7);
}
diff --git a/engines/lastexpress/sound/sound.h b/engines/lastexpress/sound/sound.h
index fad0e6dad9..f832574ba5 100644
--- a/engines/lastexpress/sound/sound.h
+++ b/engines/lastexpress/sound/sound.h
@@ -47,7 +47,7 @@ public:
void playFightSound(byte action, byte a4);
void playLocomotiveSound();
void playWarningCompartment(EntityIndex entity, ObjectIndex compartment);
- void playLoopingSound(int param);
+ void playAmbientSound(int param);
// Dialog & Letters
void readText(int id);
@@ -68,7 +68,7 @@ public:
uint32 getData0() { return _data0; }
int32 getData1() { return _data1; }
int32 getData2() { return _data2; }
- uint32 getLoopingSoundDuration() { return _loopingSoundDuration; }
+ uint32 getAmbientSoundDuration() { return _ambientSoundDuration; }
// Setters
void setData1(int32 data) { _data1 = data; }
@@ -81,7 +81,7 @@ private:
uint32 _lastWarning[12];
// Looping sound
- int _loopingSoundDuration;
+ int _ambientSoundDuration;
// Unknown data
uint32 _data0;