diff options
author | Paul Gilbert | 2013-05-21 11:18:40 +1000 |
---|---|---|
committer | Paul Gilbert | 2013-05-21 11:18:40 +1000 |
commit | 4b638bc4b05ce42432979b8b06ad0afac31142a7 (patch) | |
tree | 744b0a6f5b5f7e864cba84ee1096dc9b5b42ced0 /engines | |
parent | 0c5561cc07ff6257b832feeca644bcd136fe2a0f (diff) | |
download | scummvm-rg350-4b638bc4b05ce42432979b8b06ad0afac31142a7.tar.gz scummvm-rg350-4b638bc4b05ce42432979b8b06ad0afac31142a7.tar.bz2 scummvm-rg350-4b638bc4b05ce42432979b8b06ad0afac31142a7.zip |
VOYEUR: Further work on bolt file loading
Diffstat (limited to 'engines')
-rw-r--r-- | engines/voyeur/files.cpp | 63 | ||||
-rw-r--r-- | engines/voyeur/files.h | 27 | ||||
-rw-r--r-- | engines/voyeur/voyeur.cpp | 6 | ||||
-rw-r--r-- | engines/voyeur/voyeur.h | 1 |
4 files changed, 81 insertions, 16 deletions
diff --git a/engines/voyeur/files.cpp b/engines/voyeur/files.cpp index 4480f48f18..fa3d27e1d6 100644 --- a/engines/voyeur/files.cpp +++ b/engines/voyeur/files.cpp @@ -28,7 +28,7 @@ FilesManager::FilesManager() { _decompressSize = 0x7000; } -bool FilesManager::openBOLTLib(const Common::String &filename, BoltFile *&boltFile) { +bool FilesManager::openBoltLib(const Common::String &filename, BoltFile *&boltFile) { if (boltFile != NULL) { _curLibPtr = boltFile; return true; @@ -46,11 +46,14 @@ bool FilesManager::openBOLTLib(const Common::String &filename, BoltFile *&boltFi BoltFile *BoltFile::_curLibPtr = NULL; BoltGroup *BoltFile::_curGroupPtr = NULL; +BoltEntry *BoltFile::_curMemberPtr = NULL; byte *BoltFile::_curMemInfoPtr = NULL; int BoltFile::_fromGroupFlag = 0; +byte BoltFile::_xorMask = 0; +bool BoltFile::_encrypt = false; BoltFile::BoltFile() { - if (!_curFd.open("buoy.blt")) + if (!_curFd.open("bvoy.blt")) error("Could not open buoy.blt"); _curFilePosition = 0; @@ -63,7 +66,7 @@ BoltFile::BoltFile() { int totalGroups = header[11] ? header[11] : 0x100; for (int i = 0; i < totalGroups; ++i) - _groups.push_back(BoltGroup(_curFd.readStream(_curFd.size()))); + _groups.push_back(BoltGroup(_curFd))); } BoltFile::~BoltFile() { @@ -104,6 +107,40 @@ bool BoltFile::getBoltGroup(uint32 id) { return true; } +byte *BoltFile::memberAddr(uint32 id) { + BoltGroup &group = _groups[id >> 8]; + if (!group._loaded) + return NULL; + + return group._entries[id & 0xff]._data; +} + +byte *BoltFile::getBoltMember(uint32 id) { + _curLibPtr = this; + + // Get the group, and load it's entry list if not already loaded + _curGroupPtr = &_groups[(id >> 8) & 0xff << 4]; + if (!_curGroupPtr->_loaded) + _curGroupPtr->load(); + + // Get the entry + _curMemberPtr = &_curGroupPtr->_entries[id & 0xff]; + if (_curMemberPtr->_field1) + initMem(_curMemberPtr->_field1); + + // Return the data for the entry if it's already been loaded + if (_curMemberPtr->_data) + return _curMemberPtr->_data; + + _xorMask = _curMemberPtr->_xorMask; + _encrypt = (_curMemberPtr->_mode & 0x10) != 0; + + if (_curGroupPtr->_loaded) { + + } + //TODO +} + /*------------------------------------------------------------------------*/ BoltGroup::BoltGroup(Common::SeekableReadStream *f): _file(f) { @@ -114,7 +151,7 @@ BoltGroup::BoltGroup(Common::SeekableReadStream *f): _file(f) { _file->read(&buffer[0], BOLT_GROUP_SIZE); _loaded = false; _callInitGro = buffer[1] != 0; - _count = buffer[3]; + _count = buffer[3] ? buffer[3] : 256; // TODO: Added this in. Check it's okay _fileOffset = READ_LE_UINT32(&buffer[8]); } @@ -128,16 +165,30 @@ void BoltGroup::load() { int count = _count ? _count : 256; for (int i = 0; i < count; ++i) _entries.push_back(BoltEntry(_file)); + + _loaded = true; } /*------------------------------------------------------------------------*/ BoltEntry::BoltEntry(Common::SeekableReadStream *f): _file(f) { - + _data = NULL; + + byte buffer[16]; + _file->read(&buffer[0], 16); + _mode = buffer[0]; + _field1 = buffer[1]; + _field3 = buffer[3]; + _xorMask = buffer[4] & 0xff; // TODO: Is this right?? + _size = READ_LE_UINT32(&buffer[4]); + _fileOffset = READ_LE_UINT32(&buffer[8]); } -void BoltEntry::load() { +BoltEntry::~BoltEntry() { + delete[] _data; +} +void BoltEntry::load() { } } // End of namespace Voyeur diff --git a/engines/voyeur/files.h b/engines/voyeur/files.h index 1db1fdf4b0..381ba20255 100644 --- a/engines/voyeur/files.h +++ b/engines/voyeur/files.h @@ -37,27 +37,32 @@ class BoltFile { private: static BoltFile *_curLibPtr; static BoltGroup *_curGroupPtr; + static BoltEntry *_curMemberPtr; static byte *_curMemInfoPtr; static int _fromGroupFlag; + static byte _xorMask; + static bool _encrypt; private: Common::File _curFd; int _curFilePosition; Common::Array<BoltGroup> _groups; private: - bool getBoltGroup(uint32 id); void resolveAll() {} - byte *getBoltMember(uint32 id) { return NULL; } -public: - BoltFile(); - ~BoltFile(); + byte *getBoltMember(uint32 id); // Methods copied into bolt virtual table void initType() {} void termType() {} - void initMem() {} + void initMem(int id) {} void termMem() {} void initGro() {} void termGro() {} +public: + BoltFile(); + ~BoltFile(); + + bool getBoltGroup(uint32 id); + byte *memberAddr(uint32 id); }; class BoltGroup { @@ -81,9 +86,16 @@ class BoltEntry { private: Common::SeekableReadStream *_file; public: + byte _mode; + byte _field1; + byte _field3; int _fileOffset; + byte _xorMask; + int _size; + byte *_data; public: BoltEntry(Common::SeekableReadStream *f); + virtual ~BoltEntry(); void load(); }; @@ -96,8 +108,7 @@ public: public: FilesManager(); - bool openBOLTLib(const Common::String &filename, BoltFile *&boltFile); - + bool openBoltLib(const Common::String &filename, BoltFile *&boltFile); }; } // End of namespace Voyeur diff --git a/engines/voyeur/voyeur.cpp b/engines/voyeur/voyeur.cpp index dc3fcb221a..256a642de0 100644 --- a/engines/voyeur/voyeur.cpp +++ b/engines/voyeur/voyeur.cpp @@ -96,8 +96,10 @@ void VoyeurEngine::ESP_Init() { } void VoyeurEngine::globalInitBolt() { - _filesManager.openBOLTLib("buoy.blt", _bVoyBoltFile); - + _filesManager.openBoltLib("bvoy.blt", _bVoyBoltFile); + _bVoyBoltFile->getBoltGroup(0x10000); + _bVoyBoltFile->getBoltGroup(0x10100); + _fontPtr = _bVoyBoltFile->memberAddr(0x101); } diff --git a/engines/voyeur/voyeur.h b/engines/voyeur/voyeur.h index 8b5eb75ba0..fb30359130 100644 --- a/engines/voyeur/voyeur.h +++ b/engines/voyeur/voyeur.h @@ -66,6 +66,7 @@ private: GraphicsManager _graphicsManager; BoltFile *_bVoyBoltFile; + byte *_fontPtr; void ESP_Init(); void initialiseManagers(); |