[Scummvm-cvs-logs] SF.net SVN: scummvm:[36060] scummvm/trunk

cyx at users.sourceforge.net cyx at users.sourceforge.net
Sun Jan 25 13:10:06 CET 2009


Revision: 36060
          http://scummvm.svn.sourceforge.net/scummvm/?rev=36060&view=rev
Author:   cyx
Date:     2009-01-25 12:10:06 +0000 (Sun, 25 Jan 2009)

Log Message:
-----------
TUCKER: modified flic playback to make use of dirtyrects

Modified Paths:
--------------
    scummvm/trunk/engines/tucker/sequences.cpp
    scummvm/trunk/engines/tucker/tucker.h
    scummvm/trunk/graphics/video/flic_player.cpp
    scummvm/trunk/graphics/video/flic_player.h

Modified: scummvm/trunk/engines/tucker/sequences.cpp
===================================================================
--- scummvm/trunk/engines/tucker/sequences.cpp	2009-01-25 11:15:30 UTC (rev 36059)
+++ scummvm/trunk/engines/tucker/sequences.cpp	2009-01-25 12:10:06 UTC (rev 36060)
@@ -496,7 +496,6 @@
 AnimationSequencePlayer::AnimationSequencePlayer(OSystem *system, Audio::Mixer *mixer, Common::EventManager *event, int num)
 	: _system(system), _mixer(mixer), _event(event), _seqNum(num) {
 	memset(_animationPalette, 0, sizeof(_animationPalette));
-	memset(_paletteBuffer, 0, sizeof(_paletteBuffer));
 	_soundSeqDataOffset = 0;
 	_soundSeqDataCount = 0;
 	_soundSeqDataIndex = 0;
@@ -559,7 +558,7 @@
 			++_updateFuncIndex;
 			_seqNum = this->_updateFunc[_updateFuncIndex].num;
 		}
-		_system->copyRectToScreen(_offscreenBuffer, 320, 0, 0, kScreenWidth, kScreenHeight);
+		_system->copyRectToScreen(_offscreenBuffer, kScreenWidth, 0, 0, kScreenWidth, kScreenHeight);
 		_system->setPalette(_animationPalette, 0, 256);
 		_system->updateScreen();
 		syncTime();
@@ -832,19 +831,20 @@
 }
 
 void AnimationSequencePlayer::fadeInPalette() {
-	memset(_paletteBuffer, 0, sizeof(_paletteBuffer));
+	uint8 paletteBuffer[256 * 4];
+	memset(paletteBuffer, 0, sizeof(paletteBuffer));
 	bool fadeColors = true;
 	for (int step = 0; step < 64; ++step) {
 		if (fadeColors) {
 			fadeColors = false;
 			for (int i = 0; i < 1024; ++i) {
-				if ((i & 3) != 3 && _paletteBuffer[i] < _animationPalette[i]) {
-					const int color = _paletteBuffer[i] + 4;
-					_paletteBuffer[i] = MIN<int>(color, _animationPalette[i]);
+				if ((i & 3) != 3 && paletteBuffer[i] < _animationPalette[i]) {
+					const int color = paletteBuffer[i] + 4;
+					paletteBuffer[i] = MIN<int>(color, _animationPalette[i]);
 					fadeColors = true;
 				}
 			}
-			_system->setPalette(_paletteBuffer, 0, 256);
+			_system->setPalette(paletteBuffer, 0, 256);
 			_system->updateScreen();
 		}
 		_system->delayMillis(1000 / 60);
@@ -852,19 +852,20 @@
 }
 
 void AnimationSequencePlayer::fadeOutPalette() {
-	memcpy(_paletteBuffer, _animationPalette, 1024);
+	uint8 paletteBuffer[256 * 4];
+	memcpy(paletteBuffer, _animationPalette, 1024);
 	bool fadeColors = true;
 	for (int step = 0; step < 64; ++step) {
 		if (fadeColors) {
 			fadeColors = false;
 			for (int i = 0; i < 1024; ++i) {
-				if ((i & 3) != 3 && _paletteBuffer[i] > 0) {
-					const int color = _paletteBuffer[i] - 4;
-					_paletteBuffer[i] = MAX<int>(0, color);
+				if ((i & 3) != 3 && paletteBuffer[i] > 0) {
+					const int color = paletteBuffer[i] - 4;
+					paletteBuffer[i] = MAX<int>(0, color);
 					fadeColors = true;
 				}
 			}
-			_system->setPalette(_paletteBuffer, 0, 256);
+			_system->setPalette(paletteBuffer, 0, 256);
 			_system->updateScreen();
 		}
 		_system->delayMillis(1000 / 60);
@@ -902,13 +903,13 @@
 	_flicPlayer[index].decodeNextFrame();
 	if (index == 0) {
 		memcpy(_animationPalette, _flicPlayer[index].getPalette(), 1024);
-		memcpy(_offscreenBuffer, _flicPlayer[index].getOffscreen(), kScreenWidth * kScreenHeight);
+		_flicPlayer[index].copyDirtyRectsToBuffer(_offscreenBuffer, kScreenWidth);
 	}
 }
 
 void AnimationSequencePlayer::decodeNextAnimationFrame(int index) {
 	_flicPlayer[index].decodeNextFrame();
-	memcpy(_offscreenBuffer, _flicPlayer[index].getOffscreen(), kScreenWidth * kScreenHeight);
+	_flicPlayer[index].copyDirtyRectsToBuffer(_offscreenBuffer, kScreenWidth);
 	if (index == 0) {
 		if (_flicPlayer[index].isPaletteDirty()) {
 			memcpy(_animationPalette, _flicPlayer[index].getPalette(), 1024);
@@ -946,11 +947,11 @@
 			_flicPlayer[1].reset();
 		}
 	}
-	_flicPlayer[0].decodeNextFrame();
-	const uint8 *t = _flicPlayer[1].getOffscreen();
-	for (int i = 0; i < 64000; ++i) {
-		const uint8 color = _flicPlayer[0].getOffscreen()[i];
-		_offscreenBuffer[i] = color ? color : t[i];
+	decodeNextAnimationFrame(0);
+	for (int i = 0; i < kScreenWidth * kScreenHeight; ++i) {
+		if (_offscreenBuffer[i] == 0) {
+			_offscreenBuffer[i] = _flicPlayer[1].getOffscreen()[i];
+		}
 	}
 	updateSounds();
 	if (_flicPlayer[0].isLastFrame()) {
@@ -1049,13 +1050,14 @@
 }
 
 void AnimationSequencePlayer::drawPic1Part10() {
-	for (int y = 0; y < 200; ++y) {
-		memcpy(_offscreenBuffer + y * 320, _picBufPtr + 800 + y * 640 + _updateScreenWidth, 320);
-	}
-	for (int i = 0; i < 64000; ++i) {
-		const uint8 color = _flicPlayer[0].getOffscreen()[i];
-		if (color) {
-			_offscreenBuffer[i] = color;
+	int offset = 0;
+	for (int y = 0; y < kScreenHeight; ++y) {
+		for (int x = 0; x < kScreenWidth; ++x) {
+			uint8 color = _flicPlayer[0].getOffscreen()[offset];
+			if (color == 0) {
+				color = _picBufPtr[800 + y * 640 + _updateScreenWidth + x];
+			}
+			_offscreenBuffer[offset++] = color;
 		}
 	}
 }
@@ -1070,12 +1072,11 @@
 
 void AnimationSequencePlayer::playIntroSeq9_10() {
 	decodeNextAnimationFrame(0);
-	if (_flicPlayer[0].getCurFrame() == 984) {
-		drawPic2Part10();
-	}
 	if (_flicPlayer[0].getCurFrame() >= 264 && _flicPlayer[0].getCurFrame() <= 295) {
 		drawPic1Part10();
 		_updateScreenWidth += 6;
+	} else if (_flicPlayer[0].getCurFrame() == 984) {
+		drawPic2Part10();
 	} else if (_flicPlayer[0].getCurFrame() >= 988 && _flicPlayer[0].getCurFrame() <= 996) {
 		drawPic1Part10();
 		_updateScreenWidth -= 25;

Modified: scummvm/trunk/engines/tucker/tucker.h
===================================================================
--- scummvm/trunk/engines/tucker/tucker.h	2009-01-25 11:15:30 UTC (rev 36059)
+++ scummvm/trunk/engines/tucker/tucker.h	2009-01-25 12:10:06 UTC (rev 36060)
@@ -912,7 +912,7 @@
 	const SequenceUpdateFunc *_updateFunc;
 	int _updateFuncIndex;
 	::Graphics::FlicPlayer _flicPlayer[2];
-	uint8 _animationPalette[256 * 4], _paletteBuffer[256 * 4];
+	uint8 _animationPalette[256 * 4];
 	int _soundsList1Offset;
 	int _soundsList1Count;
 	int _soundsList2Offset;

Modified: scummvm/trunk/graphics/video/flic_player.cpp
===================================================================
--- scummvm/trunk/graphics/video/flic_player.cpp	2009-01-25 11:15:30 UTC (rev 36059)
+++ scummvm/trunk/graphics/video/flic_player.cpp	2009-01-25 12:10:06 UTC (rev 36060)
@@ -77,6 +77,7 @@
 	if (_flicInfo.type != 0xAF12) {
 		warning("FlicPlayer::FlicPlayer(): attempted to load non-FLC data (type = 0x%04X)", _flicInfo.type);
 		delete _fileStream;
+		_fileStream = 0;
 		return false;
 	}
 
@@ -109,6 +110,8 @@
 
 	delete[] _offscreen;
 	_offscreen = 0;
+
+	_dirtyRects.clear();
 }
 
 void FlicPlayer::redraw() {
@@ -307,6 +310,16 @@
 	}
 }
 
+void FlicPlayer::copyDirtyRectsToBuffer(uint8 *dst, uint pitch) {
+	for (Common::List<Common::Rect>::const_iterator it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
+		for (int y = (*it).top; y < (*it).bottom; ++y) {
+			const int x = (*it).left;
+			memcpy(dst + y * pitch + x, _offscreen + y * _flicInfo.width + x, (*it).right - x);
+		}
+	}
+	_dirtyRects.clear();
+}
+
 void FlicPlayer::copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch) {
 	uint h = _flicInfo.height;
 	uint w = _flicInfo.width;

Modified: scummvm/trunk/graphics/video/flic_player.h
===================================================================
--- scummvm/trunk/graphics/video/flic_player.h	2009-01-25 11:15:30 UTC (rev 36059)
+++ scummvm/trunk/graphics/video/flic_player.h	2009-01-25 12:10:06 UTC (rev 36060)
@@ -105,6 +105,8 @@
 	void redraw();
 	void reset();
 
+	void copyDirtyRectsToBuffer(uint8 *dst, uint pitch);
+
 	/**
 	 * Copy current frame into the specified position of the destination
 	 * buffer.


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