WAGE: Implement sound decoder

This commit is contained in:
Eugene Sandulenko 2016-02-16 21:41:02 +01:00
parent 57449d32d4
commit 7bbe1a94c1
2 changed files with 28 additions and 3 deletions

View File

@ -45,10 +45,35 @@
*
*/
#include "common/stream.h"
#include "wage/wage.h"
#include "wage/sound.h"
namespace Wage {
static const int8 deltas[] = { 0,-49,-36,-25,-16,-9,-4,-1,0,1,4,9,16,25,36,49 };
Sound::Sound(Common::String name, Common::SeekableReadStream *data) : _name(name) {
int size = data->size() - 20;
_data = (byte *)calloc(2 * size, 1);
data->skip(20); // Skip header
byte value = 0x80;
for (int i = 0; i < size; i++) {
byte d = data->readByte();
value += deltas[d & 0xf];
_data[i * 2] = value;
value += deltas[(d >> 4) & 0xf];
_data[i * 2 + 1] = value;
}
}
Sound::~Sound() {
free(_data);
}
void WageEngine::playSound(Common::String soundName) {
warning("STUB: WageEngine::playSound(%s)", soundName.c_str());
}

View File

@ -52,11 +52,11 @@ namespace Wage {
class Sound {
public:
Sound(Common::String name, Common::SeekableReadStream *data) : _name(name), _data(data) {}
~Sound() { }
Sound(Common::String name, Common::SeekableReadStream *data);
~Sound();
Common::String _name;
Common::SeekableReadStream *_data;
byte *_data;
};
} // End of namespace Wage