aboutsummaryrefslogtreecommitdiff
path: root/engines/tsage
diff options
context:
space:
mode:
Diffstat (limited to 'engines/tsage')
-rw-r--r--engines/tsage/sound.cpp92
-rw-r--r--engines/tsage/sound.h7
2 files changed, 87 insertions, 12 deletions
diff --git a/engines/tsage/sound.cpp b/engines/tsage/sound.cpp
index 2b7a2c686d..39ebf07221 100644
--- a/engines/tsage/sound.cpp
+++ b/engines/tsage/sound.cpp
@@ -94,7 +94,7 @@ Common::List<SoundDriverEntry> &SoundManager::buildDriverList(bool detectFlag) {
}
void SoundManager::installConfigDrivers() {
-
+ installDriver(ADLIB_DRIVER_NUM);
}
Common::List<SoundDriverEntry> &SoundManager::getDriverList(bool detectFlag) {
@@ -329,6 +329,10 @@ void SoundManager::listenerSynchronise(Serialiser &s) {
/*--------------------------------------------------------------------------*/
+SoundManager &SoundManager::sfManager() {
+ return _globals->_soundManager;
+}
+
void SoundManager::_soSetTimeIndex(int timeIndex) {
warning("TODO: _soSetTimeIndex");
}
@@ -346,12 +350,19 @@ int SoundManager::_sfDetermineGroup(const byte *soundData) {
return 0;
}
-void SoundManager::_sfAddToPlayList(Sound*soundData) {
-
+void SoundManager::_sfAddToPlayList(Sound *sound) {
+ ++sfManager()._suspendCtr;
+ _sfDoAddToPlayList(sound);
+ sound->_field6 = 0;
+ _sfRethinkVoiceTypes();
+ --sfManager()._suspendCtr;
}
void SoundManager::_sfRemoveFromPlayList(Sound *sound) {
-
+ ++sfManager()._suspendCtr;
+ if (_sfDoRemoveFromPlayList(sound))
+ _sfRethinkVoiceTypes();
+ --sfManager()._suspendCtr;
}
bool SoundManager::_sfIsOnPlayList(Sound *sound) {
@@ -368,23 +379,35 @@ void SoundManager::_sfRethinkVoiceTypes() {
void SoundManager::_sfUpdateVolume(Sound *sound) {
_sfDereferenceAll();
- sub_233EE(sound);
+ _sfDoUpdateVolume(sound);
}
void SoundManager::_sfDereferenceAll() {
-
-}
-
-void SoundManager::sub_233EE(Sound *sound) {
-
+ // Orignal used handles for both the driver list and voiceStructPtrs list. This method then refreshed
+ // pointer lists based on the handles. Since in ScummVM we're just using pointers directly, this
+ // method doesn't need any implementation
}
void SoundManager::_sfUpdatePriority(Sound *sound) {
+ ++_globals->_soundManager._suspendCtr;
+ int tempPriority = (sound->_priority2 == 255) ? sound->_soundPriority : sound->_priority;
+ if (sound->_priority != tempPriority) {
+ sound->_priority = tempPriority;
+ if (_sfDoRemoveFromPlayList(sound)) {
+ _sfDoAddToPlayList(sound);
+ _sfRethinkVoiceTypes();
+ }
+ }
+
+ --_globals->_soundManager._suspendCtr;
}
void SoundManager::_sfUpdateLoop(Sound *sound) {
-
+ if (sound->_loopFlag2)
+ sound->_loopFlag = sound->_loop;
+ else
+ sound->_loopFlag = sound->_loopFlag2;
}
void SoundManager::_sfSetMasterVol(int volume) {
@@ -452,6 +475,53 @@ void SoundManager::_sfInstallPatchBank(const byte *bankData) {
}
+/**
+ * Adds the specified sound in the playing sound list, inserting in order of priority
+ */
+void SoundManager::_sfDoAddToPlayList(Sound *sound) {
+ ++sfManager()._suspendCtr;
+
+ Common::List<Sound *>::iterator i = sfManager()._playList.begin();
+ while ((i != sfManager()._playList.end()) && (sound->_priority > (*i)->_priority))
+ ++i;
+
+ sfManager()._playList.insert(i, sound);
+ --sfManager()._suspendCtr;
+}
+
+/**
+ * Removes the specified sound from the play list
+ */
+bool SoundManager::_sfDoRemoveFromPlayList(Sound *sound) {
+ ++sfManager()._suspendCtr;
+
+ bool result = false;
+ for (Common::List<Sound *>::iterator i = sfManager()._playList.begin(); i != sfManager()._playList.end(); ++i) {
+ if (*i == sound) {
+ result = true;
+ sfManager()._playList.erase(i);
+ break;
+ }
+ }
+
+ --sfManager()._suspendCtr;
+ return result;
+}
+
+void SoundManager::_sfDoUpdateVolume(Sound *sound) {
+ ++_globals->_soundManager._suspendCtr;
+
+ for (int idx = 0; idx < 16; ++idx) {
+ Sound *snd = sfManager()._voiceStructPtrs[idx];
+ if (!snd)
+ continue;
+
+ // TODO: More stuff
+ }
+
+ --_globals->_soundManager._suspendCtr;
+}
+
/*--------------------------------------------------------------------------*/
Sound::Sound() {
diff --git a/engines/tsage/sound.h b/engines/tsage/sound.h
index 40388d1055..6f86a930c0 100644
--- a/engines/tsage/sound.h
+++ b/engines/tsage/sound.h
@@ -88,6 +88,7 @@ public:
int _field89[SOUND_ARR_SIZE];
uint16 _groupList[SOUND_ARR_SIZE];
int _fieldE9[SOUND_ARR_SIZE];
+ Sound *_voiceStructPtrs[SOUND_ARR_SIZE];
public:
SoundManager();
~SoundManager();
@@ -132,6 +133,7 @@ public:
void unloadSound(int soundNum);
// _so methods
+ static SoundManager &sfManager();
static void _sfTerminate();
static void _soSetTimeIndex(int timeIndex);
static int _sfDetermineGroup(const byte *soundData);
@@ -141,7 +143,6 @@ public:
static void _sfRethinkVoiceTypes();
static void _sfUpdateVolume(Sound *sound);
static void _sfDereferenceAll();
- static void sub_233EE(Sound *sound);
static void _sfUpdatePriority(Sound *sound);
static void _sfUpdateLoop(Sound *sound);
static void _sfSetMasterVol(int volume);
@@ -150,6 +151,9 @@ public:
static bool _sfInstallDriver(SoundDriver *driver);
static void _sfUnInstallDriver(SoundDriver *driver);
static void _sfInstallPatchBank(const byte *bankData);
+ static void _sfDoAddToPlayList(Sound *sound);
+ static bool _sfDoRemoveFromPlayList(Sound *sound);
+ static void _sfDoUpdateVolume(Sound *sound);
};
class Sound: public EventHandler {
@@ -158,6 +162,7 @@ private:
void _unPrime();
void orientAfterRestore();
public:
+ int _field0;
int _field6;
int _soundNum;
int _groupNum;