diff options
author | Paul Gilbert | 2017-01-29 22:36:12 -0500 |
---|---|---|
committer | Paul Gilbert | 2017-01-29 22:36:12 -0500 |
commit | 9059779b9d214ffd380370fc309d707d10d7440d (patch) | |
tree | 37b8a282feaaa48800056aade8cf8ad1ae35c79d /engines/titanic | |
parent | 1948b62a80f056050f94c8a56f00de58f42394b2 (diff) | |
download | scummvm-rg350-9059779b9d214ffd380370fc309d707d10d7440d.tar.gz scummvm-rg350-9059779b9d214ffd380370fc309d707d10d7440d.tar.bz2 scummvm-rg350-9059779b9d214ffd380370fc309d707d10d7440d.zip |
TITANIC: Implementing initialization and trigger for CMusicWave
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/core/game_object.h | 10 | ||||
-rw-r--r-- | engines/titanic/sound/music_player.cpp | 8 | ||||
-rw-r--r-- | engines/titanic/sound/music_room_handler.cpp | 24 | ||||
-rw-r--r-- | engines/titanic/sound/music_room_handler.h | 4 | ||||
-rw-r--r-- | engines/titanic/sound/music_wave.cpp | 67 | ||||
-rw-r--r-- | engines/titanic/sound/music_wave.h | 17 |
6 files changed, 104 insertions, 26 deletions
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index 30b3321128..a56095c60f 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -462,11 +462,6 @@ protected: */ void setPassengerClass(PassengerClass newClass); - /** - * Overrides whether the object's movie has audio timing - */ - void movieSetAudioTiming(bool flag); - void fn10(int v1, int v2, int v3); /** @@ -638,6 +633,11 @@ public: void stopMovie(); /** + * Overrides whether the object's movie has audio timing + */ + void movieSetAudioTiming(bool flag); + + /** * Get the current movie frame */ int getMovieFrame() const; diff --git a/engines/titanic/sound/music_player.cpp b/engines/titanic/sound/music_player.cpp index a6a791f96e..1f8a847cd2 100644 --- a/engines/titanic/sound/music_player.cpp +++ b/engines/titanic/sound/music_player.cpp @@ -130,26 +130,26 @@ bool CMusicPlayer::CreateMusicPlayerMsg(CCreateMusicPlayerMsg *msg) { CMusicWave *wave; if (musicHandler) { - wave = musicHandler->createMusicWave(0, 3); + wave = musicHandler->createMusicWave(BELLS, 3); wave->load(0, "z#490.wav", 60); wave->load(1, "z#488.wav", 62); wave->load(2, "z#489.wav", 63); - wave = musicHandler->createMusicWave(1, 5); + wave = musicHandler->createMusicWave(SNAKE, 5); wave->load(0, "z#493.wav", 22); wave->load(1, "z#495.wav", 29); wave->load(2, "z#492.wav", 34); wave->load(3, "z#494.wav", 41); wave->load(4, "z#491.wav", 46); - wave = musicHandler->createMusicWave(2, 5); + wave = musicHandler->createMusicWave(PIANO, 5); wave->load(0, "z#499.wav", 26); wave->load(1, "z#497.wav", 34); wave->load(2, "z#498.wav", 38); wave->load(3, "z#496.wav", 46); wave->load(4, "z#500.wav", 60); - wave = musicHandler->createMusicWave(3, 7); + wave = musicHandler->createMusicWave(BASS, 7); wave->load(0, "z#504.wav", 22); wave->load(1, "z#507.wav", 29); wave->load(2, "z#503.wav", 34); diff --git a/engines/titanic/sound/music_room_handler.cpp b/engines/titanic/sound/music_room_handler.cpp index d9e2eeb72e..5a6f48ae17 100644 --- a/engines/titanic/sound/music_room_handler.cpp +++ b/engines/titanic/sound/music_room_handler.cpp @@ -39,26 +39,26 @@ CMusicRoomHandler::~CMusicRoomHandler() { delete _musicWaves[idx]; } -CMusicWave *CMusicRoomHandler::createMusicWave(int waveIndex, int count) { - switch (waveIndex) { - case 0: - _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 2); +CMusicWave *CMusicRoomHandler::createMusicWave(MusicInstrument instrument, int count) { + switch (instrument) { + case BELLS: + _musicWaves[BELLS] = new CMusicWave(_project, _soundManager, MV_BELLS); break; - case 1: - _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 3); + case SNAKE: + _musicWaves[SNAKE] = new CMusicWave(_project, _soundManager, MV_SNAKE); break; - case 2: - _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 0); + case PIANO: + _musicWaves[PIANO] = new CMusicWave(_project, _soundManager, MV_PIANO); break; - case 3: - _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 1); + case BASS: + _musicWaves[BASS] = new CMusicWave(_project, _soundManager, MV_BASS); break; default: return nullptr; } - _musicWaves[waveIndex]->setSize(count); - return _musicWaves[waveIndex]; + _musicWaves[instrument]->setSize(count); + return _musicWaves[instrument]; } void CMusicRoomHandler::createWaveFile(int musicVolume) { diff --git a/engines/titanic/sound/music_room_handler.h b/engines/titanic/sound/music_room_handler.h index 49b9ec836c..aad8ca1bd9 100644 --- a/engines/titanic/sound/music_room_handler.h +++ b/engines/titanic/sound/music_room_handler.h @@ -68,10 +68,10 @@ public: /** * Creates a new music wave class instance, and assigns it to a slot * in the music handler - * @param waveIndex Slot to save new instance in + * @param instrument Which instrument instance is for * @param count Number of files the new instance will contain */ - CMusicWave *createMusicWave(int waveIndex, int count); + CMusicWave *createMusicWave(MusicInstrument instrument, int count); void createWaveFile(int musicVolume); diff --git a/engines/titanic/sound/music_wave.cpp b/engines/titanic/sound/music_wave.cpp index 560fdd7513..6cfab5aed4 100644 --- a/engines/titanic/sound/music_wave.cpp +++ b/engines/titanic/sound/music_wave.cpp @@ -23,11 +23,43 @@ #include "titanic/sound/music_wave.h" #include "titanic/sound/sound_manager.h" #include "titanic/core/project_item.h" +#include "titanic/core/game_object.h" namespace Titanic { -CMusicWave::CMusicWave(CProjectItem *project, CSoundManager *soundManager, int index) : - _soundManager(soundManager) { +CMusicWave::CMusicWave(CProjectItem *project, CSoundManager *soundManager, MusicWaveInstrument instrument) : + _soundManager(soundManager), _instrument(instrument) { + Common::fill(&_gameObjects[0], &_gameObjects[4], (CGameObject *)nullptr); + _field20 = _field24 = 0; + _field4C = 0; + + switch (instrument) { + case MV_PIANO: + _gameObjects[0] = static_cast<CGameObject *>(_project->findByName("Piano Man")); + _gameObjects[1] = static_cast<CGameObject *>(_project->findByName("Piano Mouth")); + _gameObjects[2] = static_cast<CGameObject *>(_project->findByName("Piano Left Arm")); + _gameObjects[3] = static_cast<CGameObject *>(_project->findByName("Piano Right Arm")); + _field20 = 0xCCCCCCCD; + _field24 = 0x3FDCCCCC; + break; + + case MV_BASS: + _gameObjects[0] = static_cast<CGameObject *>(_project->findByName("Bass Player")); + break; + + case MV_BELLS: + _gameObjects[0] = static_cast<CGameObject *>(_project->findByName("Tubular Bells")); + _field20 = 0x9999999A; + _field24 = 0x3FD99999; + + case MV_SNAKE: + _gameObjects[0] = static_cast<CGameObject *>(_project->findByName("Snake Hammer")); + _gameObjects[1] = static_cast<CGameObject *>(_project->findByName("Snake Glass")); + _gameObjects[2] = static_cast<CGameObject *>(_project->findByName("Snake Head")); + _field20 = 0x5C28F5C3; + _field24 = 0x3FC5C28F; + break; + } } void CMusicWave::setSize(uint count) { @@ -48,7 +80,38 @@ CWaveFile *CMusicWave::createWaveFile(const CString &name) { } void CMusicWave::stop() { + // TODO +} + +void CMusicWave::trigger() { + if (_gameObjects[0]) { + switch (_instrument) { + case MV_PIANO: + _gameObjects[0]->playMovie(0, 29, MOVIE_STOP_PREVIOUS); + _gameObjects[2]->loadFrame(14); + _gameObjects[3]->loadFrame(22); + break; + + case MV_BELLS: + _gameObjects[0]->loadFrame(0); + _gameObjects[0]->movieSetAudioTiming(true); + break; + + case MV_SNAKE: + _field4C = 22; + _gameObjects[1]->playMovie(0, 22, 0); + _gameObjects[2]->playMovie(0, 35, MOVIE_STOP_PREVIOUS); + _gameObjects[0]->playMovie(0, 1, MOVIE_STOP_PREVIOUS); + _gameObjects[0]->playMovie(0, 1, 0); + _gameObjects[0]->playMovie(0, 1, 0); + _gameObjects[0]->playMovie(0, 1, 0); + _gameObjects[0]->playMovie(0, 1, 0); + break; + default: + break; + } + } } } // End of namespace Titanic diff --git a/engines/titanic/sound/music_wave.h b/engines/titanic/sound/music_wave.h index 4082a926cf..04709d18c6 100644 --- a/engines/titanic/sound/music_wave.h +++ b/engines/titanic/sound/music_wave.h @@ -28,9 +28,12 @@ namespace Titanic { +enum MusicWaveInstrument { MV_PIANO = 0, MV_BASS = 1, MV_BELLS = 2, MV_SNAKE = 3 }; + class CProjectItem; class CSoundManager; class CWaveFile; +class CGameObject; class CMusicWave { struct CMusicWaveFile { @@ -41,13 +44,19 @@ class CMusicWave { private: CSoundManager *_soundManager; Common::Array<CMusicWaveFile> _items; + MusicWaveInstrument _instrument; + CProjectItem *_project; + CGameObject *_gameObjects[4]; + int _field20; + int _field24; + int _field4C; private: /** * Loads the specified wave file, and returns a CWaveFile instance for it */ CWaveFile *createWaveFile(const CString &name); public: - CMusicWave(CProjectItem *project, CSoundManager *soundManager, int index); + CMusicWave(CProjectItem *project, CSoundManager *soundManager, MusicWaveInstrument instrument); /** * Sets the maximum number of allowed files that be defined @@ -63,6 +72,12 @@ public: * Stops the music */ void stop(); + + /** + * Called regularly to handle triggering the animation of the + * musical instrument associated with the instance + */ + void trigger(); }; } // End of namespace Titanic |