COMMON: Uplift rnc decoder from toon to common

Toon has a RNC implementation with 2 differences from the one taken from SKY:

1. Protection against overread. Add it to common version and adjust callers
   in sky.
2. Lack of key parameter for obfuscation. We ignore it anyway and don't
   support obfuscation, so delete it in common version as well
This commit is contained in:
Vladimir Serbinenko 2022-11-25 02:43:21 +01:00
parent 074888e6b8
commit c5373134d2
7 changed files with 187 additions and 467 deletions

View file

@ -132,7 +132,7 @@ uint8 *Disk::loadFile(uint16 fileNr) {
if ((fileFlags >> 22) & 0x1) { //do we include the header?
// don't return the file's header
output = uncompDest;
unpackLen = _rncDecoder.unpackM1(input, output, 0);
unpackLen = _rncDecoder.unpackM1(input, fileSize - sizeof(DataFileHeader), output);
} else {
#ifdef SCUMM_BIG_ENDIAN
// Convert DataFileHeader to BE (it only consists of 16 bit words)
@ -143,7 +143,7 @@ uint8 *Disk::loadFile(uint16 fileNr) {
memcpy(uncompDest, fileDest, sizeof(DataFileHeader));
output = uncompDest + sizeof(DataFileHeader);
unpackLen = _rncDecoder.unpackM1(input, output, 0);
unpackLen = _rncDecoder.unpackM1(input, fileSize - sizeof(DataFileHeader), output);
if (unpackLen)
unpackLen += sizeof(DataFileHeader);
}