ScummVM API documentation
compression.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef MADS_COMPRESSION_H
23 #define MADS_COMPRESSION_H
24 
25 #include "common/memstream.h"
26 #include "common/path.h"
27 #include "common/stream.h"
28 
29 namespace MADS {
30 
31 class RexNebularEngine;
32 
33 enum CompressionType { COMPRESS_NONE = 0, COMPRESS_FAB = 1 };
34 
35 struct MadsPackEntry {
36 public:
37  CompressionType _type;
38  byte _priority;
39  uint32 _size;
40  uint32 _compressedSize;
41  byte *_data;
42 };
43 
44 class MadsPack {
45 private:
46  MadsPackEntry *_items;
47  int _count;
48  int _dataOffset;
49 
50  void initialize(Common::SeekableReadStream *stream);
51 public:
52  static bool isCompressed(Common::SeekableReadStream *stream);
54  MadsPack(const Common::Path &resourceName, RexNebularEngine *_vm);
55  ~MadsPack();
56 
57  int getCount() const { return _count; }
58  MadsPackEntry &getItem(int index) const {
59  assert(index < _count);
60  return _items[index]; }
61  MadsPackEntry &operator[](int index) const {
62  assert(index < _count);
63  return _items[index];
64  }
65  Common::MemoryReadStream *getItemStream(int index) {
66  assert(index < _count);
67  return new Common::MemoryReadStream(_items[index]._data, _items[index]._size,
68  DisposeAfterUse::NO);
69  }
70  int getDataOffset() const { return _dataOffset; }
71 };
72 
74 private:
75  int _bitsLeft;
76  uint32 _bitBuffer;
77  const byte *_srcData, *_srcP;
78  int _srcSize;
79 
80  int getBit();
81 public:
82  void decompress(const byte *srcData, int srcSize, byte *destData, int destSize);
83 };
84 
85 } // namespace MADS
86 
87 #endif
Definition: compression.h:35
Definition: compression.h:73
Definition: path.h:52
Definition: stream.h:745
Definition: compression.h:44
Definition: nebular.h:50
Definition: memstream.h:43
Definition: action.h:28