TITANIC: Implemented CMusicWave fn2

This commit is contained in:
Paul Gilbert 2017-02-04 20:55:11 -05:00
parent c31efeb8c7
commit b0b534e4a0
2 changed files with 33 additions and 1 deletions

View File

@ -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

View File

@ -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: