[Scummvm-git-logs] scummvm master -> b005198eb15c15450a67842f8e8b936c3a0d08a6

dreammaster dreammaster at scummvm.org
Sun Feb 5 00:43:33 CET 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:
b005198eb1 TITANIC: Implemented remainder of CMusicRoomHandler code


Commit: b005198eb15c15450a67842f8e8b936c3a0d08a6
    https://github.com/scummvm/scummvm/commit/b005198eb15c15450a67842f8e8b936c3a0d08a6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-02-04T18:43:24-05:00

Commit Message:
TITANIC: Implemented remainder of CMusicRoomHandler code

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


diff --git a/engines/titanic/sound/music_room_handler.cpp b/engines/titanic/sound/music_room_handler.cpp
index ea1aaf2..ad7105b 100644
--- a/engines/titanic/sound/music_room_handler.cpp
+++ b/engines/titanic/sound/music_room_handler.cpp
@@ -219,7 +219,7 @@ void CMusicRoomHandler::updateAudio() {
 				if (amount > 0) {
 					count -= amount;
 					ptr += amount;
-				} else if (!fn2()) {
+				} else if (!fn2(waveIdx)) {
 					--_field108;
 					break;
 				}
@@ -267,14 +267,56 @@ void CMusicRoomHandler::fn1() {
 	}
 }
 
-bool CMusicRoomHandler::fn2() {
-	// TODO
-	return false;
+bool CMusicRoomHandler::fn2(int index) {
+	int &arrIndex = _array4[index];
+	if (arrIndex < 0) {
+		_musicWaves[index]->reset();
+		return false;
+	}
+
+	const CMusicObject &mObj = *_array3[index];
+	if (arrIndex >= mObj.size()) {
+		arrIndex = -1;
+		_musicWaves[index]->reset();
+		return false;
+	}
+
+	const CValuePair &vp = mObj[arrIndex];
+	int freq = static_cast<int>(fn3(index, arrIndex) * 44100.0) & ~1;
+
+	if (vp._field0 == 0x7FFFFFFF || _array1[index]._muteControl)
+		_musicWaves[index]->setState(freq);
+	else
+		_musicWaves[index]->fn1(getPitch(index, arrIndex), freq);
+
+	if (_array1[index]._directionControl == _array2[index]._directionControl) {
+		++arrIndex;
+	} else {
+		--arrIndex;
+	}
+
+	return true;
 }
 
-double CMusicRoomHandler::fn3(int index, int val) {
-	// TODO
-	return 0;
+double CMusicRoomHandler::fn3(int index, int arrIndex) {
+	const CValuePair &vp = (*_array3[index])[arrIndex];
+
+	switch (_array1[index]._speedControl + _array2[index]._speedControl + 3) {
+	case 0:
+		return (double)vp._field4 * 1.5 * 0.0625 * 0.46875;
+	case 1:
+		return (double)vp._field4 * 1.33 * 0.0625 * 0.46875;
+	case 2:
+		return (double)vp._field4 * 1.25 * 0.0625 * 0.46875;
+	case 4:
+		return (double)vp._field4 * 0.75 * 0.0625 * 0.46875;
+	case 5:
+		return (double)vp._field4 * 0.67 * 0.0625 * 0.46875;
+	case 6:
+		return (double)vp._field4 * 0.5 * 0.0625 * 0.46875;
+	default:
+		return (double)vp._field4 * 1.0 * 0.0625 * 0.46875;
+	}
 }
 
 int CMusicRoomHandler::getPitch(int index, int arrIndex) {
diff --git a/engines/titanic/sound/music_room_handler.h b/engines/titanic/sound/music_room_handler.h
index dd8b62e..5f615cc 100644
--- a/engines/titanic/sound/music_room_handler.h
+++ b/engines/titanic/sound/music_room_handler.h
@@ -71,8 +71,8 @@ private:
 
 	void updateAudio();
 	void fn1();
-	bool fn2();
-	double fn3(int index, int val);
+	bool fn2(int index);
+	double fn3(int index, int arrIndex);
 	int getPitch(int index, int arrIndex);
 
 public:
diff --git a/engines/titanic/sound/music_wave.cpp b/engines/titanic/sound/music_wave.cpp
index cbb4fbf..e000356 100644
--- a/engines/titanic/sound/music_wave.cpp
+++ b/engines/titanic/sound/music_wave.cpp
@@ -268,4 +268,8 @@ int CMusicWave::setData(const byte *data, int count) {
 	return 0;
 }
 
+void CMusicWave::fn1(int val1, int val2) {
+	// TODO
+}
+
 } // End of namespace Titanic
diff --git a/engines/titanic/sound/music_wave.h b/engines/titanic/sound/music_wave.h
index b65363c..0e46965 100644
--- a/engines/titanic/sound/music_wave.h
+++ b/engines/titanic/sound/music_wave.h
@@ -108,6 +108,7 @@ public:
 	void setState(int val);
 
 	int setData(const byte *data, int count);
+	void fn1(int val1, int val2);
 };
 
 } // End of namespace Titanic





More information about the Scummvm-git-logs mailing list