2007-05-30 21:56:52 +00:00
|
|
|
/* 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.
|
2003-03-06 15:35:07 +00:00
|
|
|
*
|
2021-12-26 17:47:58 +00:00
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2014-02-18 01:34:25 +00:00
|
|
|
*
|
2003-03-06 15:35:07 +00:00
|
|
|
* 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.
|
2014-02-18 01:34:25 +00:00
|
|
|
*
|
2003-03-06 15:35:07 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-12-26 17:47:58 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-03-06 15:35:07 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-11-25 01:15:46 +00:00
|
|
|
#ifndef COMMON_RNC_DECO_H
|
|
|
|
#define COMMON_RNC_DECO_H
|
2003-03-06 15:35:07 +00:00
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2022-11-25 01:15:46 +00:00
|
|
|
namespace Common {
|
2004-01-03 01:58:58 +00:00
|
|
|
|
2022-11-25 01:15:46 +00:00
|
|
|
// Decoder for RNC (Rob Norton Computing) ProPack compression.
|
2003-03-06 15:35:07 +00:00
|
|
|
class RncDecoder {
|
|
|
|
|
|
|
|
protected:
|
|
|
|
uint16 _rawTable[64];
|
|
|
|
uint16 _posTable[64];
|
|
|
|
uint16 _lenTable[64];
|
|
|
|
uint16 _crcTable[256];
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-03-06 15:35:07 +00:00
|
|
|
uint16 _bitBuffl;
|
|
|
|
uint16 _bitBuffh;
|
|
|
|
uint8 _bitCount;
|
|
|
|
|
2003-07-06 22:50:37 +00:00
|
|
|
const uint8 *_srcPtr;
|
|
|
|
uint8 *_dstPtr;
|
2003-03-06 15:35:07 +00:00
|
|
|
|
2022-11-25 01:43:21 +00:00
|
|
|
int32 _inputByteLeft;
|
|
|
|
|
2003-03-06 15:35:07 +00:00
|
|
|
public:
|
|
|
|
RncDecoder();
|
|
|
|
~RncDecoder();
|
2022-11-25 01:43:21 +00:00
|
|
|
int32 unpackM1(const void *input, uint inputSize, void *output);
|
|
|
|
int32 unpackM2(const void *input, void *output);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2022-11-25 01:43:21 +00:00
|
|
|
static const uint32 kRnc1Signature = 0x524E4301; // "RNC\001"
|
|
|
|
static const uint32 kRnc2Signature = 0x524E4302; // "RNC\002"
|
2022-11-25 01:12:47 +00:00
|
|
|
|
2003-03-06 15:35:07 +00:00
|
|
|
protected:
|
|
|
|
void initCrc();
|
2003-07-06 22:50:37 +00:00
|
|
|
uint16 crcBlock(const uint8 *block, uint32 size);
|
2003-03-06 15:35:07 +00:00
|
|
|
uint16 inputBits(uint8 amount);
|
|
|
|
void makeHufftable(uint16 *table);
|
|
|
|
uint16 inputValue(uint16 *table);
|
2022-11-25 01:43:21 +00:00
|
|
|
int getbit();
|
2003-03-06 15:35:07 +00:00
|
|
|
};
|
|
|
|
|
2022-11-25 01:15:46 +00:00
|
|
|
} // End of namespace Common
|
2004-01-03 01:58:58 +00:00
|
|
|
|
2003-03-06 15:35:07 +00:00
|
|
|
#endif
|