aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/support
diff options
context:
space:
mode:
authorPaul Gilbert2017-08-12 20:09:18 -0400
committerPaul Gilbert2017-08-12 20:09:18 -0400
commitf132cbcf8570eb2a125d6c079997762ffffdab08 (patch)
tree90180a31c5677bd0361d59ea5badfc1f74e52565 /engines/titanic/support
parent6a5c52019458e13941abb3f6ab3f4cd1607c3989 (diff)
downloadscummvm-rg350-f132cbcf8570eb2a125d6c079997762ffffdab08.tar.gz
scummvm-rg350-f132cbcf8570eb2a125d6c079997762ffffdab08.tar.bz2
scummvm-rg350-f132cbcf8570eb2a125d6c079997762ffffdab08.zip
TITANIC: Add support for compressed bitmaps in titanic.dat
Diffstat (limited to 'engines/titanic/support')
-rw-r--r--engines/titanic/support/files_manager.cpp20
-rw-r--r--engines/titanic/support/files_manager.h9
2 files changed, 21 insertions, 8 deletions
diff --git a/engines/titanic/support/files_manager.cpp b/engines/titanic/support/files_manager.cpp
index 5fc9379917..eebd56c1fa 100644
--- a/engines/titanic/support/files_manager.cpp
+++ b/engines/titanic/support/files_manager.cpp
@@ -22,6 +22,7 @@
#include "common/file.h"
#include "common/memstream.h"
+#include "common/zlib.h"
#include "titanic/support/files_manager.h"
#include "titanic/game_manager.h"
#include "titanic/titanic.h"
@@ -29,7 +30,7 @@
namespace Titanic {
CFilesManager::CFilesManager(TitanicEngine *vm) : _vm(vm), _gameManager(nullptr),
- _assetsPath("Assets"), _drive(-1) {
+ _assetsPath("Assets"), _drive(-1), _version(0) {
}
CFilesManager::~CFilesManager() {
@@ -43,19 +44,21 @@ bool CFilesManager::loadResourceIndex() {
}
uint headerId = _datFile.readUint32BE();
- uint version = _datFile.readUint16LE();
- if (headerId != MKTAG('S', 'V', 'T', 'N') || version < 1) {
+ _version = _datFile.readUint16LE();
+ if (headerId != MKTAG('S', 'V', 'T', 'N') || _version < 1) {
g_vm->GUIError("titanic.dat has invalid contents");
return false;
}
// Read in entries
- uint offset, size;
+ uint offset, size, flags;
char c;
Common::String resourceName;
for (;;) {
offset = _datFile.readUint32LE();
size = _datFile.readUint32LE();
+ flags = (_version == 1) ? 0 : _datFile.readUint16LE();
+
if (offset == 0 && size == 0)
break;
@@ -63,7 +66,7 @@ bool CFilesManager::loadResourceIndex() {
while ((c = _datFile.readByte()) != '\0')
resName += c;
- _resources[resName] = ResourceEntry(offset, size);
+ _resources[resName] = ResourceEntry(offset, size, flags);
}
return true;
@@ -136,8 +139,13 @@ Common::SeekableReadStream *CFilesManager::getResource(const CString &str) {
_datFile.seek(resEntry._offset);
- return (resEntry._size > 0) ? _datFile.readStream(resEntry._size) :
+ Common::SeekableReadStream *stream = (resEntry._size > 0) ?
+ _datFile.readStream(resEntry._size) :
new Common::MemoryReadStream(nullptr, 0);
+ if (resEntry._flags & FLAG_COMPRESSED)
+ stream = Common::wrapCompressedReadStream(stream);
+
+ return stream;
}
} // End of namespace Titanic
diff --git a/engines/titanic/support/files_manager.h b/engines/titanic/support/files_manager.h
index 7627ececdd..c1e3c3b274 100644
--- a/engines/titanic/support/files_manager.h
+++ b/engines/titanic/support/files_manager.h
@@ -29,6 +29,8 @@
namespace Titanic {
+enum ResourceFlag { FLAG_COMPRESSED = 1 };
+
class TitanicEngine;
class CGameManager;
@@ -39,9 +41,11 @@ class CFilesManager {
struct ResourceEntry {
uint _offset;
uint _size;
+ uint _flags;
- ResourceEntry() : _offset(0), _size(0) {}
- ResourceEntry(uint offset, uint size) : _offset(offset), _size(size) {}
+ ResourceEntry() : _offset(0), _size(0), _flags(0) {}
+ ResourceEntry(uint offset, uint size, uint flags) :
+ _offset(offset), _size(size), _flags(flags) {}
};
typedef Common::HashMap<Common::String, ResourceEntry> ResourceHash;
private:
@@ -52,6 +56,7 @@ private:
CFilesManagerList _list;
int _drive;
const CString _assetsPath;
+ int _version;
public:
CFilesManager(TitanicEngine *vm);
~CFilesManager();