[Scummvm-cvs-logs] SF.net SVN: scummvm: [32653] scummvm/trunk/engines/cine

buddha_ at users.sourceforge.net buddha_ at users.sourceforge.net
Tue Jun 10 23:34:26 CEST 2008


Revision: 32653
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32653&view=rev
Author:   buddha_
Date:     2008-06-10 14:34:26 -0700 (Tue, 10 Jun 2008)

Log Message:
-----------
unpackerHelper2(numBits) -> copyRelocatesBytes(offset, numBytes) and some revising of the unpacking routine.

Modified Paths:
--------------
    scummvm/trunk/engines/cine/unpack.cpp
    scummvm/trunk/engines/cine/unpack.h

Modified: scummvm/trunk/engines/cine/unpack.cpp
===================================================================
--- scummvm/trunk/engines/cine/unpack.cpp	2008-06-10 21:14:38 UTC (rev 32652)
+++ scummvm/trunk/engines/cine/unpack.cpp	2008-06-10 21:34:26 UTC (rev 32653)
@@ -73,12 +73,10 @@
 	}
 }
 
-void CineUnpacker::unpackHelper2(byte numBits) {
-	uint16 i = getBits(numBits);
-	uint16 count = _size + 1;
-	_datasize -= count;
-	while (count--) {
-		*_dst = *(_dst + i);
+void CineUnpacker::copyRelocatedBytes(uint16 offset, uint16 numBytes) {
+	_datasize -= numBytes;
+	while (numBytes--) {
+		*_dst = *(_dst + offset);
 		--_dst;
 	}
 }
@@ -87,28 +85,30 @@
 	_src = src + srcLen - 4;
 	_datasize = readSource();
 	_dst = dst + _datasize - 1;
-	_size = 0;
 	_crc = readSource();
 	_chk = readSource();
 	_crc ^= _chk;
 	do {
 		if (!nextBit()) {
-			_size = 1;
 			if (!nextBit()) {
 				unpackHelper1(3, 0);
 			} else {
-				unpackHelper2(8);
+				uint16 numBytes = 2;
+				uint16 offset   = getBits(8);
+				copyRelocatedBytes(offset, numBytes);
 			}
 		} else {
 			uint16 c = getBits(2);
 			if (c == 3) {
 				unpackHelper1(8, 8);
-			} else if (c < 2) {
-				_size = c + 2;
-				unpackHelper2(c + 9);
-			} else {
-				_size = getBits(8);
-				unpackHelper2(12);
+			} else if (c < 2) { // c == 0 || c == 1
+				uint16 numBytes = c + 3;
+				uint16 offset   = getBits(c + 9);
+				copyRelocatedBytes(offset, numBytes);
+			} else { // c == 2
+				uint16 numBytes = getBits(8) + 1;
+				uint16 offset   = getBits(12);
+				copyRelocatedBytes(offset, numBytes);
 			}
 		}
 	} while (_datasize > 0 && _src >= src - 4);

Modified: scummvm/trunk/engines/cine/unpack.h
===================================================================
--- scummvm/trunk/engines/cine/unpack.h	2008-06-10 21:14:38 UTC (rev 32652)
+++ scummvm/trunk/engines/cine/unpack.h	2008-06-10 21:34:26 UTC (rev 32653)
@@ -42,9 +42,9 @@
 	int nextBit();
 	uint16 getBits(byte numBits);
 	void unpackHelper1(byte numBits, byte addCount);
-	void unpackHelper2(byte numBits);
+	void copyRelocatedBytes(uint16 offset, uint16 numBytes);
 private:
-	int _size, _datasize;
+	int _datasize;
 	uint32 _crc;
 	uint32 _chk;
 	byte *_dst;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list