getbit() { int val,length; skip: length=1; val=getc2(in); pos++; if (val==EOF) exit(0); while (val<=0x80) { length++; val=getc2(in); pos++; if (val==EOF) exit(0); } length++; val=getc2(in); pos++; if (val==EOF) exit(0); while (val>=0x80) { length++; val=getc2(in); pos++; if (val==EOF) exit(0); } if (length>30) return 1; else return 0; }
//------------------------------- // Huffman decompressor //------------------------------- int DecompressorHuffman::unpack(Common::ReadStream *src, byte *dest, uint32 nPacked, uint32 nUnpacked) { init(src, dest, nPacked, nUnpacked); byte numnodes; int16 c; uint16 terminator; numnodes = _src->readByte(); terminator = _src->readByte() | 0x100; _nodes = new byte [numnodes << 1]; _src->read(_nodes, numnodes << 1); while ((c = getc2()) != terminator && (c >= 0) && !isFinished()) putByte(c); delete[] _nodes; return _dwWrote == _szUnpacked ? 0 : 1; }