aboutsummaryrefslogtreecommitdiff
path: root/engines/glk
diff options
context:
space:
mode:
authorPaul Gilbert2019-02-27 19:16:46 -0800
committerPaul Gilbert2019-02-27 21:34:46 -0800
commitacb39303f162490edbac22199b8bad144e3f4a62 (patch)
tree87b40a0bbd93acbe8288a73b3b1d7fca6f2aea8d /engines/glk
parent1c75912ecf262dea13a845250eaf2bbad3276c4b (diff)
downloadscummvm-rg350-acb39303f162490edbac22199b8bad144e3f4a62.tar.gz
scummvm-rg350-acb39303f162490edbac22199b8bad144e3f4a62.tar.bz2
scummvm-rg350-acb39303f162490edbac22199b8bad144e3f4a62.zip
GLK: FROTZ: Improved palette reading
Diffstat (limited to 'engines/glk')
-rw-r--r--engines/glk/frotz/pics.cpp23
-rw-r--r--engines/glk/frotz/pics.h6
2 files changed, 22 insertions, 7 deletions
diff --git a/engines/glk/frotz/pics.cpp b/engines/glk/frotz/pics.cpp
index 9dca324315..a3df86a53c 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<byte> &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 68facf5b9f..d4027a2dda 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<byte> &palette) const;
public:
/**
* Returns true if an mg1 file exists for the game