aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/tsage/core.cpp18
-rw-r--r--engines/tsage/sound.cpp156
-rw-r--r--engines/tsage/sound.h67
3 files changed, 175 insertions, 66 deletions
diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp
index 4cbe70f0e3..873bbc56a5 100644
--- a/engines/tsage/core.cpp
+++ b/engines/tsage/core.cpp
@@ -2945,24 +2945,6 @@ int SceneRegions::indexOf(const Common::Point &pt) {
/*--------------------------------------------------------------------------*/
-ASound::ASound() {
- _action = NULL;
- _field280 = -1;
-}
-
-void ASound::synchronize(Serializer &s) {
- EventHandler::synchronize(s);
-
- SYNC_POINTER(_action);
- s.syncAsSint16LE(_field280);
-}
-
-void ASound::dispatch() {
-
-}
-
-/*--------------------------------------------------------------------------*/
-
void SceneItemList::addItems(SceneItem *first, ...) {
va_list va;
va_start(va, first);
diff --git a/engines/tsage/sound.cpp b/engines/tsage/sound.cpp
index 912bbacadd..c628cf4d31 100644
--- a/engines/tsage/sound.cpp
+++ b/engines/tsage/sound.cpp
@@ -56,93 +56,191 @@ void SoundManager::listenerSynchronize(Serializer &s) {
/*--------------------------------------------------------------------------*/
-void ASound::play(int soundNum, Action *action, int volume) {
-
+void Sound::play(int soundNum, int volume) {
+
}
-void ASound::stop() {
+void Sound::stop() {
}
-void ASound::prime(int v, Action *action) {
+void Sound::prime(int soundNum) {
}
-void ASound::unPrime() {
+void Sound::prime(int soundNum, int v2) {
+
+}
+
+void Sound::_unPrime() {
}
-void ASound::go() {
+void Sound::unPrime() {
}
-void ASound::hault(void) {
+void Sound::go() {
+
}
-int ASound::getSoundNum() const { return 0; }
-bool ASound::isPlaying() const { return false; }
-bool ASound::isPaused() const { return false; }
-bool ASound::isMuted() const { return false; }
+void Sound::halt(void) {
-void ASound::pause() {
+}
+int Sound::getSoundNum() const {
+ return 0;
}
-void ASound::mute() {
+bool Sound::isPlaying() const {
+ return false;
+}
+bool Sound::isPrimed() const {
+ return false;
}
-void ASound::fadeIn() {
+bool Sound::isPaused() const {
+ return false;
+}
+bool Sound::isMuted() const {
+ return false;
}
-void ASound::fadeOut(EventHandler *evtHandler) {
+void Sound::pause() {
}
-void ASound::fade(int v1, int v2, int v3, int v4, EventHandler *evtHandler) {
+void Sound::mute() {
}
-void ASound::setTimeIndex(uint32 timeIndex) {
+void Sound::fadeIn() {
}
-uint32 ASound::getTimeIndex() const {
- return 0;
+void Sound::fadeOut(EventHandler *evtHandler) {
+
}
-void ASound::setPri(int v) {
+void Sound::fade(int v1, int v2, int v3, int v4) {
}
-void ASound::setLoop(bool flag) {
+void Sound::setTimeIndex(uint32 timeIndex) {
}
-int ASound::getPri() const {
- return 0;
+uint32 Sound::getTimeIndex() const {
+ return 0;
+}
+
+bool Sound::getCueValue() const {
+ return false;
}
-bool ASound::getLoop() {
- return false;
+void Sound::setCueValue(bool flag) {
+
}
-void ASound::setVolume(int volume) {
+void Sound::setVol(int volume) {
}
-int ASound::getVol() const {
+int Sound::getVol() const {
return 0;
}
-void ASound::holdAt(int v) {
+void Sound::setPri(int v) {
+
+}
+
+void Sound::setLoop(bool flag) {
}
-void ASound::release() {
+int Sound::getPri() const {
+ return 0;
+}
+bool Sound::getLoop() {
+ return false;
}
+void Sound::holdAt(int v) {
+
+}
+
+void Sound::release() {
+
+}
+
+
+/*--------------------------------------------------------------------------*/
+
+ASound::ASound(): EventHandler() {
+ _action = NULL;
+ _cueFlag = false;
+}
+
+void ASound::synchronize(Serializer &s) {
+ EventHandler::synchronize(s);
+ SYNC_POINTER(_action);
+ s.syncAsByte(_cueFlag);
+}
+
+void ASound::dispatch() {
+ EventHandler::dispatch();
+
+ if (!_sound.getCueValue()) {
+ _cueFlag = false;
+ _sound.setCueValue(true);
+
+ if (_action)
+ _action->signal();
+ }
+
+ if (!_cueFlag) {
+ if (!_sound.isPrimed()) {
+ _cueFlag = true;
+ if (_action) {
+ _action->signal();
+ _action = NULL;
+ }
+ }
+ }
+}
+
+void ASound::play(int soundNum, Action *action, int volume) {
+ _action = action;
+ _cueFlag = false;
+
+ setVol(volume);
+ _sound.play(soundNum);
+}
+
+void ASound::stop() {
+ _sound.stop();
+ _action = NULL;
+}
+
+void ASound::prime(int soundNum, Action *action) {
+ _action = action;
+ _cueFlag = false;
+ _sound.prime(soundNum);
+}
+
+void ASound::unPrime() {
+ _sound.unPrime();
+ _action = NULL;
+}
+
+void ASound::fade(int v1, int v2, int v3, int v4, Action *action) {
+ if (action)
+ _action = action;
+
+ _sound.fade(v1, v2, v3, v4);
+}
} // End of namespace tSage
diff --git a/engines/tsage/sound.h b/engines/tsage/sound.h
index d1099fabcc..2155a935cd 100644
--- a/engines/tsage/sound.h
+++ b/engines/tsage/sound.h
@@ -44,46 +44,75 @@ public:
class Sound: public EventHandler {
public:
-
-};
-
-class ASound: public Sound {
-public:
- Sound _sound;
- Action *_action;
- int _field280;
-
- ASound();
- virtual void synchronize(Serializer &s);
- virtual void dispatch();
-
- void play(int soundNum, Action *action = NULL, int volume = 127);
+ void play(int soundNum, int volume = 127);
void stop();
- void prime(int v, Action *action = NULL);
+ void prime(int soundNum);
+ void prime(int soundNum, int v2);
+ void _unPrime();
void unPrime();
void go();
- void hault(void);
+ void halt(void);
int getSoundNum() const;
bool isPlaying() const;
+ bool isPrimed() const;
bool isPaused() const;
bool isMuted() const;
void pause();
void mute();
void fadeIn();
void fadeOut(EventHandler *evtHandler);
- void fade(int v1, int v2, int v3, int v4, EventHandler *evtHandler);
+ void fade(int v1, int v2, int v3, int v4);
void setTimeIndex(uint32 timeIndex);
uint32 getTimeIndex() const;
+ bool getCueValue() const;
+ void setCueValue(bool flag);
+ void setVol(int volume);
+ int getVol() const;
void setPri(int v);
void setLoop(bool flag);
int getPri() const;
bool getLoop();
- void setVolume(int volume);
- int getVol() const;
void holdAt(int v);
void release();
};
+class ASound: public EventHandler {
+public:
+ Sound _sound;
+ Action *_action;
+ bool _cueFlag;
+
+ ASound();
+ virtual void synchronize(Serializer &s);
+ virtual void dispatch();
+
+ void play(int soundNum, Action *action = NULL, int volume = 127);
+ void stop();
+ void prime(int soundNum, Action *action = NULL);
+ void unPrime();
+ void go() { _sound.go(); }
+ void hault(void) { _sound.halt(); }
+ int getSoundNum() const { return _sound.getSoundNum(); }
+ bool isPlaying() const { return _sound.isPlaying(); }
+ bool isPaused() const { return _sound.isPaused(); }
+ bool isMuted() const { return _sound.isMuted(); }
+ void pause() { _sound.pause(); }
+ void mute() { _sound.mute(); }
+ void fadeIn() { fade(127, 5, 10, 0, NULL); }
+ void fadeOut(Action *action) { fade(0, 5, 10, 1, action); }
+ void fade(int v1, int v2, int v3, int v4, Action *action);
+ void setTimeIndex(uint32 timeIndex) { _sound.setTimeIndex(timeIndex); }
+ uint32 getTimeIndex() const { return _sound.getTimeIndex(); }
+ void setPri(int v) { _sound.setPri(v); }
+ void setLoop(bool flag) { _sound.setLoop(flag); }
+ int getPri() const { return _sound.getPri(); }
+ bool getLoop() { return _sound.getLoop(); }
+ void setVol(int volume) { _sound.setVol(volume); }
+ int getVol() const { return _sound.getVol(); }
+ void holdAt(int v) { _sound.holdAt(v); }
+ void release() { _sound.release(); }
+};
+
} // End of namespace tSage
#endif