diff options
author | Paul Gilbert | 2016-02-15 16:17:38 -0500 |
---|---|---|
committer | Paul Gilbert | 2016-02-15 16:17:38 -0500 |
commit | 2753998868fe9f456b87f87a786fb5d58fb2c232 (patch) | |
tree | fa7d1c82c6144e84e4d720a26a5a46f2a7abf983 /engines/titanic/files.cpp | |
parent | 84c24b08079bc787e17995868fdd426f0a58d3da (diff) | |
download | scummvm-rg350-2753998868fe9f456b87f87a786fb5d58fb2c232.tar.gz scummvm-rg350-2753998868fe9f456b87f87a786fb5d58fb2c232.tar.bz2 scummvm-rg350-2753998868fe9f456b87f87a786fb5d58fb2c232.zip |
TITANIC: Work on decompressor
Diffstat (limited to 'engines/titanic/files.cpp')
-rw-r--r-- | engines/titanic/files.cpp | 96 |
1 files changed, 78 insertions, 18 deletions
diff --git a/engines/titanic/files.cpp b/engines/titanic/files.cpp index a49c47a9ab..6432595748 100644 --- a/engines/titanic/files.cpp +++ b/engines/titanic/files.cpp @@ -171,8 +171,79 @@ double SimpleFile::readFloat() { /*------------------------------------------------------------------------*/ +DecompressorData::DecompressorData() { + _field0 = 0; + _field4 = 0; + _field8 = 0; + _fieldC = 0; + _field10 = 0; + _field14 = 0; +} + +/*------------------------------------------------------------------------*/ + +Decompressor::Decompressor() { + _createFn = nullptr; + _destroyFn = nullptr; + _field18 = 0; + _dataPtr = nullptr; + _field28 = 0; +} + +void Decompressor::load(const char *version, int v) { + if (!version || *version != '1') + error("Bad version"); + + _field18 = 0; + if (!_createFn) { + _createFn = &Decompressor::createMethod; + _field28 = 0; + } + + if (!_destroyFn) { + _destroyFn = &Decompressor::destroyMethod; + } + + _dataPtr = (this->*_createFn)(_field28, 1, 24); + _dataPtr->_field14 = 0; + _dataPtr->_fieldC = 0; + if (v < 0) { + v = -v; + _dataPtr->_fieldC = 1; + } + + if (v < 8 || v > 15) + error("Bad parameter"); + + _dataPtr->_field10 = v; + _dataPtr->_field14 = sub1(_dataPtr->_fieldC ? nullptr : &Decompressor::method3, 1 << v); + + if (_dataPtr->_field14) + sub2(); + else + close(); +} + +int Decompressor::sub1(Method3Fn fn, int v) { + +} + +void Decompressor::close() { + +} + +DecompressorData *Decompressor::createMethod(int v1, int v2, int v3) { + return new DecompressorData(); +} + +void Decompressor::destroyMethod(DecompressorData *ptr) { + delete ptr; +} + +/*------------------------------------------------------------------------*/ + CompressedFile::CompressedFile() : SimpleFile() { - _field48 = 0; + _fileMode = 0; _isReading = 0; _field260 = 0; _mode = 0; @@ -185,10 +256,11 @@ void CompressedFile::open(const Common::String &name, FileMode mode) { SimpleFile::open(name, mode); if (mode == FILE_READ) { - validate(&_mode, "1.0.4", 0x38); - _field48 = 2; + _decompressor.load(); + _fileMode = 2; } else if (mode == FILE_WRITE) { - validate(&_mode, "1.0.4", 0x38); + _decompressor.load(); + _fileMode = 1; } } void CompressedFile::close() { @@ -211,7 +283,8 @@ size_t CompressedFile::unsafeRead(void *dst, size_t count) { while (count > 0) { if (_queue.empty()) { decompress(); - + if (_queue.empty()) + break; } *dataPtr++ = _queue.pop(); @@ -222,19 +295,6 @@ size_t CompressedFile::unsafeRead(void *dst, size_t count) { return bytesRead; } -void CompressedFile::validate(int *mode, const char *version, int v3) { - validate2(mode, 15, version, v3); -} - -int CompressedFile::validate2(int *mode, int v15, const char *version, int v3) { - if (!version || *version != '1' || v3 != 0x38) - return -6; - if (!mode) - return -2; - - // TODO -} - void CompressedFile::decompress() { } |