diff options
author | Colin Snover | 2016-07-03 17:57:58 -0500 |
---|---|---|
committer | Colin Snover | 2016-08-19 14:08:22 -0500 |
commit | 0f2748b15a630f9d12ff0511d4e4cde79b8e915f (patch) | |
tree | 28044c339c74b76bb963af54f382dcd5530e40de /engines/sci/sound/decoders | |
parent | 7da359755d31b6a5a98fc791f795139441c82b56 (diff) | |
download | scummvm-rg350-0f2748b15a630f9d12ff0511d4e4cde79b8e915f.tar.gz scummvm-rg350-0f2748b15a630f9d12ff0511d4e4cde79b8e915f.tar.bz2 scummvm-rg350-0f2748b15a630f9d12ff0511d4e4cde79b8e915f.zip |
SCI32: Implement kRobot
Diffstat (limited to 'engines/sci/sound/decoders')
-rw-r--r-- | engines/sci/sound/decoders/sol.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/engines/sci/sound/decoders/sol.cpp b/engines/sci/sound/decoders/sol.cpp index e445403120..ee1ba35406 100644 --- a/engines/sci/sound/decoders/sol.cpp +++ b/engines/sci/sound/decoders/sol.cpp @@ -21,6 +21,7 @@ */ #include "audio/audiostream.h" +#include "audio/rate.h" #include "audio/decoders/raw.h" #include "common/substream.h" #include "common/util.h" @@ -52,7 +53,7 @@ static const byte tableDPCM8[8] = { 0, 1, 2, 3, 6, 10, 15, 21 }; * Decompresses 16-bit DPCM compressed audio. Each byte read * outputs one sample into the decompression buffer. */ -static void deDPCM16(int16 *out, Common::ReadStream &audioStream, uint32 numBytes, int16 &sample) { +static void deDPCM16(int16 *out, Common::ReadStream &audioStream, const uint32 numBytes, int16 &sample) { for (uint32 i = 0; i < numBytes; ++i) { const uint8 delta = audioStream.readByte(); if (delta & 0x80) { @@ -65,6 +66,19 @@ static void deDPCM16(int16 *out, Common::ReadStream &audioStream, uint32 numByte } } +void deDPCM16(int16 *out, const byte *in, const uint32 numBytes, int16 &sample) { + for (uint32 i = 0; i < numBytes; ++i) { + const uint8 delta = *in++; + if (delta & 0x80) { + sample -= tableDPCM16[delta & 0x7f]; + } else { + sample += tableDPCM16[delta]; + } + sample = CLIP<int16>(sample, -32768, 32767); + *out++ = TO_LE_16(sample); + } +} + /** * Decompresses one half of an 8-bit DPCM compressed audio * byte. @@ -178,7 +192,7 @@ int SOLStream<STEREO, S16BIT>::getRate() const { template <bool STEREO, bool S16BIT> bool SOLStream<STEREO, S16BIT>::endOfData() const { - return _stream->eos() || _stream->pos() >= _dataOffset + _rawDataSize; + return _stream->eos() || _stream->pos() >= _rawDataSize; } template <bool STEREO, bool S16BIT> @@ -269,5 +283,4 @@ Audio::SeekableAudioStream *makeSOLStream(Common::SeekableReadStream *headerStre return Audio::makeRawStream(dataStream, sampleRate, rawFlags, disposeAfterUse); } - } |