aboutsummaryrefslogtreecommitdiff
path: root/engines/lastexpress/data
diff options
context:
space:
mode:
Diffstat (limited to 'engines/lastexpress/data')
-rw-r--r--engines/lastexpress/data/animation.cpp12
-rw-r--r--engines/lastexpress/data/background.cpp2
-rw-r--r--engines/lastexpress/data/font.cpp8
-rw-r--r--engines/lastexpress/data/scene.cpp8
-rw-r--r--engines/lastexpress/data/sequence.cpp14
-rw-r--r--engines/lastexpress/data/snd.cpp396
-rw-r--r--engines/lastexpress/data/snd.h14
-rw-r--r--engines/lastexpress/data/subtitle.cpp4
8 files changed, 418 insertions, 40 deletions
diff --git a/engines/lastexpress/data/animation.cpp b/engines/lastexpress/data/animation.cpp
index 1cbf7672d1..28d30ec7d1 100644
--- a/engines/lastexpress/data/animation.cpp
+++ b/engines/lastexpress/data/animation.cpp
@@ -77,7 +77,7 @@ bool Animation::load(Common::SeekableReadStream *stream, int flag) {
// Check if there is enough data
if (_stream->size() - _stream->pos() < (signed)(numChunks * sizeof(Chunk))) {
- debugC(2, kLastExpressDebugGraphics, "NIS file seems to be corrupted!");
+ debugC(2, kLastExpressDebugGraphics, "NIS file seems to be corrupted");
return false;
}
@@ -101,10 +101,10 @@ bool Animation::load(Common::SeekableReadStream *stream, int flag) {
bool Animation::process() {
if (!_currentChunk)
- error("Animation::process - internal error: the current chunk iterator is invalid!");
+ error("[Animation::process] Current chunk iterator is invalid");
if (_stream == NULL || _chunks.size() == 0)
- error("Trying to show an animation before loading data");
+ error("[Animation::process] Trying to show an animation before loading data");
// TODO: - subtract the time paused by the GUI
// - Re-implement to be closer to the original engine
@@ -191,7 +191,7 @@ bool Animation::process() {
break;
default:
- error(" UNKNOWN chunk type=%x frame=%d size=%d", _currentChunk->type, _currentChunk->frame, _currentChunk->size);
+ error("[Animation::process] UNKNOWN chunk type=%x frame=%d size=%d", _currentChunk->type, _currentChunk->frame, _currentChunk->size);
break;
}
_currentChunk++;
@@ -206,7 +206,7 @@ bool Animation::hasEnded() {
Common::Rect Animation::draw(Graphics::Surface *surface) {
if (!_overlay)
- error("Animation::draw - internal error: the current overlay animation frame is invalid!");
+ error("[Animation::draw] Current overlay animation frame is invalid");
// Paint the background
if (_backgroundCurrent == 1 && _background1)
@@ -242,7 +242,7 @@ AnimFrame *Animation::processChunkFrame(Common::SeekableReadStream *in, const Ch
void Animation::processChunkAudio(Common::SeekableReadStream *in, const Chunk &c) {
if (!_audio)
- error("Animation::processChunkAudio - internal error: the audio stream is invalid!");
+ error("[Animation::processChunkAudio] Audio stream is invalid");
// Skip the Snd header, to queue just the audio blocks
uint32 size = c.size;
diff --git a/engines/lastexpress/data/background.cpp b/engines/lastexpress/data/background.cpp
index de6fd7eeae..3d866c26f9 100644
--- a/engines/lastexpress/data/background.cpp
+++ b/engines/lastexpress/data/background.cpp
@@ -85,7 +85,7 @@ bool Background::load(Common::SeekableReadStream *stream) {
Common::Rect Background::draw(Graphics::Surface *surface) {
if (!_data) {
- debugC(2, kLastExpressDebugGraphics, "Trying to show a background before loading data!");
+ debugC(2, kLastExpressDebugGraphics, "Trying to show a background before loading data");
return Common::Rect();
}
diff --git a/engines/lastexpress/data/font.cpp b/engines/lastexpress/data/font.cpp
index 9a60b88a25..79cf64e617 100644
--- a/engines/lastexpress/data/font.cpp
+++ b/engines/lastexpress/data/font.cpp
@@ -89,17 +89,17 @@ bool Font::load(Common::SeekableReadStream *stream) {
uint16 Font::getCharGlyph(uint16 c) const {
//warning("%c", c);
if (c >= 0x200)
- error("Express::Font: Invalid character %d", c);
+ error("[Font::getCharGlyph] Invalid character %d", c);
return _charMap[c];
}
byte *Font::getGlyphImg(uint16 g) {
if (!_glyphs)
- error("Express::getGlyphImg: Invalid glyphs!");
+ error("[Font::getGlyphImg] Invalid glyphs");
if (g >= _numGlyphs)
- error("Express::getGlyphImg: Invalid glyph %d (%d available)", g, _numGlyphs);
+ error("[Font::getGlyphImg] Invalid glyph %d (%d available)", g, _numGlyphs);
return _glyphs + g * 18 * 8;
}
@@ -140,7 +140,7 @@ uint8 Font::getCharWidth(uint16 c) const{
return 10;
} else {
if (!_glyphWidths)
- error("Express::getCharWidth: Invalid glyphs widths!");
+ error("[Font::getCharWidth] Invalid glyphs widths");
return _glyphWidths[getCharGlyph(c)];
}
diff --git a/engines/lastexpress/data/scene.cpp b/engines/lastexpress/data/scene.cpp
index 2ec8e6935d..8f279ffbb3 100644
--- a/engines/lastexpress/data/scene.cpp
+++ b/engines/lastexpress/data/scene.cpp
@@ -187,10 +187,10 @@ bool Scene::checkHotSpot(const Common::Point &coord, SceneHotspot **hotspot) {
SceneHotspot *Scene::getHotspot(uint index) {
if (_hotspots.empty())
- error("Scene::getHotspot: scene does not have any hotspots!");
+ error("[Scene::getHotspot] Scene does not have any hotspots");
if (index >= _hotspots.size())
- error("Scene::getHotspot: invalid index (was: %d, max: %d)", index, _hotspots.size() - 1);
+ error("[Scene::getHotspot] Invalid index (was: %d, max: %d)", index, _hotspots.size() - 1);
return _hotspots[index];
}
@@ -202,7 +202,7 @@ Common::Rect Scene::draw(Graphics::Surface *surface) {
Common::String sceneName(_name);
sceneName.trim();
if (sceneName.empty())
- error("Scene::draw: This scene is not a valid drawing scene!");
+ error("[Scene::draw] This scene is not a valid drawing scene");
// Load background
Background *background = ((LastExpressEngine *)g_engine)->getResourceManager()->loadBackground(sceneName);
@@ -260,7 +260,7 @@ bool SceneLoader::load(Common::SeekableReadStream *stream) {
// Read the default scene to get the total number of scenes
Scene *header = Scene::load(_stream);
if (!header)
- error("SceneLoader::load: Invalid data file!");
+ error("[SceneLoader::load] Invalid data file");
debugC(2, kLastExpressDebugScenes, " found %d entries", header->entityPosition); /* Header entityPosition is the scene count */
diff --git a/engines/lastexpress/data/sequence.cpp b/engines/lastexpress/data/sequence.cpp
index a27c27de2e..a62348f6c0 100644
--- a/engines/lastexpress/data/sequence.cpp
+++ b/engines/lastexpress/data/sequence.cpp
@@ -115,7 +115,7 @@ AnimFrame::AnimFrame(Common::SeekableReadStream *in, const FrameInfo &f) : _pale
decompFF(in, f);
break;
default:
- error("Unknown frame compression: %d", f.compressionType);
+ error("[AnimFrame::AnimFrame] Unknown frame compression: %d", f.compressionType);
}
readPalette(in, f);
@@ -379,11 +379,11 @@ bool Sequence::load(Common::SeekableReadStream *stream, byte field30) {
// Move stream to start of frame
_stream->seek((int32)(_sequenceHeaderSize + i * _sequenceFrameSize), SEEK_SET);
if (_stream->eos())
- error("Couldn't seek to the current frame data");
+ error("[Sequence::load] Couldn't seek to the current frame data");
// Check if there is enough data
if ((unsigned)(_stream->size() - _stream->pos()) < _sequenceFrameSize)
- error("The sequence frame does not have a valid header");
+ error("[Sequence::load] The sequence frame does not have a valid header");
FrameInfo info;
info.read(_stream, true);
@@ -397,10 +397,10 @@ bool Sequence::load(Common::SeekableReadStream *stream, byte field30) {
FrameInfo *Sequence::getFrameInfo(uint16 index) {
if (_frames.size() == 0)
- error("Trying to decode a sequence before loading its data");
+ error("[Sequence::getFrameInfo] Trying to decode a sequence before loading its data");
if (index > _frames.size() - 1)
- error("Invalid sequence frame requested: %d, max %d", index, _frames.size() - 1);
+ error("[Sequence::getFrameInfo] Invalid sequence frame requested: %d, max %d", index, _frames.size() - 1);
return &_frames[index];
}
@@ -463,14 +463,14 @@ bool SequenceFrame::nextFrame() {
FrameInfo *SequenceFrame::getInfo() {
if (!_sequence)
- error("SequenceFrame::getFrameInfo: Invalid sequence!");
+ error("[SequenceFrame::getInfo] Invalid sequence");
return _sequence->getFrameInfo(_frame);
}
Common::String SequenceFrame::getName() {
if (!_sequence)
- error("SequenceFrame::getName: Invalid sequence!");
+ error("[SequenceFrame::getName] Invalid sequence");
return _sequence->getName();
}
diff --git a/engines/lastexpress/data/snd.cpp b/engines/lastexpress/data/snd.cpp
index 3ffe3ca14b..6845be8808 100644
--- a/engines/lastexpress/data/snd.cpp
+++ b/engines/lastexpress/data/snd.cpp
@@ -36,16 +36,336 @@
namespace LastExpress {
+#pragma region Sound filters tables
+
+static const int stepTable[1424] = {
+ 0, 0, 0, 0, 128, 256, 384, 512, 0, 0, 0, 0, 128, 256,
+ 384, 512, 0, 0, 0, 0, 192, 320, 448, 576, 0, 0, 0, 0,
+ 192, 320, 448, 576, 64, 64, 64, 64, 256, 384, 512, 640,
+ 64, 64, 64, 64, 256, 384, 512, 640, 128, 128, 128, 128,
+ 320, 448, 576, 704, 128, 128, 128, 128, 320, 448, 576,
+ 704, 192, 192, 192, 192, 384, 512, 640, 768, 192, 192,
+ 192, 192, 384, 512, 640, 768, 256, 256, 256, 256, 448,
+ 576, 704, 832, 256, 256, 256, 256, 448, 576, 704, 832,
+ 320, 320, 320, 320, 512, 640, 768, 896, 320, 320, 320,
+ 320, 512, 640, 768, 896, 384, 384, 384, 384, 576, 704,
+ 832, 960, 384, 384, 384, 384, 576, 704, 832, 960, 448,
+ 448, 448, 448, 640, 768, 896, 1024, 448, 448, 448, 448,
+ 640, 768, 896, 1024, 512, 512, 512, 512, 704, 832, 960,
+ 1088, 512, 512, 512, 512, 704, 832, 960, 1088, 576,
+ 576, 576, 576, 768, 896, 1024, 1152, 576, 576, 576,
+ 576, 768, 896, 1024, 1152, 640, 640, 640, 640, 832,
+ 960, 1088, 1216, 640, 640, 640, 640, 832, 960, 1088,
+ 1216, 704, 704, 704, 704, 896, 1024, 1152, 1280, 704,
+ 704, 704, 704, 896, 1024, 1152, 1280, 768, 768, 768,
+ 768, 960, 1088, 1216, 1344, 768, 768, 768, 768, 960,
+ 1088, 1216, 1344, 832, 832, 832, 832, 1024, 1152, 1280,
+ 1408, 832, 832, 832, 832, 1024, 1152, 1280, 1408, 896,
+ 896, 896, 896, 1088, 1216, 1344, 1472, 896, 896, 896,
+ 896, 1088, 1216, 1344, 1472, 960, 960, 960, 960, 1152,
+ 1280, 1408, 1536, 960, 960, 960, 960, 1152, 1280, 1408,
+ 1536, 1024, 1024, 1024, 1024, 1216, 1344, 1472, 1600,
+ 1024, 1024, 1024, 1024, 1216, 1344, 1472, 1600, 1088,
+ 1088, 1088, 1088, 1280, 1408, 1536, 1664, 1088, 1088,
+ 1088, 1088, 1280, 1408, 1536, 1664, 1152, 1152, 1152,
+ 1152, 1344, 1472, 1600, 1728, 1152, 1152, 1152, 1152,
+ 1344, 1472, 1600, 1728, 1216, 1216, 1216, 1216, 1408,
+ 1536, 1664, 1792, 1216, 1216, 1216, 1216, 1408, 1536,
+ 1664, 1792, 1280, 1280, 1280, 1280, 1472, 1600, 1728,
+ 1856, 1280, 1280, 1280, 1280, 1472, 1600, 1728, 1856,
+ 1344, 1344, 1344, 1344, 1536, 1664, 1792, 1920, 1344,
+ 1344, 1344, 1344, 1536, 1664, 1792, 1920, 1408, 1408,
+ 1408, 1408, 1600, 1728, 1856, 1984, 1408, 1408, 1408,
+ 1408, 1600, 1728, 1856, 1984, 1472, 1472, 1472, 1472,
+ 1664, 1792, 1920, 2048, 1472, 1472, 1472, 1472, 1664,
+ 1792, 1920, 2048, 1536, 1536, 1536, 1536, 1728, 1856,
+ 1984, 2112, 1536, 1536, 1536, 1536, 1728, 1856, 1984,
+ 2112, 1600, 1600, 1600, 1600, 1792, 1920, 2048, 2176,
+ 1600, 1600, 1600, 1600, 1792, 1920, 2048, 2176, 1664,
+ 1664, 1664, 1664, 1856, 1984, 2112, 2240, 1664, 1664,
+ 1664, 1664, 1856, 1984, 2112, 2240, 1728, 1728, 1728,
+ 1728, 1920, 2048, 2176, 2304, 1728, 1728, 1728, 1728,
+ 1920, 2048, 2176, 2304, 1792, 1792, 1792, 1792, 1984,
+ 2112, 2240, 2368, 1792, 1792, 1792, 1792, 1984, 2112,
+ 2240, 2368, 1856, 1856, 1856, 1856, 2048, 2176, 2304,
+ 2432, 1856, 1856, 1856, 1856, 2048, 2176, 2304, 2432,
+ 1920, 1920, 1920, 1920, 2112, 2240, 2368, 2496, 1920,
+ 1920, 1920, 1920, 2112, 2240, 2368, 2496, 1984, 1984,
+ 1984, 1984, 2176, 2304, 2432, 2560, 1984, 1984, 1984,
+ 1984, 2176, 2304, 2432, 2560, 2048, 2048, 2048, 2048,
+ 2240, 2368, 2496, 2624, 2048, 2048, 2048, 2048, 2240,
+ 2368, 2496, 2624, 2112, 2112, 2112, 2112, 2304, 2432,
+ 2560, 2688, 2112, 2112, 2112, 2112, 2304, 2432, 2560,
+ 2688, 2176, 2176, 2176, 2176, 2368, 2496, 2624, 2752,
+ 2176, 2176, 2176, 2176, 2368, 2496, 2624, 2752, 2240,
+ 2240, 2240, 2240, 2432, 2560, 2688, 2816, 2240, 2240,
+ 2240, 2240, 2432, 2560, 2688, 2816, 2304, 2304, 2304,
+ 2304, 2496, 2624, 2752, 2880, 2304, 2304, 2304, 2304,
+ 2496, 2624, 2752, 2880, 2368, 2368, 2368, 2368, 2560,
+ 2688, 2816, 2944, 2368, 2368, 2368, 2368, 2560, 2688,
+ 2816, 2944, 2432, 2432, 2432, 2432, 2624, 2752, 2880,
+ 3008, 2432, 2432, 2432, 2432, 2624, 2752, 2880, 3008,
+ 2496, 2496, 2496, 2496, 2688, 2816, 2944, 3072, 2496,
+ 2496, 2496, 2496, 2688, 2816, 2944, 3072, 2560, 2560,
+ 2560, 2560, 2752, 2880, 3008, 3136, 2560, 2560, 2560,
+ 2560, 2752, 2880, 3008, 3136, 2624, 2624, 2624, 2624,
+ 2816, 2944, 3072, 3200, 2624, 2624, 2624, 2624, 2816,
+ 2944, 3072, 3200, 2688, 2688, 2688, 2688, 2880, 3008,
+ 3136, 3264, 2688, 2688, 2688, 2688, 2880, 3008, 3136,
+ 3264, 2752, 2752, 2752, 2752, 2944, 3072, 3200, 3328,
+ 2752, 2752, 2752, 2752, 2944, 3072, 3200, 3328, 2816,
+ 2816, 2816, 2816, 3008, 3136, 3264, 3392, 2816, 2816,
+ 2816, 2816, 3008, 3136, 3264, 3392, 2880, 2880, 2880,
+ 2880, 3072, 3200, 3328, 3456, 2880, 2880, 2880, 2880,
+ 3072, 3200, 3328, 3456, 2944, 2944, 2944, 2944, 3136,
+ 3264, 3392, 3520, 2944, 2944, 2944, 2944, 3136, 3264,
+ 3392, 3520, 3008, 3008, 3008, 3008, 3200, 3328, 3456,
+ 3584, 3008, 3008, 3008, 3008, 3200, 3328, 3456, 3584,
+ 3072, 3072, 3072, 3072, 3264, 3392, 3520, 3648, 3072,
+ 3072, 3072, 3072, 3264, 3392, 3520, 3648, 3136, 3136,
+ 3136, 3136, 3328, 3456, 3584, 3712, 3136, 3136, 3136,
+ 3136, 3328, 3456, 3584, 3712, 3200, 3200, 3200, 3200,
+ 3392, 3520, 3648, 3776, 3200, 3200, 3200, 3200, 3392,
+ 3520, 3648, 3776, 3264, 3264, 3264, 3264, 3456, 3584,
+ 3712, 3840, 3264, 3264, 3264, 3264, 3456, 3584, 3712,
+ 3840, 3328, 3328, 3328, 3328, 3520, 3648, 3776, 3904,
+ 3328, 3328, 3328, 3328, 3520, 3648, 3776, 3904, 3392,
+ 3392, 3392, 3392, 3584, 3712, 3840, 3968, 3392, 3392,
+ 3392, 3392, 3584, 3712, 3840, 3968, 3456, 3456, 3456,
+ 3456, 3648, 3776, 3904, 4032, 3456, 3456, 3456, 3456,
+ 3648, 3776, 3904, 4032, 3520, 3520, 3520, 3520, 3712,
+ 3840, 3968, 4096, 3520, 3520, 3520, 3520, 3712, 3840,
+ 3968, 4096, 3584, 3584, 3584, 3584, 3776, 3904, 4032,
+ 4160, 3584, 3584, 3584, 3584, 3776, 3904, 4032, 4160,
+ 3648, 3648, 3648, 3648, 3840, 3968, 4096, 4224, 3648,
+ 3648, 3648, 3648, 3840, 3968, 4096, 4224, 3712, 3712,
+ 3712, 3712, 3904, 4032, 4160, 4288, 3712, 3712, 3712,
+ 3712, 3904, 4032, 4160, 4288, 3776, 3776, 3776, 3776,
+ 3968, 4096, 4224, 4352, 3776, 3776, 3776, 3776, 3968,
+ 4096, 4224, 4352, 3840, 3840, 3840, 3840, 4032, 4160,
+ 4288, 4416, 3840, 3840, 3840, 3840, 4032, 4160, 4288,
+ 4416, 3904, 3904, 3904, 3904, 4096, 4224, 4352, 4480,
+ 3904, 3904, 3904, 3904, 4096, 4224, 4352, 4480, 3968,
+ 3968, 3968, 3968, 4160, 4288, 4416, 4544, 3968, 3968,
+ 3968, 3968, 4160, 4288, 4416, 4544, 4032, 4032, 4032,
+ 4032, 4224, 4352, 4480, 4608, 4032, 4032, 4032, 4032,
+ 4224, 4352, 4480, 4608, 4096, 4096, 4096, 4096, 4288,
+ 4416, 4544, 4672, 4096, 4096, 4096, 4096, 4288, 4416,
+ 4544, 4672, 4160, 4160, 4160, 4160, 4352, 4480, 4608,
+ 4736, 4160, 4160, 4160, 4160, 4352, 4480, 4608, 4736,
+ 4224, 4224, 4224, 4224, 4416, 4544, 4672, 4800, 4224,
+ 4224, 4224, 4224, 4416, 4544, 4672, 4800, 4288, 4288,
+ 4288, 4288, 4480, 4608, 4736, 4864, 4288, 4288, 4288,
+ 4288, 4480, 4608, 4736, 4864, 4352, 4352, 4352, 4352,
+ 4544, 4672, 4800, 4928, 4352, 4352, 4352, 4352, 4544,
+ 4672, 4800, 4928, 4416, 4416, 4416, 4416, 4608, 4736,
+ 4864, 4992, 4416, 4416, 4416, 4416, 4608, 4736, 4864,
+ 4992, 4480, 4480, 4480, 4480, 4672, 4800, 4928, 5056,
+ 4480, 4480, 4480, 4480, 4672, 4800, 4928, 5056, 4544,
+ 4544, 4544, 4544, 4736, 4864, 4992, 5120, 4544, 4544,
+ 4544, 4544, 4736, 4864, 4992, 5120, 4608, 4608, 4608,
+ 4608, 4800, 4928, 5056, 5184, 4608, 4608, 4608, 4608,
+ 4800, 4928, 5056, 5184, 4672, 4672, 4672, 4672, 4864,
+ 4992, 5120, 5248, 4672, 4672, 4672, 4672, 4864, 4992,
+ 5120, 5248, 4736, 4736, 4736, 4736, 4928, 5056, 5184,
+ 5312, 4736, 4736, 4736, 4736, 4928, 5056, 5184, 5312,
+ 4800, 4800, 4800, 4800, 4992, 5120, 5248, 5376, 4800,
+ 4800, 4800, 4800, 4992, 5120, 5248, 5376, 4864, 4864,
+ 4864, 4864, 5056, 5184, 5312, 5440, 4864, 4864, 4864,
+ 4864, 5056, 5184, 5312, 5440, 4928, 4928, 4928, 4928,
+ 5120, 5248, 5376, 5504, 4928, 4928, 4928, 4928, 5120,
+ 5248, 5376, 5504, 4992, 4992, 4992, 4992, 5184, 5312,
+ 5440, 5568, 4992, 4992, 4992, 4992, 5184, 5312, 5440,
+ 5568, 5056, 5056, 5056, 5056, 5248, 5376, 5504, 5632,
+ 5056, 5056, 5056, 5056, 5248, 5376, 5504, 5632, 5120,
+ 5120, 5120, 5120, 5312, 5440, 5568, 5632, 5120, 5120,
+ 5120, 5120, 5312, 5440, 5568, 5632, 5184, 5184, 5184,
+ 5184, 5376, 5504, 5632, 5632, 5184, 5184, 5184, 5184,
+ 5376, 5504, 5632, 5632, 5248, 5248, 5248, 5248, 5440,
+ 5568, 5632, 5632, 5248, 5248, 5248, 5248, 5440, 5568,
+ 5632, 5632, 5312, 5312, 5312, 5312, 5504, 5632, 5632,
+ 5632, 5312, 5312, 5312, 5312, 5504, 5632, 5632, 5632,
+ 5376, 5376, 5376, 5376, 5568, 5632, 5632, 5632, 5376,
+ 5376, 5376, 5376, 5568, 5632, 5632, 5632, 5440, 5440,
+ 5440, 5440, 5632, 5632, 5632, 5632, 5440, 5440, 5440,
+ 5440, 5632, 5632, 5632, 5632, 5504, 5504, 5504, 5504,
+ 5632, 5632, 5632, 5632, 5504, 5504, 5504, 5504, 5632,
+ 5632, 5632, 5632, 5568, 5568, 5568, 5568, 5632, 5632,
+ 5632, 5632, 5568, 5568, 5568, 5568, 5632, 5632, 5632,
+ 5632
+};
+
+static const int imaTable[1424] = {
+ 0, 2, 4, 6, 7, 9, 11, 13, 0, -2, -4, -6, -7, -9, -11,
+ -13, 1, 3, 5, 7, 9, 11, 13, 15, -1, -3, -5, -7, -9,
+ -11, -13, -15, 1, 3, 5, 7, 10, 12, 14, 16, -1, -3, -5,
+ -7, -10, -12, -14, -16, 1, 3, 6, 8, 11, 13, 16, 18,
+ -1, -3, -6, -8, -11, -13, -16, -18, 1, 4, 6, 9, 12,
+ 15, 17, 20, -1, -4, -6, -9, -12, -15, -17, -20, 1, 4,
+ 7, 10, 13, 16, 19, 22, -1, -4, -7, -10, -13, -16, -19,
+ -22, 1, 4, 8, 11, 14, 17, 21, 24, -1, -4, -8, -11, -14,
+ -17, -21, -24, 1, 5, 8, 12, 15, 19, 22, 26, -1, -5,
+ -8, -12, -15, -19, -22, -26, 2, 6, 10, 14, 18, 22, 26,
+ 30, -2, -6, -10, -14, -18, -22, -26, -30, 2, 6, 10,
+ 14, 19, 23, 27, 31, -2, -6, -10, -14, -19, -23, -27,
+ -31, 2, 7, 11, 16, 21, 26, 30, 35, -2, -7, -11, -16,
+ -21, -26, -30, -35, 2, 7, 13, 18, 23, 28, 34, 39, -2,
+ -7, -13, -18, -23, -28, -34, -39, 2, 8, 14, 20, 25,
+ 31, 37, 43, -2, -8, -14, -20, -25, -31, -37, -43, 3,
+ 9, 15, 21, 28, 34, 40, 46, -3, -9, -15, -21, -28, -34,
+ -40, -46, 3, 10, 17, 24, 31, 38, 45, 52, -3, -10, -17,
+ -24, -31, -38, -45, -52, 3, 11, 19, 27, 34, 42, 50,
+ 58, -3, -11, -19, -27, -34, -42, -50, -58, 4, 12, 21,
+ 29, 38, 46, 55, 63, -4, -12, -21, -29, -38, -46, -55,
+ -63, 4, 13, 23, 32, 41, 50, 60, 69, -4, -13, -23, -32,
+ -41, -50, -60, -69, 5, 15, 25, 35, 46, 56, 66, 76, -5,
+ -15, -25, -35, -46, -56, -66, -76, 5, 16, 28, 39, 50,
+ 61, 73, 84, -5, -16, -28, -39, -50, -61, -73, -84, 6,
+ 18, 31, 43, 56, 68, 81, 93, -6, -18, -31, -43, -56,
+ -68, -81, -93, 6, 20, 34, 48, 61, 75, 89, 103, -6, -20,
+ -34, -48, -61, -75, -89, -103, 7, 22, 37, 52, 67, 82,
+ 97, 112, -7, -22, -37, -52, -67, -82, -97, -112, 8,
+ 24, 41, 57, 74, 90, 107, 123, -8, -24, -41, -57, -74,
+ -90, -107, -123, 9, 27, 45, 63, 82, 100, 118, 136, -9,
+ -27, -45, -63, -82, -100, -118, -136, 10, 30, 50, 70,
+ 90, 110, 130, 150, -10, -30, -50, -70, -90, -110, -130,
+ -150, 11, 33, 55, 77, 99, 121, 143, 165, -11, -33, -55,
+ -77, -99, -121, -143, -165, 12, 36, 60, 84, 109, 133,
+ 157, 181, -12, -36, -60, -84, -109, -133, -157, -181,
+ 13, 40, 66, 93, 120, 147, 173, 200, -13, -40, -66, -93,
+ -120, -147, -173, -200, 14, 44, 73, 103, 132, 162, 191,
+ 221, -14, -44, -73, -103, -132, -162, -191, -221, 16,
+ 48, 81, 113, 146, 178, 211, 243, -16, -48, -81, -113,
+ -146, -178, -211, -243, 17, 53, 89, 125, 160, 196, 232,
+ 268, -17, -53, -89, -125, -160, -196, -232, -268, 19,
+ 58, 98, 137, 176, 215, 255, 294, -19, -58, -98, -137,
+ -176, -215, -255, -294, 21, 64, 108, 151, 194, 237,
+ 281, 324, -21, -64, -108, -151, -194, -237, -281, -324,
+ 23, 71, 118, 166, 213, 261, 308, 356, -23, -71, -118,
+ -166, -213, -261, -308, -356, 26, 78, 130, 182, 235,
+ 287, 339, 391, -26, -78, -130, -182, -235, -287, -339,
+ -391, 28, 86, 143, 201, 258, 316, 373, 431, -28, -86,
+ -143, -201, -258, -316, -373, -431, 31, 94, 158, 221,
+ 284, 347, 411, 474, -31, -94, -158, -221, -284, -347,
+ -411, -474, 34, 104, 174, 244, 313, 383, 453, 523, -34,
+ -104, -174, -244, -313, -383, -453, -523, 38, 115, 191,
+ 268, 345, 422, 498, 575, -38, -115, -191, -268, -345,
+ -422, -498, -575, 42, 126, 210, 294, 379, 463, 547,
+ 631, -42, -126, -210, -294, -379, -463, -547, -631,
+ 46, 139, 231, 324, 417, 510, 602, 695, -46, -139, -231,
+ -324, -417, -510, -602, -695, 51, 153, 255, 357, 459,
+ 561, 663, 765, -51, -153, -255, -357, -459, -561, -663,
+ -765, 56, 168, 280, 392, 505, 617, 729, 841, -56, -168,
+ -280, -392, -505, -617, -729, -841, 61, 185, 308, 432,
+ 555, 679, 802, 926, -61, -185, -308, -432, -555, -679,
+ -802, -926, 68, 204, 340, 476, 612, 748, 884, 1020,
+ -68, -204, -340, -476, -612, -748, -884, -1020, 74,
+ 224, 373, 523, 672, 822, 971, 1121, -74, -224, -373,
+ -523, -672, -822, -971, -1121, 82, 246, 411, 575, 740,
+ 904, 1069, 1233, -82, -246, -411, -575, -740, -904,
+ -1069, -1233, 90, 271, 452, 633, 814, 995, 1176, 1357,
+ -90, -271, -452, -633, -814, -995, -1176, -1357, 99,
+ 298, 497, 696, 895, 1094, 1293, 1492, -99, -298, -497,
+ -696, -895, -1094, -1293, -1492, 109, 328, 547, 766,
+ 985, 1204, 1423, 1642, -109, -328, -547, -766, -985,
+ -1204, -1423, -1642, 120, 361, 601, 842, 1083, 1324,
+ 1564, 1805, -120, -361, -601, -842, -1083, -1324, -1564,
+ -1805, 132, 397, 662, 927, 1192, 1457, 1722, 1987, -132,
+ -397, -662, -927, -1192, -1457, -1722, -1987, 145, 437,
+ 728, 1020, 1311, 1603, 1894, 2186, -145, -437, -728,
+ -1020, -1311, -1603, -1894, -2186, 160, 480, 801, 1121,
+ 1442, 1762, 2083, 2403, -160, -480, -801, -1121, -1442,
+ -1762, -2083, -2403, 176, 529, 881, 1234, 1587, 1940,
+ 2292, 2645, -176, -529, -881, -1234, -1587, -1940, -2292,
+ -2645, 194, 582, 970, 1358, 1746, 2134, 2522, 2910,
+ -194, -582, -970, -1358, -1746, -2134, -2522, -2910,
+ 213, 640, 1066, 1493, 1920, 2347, 2773, 3200, -213,
+ -640, -1066, -1493, -1920, -2347, -2773, -3200, 234,
+ 704, 1173, 1643, 2112, 2582, 3051, 3521, -234, -704,
+ -1173, -1643, -2112, -2582, -3051, -3521, 258, 774,
+ 1291, 1807, 2324, 2840, 3357, 3873, -258, -774, -1291,
+ -1807, -2324, -2840, -3357, -3873, 284, 852, 1420, 1988,
+ 2556, 3124, 3692, 4260, -284, -852, -1420, -1988, -2556,
+ -3124, -3692, -4260, 312, 937, 1561, 2186, 2811, 3436,
+ 4060, 4685, -312, -937, -1561, -2186, -2811, -3436,
+ -4060, -4685, 343, 1030, 1718, 2405, 3092, 3779, 4467,
+ 5154, -343, -1030, -1718, -2405, -3092, -3779, -4467,
+ -5154, 378, 1134, 1890, 2646, 3402, 4158, 4914, 5670,
+ -378, -1134, -1890, -2646, -3402, -4158, -4914, -5670,
+ 415, 1247, 2079, 2911, 3742, 4574, 5406, 6238, -415,
+ -1247, -2079, -2911, -3742, -4574, -5406, -6238, 457,
+ 1372, 2287, 3202, 4117, 5032, 5947, 6862, -457, -1372,
+ -2287, -3202, -4117, -5032, -5947, -6862, 503, 1509,
+ 2516, 3522, 4529, 5535, 6542, 7548, -503, -1509, -2516,
+ -3522, -4529, -5535, -6542, -7548, 553, 1660, 2767,
+ 3874, 4981, 6088, 7195, 8302, -553, -1660, -2767, -3874,
+ -4981, -6088, -7195, -8302, 608, 1826, 3044, 4262, 5479,
+ 6697, 7915, 9133, -608, -1826, -3044, -4262, -5479,
+ -6697, -7915, -9133, 669, 2009, 3348, 4688, 6027, 7367,
+ 8706, 10046, -669, -2009, -3348, -4688, -6027, -7367,
+ -8706, -10046, 736, 2210, 3683, 5157, 6630, 8104, 9577,
+ 11051, -736, -2210, -3683, -5157, -6630, -8104, -9577,
+ -11051, 810, 2431, 4052, 5673, 7294, 8915, 10536, 12157,
+ -810, -2431, -4052, -5673, -7294, -8915, -10536, -12157,
+ 891, 2674, 4457, 6240, 8023, 9806, 11589, 13372, -891,
+ -2674, -4457, -6240, -8023, -9806, -11589, -13372, 980,
+ 2941, 4903, 6864, 8825, 10786, 12748, 14709, -980, -2941,
+ -4903, -6864, -8825, -10786, -12748, -14709, 1078, 3236,
+ 5393, 7551, 9708, 11866, 14023, 16181, -1078, -3236,
+ -5393, -7551, -9708, -11866, -14023, -16181, 1186, 3559,
+ 5933, 8306, 10679, 13052, 15426, 17799, -1186, -3559,
+ -5933, -8306, -10679, -13052, -15426, -17799, 1305,
+ 3915, 6526, 9136, 11747, 14357, 16968, 19578, -1305,
+ -3915, -6526, -9136, -11747, -14357, -16968, -19578,
+ 1435, 4307, 7179, 10051, 12922, 15794, 18666, 21538,
+ -1435, -4307, -7179, -10051, -12922, -15794, -18666,
+ -21538, 1579, 4738, 7896, 11055, 14214, 17373, 20531,
+ 23690, -1579, -4738, -7896, -11055, -14214, -17373,
+ -20531, -23690, 1737, 5212, 8686, 12161, 15636, 19111,
+ 22585, 26060, -1737, -5212, -8686, -12161, -15636, -19111,
+ -22585, -26060, 1911, 5733, 9555, 13377, 17200, 21022,
+ 24844, 28666, -1911, -5733, -9555, -13377, -17200, -21022,
+ -24844, -28666, 2102, 6306, 10511, 14715, 18920, 23124,
+ 27329, 31533, -2102, -6306, -10511, -14715, -18920,
+ -23124, -27329, -31533, 2312, 6937, 11562, 16187, 20812,
+ 25437, 30062, 32767, -2312, -6937, -11562, -16187, -20812,
+ -25437, -30062, -32767, 2543, 7631, 12718, 17806, 22893,
+ 27981, 32767, 32767, -2543, -7631, -12718, -17806, -22893,
+ -27981, -32767, -32767, 2798, 8394, 13990, 19586, 25183,
+ 30779, 32767, 32767, -2798, -8394, -13990, -19586, -25183,
+ -30779, -32767, -32767, 3077, 9233, 15389, 21545, 27700,
+ 32767, 32767, 32767, -3077, -9233, -15389, -21545, -27700,
+ -32767, -32767, -32767, 3385, 10157, 16928, 23700, 30471,
+ 32767, 32767, 32767, -3385, -10157, -16928, -23700,
+ -30471, -32767, -32767, -32767, 3724, 11172, 18621,
+ 26069, 32767, 32767, 32767, 32767, -3724, -11172, -18621,
+ -26069, -32767, -32767, -32767, -32767, 4095, 12287,
+ 20479, 28671, 32767, 32767, 32767, 32767, -4095, -12287,
+ -20479, -28671, -32767, -32767, -32767, -32767
+};
+
+static const int p1s[17] = { 0, 4, 3, 4, 2, 4, 3, 4, 1, 4, 3, 4, 2, 4, 3, 4, 0 };
+static const int p2s[17] = { 0, 1, 1, 3, 1, 5, 3, 7, 1, 9, 5, 11, 3, 13, 7, 15, 1 };
+
+#pragma endregion
+
// Last Express ADPCM is similar to MS IMA mono, but inverts its nibbles
// and does not have the 4 byte per channel requirement
-class LastExpress_ADPCMStream : public Audio::Ima_ADPCMStream {
+class LastExpress_ADPCMStream : public Audio::ADPCMStream {
public:
- LastExpress_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, uint32 blockSize) :
- Audio::Ima_ADPCMStream(stream, disposeAfterUse, size, 44100, 1, blockSize) {}
+ LastExpress_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, uint32 blockSize, int32 filterId) :
+ Audio::ADPCMStream(stream, disposeAfterUse, size, 44100, 1, blockSize) {
+ _currentFilterId = -1;
+ _nextFilterId = filterId;
+ }
int readBuffer(int16 *buffer, const int numSamples) {
int samples = 0;
+ // Temporary data
+ int step = 0;
+ int sample = 0;
+ byte idx = 0;
assert(numSamples % 2 == 0);
@@ -53,20 +373,50 @@ public:
if (_blockPos[0] == _blockAlign) {
// read block header
_status.ima_ch[0].last = _stream->readSint16LE();
- _status.ima_ch[0].stepIndex = _stream->readSint16LE();
+ _status.ima_ch[0].stepIndex = _stream->readSint16LE() << 6;
_blockPos[0] = 4;
+
+ // Get current filter
+ _currentFilterId = _nextFilterId;
+ _nextFilterId = -1;
+
+ // No filter: skip decoding
+ if (_currentFilterId == -1)
+ break;
+
+ // Compute step adjustment
+ _stepAdjust1 = p1s[_currentFilterId];
+ _stepAdjust2 = p2s[_currentFilterId];
}
for (; samples < numSamples && _blockPos[0] < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples += 2) {
byte data = _stream->readByte();
_blockPos[0]++;
- buffer[samples] = decodeIMA((data >> 4) & 0x0f);
- buffer[samples + 1] = decodeIMA(data & 0x0f);
+
+ // First nibble
+ idx = data >> 4;
+ step = stepTable[idx + _status.ima_ch[0].stepIndex / 4];
+ sample = CLIP(imaTable[idx + _status.ima_ch[0].stepIndex / 4] + _status.ima_ch[0].last, -32767, 32767);
+ buffer[samples] = (_stepAdjust2 * sample) >> _stepAdjust1;
+
+ // Second nibble
+ idx = data & 0xF;
+ _status.ima_ch[0].stepIndex = stepTable[idx + step / 4];
+ _status.ima_ch[0].last = CLIP(imaTable[idx + step / 4] + sample, -32767, 32767);
+ buffer[samples + 1] = (_stepAdjust2 * _status.ima_ch[0].last) >> _stepAdjust1;
}
}
return samples;
}
+
+ void setFilterId(int32 filterId) { _nextFilterId = filterId; }
+
+private:
+ int32 _currentFilterId;
+ int32 _nextFilterId; // the sound filter id, -1 for none
+ int32 _stepAdjust1;
+ int32 _stepAdjust2;
};
//////////////////////////////////////////////////////////////////////////
@@ -92,8 +442,8 @@ void SimpleSound::loadHeader(Common::SeekableReadStream *in) {
_blockSize = _size / _blocks;
}
-Audio::AudioStream *SimpleSound::makeDecoder(Common::SeekableReadStream *in, uint32 size) const {
- return new LastExpress_ADPCMStream(in, DisposeAfterUse::YES, size, _blockSize);
+Audio::AudioStream *SimpleSound::makeDecoder(Common::SeekableReadStream *in, uint32 size, int32 filterId) const {
+ return new LastExpress_ADPCMStream(in, DisposeAfterUse::YES, size, _blockSize, filterId);
}
void SimpleSound::play(Audio::AudioStream *as) {
@@ -103,10 +453,11 @@ void SimpleSound::play(Audio::AudioStream *as) {
//////////////////////////////////////////////////////////////////////////
// StreamedSound
//////////////////////////////////////////////////////////////////////////
-StreamedSound::StreamedSound() {}
+StreamedSound::StreamedSound() : _as(NULL), _loaded(false) {}
+
StreamedSound::~StreamedSound() {}
-bool StreamedSound::load(Common::SeekableReadStream *stream) {
+bool StreamedSound::load(Common::SeekableReadStream *stream, int32 filterId) {
if (!stream)
return false;
@@ -115,14 +466,27 @@ bool StreamedSound::load(Common::SeekableReadStream *stream) {
loadHeader(stream);
// Start decoding the input stream
- Audio::AudioStream *as = makeDecoder(stream, _size);
+ _as = makeDecoder(stream, _size, filterId);
// Start playing the decoded audio stream
- play(as);
+ play(_as);
+
+ _loaded = true;
return true;
}
+bool StreamedSound::isFinished() {
+ if (!_loaded)
+ return false;
+
+ return !g_system->getMixer()->isSoundHandleActive(_handle);
+}
+
+void StreamedSound::setFilterId(int32 filterId) {
+ ((LastExpress_ADPCMStream *)_as)->setFilterId(filterId);
+}
+
//////////////////////////////////////////////////////////////////////////
// StreamedSound
//////////////////////////////////////////////////////////////////////////
@@ -152,7 +516,7 @@ void AppendableSound::queueBuffer(const byte *data, uint32 size) {
void AppendableSound::queueBuffer(Common::SeekableReadStream *bufferIn) {
if (!_as)
- error("AppendableSound::queueBuffer - internal error: the audio stream is invalid!");
+ error("[AppendableSound::queueBuffer] Audio stream is invalid");
// Setup the ADPCM decoder
uint32 sizeIn = (uint32)bufferIn->size();
@@ -164,7 +528,7 @@ void AppendableSound::queueBuffer(Common::SeekableReadStream *bufferIn) {
void AppendableSound::finish() {
if (!_as)
- error("AppendableSound::queueBuffer - internal error: the audio stream is invalid!");
+ error("[AppendableSound::finish] Audio stream is invalid");
if (!_finished)
_as->finish();
@@ -172,4 +536,8 @@ void AppendableSound::finish() {
_finished = true;
}
+bool AppendableSound::isFinished() {
+ return _as->endOfStream();
+}
+
} // End of namespace LastExpress
diff --git a/engines/lastexpress/data/snd.h b/engines/lastexpress/data/snd.h
index 95a136ee1c..7111d939e7 100644
--- a/engines/lastexpress/data/snd.h
+++ b/engines/lastexpress/data/snd.h
@@ -55,10 +55,11 @@ public:
virtual ~SimpleSound();
void stop() const;
+ virtual bool isFinished() = 0;
protected:
void loadHeader(Common::SeekableReadStream *in);
- Audio::AudioStream *makeDecoder(Common::SeekableReadStream *in, uint32 size) const;
+ Audio::AudioStream *makeDecoder(Common::SeekableReadStream *in, uint32 size, int32 filterId = -1) const;
void play(Audio::AudioStream *as);
uint32 _size; ///< data size
@@ -75,7 +76,14 @@ public:
StreamedSound();
~StreamedSound();
- bool load(Common::SeekableReadStream *stream);
+ bool load(Common::SeekableReadStream *stream, int32 filterId = -1);
+ virtual bool isFinished();
+
+ void setFilterId(int32 filterId);
+
+private:
+ Audio::AudioStream *_as;
+ bool _loaded;
};
class AppendableSound : public SimpleSound {
@@ -87,6 +95,8 @@ public:
void queueBuffer(Common::SeekableReadStream *bufferIn);
void finish();
+ virtual bool isFinished();
+
private:
Audio::QueuingAudioStream *_as;
bool _finished;
diff --git a/engines/lastexpress/data/subtitle.cpp b/engines/lastexpress/data/subtitle.cpp
index c3a7397b66..0be832cbdd 100644
--- a/engines/lastexpress/data/subtitle.cpp
+++ b/engines/lastexpress/data/subtitle.cpp
@@ -168,13 +168,13 @@ bool SubtitleManager::load(Common::SeekableReadStream *stream) {
// Read header to get the number of subtitles
uint32 numSubtitles = stream->readUint16LE();
if (stream->eos())
- error("Cannot read from subtitle file");
+ error("[SubtitleManager::load] Cannot read from subtitle file");
debugC(3, kLastExpressDebugSubtitle, "Number of subtitles in file: %d", numSubtitles);
// TODO: Check that stream contain enough data
//if (stream->size() < (signed)(numSubtitles * sizeof(SubtitleData))) {
- //debugC(2, kLastExpressDebugSubtitle, "Subtitle file does not contain valid data!");
+ //debugC(2, kLastExpressDebugSubtitle, "Subtitle file does not contain valid data");
//return false;
//}