aboutsummaryrefslogtreecommitdiff
path: root/engines/made/redreader.h
diff options
context:
space:
mode:
authorBenjamin Haisch2008-04-23 08:08:37 +0000
committerBenjamin Haisch2008-04-23 08:08:37 +0000
commit6069dba988e9940b4d5285d6abc01b83967f8702 (patch)
tree3e70fa2ecffca571d1dde627a5f052653a44ae57 /engines/made/redreader.h
parent18ed600abea41fee47f92fa798f6fe49c5c37d25 (diff)
downloadscummvm-rg350-6069dba988e9940b4d5285d6abc01b83967f8702.tar.gz
scummvm-rg350-6069dba988e9940b4d5285d6abc01b83967f8702.tar.bz2
scummvm-rg350-6069dba988e9940b4d5285d6abc01b83967f8702.zip
Implemented direct loading of rtzcd.dat from the archive rtzcd.red, i.e. the game doesn't have to be installed first to get rtzcd.dat. Also added the respective detection entry.
svn-id: r31661
Diffstat (limited to 'engines/made/redreader.h')
-rw-r--r--engines/made/redreader.h108
1 files changed, 108 insertions, 0 deletions
diff --git a/engines/made/redreader.h b/engines/made/redreader.h
new file mode 100644
index 0000000000..362a94706e
--- /dev/null
+++ b/engines/made/redreader.h
@@ -0,0 +1,108 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef MADE_REDREADER_H
+#define MADE_REDREADER_H
+
+#include "common/util.h"
+#include "common/file.h"
+#include "common/stream.h"
+
+namespace Made {
+
+class RedReader {
+public:
+ Common::MemoryReadStream *load(const char *redFilename, const char *filename);
+ static Common::MemoryReadStream *loadFromRed(const char *redFilename, const char *filename);
+private:
+ struct FileEntry {
+ uint32 compSize, origSize;
+ };
+ bool seekFile(Common::File &fd, FileEntry &fileEntry, const char *filename);
+};
+
+const uint BITBUFSIZ = 16;
+const uint DICBIT = 13;
+const uint DICSIZ = 1 << DICBIT;
+const uint MATCHBIT = 8;
+const uint MAXMATCH = 256;
+const uint THRESHOLD = 3;
+const uint NC = 255 + MAXMATCH + 2 - THRESHOLD;
+const uint CBIT = 9;
+const uint CODE_BIT = 16;
+const uint NP = DICBIT + 1;
+const int NT = CODE_BIT + 3;
+const uint PBIT = 4;
+const uint TBIT = 5;
+const uint NPT = NT;
+
+class LzhDecompressor {
+public:
+ LzhDecompressor();
+ ~LzhDecompressor();
+ int decompress(Common::SeekableReadStream &source, byte *dest, uint32 compSize, uint32 origSize);
+private:
+ Common::SeekableReadStream *_source;
+ uint32 _compSize, _blockPos;
+
+ uint16 _bitbuf;
+ uint _subbitbuf;
+ int _bitcount;
+ uint16 _left[2 * NC - 1], _right[2 * NC - 1];
+ byte _c_len[NC], _pt_len[NPT];
+ uint _blocksize;
+ uint16 _c_table[4096], _pt_table[256];
+ int tree_n, heapsize;
+ short heap[NC + 1];
+ uint16 *freq, *sortptr, len_cnt[17];
+ byte *len_table;
+
+ int decode_i, decode_j;
+ int count_len_depth;
+
+ byte readByte();
+
+ void fillbuf(int count);
+ uint getbits(int count);
+ void init_getbits(void);
+ void decode_start(void);
+ void decode(uint count, byte text[]);
+ void huf_decode_start(void);
+ unsigned int decode_c(void);
+ unsigned int decode_p();
+ void read_pt_len(int nn, int nbit, int i_special);
+ void read_c_len();
+ void count_len(int i);
+ void make_len(int root);
+ void downheap(int i);
+ void make_code(int n, byte len[], uint16 code[]);
+ void make_table(uint nchar, byte bitlen[], uint tablebits, uint16 table[]);
+ int make_tree(int nparm, uint16 freqparm[], byte lenparm[], uint16 codeparm[]);
+
+};
+
+} // End of namespace Made
+
+#endif /* MADE_H */