aboutsummaryrefslogtreecommitdiff
path: root/engines/glk
diff options
context:
space:
mode:
authorPaul Gilbert2019-08-01 19:48:04 -0700
committerPaul Gilbert2019-08-01 22:05:40 -0700
commitd680b0b02983350c16e106c50aea152eefc6b585 (patch)
tree0a624a688488308c644ecac4c7861d3c58aca055 /engines/glk
parent0554ec80008da2d8b5d29465452574dd61e3da57 (diff)
downloadscummvm-rg350-d680b0b02983350c16e106c50aea152eefc6b585.tar.gz
scummvm-rg350-d680b0b02983350c16e106c50aea152eefc6b585.tar.bz2
scummvm-rg350-d680b0b02983350c16e106c50aea152eefc6b585.zip
GLK: Added Blorb mapping to the optional adaptive palette list
Diffstat (limited to 'engines/glk')
-rw-r--r--engines/glk/blorb.cpp29
-rw-r--r--engines/glk/blorb.h1
2 files changed, 29 insertions, 1 deletions
diff --git a/engines/glk/blorb.cpp b/engines/glk/blorb.cpp
index 849e6866e0..b97ee319c7 100644
--- a/engines/glk/blorb.cpp
+++ b/engines/glk/blorb.cpp
@@ -162,6 +162,27 @@ Common::ErrorCode Blorb::load() {
}
}
+ // Check through any optional remaining chunks for an adaptive palette list
+ while (f.pos() < f.size()) {
+ uint chunkId = f.readUint32BE();
+ uint chunkSize = f.readUint32BE();
+
+ if (chunkId == ID_APal) {
+ // Found one, so create an entry so it can be opened as file named "apal"
+ ChunkEntry ce;
+ ce._filename = "apal";
+ ce._offset = f.pos();
+ ce._size = chunkSize;
+ ce._type = ID_APal;
+ _chunks.push_back(ce);
+ break;
+ }
+
+ if (chunkSize & 1)
+ ++chunkSize;
+ f.skip(chunkSize);
+ }
+
return Common::kNoError;
}
@@ -169,8 +190,9 @@ bool Blorb::readRIdx(Common::SeekableReadStream &stream, Common::Array<ChunkEntr
if (stream.readUint32BE() != ID_RIdx)
return false;
- stream.readUint32BE();
+ uint chunkLen = stream.readUint32BE();
uint count = stream.readUint32BE();
+ assert(count == (chunkLen - 4) / 12);
// First read in the resource index
for (uint idx = 0; idx < count; ++idx) {
@@ -182,6 +204,9 @@ bool Blorb::readRIdx(Common::SeekableReadStream &stream, Common::Array<ChunkEntr
chunks.push_back(ce);
}
+ // Temporarily store the start of the next chunk of the file (if any)
+ size_t nextChunkOffset = stream.pos();
+
// Further iterate through the resources
for (uint idx = 0; idx < chunks.size(); ++idx) {
ChunkEntry &ce = chunks[idx];
@@ -192,6 +217,8 @@ bool Blorb::readRIdx(Common::SeekableReadStream &stream, Common::Array<ChunkEntr
ce._size = stream.readUint32BE();
}
+ // Reset back to the next chunk, and return that the index was successfully read
+ stream.seek(nextChunkOffset);
return true;
}
diff --git a/engines/glk/blorb.h b/engines/glk/blorb.h
index 5d72e2cf06..6076428449 100644
--- a/engines/glk/blorb.h
+++ b/engines/glk/blorb.h
@@ -46,6 +46,7 @@ enum {
ID_FORM = MKTAG('F', 'O', 'R', 'M'),
ID_IFRS = MKTAG('I', 'F', 'R', 'S'),
ID_RIdx = MKTAG('R', 'I', 'd', 'x'),
+ ID_APal = MKTAG('A', 'P', 'a', 'l'),
ID_Snd = MKTAG('S', 'n', 'd', ' '),
ID_Exec = MKTAG('E', 'x', 'e', 'c'),