diff options
Diffstat (limited to 'engines/cryomni3d/video/hnm_decoder.cpp')
-rw-r--r-- | engines/cryomni3d/video/hnm_decoder.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/engines/cryomni3d/video/hnm_decoder.cpp b/engines/cryomni3d/video/hnm_decoder.cpp index 355345beaa..0451828f0c 100644 --- a/engines/cryomni3d/video/hnm_decoder.cpp +++ b/engines/cryomni3d/video/hnm_decoder.cpp @@ -35,13 +35,16 @@ namespace Video { // When no sound display a frame every 80ms -HNMDecoder::HNMDecoder(bool loop) : _regularFrameDelay(80), _videoTrack(nullptr), - _audioTrack(nullptr), _stream(nullptr), _loop(loop) { +HNMDecoder::HNMDecoder(bool loop, byte *initialPalette) : _regularFrameDelay(80), + _videoTrack(nullptr), _audioTrack(nullptr), _stream(nullptr), + _loop(loop), _initialPalette(initialPalette) { } HNMDecoder::~HNMDecoder() { close(); + delete[] _initialPalette; + // We don't deallocate _videoTrack and _audioTrack as they are owned by base class } @@ -79,7 +82,7 @@ bool HNMDecoder::loadStream(Common::SeekableReadStream *stream) { frameCount = 0; } - _videoTrack = new HNM4VideoTrack(width, height, frameSize, frameCount, _regularFrameDelay); + _videoTrack = new HNM4VideoTrack(width, height, frameSize, frameCount, _regularFrameDelay, _initialPalette); if (soundBits != 0 && soundChannels != 0) { // HNM4 is 22050Hz _audioTrack = new DPCMAudioTrack(soundChannels, soundBits, 22050, getSoundType()); @@ -149,13 +152,18 @@ void HNMDecoder::readNextPacket() { } HNMDecoder::HNM4VideoTrack::HNM4VideoTrack(uint32 width, uint32 height, uint32 frameSize, - uint32 frameCount, uint32 regularFrameDelay) : + uint32 frameCount, uint32 regularFrameDelay, const byte *initialPalette) : _frameCount(frameCount), _regularFrameDelay(regularFrameDelay), _nextFrameStartTime(0) { restart(); _curFrame = -1; - memset(_palette, 0, 256 * 3); + // Get the currently loaded palette for undefined colors + if (initialPalette) { + memcpy(_palette, initialPalette, 256 * 3); + } else { + memset(_palette, 0, 256 * 3); + } if (width * height != frameSize) { error("Invalid frameSize"); |