diff options
| author | Max Horn | 2003-03-06 16:33:29 +0000 | 
|---|---|---|
| committer | Max Horn | 2003-03-06 16:33:29 +0000 | 
| commit | 31890b30fd4d2248c8d0a8791019c73f5112def9 (patch) | |
| tree | 5664b6c630329862ecde7b4da8f8709c452362b0 | |
| parent | 6ce098172f3754a2c279e1e2d156f3354c612011 (diff) | |
| download | scummvm-rg350-31890b30fd4d2248c8d0a8791019c73f5112def9.tar.gz scummvm-rg350-31890b30fd4d2248c8d0a8791019c73f5112def9.tar.bz2 scummvm-rg350-31890b30fd4d2248c8d0a8791019c73f5112def9.zip  | |
more cleanup
svn-id: r6715
| -rw-r--r-- | sky/rnc_deco.cpp | 39 | 
1 files changed, 17 insertions, 22 deletions
diff --git a/sky/rnc_deco.cpp b/sky/rnc_deco.cpp index 541ba6f93f..74339347c9 100644 --- a/sky/rnc_deco.cpp +++ b/sky/rnc_deco.cpp @@ -248,13 +248,14 @@ int32 RncDecoder::unpackM1(void *input, void *output, uint16 key)  		counts = inputBits(16); -		for (;;) { -			uint32 inputBytes = inputValue(_rawTable); - -			if (inputBytes) { -				memcpy(_dstPtr, _srcPtr, inputBytes); //memcpy is allowed here -				_dstPtr += inputBytes; -				_srcPtr += inputBytes; +		do { +			uint32 inputLength = inputValue(_rawTable); +			uint32 inputOffset; + +			if (inputLength) { +				memcpy(_dstPtr, _srcPtr, inputLength); //memcpy is allowed here +				_dstPtr += inputLength; +				_srcPtr += inputLength;  				uint16 b = READ_LE_UINT16(_srcPtr);  				uint16 a = ROL(b, _bitCount);  				uint16 d = ((1 << _bitCount) - 1); @@ -269,22 +270,16 @@ int32 RncDecoder::unpackM1(void *input, void *output, uint16 key)  				_bitBuffh = a;  			} -			if (--counts) { -				uint32 inputOffset = inputValue(_posTable) + 1; -				uint32 inputLength = inputValue(_lenTable) + MIN_LENGTH; - -				inputHigh = _srcPtr; -				_srcPtr = (_dstPtr-inputOffset); - -				//Don't use memcpy here! because input and output overlap	 +			if (counts > 1) { +				inputOffset = inputValue(_posTable) + 1; +				inputLength = inputValue(_lenTable) + MIN_LENGTH; +	 +				// Don't use memcpy here! because input and output overlap. +				uint8 *tmpPtr = (_dstPtr-inputOffset);  				while (inputLength--) -					*_dstPtr++ = *_srcPtr++; - -				_srcPtr = inputHigh; -			} else -				break; - -		} +					*_dstPtr++ = *tmpPtr++; +			} +		} while (--counts);  	} while (--blocks);  	if (CHECKSUMS) {  | 
