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

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Wed Aug 23 23:13:30 CEST 2006


Revision: 23742
Author:   eriktorbjorn
Date:     2006-08-23 14:13:11 -0700 (Wed, 23 Aug 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=23742&view=rev

Log Message:
-----------
The DXA player now bases subtitle position on screen size, rather than frame
size. This should help people who want to use the smaller, low-quality
cutscenes instead of the high-quality ones.

The MPEG player probably doesn't know this trick. Maybe later.

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	2006-08-23 04:26:01 UTC (rev 23741)
+++ scummvm/trunk/engines/sword2/animation.cpp	2006-08-23 21:13:11 UTC (rev 23742)
@@ -219,12 +219,21 @@
 	}
 }
 
+void MoviePlayer::calcTextPosition(MovieTextObject *t, int &xPos, int &yPos) {
+	xPos = 320 - t->textSprite->w / 2;
+	yPos = 420 - t->textSprite->h;
+}
+
 void MoviePlayer::drawTextObject(MovieTextObject *t) {
 	if (t->textSprite && _textSurface) {
 		int screenWidth = _vm->_screen->getScreenWide();
 		byte *src = t->textSprite->data;
-		byte *dst = _frameBuffer + (_frameY + _frameHeight - t->textSprite->h - 20) * screenWidth + _frameX + (_frameWidth - t->textSprite->w) / 2;
+		int xPos, yPos;
 
+		calcTextPosition(t, xPos, yPos);
+
+		byte *dst = _frameBuffer + yPos * screenWidth + xPos;
+
 		for (int y = 0; y < t->textSprite->h; y++) {
 			for (int x = 0; x < t->textSprite->w; x++) {
 				if (src[x] == 1)
@@ -235,10 +244,32 @@
 			src += t->textSprite->w;
 			dst += screenWidth;
 		}
+
+		if (yPos + t->textSprite->h > _frameY + _frameHeight || t->textSprite->w > _frameWidth) {
+			_system->copyRectToScreen(_frameBuffer + yPos * screenWidth + xPos, screenWidth, xPos, yPos, t->textSprite->w, t->textSprite->h);
+		}
 	}
 }
 
 void MoviePlayer::undrawTextObject(MovieTextObject *t) {
+	int xPos, yPos;
+
+	calcTextPosition(t, xPos, yPos);
+
+	// We only need to undraw the text if it's outside the frame. Otherwise
+	// the next frame will cover the old text anyway.
+
+	if (yPos + t->textSprite->h > _frameY + _frameHeight || t->textSprite->w > _frameWidth) {
+		int screenWidth = _vm->_screen->getScreenWide();
+		byte *dst = _frameBuffer + yPos * screenWidth + xPos;
+
+		for (int y = 0; y < t->textSprite->h; y++) {
+			memset(dst, 0, t->textSprite->w);
+			dst += screenWidth;
+		}
+
+		_system->copyRectToScreen(_frameBuffer + yPos * screenWidth + xPos, screenWidth, xPos, yPos, t->textSprite->w, t->textSprite->h);
+	}
 }
 
 bool MoviePlayer::load(const char *name, MovieTextObject *text[]) {
@@ -398,11 +429,6 @@
 		updateScreen();
 	}
 
-	// The current text object may still be open
-	if (_textList && _textList[_currentText]) {
-		closeTextObject(_textList[_currentText]);
-	}
-
 	if (!terminate) {
 		// Wait for the voice and sound track to stop playing. This is
 		// to make sure that we don't cut off the speech in
@@ -417,6 +443,12 @@
 		_mixer->stopHandle(_bgSoundHandle);
 	}
 
+	// The current text object may still be open
+	if (_textList && _textList[_currentText]) {
+		undrawTextObject(_textList[_currentText]);
+		closeTextObject(_textList[_currentText]);
+	}
+
 	if (!_seamless) {
 		clearFrame();
 		drawFrame();
@@ -575,6 +607,11 @@
 	}
 }
 
+void MoviePlayerMPEG::undrawTextObject(MovieTextObject *t) {
+	// As long as we only have subtitles for full-sized cutscenes, we don't
+	// really need to implement this function.
+}
+
 void AnimationState::drawTextObject(SpriteInfo *s, byte *src) {
 	int moviePitch = _movieScale * _movieWidth;
 	int textX = _movieScale * s->x;

Modified: scummvm/trunk/engines/sword2/animation.h
===================================================================
--- scummvm/trunk/engines/sword2/animation.h	2006-08-23 04:26:01 UTC (rev 23741)
+++ scummvm/trunk/engines/sword2/animation.h	2006-08-23 21:13:11 UTC (rev 23742)
@@ -91,6 +91,7 @@
 
 	void openTextObject(MovieTextObject *t);
 	void closeTextObject(MovieTextObject *t);
+	void calcTextPosition(MovieTextObject *t, int &xPos, int &yPos);
 
 	virtual void handleScreenChanged() {}
 
@@ -113,17 +114,17 @@
 
 class MoviePlayerDummy : public MoviePlayer {
 protected:
-	virtual bool decodeFrame();
-	virtual void syncFrame();
-	virtual void drawFrame();
-	virtual void drawTextObject(MovieTextObject *t);
-	virtual void undrawTextObject(MovieTextObject *t);
+	bool decodeFrame();
+	void syncFrame();
+	void drawFrame();
+	void drawTextObject(MovieTextObject *t);
+	void undrawTextObject(MovieTextObject *t);
 
 public:
 	MoviePlayerDummy(Sword2Engine *vm);
 	virtual ~MoviePlayerDummy();
 
-	virtual bool load(const char *name, MovieTextObject *text[]);
+	bool load(const char *name, MovieTextObject *text[]);
 };
 
 #ifdef USE_MPEG2
@@ -158,32 +159,33 @@
 	virtual void syncFrame();
 
 #ifndef BACKEND_8BIT
-	virtual void handleScreenChanged();
-	virtual void clearFrame();
-	virtual void drawFrame();
-	virtual void updateScreen();
-	virtual void drawTextObject(MovieTextObject *t);
+	void handleScreenChanged();
+	void clearFrame();
+	void drawFrame();
+	void updateScreen();
+	void drawTextObject(MovieTextObject *t);
+	void undrawTextObject(MovieTextObject *t);
 #endif
 
 public:
 	MoviePlayerMPEG(Sword2Engine *vm);
-	virtual ~MoviePlayerMPEG();
+	~MoviePlayerMPEG();
 
-	virtual bool load(const char *name, MovieTextObject *text[]);
+	bool load(const char *name, MovieTextObject *text[]);
 };
 #endif
 
 #ifdef USE_ZLIB
 class MoviePlayerDXA : public MoviePlayer, ::Graphics::DXAPlayer {
 protected:
-	virtual void setPalette(byte *pal);
-	virtual bool decodeFrame();
+	void setPalette(byte *pal);
+	bool decodeFrame();
 
 public:
 	MoviePlayerDXA(Sword2Engine *vm);
-	virtual ~MoviePlayerDXA();
+	~MoviePlayerDXA();
 
-	virtual bool load(const char *name, MovieTextObject *text[]);
+	bool load(const char *name, MovieTextObject *text[]);
 };
 #endif
 


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