[Scummvm-git-logs] scummvm master -> 3e52288a2de05366f25624b5f7f77b13639e4882

dreammaster dreammaster at scummvm.org
Mon Oct 16 02:57:18 CEST 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
3e52288a2d TITANIC: Music room handler field renames & better anim sync to music


Commit: 3e52288a2de05366f25624b5f7f77b13639e4882
    https://github.com/scummvm/scummvm/commit/3e52288a2de05366f25624b5f7f77b13639e4882
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-10-15T20:57:09-04:00

Commit Message:
TITANIC: Music room handler field renames & better anim sync to music

Changed paths:
    engines/titanic/sound/music_room_handler.cpp
    engines/titanic/sound/music_room_handler.h
    engines/titanic/sound/music_room_instrument.cpp
    engines/titanic/sound/music_room_instrument.h


diff --git a/engines/titanic/sound/music_room_handler.cpp b/engines/titanic/sound/music_room_handler.cpp
index 3b66459..680dfed 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 ec117e3..0eed315 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 15ac2cd..882325c 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 d859fe2..ae9536b 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





More information about the Scummvm-git-logs mailing list