diff options
author | Iskrich | 2016-05-17 01:34:55 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 75a01e0ea096c17bb6809140c3c69026362ccbe2 (patch) | |
tree | 8ad673c3272bf18d1af5928e434152056b839469 /engines/director | |
parent | acc0d70054f34f8acd2cc2e4647156c238cd2181 (diff) | |
download | scummvm-rg350-75a01e0ea096c17bb6809140c3c69026362ccbe2.tar.gz scummvm-rg350-75a01e0ea096c17bb6809140c3c69026362ccbe2.tar.bz2 scummvm-rg350-75a01e0ea096c17bb6809140c3c69026362ccbe2.zip |
DIRECTOR: Refactoring palette loading
Diffstat (limited to 'engines/director')
-rw-r--r-- | engines/director/dib.cpp | 41 | ||||
-rw-r--r-- | engines/director/director.cpp | 6 |
2 files changed, 22 insertions, 25 deletions
diff --git a/engines/director/dib.cpp b/engines/director/dib.cpp index 3cf23d6982..af7ef6c966 100644 --- a/engines/director/dib.cpp +++ b/engines/director/dib.cpp @@ -28,6 +28,7 @@ #include "graphics/pixelformat.h" #include "graphics/surface.h" #include "image/codecs/codec.h" +#include "common/util.h" #include "common/debug.h" namespace Director { @@ -48,7 +49,6 @@ void DIBDecoder::destroy() { delete[] _palette; _palette = 0; - _paletteColorCount = 0; delete _codec; @@ -56,31 +56,28 @@ void DIBDecoder::destroy() { } void DIBDecoder::loadPalette(Common::SeekableReadStream &stream) { - uint16 palentries = 256; _palette = new byte[1024]; - uint16 size = stream.size(); - uint16 index = 0; - for (int i = 6; i < stream.size() + 6; i+=6) { - uint16 n = size - i; - if (i >= palentries) { - break; - } - stream.seek(n + 4); - _palette[index] = stream.readByte(); - ++index; - stream.seek(n + 2); - _palette[index] = stream.readByte(); - ++index; - stream.seek(n); - _palette[index] = stream.readByte(); - ++index; - _palette[index] = 0; - ++index; + uint16 steps = stream.size()/6; + uint16 index = (steps * 4) - 1; + + for (uint8 i = 0; i < steps; i++) { + _palette[index--] = 0; + + _palette[index--] = stream.readByte(); + stream.readByte(); + + _palette[index--] = stream.readByte(); + stream.readByte(); + + _palette[index--] = stream.readByte(); + stream.readByte(); } + + index = (steps * 4) - 1; + while (index < 1024) { - _palette[index] = 0; - ++index; + _palette[index++] = 0; } } diff --git a/engines/director/director.cpp b/engines/director/director.cpp index e06459144b..0ddb8a7350 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -54,11 +54,11 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam //FIXME RIFFArchive riff; riff.openFile("bookshelf_example.mmm"); - Common::SeekableReadStream *dib = riff.getResource(1145651744, 1103); - Common::SeekableReadStream *pal = riff.getResource(1129076052, 1025); Director::DIBDecoder img; - img.loadPalette(*pal); + Common::SeekableReadStream *dib = riff.getResource(MKTAG('D', 'I', 'B', ' '), 1103); img.loadStream(*dib); + Common::SeekableReadStream *pal = riff.getResource(MKTAG('C', 'L', 'U', 'T'), 1025); + img.loadPalette(*pal); } DirectorEngine::~DirectorEngine() { |