aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2016-02-16 21:41:02 +0100
committerEugene Sandulenko2016-02-16 21:41:41 +0100
commit7bbe1a94c10f8e8f79e25434157469b39db8cc35 (patch)
tree7f5769ba5b9e002422094bcaaf2031ca243ead23 /engines
parent57449d32d423f8bd3ea57b306c2a4dcdae4843f1 (diff)
downloadscummvm-rg350-7bbe1a94c10f8e8f79e25434157469b39db8cc35.tar.gz
scummvm-rg350-7bbe1a94c10f8e8f79e25434157469b39db8cc35.tar.bz2
scummvm-rg350-7bbe1a94c10f8e8f79e25434157469b39db8cc35.zip
WAGE: Implement sound decoder
Diffstat (limited to 'engines')
-rw-r--r--engines/wage/sound.cpp25
-rw-r--r--engines/wage/sound.h6
2 files changed, 28 insertions, 3 deletions
diff --git a/engines/wage/sound.cpp b/engines/wage/sound.cpp
index 003555069d..bcb274cab9 100644
--- a/engines/wage/sound.cpp
+++ b/engines/wage/sound.cpp
@@ -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());
}
diff --git a/engines/wage/sound.h b/engines/wage/sound.h
index 76d9202aeb..eccfe33170 100644
--- a/engines/wage/sound.h
+++ b/engines/wage/sound.h
@@ -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