[Scummvm-cvs-logs] SF.net SVN: scummvm: [25646] scummvm/trunk/engines/scumm/smush

cyx at users.sourceforge.net cyx at users.sourceforge.net
Sat Feb 17 02:33:48 CET 2007


Revision: 25646
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25646&view=rev
Author:   cyx
Date:     2007-02-16 17:33:47 -0800 (Fri, 16 Feb 2007)

Log Message:
-----------
cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/smush/codec47.cpp
    scummvm/trunk/engines/scumm/smush/smush_player.cpp
    scummvm/trunk/engines/scumm/smush/smush_player.h

Modified: scummvm/trunk/engines/scumm/smush/codec47.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/codec47.cpp	2007-02-17 01:24:50 UTC (rev 25645)
+++ scummvm/trunk/engines/scumm/smush/codec47.cpp	2007-02-17 01:33:47 UTC (rev 25646)
@@ -543,7 +543,6 @@
 	int32 seq_nb = READ_LE_UINT16(src + 0);
 
 	const byte *gfx_data = src + 26;
-	byte *tmp_ptr;
 
 	if (seq_nb == 0) {
 		makeTables47(_width);
@@ -583,14 +582,10 @@
 
 	if (seq_nb == _prevSeqNb + 1) {
 		if (src[3] == 1) {
-			tmp_ptr = _curBuf;
-			_curBuf = _deltaBufs[1];
-			_deltaBufs[1] = tmp_ptr;
+			SWAP(_curBuf, _deltaBufs[1]);
 		} else if (src[3] == 2) {
-			tmp_ptr = _deltaBufs[0];
-			_deltaBufs[0] = _deltaBufs[1];
-			_deltaBufs[1] = _curBuf;
-			_curBuf = tmp_ptr;
+			SWAP(_deltaBufs[0], _deltaBufs[1]);
+			SWAP(_deltaBufs[1], _curBuf);
 		}
 	}
 	_prevSeqNb = seq_nb;

Modified: scummvm/trunk/engines/scumm/smush/smush_player.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/smush_player.cpp	2007-02-17 01:24:50 UTC (rev 25645)
+++ scummvm/trunk/engines/scumm/smush/smush_player.cpp	2007-02-17 01:33:47 UTC (rev 25646)
@@ -63,6 +63,7 @@
 namespace Scumm {
 
 static const int MAX_STRINGS = 200;
+static const int ETRS_HEADER_LENGTH = 16;
 
 class StringResource {
 private:
@@ -193,26 +194,13 @@
 	theFile.read(filebuffer, length);
 	filebuffer[length] = 0;
 
-	if (is_encoded) {
-		enum {
-			ETRS_HEADER_LENGTH = 16
-		};
+	if (is_encoded && READ_BE_UINT32(filebuffer) == MKID_BE('ETRS')) {
 		assert(length > ETRS_HEADER_LENGTH);
-		Chunk::type type = READ_BE_UINT32(filebuffer);
-
-		if (type != MKID_BE('ETRS')) {
-			delete [] filebuffer;
-			return getStrings(vm, file, false);
-		}
-
-		char *old = filebuffer;
-		filebuffer = new char[length - ETRS_HEADER_LENGTH + 1];
-		for (int32 i = ETRS_HEADER_LENGTH; i < length; i++) {
-			filebuffer[i - ETRS_HEADER_LENGTH] = old[i] ^ 0xCC;
-		}
-		filebuffer[length - ETRS_HEADER_LENGTH] = '\0';
-		delete []old;
 		length -= ETRS_HEADER_LENGTH;
+		for (int i = 0; i < length; ++i) {
+			filebuffer[i] = filebuffer[i + ETRS_HEADER_LENGTH] ^ 0xCC;
+		}
+		filebuffer[length] = '\0';
 	}
 	StringResource *sr = new StringResource;
 	assert(sr);
@@ -721,7 +709,7 @@
 		return true;
 	}
 
-	if ((_strings = getStrings(_vm, "digtxt.trs", true)) != 0) {
+	if (_vm->_game.id == GID_DIG && (_strings = getStrings(_vm, "digtxt.trs", true)) != 0) {
 		return true;
 	}
 	return false;
@@ -733,11 +721,7 @@
 
 static byte delta_color(byte org_color, int16 delta_color) {
 	int t = (org_color * 129 + delta_color) / 128;
-	if (t > 255)
-		t = 255;
-	if (t < 0)
-		t = 0;
-	return (byte)t;
+	return CLIP(t, 0, 255);
 }
 
 void SmushPlayer::handleDeltaPalette(Chunk &b) {
@@ -783,6 +767,26 @@
 void smush_decode_codec1(byte *dst, const byte *src, int left, int top, int width, int height, int pitch);
 
 void SmushPlayer::decodeFrameObject(int codec, const uint8 *src, int left, int top, int width, int height) {
+	if ((height == 242) && (width == 384)) {
+		if (_specialBuffer == 0)
+			_specialBuffer = (byte *)malloc(242 * 384);
+		_dst = _specialBuffer;
+	} else if ((height > _vm->_screenHeight) || (width > _vm->_screenWidth))
+		return;
+	// FT Insane uses smaller frames to draw overlays with moving objects
+	// Other .san files do have them as well but their purpose in unknown
+	// and often it causes memory overdraw. So just skip those frames
+	else if (!_insanity && ((height != _vm->_screenHeight) || (width != _vm->_screenWidth)))
+		return;
+
+	if ((height == 242) && (width == 384)) {
+		_width = width;
+		_height = height;
+	} else {
+		_width = _vm->_screenWidth;
+		_height = _vm->_screenHeight;
+	}
+
 	switch (codec) {
 	case 1:
 	case 3:
@@ -803,6 +807,14 @@
 	default:
 		error("Invalid codec for frame object : %d", codec);
 	}
+
+	if (_storeFrame) {
+		if (_frameBuffer == NULL) {
+			_frameBuffer = (byte *)malloc(_width * _height);
+		}
+		memcpy(_frameBuffer, _dst, _width * _height);
+		_storeFrame = false;
+	}
 }
 
 #ifdef USE_ZLIB
@@ -831,37 +843,8 @@
 	int width = READ_LE_UINT16(ptr); ptr += 2;
 	int height = READ_LE_UINT16(ptr); ptr += 2;
 
-	if ((height == 242) && (width == 384)) {
-		if (_specialBuffer == 0)
-			_specialBuffer = (byte *)malloc(242 * 384);
-		_dst = _specialBuffer;
-	} else if ((height > _vm->_screenHeight) || (width > _vm->_screenWidth))
-		return;
-
-	// FT Insane uses smaller frames to draw overlays with moving objects
-	// Other .san files do have them as well but their purpose in unknown
-	// and often it causes memory overdraw. So just skip those frames
-	else if (!_insanity && ((height != _vm->_screenHeight) || (width != _vm->_screenWidth)))
-		return;
-
-	if ((height == 242) && (width == 384)) {
-		_width = width;
-		_height = height;
-	} else {
-		_width = _vm->_screenWidth;
-		_height = _vm->_screenHeight;
-	}
-
 	decodeFrameObject(codec, fobjBuffer + 14, left, top, width, height);
 
-	if (_storeFrame) {
-		if (_frameBuffer == NULL) {
-			_frameBuffer = (byte *)malloc(_width * _height);
-		}
-		memcpy(_frameBuffer, _dst, _width * _height);
-		_storeFrame = false;
-	}
-
 	free(fobjBuffer);
 }
 #endif
@@ -879,26 +862,6 @@
 	int width = b.readUint16LE();
 	int height = b.readUint16LE();
 
-	if ((height == 242) && (width == 384)) {
-		if (_specialBuffer == 0)
-			_specialBuffer = (byte *)malloc(242 * 384);
-		_dst = _specialBuffer;
-	} else if ((height > _vm->_screenHeight) || (width > _vm->_screenWidth))
-		return;
-	// FT Insane uses smaller frames to draw overlays with moving objects
-	// Other .san files do have them as well but their purpose in unknown
-	// and often it causes memory overdraw. So just skip those frames
-	else if (!_insanity && ((height != _vm->_screenHeight) || (width != _vm->_screenWidth)))
-		return;
-
-	if ((height == 242) && (width == 384)) {
-		_width = width;
-		_height = height;
-	} else {
-		_width = _vm->_screenWidth;
-		_height = _vm->_screenHeight;
-	}
-
 	b.readUint16LE();
 	b.readUint16LE();
 
@@ -909,14 +872,6 @@
 
 	decodeFrameObject(codec, chunk_buffer, left, top, width, height);
 
-	if (_storeFrame) {
-		if (_frameBuffer == NULL) {
-			_frameBuffer = (byte *)malloc(_width * _height);
-		}
-		memcpy(_frameBuffer, _dst, _width * _height);
-		_storeFrame = false;
-	}
-
 	free(chunk_buffer);
 }
 
@@ -1376,16 +1331,11 @@
 			skipped = 0;
 		if (_updateNeeded) {
 			if (!skipFrame) {
-				int w = _width, h = _height;
-
 				// Workaround for bug #1386333: "FT DEMO: assertion triggered
 				// when playing movie". Some frames there are 384 x 224
-				if (w > _vm->_screenWidth)
-					w = _vm->_screenWidth;
+				int w = MIN(_width, _vm->_screenWidth);
+				int h = MIN(_height, _vm->_screenHeight);
 
-				if (h > _vm->_screenHeight)
-					h = _vm->_screenHeight;
-
 				_vm->_system->copyRectToScreen(_dst, _width, 0, 0, w, h);
 				_vm->_system->updateScreen();
 				_updateNeeded = false;
@@ -1414,4 +1364,3 @@
 }
 
 } // End of namespace Scumm
-

Modified: scummvm/trunk/engines/scumm/smush/smush_player.h
===================================================================
--- scummvm/trunk/engines/scumm/smush/smush_player.h	2007-02-17 01:24:50 UTC (rev 25645)
+++ scummvm/trunk/engines/scumm/smush/smush_player.h	2007-02-17 01:33:47 UTC (rev 25646)
@@ -71,7 +71,6 @@
 	int32 _IACTpos;
 	bool _storeFrame;
 	int _speed;
-	bool _outputSound;
 	bool _endOfFile;
 
 	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