aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2017-02-04 20:55:11 -0500
committerPaul Gilbert2017-02-04 20:55:11 -0500
commitb0b534e4a008c0ea38eff559a2f579eba5f8ab01 (patch)
tree3dd6345b3667560eefed5ac50b7a6e9c8942e3a5 /engines/titanic
parentc31efeb8c7279d83e417d33705eeb50046ccef71 (diff)
downloadscummvm-rg350-b0b534e4a008c0ea38eff559a2f579eba5f8ab01.tar.gz
scummvm-rg350-b0b534e4a008c0ea38eff559a2f579eba5f8ab01.tar.bz2
scummvm-rg350-b0b534e4a008c0ea38eff559a2f579eba5f8ab01.zip
TITANIC: Implemented CMusicWave fn2
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/sound/music_wave.cpp30
-rw-r--r--engines/titanic/sound/music_wave.h4
2 files changed, 33 insertions, 1 deletions
diff --git a/engines/titanic/sound/music_wave.cpp b/engines/titanic/sound/music_wave.cpp
index e000356a90..1d6642adc9 100644
--- a/engines/titanic/sound/music_wave.cpp
+++ b/engines/titanic/sound/music_wave.cpp
@@ -31,16 +31,21 @@ bool CMusicWave::_pianoToggle;
int CMusicWave::_pianoCtr;
int CMusicWave::_bassCtr;
byte *CMusicWave::_buffer;
+double *CMusicWave::_array;
+int CMusicWave::_arrayIndex;
void CMusicWave::init() {
_pianoToggle = false;
_pianoCtr = 0;
_bassCtr = 0;
_buffer = nullptr;
+ _array = nullptr;
+ _arrayIndex = 0;
}
void CMusicWave::deinit() {
delete[] _buffer;
+ delete[] _array;
_buffer = nullptr;
}
@@ -268,8 +273,31 @@ int CMusicWave::setData(const byte *data, int count) {
return 0;
}
-void CMusicWave::fn1(int val1, int val2) {
+void CMusicWave::fn1(int minVal, int maxVal) {
// TODO
}
+void CMusicWave::fn2(int minVal, int maxVal) {
+ delete[] _array;
+
+ // TODO: Figure out if the weird shift can be represented as a simpler equation
+ uint32 arrSize = ((uint32)minVal << 29) - (uint32)minVal + maxVal;
+ _array = new double[arrSize / 8];
+ _arrayIndex = maxVal;
+
+ _array[_arrayIndex] = 1.0;
+
+ double val = 1.0594634;
+ for (int idx = 1; idx <= maxVal; ++idx) {
+ val *= 1.0594634;
+ _array[_arrayIndex + idx] = val;
+ }
+
+ val = 0.94387404038686;
+ for (int idx = -1; idx >= minVal; --idx) {
+ val *= 0.94387404038686;
+ _array[_arrayIndex + idx] = val;
+ }
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/sound/music_wave.h b/engines/titanic/sound/music_wave.h
index 0e46965bdf..6dea734cb1 100644
--- a/engines/titanic/sound/music_wave.h
+++ b/engines/titanic/sound/music_wave.h
@@ -46,6 +46,8 @@ private:
static int _pianoCtr;
static int _bassCtr;
static byte *_buffer;
+ static double *_array;
+ static int _arrayIndex;
private:
CSoundManager *_soundManager;
Common::Array<CMusicWaveFile> _items;
@@ -63,6 +65,8 @@ private:
* Loads the specified wave file, and returns a CWaveFile instance for it
*/
CWaveFile *createWaveFile(const CString &name);
+
+ void fn2(int val1, int val2);
public:
double _floatVal;
public: