diff --git a/engines/glk/frotz/pics.cpp b/engines/glk/frotz/pics.cpp index 9dca3243157..a3df86a53ca 100644 --- a/engines/glk/frotz/pics.cpp +++ b/engines/glk/frotz/pics.cpp @@ -149,13 +149,7 @@ Common::SeekableReadStream *Pics::createReadStreamForMember(const Common::String error("Reading failed"); if (e._dataSize) { - if (e._paletteOffset) { - // Read in the image's palette - assert(e._paletteOffset); - f.seek(e._paletteOffset); - _palette->resize(f.readByte() * 3); - f.read(&(*_palette)[0], _palette->size()); - } + loadPalette(f, e, *_palette); f.seek(e._dataOffset); Common::SeekableReadStream *src = f.readStream(e._dataSize); @@ -176,5 +170,20 @@ Common::SeekableReadStream *Pics::createReadStreamForMember(const Common::String return nullptr; } +void Pics::loadPalette(Common::File &f, const Entry &e, Common::Array &palette) const { + if (e._paletteOffset) { + // Read in the image's palette + assert(e._paletteOffset); + f.seek(e._paletteOffset); + _palette->resize(f.readByte() * 3); + f.read(&(*_palette)[0], _palette->size()); + } + + if (e._flags & 1) { + byte *entry = &palette[(e._flags >> 12) * 3]; + Common::fill(entry, entry + 3, 0); + } +} + } // End of namespace Frotz } // End of namespace Glk diff --git a/engines/glk/frotz/pics.h b/engines/glk/frotz/pics.h index 68facf5b9ff..d4027a2ddab 100644 --- a/engines/glk/frotz/pics.h +++ b/engines/glk/frotz/pics.h @@ -25,6 +25,7 @@ #include "common/archive.h" #include "common/array.h" +#include "common/file.h" namespace Glk { namespace Frotz { @@ -71,6 +72,11 @@ private: * Returns the filename for the pictures archive */ static Common::String getFilename(); + + /** + * Read in the palette + */ + void loadPalette(Common::File &f, const Entry &e, Common::Array &palette) const; public: /** * Returns true if an mg1 file exists for the game