diff options
author | Paul Gilbert | 2019-01-03 18:30:22 -0800 |
---|---|---|
committer | Paul Gilbert | 2019-01-03 18:30:22 -0800 |
commit | 79052366d049b767d43258f8a8c0926f9f10d7fe (patch) | |
tree | 645b5aec9f9e4ead0b89250e12dde676b24c100b /engines | |
parent | c4c14b593ba254d1f3f1159b1b23c166667a7e56 (diff) | |
download | scummvm-rg350-79052366d049b767d43258f8a8c0926f9f10d7fe.tar.gz scummvm-rg350-79052366d049b767d43258f8a8c0926f9f10d7fe.tar.bz2 scummvm-rg350-79052366d049b767d43258f8a8c0926f9f10d7fe.zip |
GLK: FROTZ: Support using prior palette when a pic doesn't have one
Diffstat (limited to 'engines')
-rw-r--r-- | engines/glk/frotz/pics.cpp | 21 | ||||
-rw-r--r-- | engines/glk/frotz/pics.h | 6 |
2 files changed, 20 insertions, 7 deletions
diff --git a/engines/glk/frotz/pics.cpp b/engines/glk/frotz/pics.cpp index 86cd5feb25..9dca324315 100644 --- a/engines/glk/frotz/pics.cpp +++ b/engines/glk/frotz/pics.cpp @@ -41,6 +41,8 @@ Pics::Pics() : Common::Archive(), _filename(getFilename()) { if (!f.open(_filename)) error("Error reading Pics file"); + _palette = new Common::Array<byte>(); + Common::Array<uint> offsets; byte buffer[16]; f.read(buffer, 16); @@ -95,6 +97,10 @@ Pics::Pics() : Common::Archive(), _filename(getFilename()) { f.close(); } +Pics::~Pics() { + delete _palette; +} + Common::String Pics::getFilename() { Common::String filename = g_vm->getFilename(); while (filename.contains('.')) @@ -137,22 +143,23 @@ Common::SeekableReadStream *Pics::createReadStreamForMember(const Common::String for (uint idx = 0; idx < _index.size(); ++idx) { const Entry &e = _index[idx]; if (e._filename.equalsIgnoreCase(name)) { - Common::Array<byte> palette; Common::File f; Common::SeekableReadStream *dest; if (!f.open(_filename)) error("Reading failed"); if (e._dataSize) { - // 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._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()); + } f.seek(e._dataOffset); Common::SeekableReadStream *src = f.readStream(e._dataSize); - dest = decoder.decode(*src, e._flags, palette, kMCGA, e._width, e._height); + dest = decoder.decode(*src, e._flags, *_palette, kMCGA, e._width, e._height); delete src; } else { byte *rect = (byte *)malloc(2 * sizeof(uint16)); diff --git a/engines/glk/frotz/pics.h b/engines/glk/frotz/pics.h index ab2204f414..68facf5b9f 100644 --- a/engines/glk/frotz/pics.h +++ b/engines/glk/frotz/pics.h @@ -65,6 +65,7 @@ private: Common::Array<Entry> _index; ///< list of entries uint _entrySize; uint _version; + Common::Array<byte> *_palette; private: /** * Returns the filename for the pictures archive @@ -82,6 +83,11 @@ public: Pics(); /** + * Destructor + */ + ~Pics(); + + /** * Return the number of entries in the file */ size_t size() const { return _index.size(); } |