diff options
Diffstat (limited to 'engines/tsage')
-rw-r--r-- | engines/tsage/converse.cpp | 2 | ||||
-rw-r--r-- | engines/tsage/converse.h | 2 | ||||
-rw-r--r-- | engines/tsage/core.cpp | 50 | ||||
-rw-r--r-- | engines/tsage/core.h | 38 | ||||
-rw-r--r-- | engines/tsage/globals.cpp | 6 | ||||
-rw-r--r-- | engines/tsage/globals.h | 1 | ||||
-rw-r--r-- | engines/tsage/scene_logic.cpp | 14 |
7 files changed, 98 insertions, 15 deletions
diff --git a/engines/tsage/converse.cpp b/engines/tsage/converse.cpp index acc05d22b4..d737ad8306 100644 --- a/engines/tsage/converse.cpp +++ b/engines/tsage/converse.cpp @@ -231,7 +231,7 @@ void SequenceManager::signal() { case 26: v1 = getNextValue(); v2 = getNextValue(); - _SoundHandler.startSound(v1, v2 ? this : NULL, 127); + _soundHandler.startSound(v1, v2 ? this : NULL, 127); break; case 27: { v1 = getNextValue(); diff --git a/engines/tsage/converse.h b/engines/tsage/converse.h index 172a3fb617..d9cc07cf82 100644 --- a/engines/tsage/converse.h +++ b/engines/tsage/converse.h @@ -53,7 +53,7 @@ public: int _objectIndex; SceneObject *_sceneObject; SceneObject *_objectList[6]; - SoundHandler _SoundHandler; + SoundHandler _soundHandler; public: SequenceManager(); diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index 6598da6e1d..1e782f158b 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -2773,6 +2773,53 @@ int SceneRegions::indexOf(const Common::Point &pt) { /*--------------------------------------------------------------------------*/ +SoundHandler::SoundHandler() { + _action = NULL; + _field280 = -1; + if (_globals) + _globals->_sceneListeners.push_back(this); +} + +SoundHandler::~SoundHandler() { + if (_globals) + _globals->_sceneListeners.remove(this); +} + +void SoundHandler::dispatch() { + EventHandler::dispatch(); + int v = _sound.proc12(); + + if (v != -1) { + _field280 = v; + _sound.proc2(-1); + + if (_action) + _action->signal(); + } + + if (_field280 != -1) { + if (!_sound.proc3()) { + _field280 = -1; + if (_action) { + _action->signal(); + _action = NULL; + } + } + } +} + +void SoundHandler::startSound(int soundNum, Action *action, int volume) { + _action = action; + _field280 = 0; + setVolume(volume); + _sound.startSound(soundNum); + + warning("TODO: SoundHandler::startSound"); +} + + +/*--------------------------------------------------------------------------*/ + void SceneItemList::addItems(SceneItem *first, ...) { va_list va; va_start(va, first); @@ -3102,7 +3149,8 @@ GameHandler::GameHandler(): EventHandler() { } GameHandler::~GameHandler() { - _globals->_game.removeHandler(this); + if (_globals) + _globals->_game.removeHandler(this); } void GameHandler::execute() { diff --git a/engines/tsage/core.h b/engines/tsage/core.h index 43b9349ccb..3d537d3e7b 100644 --- a/engines/tsage/core.h +++ b/engines/tsage/core.h @@ -673,19 +673,39 @@ public: void proc5(int v) { warning("TODO: GameSoundHandler::proc5"); } + void proc11(int v1, int v2, int v3, int v4) { + warning("TODO: GameSoundHandler::proc11"); + } + int proc12() { + // TODO + return -1; + } + void proc2(int v) { + // TODO + } + int proc3() { + return 0; + } + void setVolume(int volume) { + warning("TODO GameSoundHandler::setVolume"); + } + void startSound(int soundNum) { + warning("TODO GameSoundHandler::startSound"); + } }; class SoundHandler: public EventHandler { public: GameSoundHandler _sound; + Action *_action; + int _field280; public: - SoundHandler() {} + SoundHandler(); + ~SoundHandler(); - void startSound(int soundNum, Action *action = NULL, int volume = 127) { - warning("TODO: SoundHandler::startSound"); - } + void startSound(int soundNum, Action *action = NULL, int volume = 127); void proc1(Action *action) { - warning("TODO: SoundHandler::proc1"); + proc11(0, 5, 10, 1, action); } void proc2(int v) { warning("TODO: SoundHandler::proc2"); @@ -699,8 +719,16 @@ public: void proc5(int v) { _sound.proc5(v); } + void proc11(int v1, int v2, int v3, int v4, Action *action) { + if (action) + _action = action; + + _sound.proc11(v1, v2, v3, v4); + } + void setVolume(int volume) { _sound.setVolume(volume); } virtual Common::String getClassName() { return "SoundHandler"; } + virtual void dispatch(); }; /*--------------------------------------------------------------------------*/ diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp index bdf9d15011..838b363cb2 100644 --- a/engines/tsage/globals.cpp +++ b/engines/tsage/globals.cpp @@ -63,6 +63,12 @@ Globals::Globals(): _sceneObjects_queue.push_front(_sceneObjects); _stru_4642E = Common::Point(-1, -1); + _sceneListeners.push_back(&_soundHandler); + _sceneListeners.push_back(&_sequenceManager._soundHandler); +} + +Globals::~Globals() { + _globals = NULL; } void Globals::reset() { diff --git a/engines/tsage/globals.h b/engines/tsage/globals.h index 30c295a7ab..17cfa4eb4b 100644 --- a/engines/tsage/globals.h +++ b/engines/tsage/globals.h @@ -72,6 +72,7 @@ public: int _stripNum; public: Globals(); + ~Globals(); void reset(); void setFlag(int flagNum) { diff --git a/engines/tsage/scene_logic.cpp b/engines/tsage/scene_logic.cpp index 1900761cf6..7a16781abe 100644 --- a/engines/tsage/scene_logic.cpp +++ b/engines/tsage/scene_logic.cpp @@ -333,7 +333,7 @@ void Scene20::Scene20_Action1::signal() { parent->_stripManager.start(20, this); break; case 2: - parent->_sound.proc1(this); + _globals->_soundHandler.proc1(this); break; case 3: _globals->_sceneManager._FadeMode = FADEMODE_GRADUAL; @@ -699,7 +699,7 @@ void Scene30::Scene30_beamAction::signal() { case 2: // Hide the beam and lower the player's hand - parent->_sound.startSound(10, 0, 127); + parent->_sound.startSound(10, NULL, 127); _globals->_player.animate(ANIM_MODE_6, this); parent->_beam.remove(); break; @@ -723,14 +723,14 @@ void Scene30::Scene30_beamAction::signal() { case 4: // Open the door - parent->_sound.startSound(11, 0, 127); + parent->_sound.startSound(11, NULL, 127); parent->_door.animate(ANIM_MODE_5, this); break; case 5: // Run the Kzin's talk sequence - parent->_sound.startSound(13, 0, 127); - _globals->_soundHandler.startSound(12, 0, 127); + parent->_sound.startSound(13, NULL, 127); + _globals->_soundHandler.startSound(12, NULL, 127); parent->_stripManager.start((parent->_sceneMode == 0) ? 30 : 37, this); break; @@ -802,12 +802,12 @@ void Scene30::Scene30_ringAction::signal() { } case 3: - parent->_sound.startSound(11, 0, 127); + parent->_sound.startSound(11, NULL, 127); parent->_door.animate(ANIM_MODE_6, this); break; case 4: { - parent->_sound.startSound(13, 0, 127); + parent->_sound.startSound(13, NULL, 127); NpcMover *kzinMover = new NpcMover(); Common::Point pt(354, 5); parent->_kzin.addMover(kzinMover, &pt, this); |