From 89693d4074091bfb998fc6fbdbfe585f53a6ad13 Mon Sep 17 00:00:00 2001 From: richiesams Date: Sun, 7 Jul 2013 10:35:00 -0500 Subject: ZVISION: Create class for decompressing and reading LZSS --- engines/zvision/lzss_read_stream.h | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 engines/zvision/lzss_read_stream.h (limited to 'engines/zvision/lzss_read_stream.h') diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h new file mode 100644 index 0000000000..7e6511a5a9 --- /dev/null +++ b/engines/zvision/lzss_read_stream.h @@ -0,0 +1,75 @@ +/* ScummVM - Graphic Adventure Engine +* +* ScummVM is the legal property of its developers, whose names +* are too numerous to list here. Please refer to the COPYRIGHT +* file distributed with this source distribution. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef ZVISION_LZSS_STREAM_H +#define ZVISION_LZSS_STREAM_H + +#include "common/types.h" +#include "common/stream.h" +#include "common/memstream.h" +#include "common/array.h" + +namespace ZVision { + +class LzssReadStream : public Common::ReadStream { +public: + /** + * A class that decompresses LZSS data and implements ReadStream for easy access + * to the decompiled data. It can either decompress all the data in the beginning + * or decompress as needed by read(). + * + * @param source The source data + * @param stream Decompress the data as needed (true) or all at once (false) + * @param decompressedSize The size of the decompressed data. If npos, the class will choose a size and grow as needed + */ + LzssReadStream(Common::SeekableReadStream *source, bool stream = true, uint32 decompressedSize = npos); + +public: + static const uint32 npos = 0xFFFFFFFFu; + static const uint16 blockSize = 0x1000u; + +private: + Common::SeekableReadStream *_source; + Common::Array _destination; + char _window[blockSize]; + uint16 _windowCursor; + uint32 _readCursor; + +public: + bool eos() const; + uint32 read(void *dataPtr, uint32 dataSize); + uint32 currentSize() const; + +private: + /** + * Decompress the next from the source stream. Or until EOS + * + * @param numberOfBytes How many bytes to decompress. This is a count of source bytes, not destination bytes + */ + void decompressBytes(uint32 numberOfBytes); + /** Decompress all of the source stream. */ + void decompressAll(); +}; + +} + +#endif -- cgit v1.2.3 From ec7915bcb9d507979fa51d76de736f10b8060255 Mon Sep 17 00:00:00 2001 From: richiesams Date: Sun, 7 Jul 2013 11:45:59 -0500 Subject: ZVISION: Fix eos checking in LzssReadStream --- engines/zvision/lzss_read_stream.h | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/zvision/lzss_read_stream.h') diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h index 7e6511a5a9..9ef1d6da37 100644 --- a/engines/zvision/lzss_read_stream.h +++ b/engines/zvision/lzss_read_stream.h @@ -53,6 +53,7 @@ private: char _window[blockSize]; uint16 _windowCursor; uint32 _readCursor; + bool _eosFlag; public: bool eos() const; -- cgit v1.2.3 From 8de12fcbd2dbfddd45bd7916e1e90b5b3e4466bc Mon Sep 17 00:00:00 2001 From: richiesams Date: Mon, 15 Jul 2013 10:36:24 -0500 Subject: ZVISION: Add underscore prefix to public static variable names --- engines/zvision/lzss_read_stream.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/zvision/lzss_read_stream.h') diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h index 9ef1d6da37..142bf9e1a2 100644 --- a/engines/zvision/lzss_read_stream.h +++ b/engines/zvision/lzss_read_stream.h @@ -41,16 +41,16 @@ public: * @param stream Decompress the data as needed (true) or all at once (false) * @param decompressedSize The size of the decompressed data. If npos, the class will choose a size and grow as needed */ - LzssReadStream(Common::SeekableReadStream *source, bool stream = true, uint32 decompressedSize = npos); + LzssReadStream(Common::SeekableReadStream *source, bool stream = true, uint32 decompressedSize = _npos); public: - static const uint32 npos = 0xFFFFFFFFu; - static const uint16 blockSize = 0x1000u; + static const uint32 _npos = 0xFFFFFFFFu; + static const uint16 _blockSize = 0x1000u; private: Common::SeekableReadStream *_source; Common::Array _destination; - char _window[blockSize]; + char _window[_blockSize]; uint16 _windowCursor; uint32 _readCursor; bool _eosFlag; -- cgit v1.2.3 From 47161ef30d8d7350a92fe28a031437abb338732c Mon Sep 17 00:00:00 2001 From: richiesams Date: Wed, 17 Jul 2013 15:37:46 -0500 Subject: ZVISION: LZSSReadStream - Decompress directly to the destination buffer instead of an intermediate buffer --- engines/zvision/lzss_read_stream.h | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'engines/zvision/lzss_read_stream.h') diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h index 142bf9e1a2..0dea25b325 100644 --- a/engines/zvision/lzss_read_stream.h +++ b/engines/zvision/lzss_read_stream.h @@ -34,14 +34,11 @@ class LzssReadStream : public Common::ReadStream { public: /** * A class that decompresses LZSS data and implements ReadStream for easy access - * to the decompiled data. It can either decompress all the data in the beginning - * or decompress as needed by read(). + * to the decompiled data. * * @param source The source data - * @param stream Decompress the data as needed (true) or all at once (false) - * @param decompressedSize The size of the decompressed data. If npos, the class will choose a size and grow as needed */ - LzssReadStream(Common::SeekableReadStream *source, bool stream = true, uint32 decompressedSize = _npos); + LzssReadStream(Common::SeekableReadStream *source); public: static const uint32 _npos = 0xFFFFFFFFu; @@ -49,7 +46,6 @@ public: private: Common::SeekableReadStream *_source; - Common::Array _destination; char _window[_blockSize]; uint16 _windowCursor; uint32 _readCursor; @@ -58,7 +54,6 @@ private: public: bool eos() const; uint32 read(void *dataPtr, uint32 dataSize); - uint32 currentSize() const; private: /** @@ -66,9 +61,7 @@ private: * * @param numberOfBytes How many bytes to decompress. This is a count of source bytes, not destination bytes */ - void decompressBytes(uint32 numberOfBytes); - /** Decompress all of the source stream. */ - void decompressAll(); + uint32 decompressBytes(byte* destination, uint32 numberOfBytes); }; } -- cgit v1.2.3 From 471364077953509ae7528d3097ca746fe5588f7c Mon Sep 17 00:00:00 2001 From: richiesams Date: Fri, 19 Jul 2013 10:24:02 -0500 Subject: ZVISION: Remove extraneous member variable --- engines/zvision/lzss_read_stream.h | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/zvision/lzss_read_stream.h') diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h index 0dea25b325..b2d6085a29 100644 --- a/engines/zvision/lzss_read_stream.h +++ b/engines/zvision/lzss_read_stream.h @@ -48,7 +48,6 @@ private: Common::SeekableReadStream *_source; char _window[_blockSize]; uint16 _windowCursor; - uint32 _readCursor; bool _eosFlag; public: -- cgit v1.2.3 From 94000e07811831f1ffdb2575b0cc3513c34a1d36 Mon Sep 17 00:00:00 2001 From: richiesams Date: Fri, 19 Jul 2013 10:25:02 -0500 Subject: ZVISION: Replace includes with forward declarations --- engines/zvision/lzss_read_stream.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'engines/zvision/lzss_read_stream.h') diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h index b2d6085a29..0814220728 100644 --- a/engines/zvision/lzss_read_stream.h +++ b/engines/zvision/lzss_read_stream.h @@ -25,9 +25,12 @@ #include "common/types.h" #include "common/stream.h" -#include "common/memstream.h" #include "common/array.h" +namespace Common { +class SeekableReadStream; +} + namespace ZVision { class LzssReadStream : public Common::ReadStream { -- cgit v1.2.3 From f1135292d0d714187b719988dba8d5a7d487fe94 Mon Sep 17 00:00:00 2001 From: richiesams Date: Tue, 30 Jul 2013 14:25:31 -0500 Subject: ZVISION: Optimize integer type usages The general thought is int is faster than int16 or byte. So if you can afford the space, use it over int16 or byte. Also, only use int32 when you specifically need the 32 bits. --- engines/zvision/lzss_read_stream.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/zvision/lzss_read_stream.h') diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h index 0814220728..25bb66339e 100644 --- a/engines/zvision/lzss_read_stream.h +++ b/engines/zvision/lzss_read_stream.h @@ -49,8 +49,8 @@ public: private: Common::SeekableReadStream *_source; - char _window[_blockSize]; - uint16 _windowCursor; + byte _window[BLOCK_SIZE]; + uint _windowCursor; bool _eosFlag; public: -- cgit v1.2.3 From 8ec0a90611560dcb29d0ceb8fc476408c0de4103 Mon Sep 17 00:00:00 2001 From: richiesams Date: Tue, 30 Jul 2013 14:38:58 -0500 Subject: ZVISION: Convert _blockSize to an anonymous enum --- engines/zvision/lzss_read_stream.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/zvision/lzss_read_stream.h') diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h index 25bb66339e..25a8b67222 100644 --- a/engines/zvision/lzss_read_stream.h +++ b/engines/zvision/lzss_read_stream.h @@ -43,9 +43,10 @@ public: */ LzssReadStream(Common::SeekableReadStream *source); -public: - static const uint32 _npos = 0xFFFFFFFFu; - static const uint16 _blockSize = 0x1000u; +private: + enum { + BLOCK_SIZE = 0x1000 + }; private: Common::SeekableReadStream *_source; -- cgit v1.2.3 From bad28dc15872e208bf21f1e6fa2ab906bca598c4 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Tue, 1 Oct 2013 20:08:41 -0500 Subject: ZVISION: Standardize includes order and format Format is: common/scummsys.h (Only if a .cpp file) header file for this file (Only if a .cpp file) zengine includes other includes, grouped by module --- engines/zvision/lzss_read_stream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision/lzss_read_stream.h') diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h index 25a8b67222..f6b1eb1a65 100644 --- a/engines/zvision/lzss_read_stream.h +++ b/engines/zvision/lzss_read_stream.h @@ -23,10 +23,10 @@ #ifndef ZVISION_LZSS_STREAM_H #define ZVISION_LZSS_STREAM_H -#include "common/types.h" #include "common/stream.h" #include "common/array.h" + namespace Common { class SeekableReadStream; } -- cgit v1.2.3