diff options
author | Paul Gilbert | 2017-10-15 20:57:09 -0400 |
---|---|---|
committer | Paul Gilbert | 2017-10-15 20:57:09 -0400 |
commit | 3e52288a2de05366f25624b5f7f77b13639e4882 (patch) | |
tree | 937b8164f067cb0d72e83ec1346d3f7dd935e97d /engines/titanic | |
parent | e26a677f6214a1c88d63a41e136dc78ad07cca11 (diff) | |
download | scummvm-rg350-3e52288a2de05366f25624b5f7f77b13639e4882.tar.gz scummvm-rg350-3e52288a2de05366f25624b5f7f77b13639e4882.tar.bz2 scummvm-rg350-3e52288a2de05366f25624b5f7f77b13639e4882.zip |
TITANIC: Music room handler field renames & better anim sync to music
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/sound/music_room_handler.cpp | 20 | ||||
-rw-r--r-- | engines/titanic/sound/music_room_handler.h | 2 | ||||
-rw-r--r-- | engines/titanic/sound/music_room_instrument.cpp | 12 | ||||
-rw-r--r-- | engines/titanic/sound/music_room_instrument.h | 2 |
4 files changed, 20 insertions, 16 deletions
diff --git a/engines/titanic/sound/music_room_handler.cpp b/engines/titanic/sound/music_room_handler.cpp index 3b6645904b..680dfed5ec 100644 --- a/engines/titanic/sound/music_room_handler.cpp +++ b/engines/titanic/sound/music_room_handler.cpp @@ -38,7 +38,7 @@ CMusicRoomHandler::CMusicRoomHandler(CProjectItem *project, CSoundManager *sound for (int idx = 0; idx < 4; ++idx) _songs[idx] = new CMusicSong(idx); Common::fill(&_startPos[0], &_startPos[4], 0); - Common::fill(&_animTime[0], &_animTime[4], 0.0); + Common::fill(&_animExpiryTime[0], &_animExpiryTime[4], 0.0); Common::fill(&_position[0], &_position[4], 0); _audioBuffer = new CAudioBuffer(88200); @@ -89,7 +89,7 @@ void CMusicRoomHandler::setup(int volume) { } _position[idx] = _startPos[idx]; - _animTime[idx] = 0.0; + _animExpiryTime[idx] = 0.0; } _instrumentsActive = 4; @@ -180,7 +180,7 @@ void CMusicRoomHandler::start() { } bool CMusicRoomHandler::update() { - uint currentTicks = g_vm->_events->getTicksCount(); + uint currentTicks = g_system->getMillis(); if (!_startTicks) { start(); @@ -239,9 +239,14 @@ void CMusicRoomHandler::updateAudio() { // Reaching end of music _audioBuffer->finalize(); } - +bool flag = false; void CMusicRoomHandler::updateInstruments() { + uint currentTicks = g_system->getMillis(); + if (_active && _soundStartTicks) { + if (!flag) { + flag = true; warning("STARTING TICKS %d", currentTicks);//***DEBUG***/ + } for (MusicInstrument instrument = BELLS; instrument <= BASS; instrument = (MusicInstrument)((int)instrument + 1)) { MusicRoomInstrument &ins1 = _array1[instrument]; @@ -254,12 +259,11 @@ void CMusicRoomHandler::updateInstruments() { continue; } - uint ticks = g_vm->_events->getTicksCount() - _soundStartTicks; - double time = (double)ticks * 0.001 - 0.6; - double threshold = _animTime[instrument] - ins->_animTime; + double time = (double)(currentTicks - _soundStartTicks) / 1000.0 - 0.6; + double threshold = _animExpiryTime[instrument] - ins->_insStartTime; if (time >= threshold) { - _animTime[instrument] += getAnimDuration(instrument, _position[instrument]); + _animExpiryTime[instrument] += getAnimDuration(instrument, _position[instrument]); const CValuePair &vp = (*_songs[instrument])[_position[instrument]]; if (vp._data != 0x7FFFFFFF) { diff --git a/engines/titanic/sound/music_room_handler.h b/engines/titanic/sound/music_room_handler.h index ec117e3098..0eed315614 100644 --- a/engines/titanic/sound/music_room_handler.h +++ b/engines/titanic/sound/music_room_handler.h @@ -55,7 +55,7 @@ private: CMusicSong *_songs[4]; int _startPos[4]; int _position[4]; - double _animTime[4]; + double _animExpiryTime[4]; bool _active; CWaveFile *_waveFile; diff --git a/engines/titanic/sound/music_room_instrument.cpp b/engines/titanic/sound/music_room_instrument.cpp index 15ac2cd192..882325c08a 100644 --- a/engines/titanic/sound/music_room_instrument.cpp +++ b/engines/titanic/sound/music_room_instrument.cpp @@ -52,7 +52,7 @@ void CMusicRoomInstrument::deinit() { CMusicRoomInstrument::CMusicRoomInstrument(CProjectItem *project, CSoundManager *soundManager, MusicWaveInstrument instrument) : _project(project), _soundManager(soundManager), _instrument(instrument) { Common::fill(&_gameObjects[0], &_gameObjects[4], (CGameObject *)nullptr); - _animTime = 0.0; + _insStartTime = 0.0; _waveIndex = -1; _readPos = 0; _readIncrement = 0; @@ -66,7 +66,7 @@ CMusicRoomInstrument::CMusicRoomInstrument(CProjectItem *project, CSoundManager _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")); - _animTime = 0.45; + _insStartTime = 0.45; break; case MV_BASS: @@ -75,14 +75,14 @@ CMusicRoomInstrument::CMusicRoomInstrument(CProjectItem *project, CSoundManager case MV_BELLS: _gameObjects[0] = static_cast<CGameObject *>(_project->findByName("Tubular Bells")); - _animTime = 0.4; + _insStartTime = 0.4; break; 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")); - _animTime = 0.17; + _insStartTime = 0.17; break; } } @@ -212,12 +212,12 @@ void CMusicRoomInstrument::update(int val) { case 60: _gameObjects[0]->playMovie(0, 512, MOVIE_STOP_PREVIOUS); _gameObjects[0]->movieSetPlaying(true); - _animTime = 0.6; + _insStartTime = 0.6; break; case 62: _gameObjects[0]->playMovie(828, 1023, MOVIE_STOP_PREVIOUS); - _animTime = 0.3; + _insStartTime = 0.3; break; case 63: diff --git a/engines/titanic/sound/music_room_instrument.h b/engines/titanic/sound/music_room_instrument.h index d859fe2a0e..ae9536b370 100644 --- a/engines/titanic/sound/music_room_instrument.h +++ b/engines/titanic/sound/music_room_instrument.h @@ -73,7 +73,7 @@ private: */ void setupArray(int minVal, int maxVal); public: - double _animTime; + double _insStartTime; public: /** * Handles initialization of static fields |