Hi,
I don't know if this forum is the correct to ask for help, but I hope that someone can give me light to this.
I'm trying to translate a game (Star Trek Judgment Rites, Enhanced CD, from English to Spanish), it is very old, from 1993, from Interplay, but the files are compressed with LZSS (or similar) algorithm.
I have a fake compression algorithm, which increases the size of the file, but I need the original compression to avoid the files to be bigger than 0xFFFF.
I tried to make the compression algorithm, tested another bunch of codes for LZSS found in inet, but without success.
This is the decompression algorithm for the files (it can be improved, of course, but this is not what I'm searching for now). I need the compression algorithm if possible:
Code:
void _uncompresslzss(uint32 CompSize, uint32 UnCompSize) {
int N = 0x1000; // This is 4096.
int THRESHOLD = 3, i = 0, j = 0;
byte *HisBuf = new byte[N];
byte b = 0, Length = 0, flagbyte = 0;
unsigned short int offsetlen;
uint32 outstreampos = 0;
uint32 bufpos = 0;
bool end = false;
unsigned int BytesRead = 0, Offset = 0;
memset(HisBuf, 0, N);
BytesRead = 0;
while (!end) {
flagbyte = (byte)compdata[BytesRead];
if (BytesRead == CompSize) end = true;
BytesRead++;
if (!end) {
for (i = 0; i < 8; i++) {
if ((flagbyte & (1 << i)) == 0) {
offsetlen = (byte)compdata[BytesRead] + ((byte)compdata[BytesRead + 1] << 8);
if (BytesRead == CompSize) end = true;
BytesRead += 2;
if (!end) {
Length = (offsetlen & 0xF) + THRESHOLD;
Offset = bufpos - ((offsetlen >> 4) & (N - 1));
for (j = 0; j < Length; j++) {
b = HisBuf[(Offset + j) & (N - 1)];
uncompdata[outstreampos++] = b;
HisBuf[bufpos] = b;
bufpos = (bufpos + 1) & (N - 1);
}
}
}
else {
b = (byte)compdata[BytesRead];
if (BytesRead == CompSize) end = true;
BytesRead++;
if (!end) {
uncompdata[outstreampos++] = b;
HisBuf[bufpos] = b;
bufpos = (bufpos + 1) & (N - 1);
}
}
}
}
}
if (outstreampos != UnCompSize)
printf("WARNING: file might not have been extracted correctly! ");
}
I attached two sample files (2x compressed + 2x uncompressed), one is bigger than the other, which is very small:
I hope someone can help me, as far as I've seen there is not any tool for the compression algorithm (at least I have not found it).
Any help will be appreciated.
Thanks a lot.