aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/sound
diff options
context:
space:
mode:
authorPaul Gilbert2017-02-04 18:43:24 -0500
committerPaul Gilbert2017-02-04 18:43:24 -0500
commitb005198eb15c15450a67842f8e8b936c3a0d08a6 (patch)
treefcf2d81aa8299828d4a1dfa86cb973fc72eb2ec9 /engines/titanic/sound
parent29ad5a0a49d2d974616bc0f42bfe26db28a9d80b (diff)
downloadscummvm-rg350-b005198eb15c15450a67842f8e8b936c3a0d08a6.tar.gz
scummvm-rg350-b005198eb15c15450a67842f8e8b936c3a0d08a6.tar.bz2
scummvm-rg350-b005198eb15c15450a67842f8e8b936c3a0d08a6.zip
TITANIC: Implemented remainder of CMusicRoomHandler code
Diffstat (limited to 'engines/titanic/sound')
-rw-r--r--engines/titanic/sound/music_room_handler.cpp56
-rw-r--r--engines/titanic/sound/music_room_handler.h4
-rw-r--r--engines/titanic/sound/music_wave.cpp4
-rw-r--r--engines/titanic/sound/music_wave.h1
4 files changed, 56 insertions, 9 deletions
diff --git a/engines/titanic/sound/music_room_handler.cpp b/engines/titanic/sound/music_room_handler.cpp
index ea1aaf2b78..ad7105bd63 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 dd8b62efe1..5f615ccd84 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 cbb4fbf3d6..e000356a90 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 b65363cef3..0e46965bdf 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