[Scummvm-cvs-logs] SF.net SVN: scummvm:[42861] scummvm/trunk/engines/sword2

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Tue Jul 28 19:54:02 CEST 2009


Revision: 42861
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42861&view=rev
Author:   eriktorbjorn
Date:     2009-07-28 17:53:59 +0000 (Tue, 28 Jul 2009)

Log Message:
-----------
Broken Sword 2, unsurprisingly, had the same subtitle drawing glitch for small
cutscenes that Broken Sword 1 had. And a memory leak. This should fix both.

Modified Paths:
--------------
    scummvm/trunk/engines/sword2/animation.cpp
    scummvm/trunk/engines/sword2/animation.h

Modified: scummvm/trunk/engines/sword2/animation.cpp
===================================================================
--- scummvm/trunk/engines/sword2/animation.cpp	2009-07-28 17:23:17 UTC (rev 42860)
+++ scummvm/trunk/engines/sword2/animation.cpp	2009-07-28 17:53:59 UTC (rev 42861)
@@ -116,7 +116,7 @@
 
 	terminated = !playVideo(stopEvents);
 
-	closeTextObject(_currentMovieText);
+	closeTextObject(_currentMovieText, NULL);
 
 	if (terminated) {
 		_snd->stopHandle(*_bgSoundHandle);
@@ -171,7 +171,7 @@
 	}
 }
 
-void MoviePlayer::closeTextObject(uint32 index) {
+void MoviePlayer::closeTextObject(uint32 index, byte *screen) {
 	if (index < _numMovieTexts) {
 		MovieText *text = &_movieTexts[index];
 
@@ -179,6 +179,32 @@
 		text->_textMem = NULL;
 
 		if (_textSurface) {
+			if (screen) {
+				// If the frame doesn't cover the entire
+				// screen, we have to erase the subtitles
+				// manually.
+
+				int frameWidth = _decoder->getWidth();
+				int frameHeight = _decoder->getHeight();
+				int frameX = (_system->getWidth() - frameWidth) / 2;
+				int frameY = (_system->getHeight() - frameHeight) / 2;
+
+				byte *dst = screen + _textY * _system->getWidth();
+
+				for (int y = 0; y < text->_textSprite.h; y++) {
+					if (_textY + y < frameY || _textY + y >= frameY + frameHeight) {
+						memset(dst + _textX, _decoder->getBlack(), text->_textSprite.w);
+					} else {
+						if (frameX > _textX)
+							memset(dst + _textX, _decoder->getBlack(), frameX - _textX);
+						if (frameX + frameWidth < _textX + text->_textSprite.w)
+							memset(dst + frameX + frameWidth, _decoder->getBlack(), _textX + text->_textSprite.w - (frameX + frameWidth));
+					}
+
+					dst += _system->getWidth();
+				}
+			}
+
 			_vm->_screen->deleteSurface(_textSurface);
 			_textSurface = NULL;
 		}
@@ -204,7 +230,7 @@
 			src = buffer;
 		}
 
-		byte *dst = screen + _textY * _decoder->getWidth() + _textX;
+		byte *dst = screen + _textY * RENDERWIDE + _textX;
 
 		for (int y = 0; y < height; y++) {
 			for (int x = 0; x < width; x++) {
@@ -214,15 +240,11 @@
 					dst[x] = white;
 			}
 			src += width;
-			dst += _decoder->getWidth();
+			dst += RENDERWIDE;
 		}
 	}
 }
 
-// FIXME: This assumes that the subtitles always fit within the frame of the
-// movie. In Broken Sword 2, that's a fairly safe assumption, but not
-// necessarily in all other games.
-
 void MoviePlayer::performPostProcessing(byte *screen) {
 	MovieText *text;
 	int frame = _decoder->getCurFrame();
@@ -247,6 +269,7 @@
 		if (frame <= text->_endFrame) {
 			drawTextObject(_currentMovieText, screen);
 		} else {
+			closeTextObject(_currentMovieText, screen);
 			_currentMovieText++;
 		}
 	}

Modified: scummvm/trunk/engines/sword2/animation.h
===================================================================
--- scummvm/trunk/engines/sword2/animation.h	2009-07-28 17:23:17 UTC (rev 42860)
+++ scummvm/trunk/engines/sword2/animation.h	2009-07-28 17:53:59 UTC (rev 42861)
@@ -98,7 +98,7 @@
 	void performPostProcessing(byte *screen);
 
 	void openTextObject(uint32 index);
-	void closeTextObject(uint32 index);
+	void closeTextObject(uint32 index, byte *screen);
 	void drawTextObject(uint32 index, byte *screen);
 };
 


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