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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef SKY_RNC_DECO_H
24 #define SKY_RNC_DECO_H
25 
26 
27 
28 #define RNC_SIGNATURE   0x524E4301 // "RNC\001"
29 
30 namespace Sky {
31 
32 class RncDecoder {
33 
34 protected:
35 	uint16 _rawTable[64];
36 	uint16 _posTable[64];
37 	uint16 _lenTable[64];
38 	uint16 _crcTable[256];
39 
40 	uint16 _bitBuffl;
41 	uint16 _bitBuffh;
42 	uint8 _bitCount;
43 
44 	const uint8 *_srcPtr;
45 	uint8 *_dstPtr;
46 
47 public:
48 	RncDecoder();
49 	~RncDecoder();
50 	int32 unpackM1(const void *input, void *output, uint16 key);
51 
52 protected:
53 	void initCrc();
54 	uint16 crcBlock(const uint8 *block, uint32 size);
55 	uint16 inputBits(uint8 amount);
56 	void makeHufftable(uint16 *table);
57 	uint16 inputValue(uint16 *table);
58 
59 };
60 
61 } // End of namespace Sky
62 
63 #endif
64