diff options
author | Filippos Karapetis | 2011-02-07 13:49:03 +0000 |
---|---|---|
committer | Filippos Karapetis | 2011-02-07 13:49:03 +0000 |
commit | a0c0331bcdb9a0736c8b5fa85de18a0319c675a2 (patch) | |
tree | 5cfd8379b6e1bee63b1ed1de65f1ff0c2f969c06 | |
parent | dda8266ec810d2e289e4d0f661078f60d69d9903 (diff) | |
download | scummvm-rg350-a0c0331bcdb9a0736c8b5fa85de18a0319c675a2.tar.gz scummvm-rg350-a0c0331bcdb9a0736c8b5fa85de18a0319c675a2.tar.bz2 scummvm-rg350-a0c0331bcdb9a0736c8b5fa85de18a0319c675a2.zip |
SCI: Unified the SEQ and robot palette code, and fixed the include safeguard of the SEQ decoder
svn-id: r55803
-rw-r--r-- | engines/sci/video/robot_decoder.cpp | 16 | ||||
-rw-r--r-- | engines/sci/video/robot_decoder.h | 2 | ||||
-rw-r--r-- | engines/sci/video/seq_decoder.cpp | 12 | ||||
-rw-r--r-- | engines/sci/video/seq_decoder.h | 5 |
4 files changed, 24 insertions, 11 deletions
diff --git a/engines/sci/video/robot_decoder.cpp b/engines/sci/video/robot_decoder.cpp index f547407076..d487c6d9b4 100644 --- a/engines/sci/video/robot_decoder.cpp +++ b/engines/sci/video/robot_decoder.cpp @@ -69,6 +69,11 @@ namespace Sci { #ifdef ENABLE_SCI32 +enum robotPalTypes { + kRobotPalVariable = 0, + kRobotPalConstant = 1 +}; + RobotDecoder::RobotDecoder(Audio::Mixer *mixer, bool isBigEndian) { _surface = 0; _fileStream = 0; @@ -116,7 +121,7 @@ bool RobotDecoder::load(Common::SeekableReadStream *stream) { _mixer->playStream(Audio::Mixer::kMusicSoundType, &_audioHandle, _audioStream); } - readPaletteChunk(); + readPaletteChunk(_header.paletteDataSize); readFrameSizesChunk(); return true; } @@ -143,11 +148,12 @@ void RobotDecoder::readHeaderChunk() { _fileStream->skip(_header.unkChunkDataSize); } -void RobotDecoder::readPaletteChunk() { - byte *paletteData = new byte[_header.paletteDataSize]; - _fileStream->read(paletteData, _header.paletteDataSize); +void RobotDecoder::readPaletteChunk(uint16 chunkSize) { + byte *paletteData = new byte[chunkSize]; + _fileStream->read(paletteData, chunkSize); // SCI1.1 palette + byte palFormat = paletteData[32]; uint16 palColorStart = READ_SCI11ENDIAN_UINT16(paletteData + 25); uint16 palColorCount = READ_SCI11ENDIAN_UINT16(paletteData + 29); @@ -155,6 +161,8 @@ void RobotDecoder::readPaletteChunk() { memset(_palette, 0, 256 * 3); for (uint16 colorNo = palColorStart; colorNo < palColorStart + palColorCount; colorNo++) { + if (palFormat == kRobotPalVariable) + palOffset++; _palette[colorNo * 3 + 0] = paletteData[palOffset++]; _palette[colorNo * 3 + 1] = paletteData[palOffset++]; _palette[colorNo * 3 + 2] = paletteData[palOffset++]; diff --git a/engines/sci/video/robot_decoder.h b/engines/sci/video/robot_decoder.h index aa68c50f5a..8a52308c25 100644 --- a/engines/sci/video/robot_decoder.h +++ b/engines/sci/video/robot_decoder.h @@ -78,7 +78,7 @@ protected: private: void readHeaderChunk(); - void readPaletteChunk(); + void readPaletteChunk(uint16 chunkSize); void readFrameSizesChunk(); void freeData(); diff --git a/engines/sci/video/seq_decoder.cpp b/engines/sci/video/seq_decoder.cpp index 3f4bd458b8..106084d427 100644 --- a/engines/sci/video/seq_decoder.cpp +++ b/engines/sci/video/seq_decoder.cpp @@ -66,10 +66,15 @@ bool SeqDecoder::load(Common::SeekableReadStream *stream) { _frameCount = _fileStream->readUint16LE(); // Set palette - int paletteSize = _fileStream->readUint32LE(); + int paletteChunkSize = _fileStream->readUint32LE(); + readPaletteChunk(paletteChunkSize); - byte *paletteData = new byte[paletteSize]; - _fileStream->read(paletteData, paletteSize); + return true; +} + +void SeqDecoder::readPaletteChunk(uint16 chunkSize) { + byte *paletteData = new byte[chunkSize]; + _fileStream->read(paletteData, chunkSize); // SCI1.1 palette byte palFormat = paletteData[32]; @@ -89,7 +94,6 @@ bool SeqDecoder::load(Common::SeekableReadStream *stream) { _dirtyPalette = true; delete[] paletteData; - return true; } void SeqDecoder::close() { diff --git a/engines/sci/video/seq_decoder.h b/engines/sci/video/seq_decoder.h index fb13d3a509..d67e35938a 100644 --- a/engines/sci/video/seq_decoder.h +++ b/engines/sci/video/seq_decoder.h @@ -23,8 +23,8 @@ * */ -#ifndef SEQ_DECODER_H -#define SEQ_DECODER_H +#ifndef SCI_VIDEO_SEQ_DECODER_H +#define SCI_VIDEO_SEQ_DECODER_H #include "video/video_decoder.h" @@ -61,6 +61,7 @@ private: SEQ_SCREEN_HEIGHT = 200 }; + void readPaletteChunk(uint16 chunkSize); bool decodeFrame(byte *rleData, int rleSize, byte *litData, int litSize, byte *dest, int left, int width, int height, int colorKey); uint16 _width, _height; |