[Scummvm-cvs-logs] SF.net SVN: scummvm:[40211] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Wed Apr 29 21:58:43 CEST 2009


Revision: 40211
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40211&view=rev
Author:   drmccoy
Date:     2009-04-29 19:58:43 +0000 (Wed, 29 Apr 2009)

Log Message:
-----------
Playing half-sized videos fullscreen in the demoplayer

Modified Paths:
--------------
    scummvm/trunk/engines/gob/coktelvideo.cpp
    scummvm/trunk/engines/gob/coktelvideo.h
    scummvm/trunk/engines/gob/demoplayer.cpp
    scummvm/trunk/engines/gob/demoplayer.h
    scummvm/trunk/engines/gob/driver_vga.cpp
    scummvm/trunk/engines/gob/driver_vga.h
    scummvm/trunk/engines/gob/video.cpp
    scummvm/trunk/engines/gob/video.h
    scummvm/trunk/engines/gob/videoplayer.cpp
    scummvm/trunk/engines/gob/videoplayer.h

Modified: scummvm/trunk/engines/gob/coktelvideo.cpp
===================================================================
--- scummvm/trunk/engines/gob/coktelvideo.cpp	2009-04-29 16:59:10 UTC (rev 40210)
+++ scummvm/trunk/engines/gob/coktelvideo.cpp	2009-04-29 19:58:43 UTC (rev 40211)
@@ -1006,6 +1006,9 @@
 		}
 	}
 
+	if (_externalCodec && _codecIndeo3)
+		_features |= kFeaturesSupportsDouble;
+
 	_soundFreq = _stream->readSint16LE();
 	_soundSliceSize = _stream->readSint16LE();
 	_soundSlicesCount = _stream->readSint16LE();

Modified: scummvm/trunk/engines/gob/coktelvideo.h
===================================================================
--- scummvm/trunk/engines/gob/coktelvideo.h	2009-04-29 16:59:10 UTC (rev 40210)
+++ scummvm/trunk/engines/gob/coktelvideo.h	2009-04-29 19:58:43 UTC (rev 40211)
@@ -56,7 +56,9 @@
 		/** Has video. */
 		kFeaturesVideo = 0x400,
 		/** Is a full color (non-paletted) video. */
-		kFeaturesFullColor = 0x4000
+		kFeaturesFullColor = 0x4000,
+		/** Supports automatic doubling. */
+		kFeaturesSupportsDouble = 0x40000000
 	};
 
 	enum StateFlags {
@@ -95,7 +97,7 @@
 	virtual ~CoktelVideo() { }
 
 	/** Returns the features the loaded video possesses. */
-	virtual uint16 getFeatures() const = 0;
+	virtual uint32 getFeatures() const = 0;
 	/** Returns the flags the loaded video possesses. */
 	virtual uint16 getFlags() const = 0;
 	/** Returns the x coordinate of the video. */
@@ -196,7 +198,7 @@
 	Imd();
 	~Imd();
 
-	uint16 getFeatures() const { return _features; }
+	uint32 getFeatures() const { return _features; }
 	uint16 getFlags() const { return _flags; }
 	int16 getX() const { return _x; }
 	int16 getY() const { return _y; }
@@ -255,7 +257,7 @@
 
 	Common::SeekableReadStream *_stream;
 	uint16 _version;
-	uint16 _features;
+	uint32 _features;
 	uint16 _flags;
 	int16 _x, _y, _width, _height;
 	int16 _stdX, _stdY, _stdWidth, _stdHeight;

Modified: scummvm/trunk/engines/gob/demoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/demoplayer.cpp	2009-04-29 16:59:10 UTC (rev 40210)
+++ scummvm/trunk/engines/gob/demoplayer.cpp	2009-04-29 19:58:43 UTC (rev 40211)
@@ -93,19 +93,67 @@
 
 	debugC(1, kDebugDemo, "Playing video \"%s\"", file);
 
-	// Playing the video
 	if (_vm->_vidPlayer->primaryOpen(file)) {
-		_vm->_vidPlayer->slotSetDoubleMode(-1, _doubleMode);
-		_vm->_vidPlayer->primaryPlay();
+		bool videoSupportsDouble =
+			((_vm->_vidPlayer->getFeatures() & CoktelVideo::kFeaturesSupportsDouble) != 0);
+
+		if (_doubleMode) {
+			if (videoSupportsDouble) {
+				_vm->_vidPlayer->slotSetDoubleMode(-1, true);
+				playVideoNormal();
+			} else
+				playVideoDoubled();
+		} else
+			playVideoNormal();
+
 		_vm->_vidPlayer->primaryClose();
 
 		if (waitTime > 0)
 			_vm->_util->longDelay(waitTime);
 	}
 
+
 	delete[] filePtr;
 }
 
+void DemoPlayer::playVideoNormal() {
+	_vm->_vidPlayer->primaryPlay();
+}
+
+void DemoPlayer::playVideoDoubled() {
+	const char *fileNameOpened;
+	char *fileName;
+
+	fileNameOpened = _vm->_vidPlayer->getFileName();
+
+	fileName = new char[strlen(fileNameOpened) + 1];
+	strcpy(fileName, fileNameOpened);
+
+	_vm->_vidPlayer->primaryClose();
+
+	if (_vm->_vidPlayer->primaryOpen(fileName, 0, -1, VideoPlayer::kFlagOtherSurface)) {
+		for (int i = 0; i < _vm->_vidPlayer->getFramesCount(); i++) {
+			if (_vm->_vidPlayer->primaryPlay(i, i))
+				break;
+
+			CoktelVideo::State state = _vm->_vidPlayer->getState();
+
+			int16 w = state.right - state.left + 1;
+			int16 h = state.bottom - state.top + 1;
+			int16 wD = (state.left * 2) + (w * 2);
+			int16 hD = (state.top * 2) + (h * 2);
+
+			_vm->_video->drawSpriteDouble(_vm->_draw->_spritesArray[0], _vm->_draw->_frontSurface,
+					state.left, state.top, state.right, state.bottom, state.left, state.top, 0);
+			_vm->_draw->dirtiedRect(_vm->_draw->_frontSurface,
+					state.left * 2, state.top * 2, wD, hD);
+			_vm->_video->retrace();
+		}
+	}
+
+	delete[] fileName;
+}
+
 void DemoPlayer::evaluateVideoMode(const char *mode) {
 	debugC(2, kDebugDemo, "Video mode \"%s\"", mode);
 

Modified: scummvm/trunk/engines/gob/demoplayer.h
===================================================================
--- scummvm/trunk/engines/gob/demoplayer.h	2009-04-29 16:59:10 UTC (rev 40210)
+++ scummvm/trunk/engines/gob/demoplayer.h	2009-04-29 19:58:43 UTC (rev 40211)
@@ -52,6 +52,9 @@
 	void evaluateVideoMode(const char *mode);
 	void clearScreen();
 	void playVideo(const char *fileName);
+
+	void playVideoNormal();
+	void playVideoDoubled();
 };
 
 } // End of namespace Gob

Modified: scummvm/trunk/engines/gob/driver_vga.cpp
===================================================================
--- scummvm/trunk/engines/gob/driver_vga.cpp	2009-04-29 16:59:10 UTC (rev 40210)
+++ scummvm/trunk/engines/gob/driver_vga.cpp	2009-04-29 19:58:43 UTC (rev 40211)
@@ -163,6 +163,43 @@
 	}
 }
 
+void VGAVideoDriver::drawSpriteDouble(SurfaceDesc *source, SurfaceDesc *dest,
+		int16 left, int16 top, int16 right, int16 bottom,
+		int16 x, int16 y, int16 transp) {
+
+	if ((x >= dest->getWidth()) || (x < 0) ||
+	    (y >= dest->getHeight()) || (y < 0))
+		return;
+
+	int16 width = MIN<int>((right - left) + 1, dest->getWidth() / 2);
+	int16 height = MIN<int>((bottom - top) + 1, dest->getHeight() / 2);
+
+	if ((width < 1) || (height < 1))
+		return;
+
+	const byte *srcPos = source->getVidMem() + (top * source->getWidth()) + left;
+	byte *destPos = dest->getVidMem() + ((y * 2) * dest->getWidth()) + (x * 2);
+
+	while (height--) {
+		const byte *srcBak = srcPos;
+
+		for (int i = 0; i < 2; i++) {
+			srcPos = srcBak;
+
+			for (int16 j = 0; j < width; j++) {
+				if (!transp || srcPos[i]) {
+					destPos[2 * j + 0] = srcPos[j];
+					destPos[2 * j + 1] = srcPos[j];
+				}
+			}
+
+			destPos += dest->getWidth();
+		}
+
+		srcPos = srcBak + source->getWidth();
+	}
+}
+
 void VGAVideoDriver::drawPackedSprite(byte *sprBuf, int16 width, int16 height,
 		int16 x, int16 y, byte transp, SurfaceDesc *dest) {
 	int destRight = x + width;

Modified: scummvm/trunk/engines/gob/driver_vga.h
===================================================================
--- scummvm/trunk/engines/gob/driver_vga.h	2009-04-29 16:59:10 UTC (rev 40210)
+++ scummvm/trunk/engines/gob/driver_vga.h	2009-04-29 19:58:43 UTC (rev 40211)
@@ -45,6 +45,8 @@
 			byte transp, SurfaceDesc *dest);
 	void drawSprite(SurfaceDesc *source, SurfaceDesc *dest, int16 left,
 			int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp);
+	void drawSpriteDouble(SurfaceDesc *source, SurfaceDesc *dest, int16 left,
+			int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp);
 	void drawPackedSprite(byte *sprBuf, int16 width, int16 height,
 			int16 x, int16 y, byte transp, SurfaceDesc *dest);
 };

Modified: scummvm/trunk/engines/gob/video.cpp
===================================================================
--- scummvm/trunk/engines/gob/video.cpp	2009-04-29 16:59:10 UTC (rev 40210)
+++ scummvm/trunk/engines/gob/video.cpp	2009-04-29 19:58:43 UTC (rev 40211)
@@ -378,6 +378,12 @@
 	_videoDriver->drawSprite(source, dest, left, top, right, bottom, x, y, transp);
 }
 
+void Video::drawSpriteDouble(SurfaceDesc *source, SurfaceDesc *dest,
+	    int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) {
+
+	_videoDriver->drawSpriteDouble(source, dest, left, top, right, bottom, x, y, transp);
+}
+
 void Video::drawLetter(int16 item, int16 x, int16 y, FontDesc *fontDesc,
 		int16 color1, int16 color2, int16 transp, SurfaceDesc *dest) {
 	byte *dataPtr;

Modified: scummvm/trunk/engines/gob/video.h
===================================================================
--- scummvm/trunk/engines/gob/video.h	2009-04-29 16:59:10 UTC (rev 40210)
+++ scummvm/trunk/engines/gob/video.h	2009-04-29 19:58:43 UTC (rev 40211)
@@ -149,6 +149,8 @@
 	void drawSprite(SurfaceDesc *source, SurfaceDesc *dest,
 			int16 left, int16 top, int16 right, int16 bottom,
 			int16 x, int16 y, int16 transp);
+	void drawSpriteDouble(SurfaceDesc *source, SurfaceDesc *dest,
+	    int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp);
 	void drawLetter(int16 item, int16 x, int16 y, FontDesc *fontDesc,
 			int16 color1, int16 color2, int16 transp, SurfaceDesc *dest);
 	void drawPackedSprite(byte *sprBuf, int16 width, int16 height,
@@ -258,6 +260,7 @@
 	VideoDriver() {}
 	virtual ~VideoDriver() {}
 	virtual void drawSprite(SurfaceDesc *source, SurfaceDesc *dest, int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) = 0;
+	virtual void drawSpriteDouble(SurfaceDesc *source, SurfaceDesc *dest, int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) = 0;
 	virtual void fillRect(SurfaceDesc *dest, int16 left, int16 top, int16 right, int16 bottom, byte color) = 0;
 	virtual void putPixel(int16 x, int16 y, byte color, SurfaceDesc *dest) = 0;
 	virtual void drawLetter(unsigned char item, int16 x, int16 y, Video::FontDesc *fontDesc, byte color1, byte color2, byte transp, SurfaceDesc *dest) = 0;

Modified: scummvm/trunk/engines/gob/videoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/videoplayer.cpp	2009-04-29 16:59:10 UTC (rev 40210)
+++ scummvm/trunk/engines/gob/videoplayer.cpp	2009-04-29 19:58:43 UTC (rev 40211)
@@ -114,6 +114,10 @@
 	return _video;
 }
 
+uint32 VideoPlayer::Video::getFeatures() const {
+	return _video->getFeatures();
+}
+
 CoktelVideo::State VideoPlayer::Video::getState() const {
 	return _state;
 }
@@ -286,12 +290,12 @@
 	return true;
 }
 
-void VideoPlayer::primaryPlay(int16 startFrame, int16 lastFrame, int16 breakKey,
+bool VideoPlayer::primaryPlay(int16 startFrame, int16 lastFrame, int16 breakKey,
 		uint16 palCmd, int16 palStart, int16 palEnd,
 		int16 palFrame, int16 endFrame, bool fade, int16 reverseTo, bool forceSeek) {
 
 	if (!_primaryVideo->isOpen())
-		return;
+		return false;
 
 	CoktelVideo &video = *(_primaryVideo->getVideo());
 
@@ -318,9 +322,13 @@
 	if (fade)
 		_vm->_palAnim->fade(0, -2, 0);
 
+	bool canceled = false;
+
 	while (startFrame <= lastFrame) {
-		if (doPlay(startFrame, breakKey, palCmd, palStart, palEnd, palFrame, endFrame))
+		if (doPlay(startFrame, breakKey, palCmd, palStart, palEnd, palFrame, endFrame)) {
+			canceled = true;
 			break;
+		}
 
 		evalBgShading(video);
 
@@ -355,6 +363,8 @@
 	}
 
 	evalBgShading(video);
+
+	return canceled;
 }
 
 void VideoPlayer::primaryClose() {
@@ -493,6 +503,15 @@
 	return 0;
 }
 
+const char *VideoPlayer::getFileName(int slot) const {
+	const Video *video = getVideoBySlot(slot);
+
+	if (video)
+		return video->getFileName();
+
+	return "";
+}
+
 uint16 VideoPlayer::getFlags(int slot) const {
 	const Video *video = getVideoBySlot(slot);
 
@@ -556,6 +575,25 @@
 	return 0;
 }
 
+uint32 VideoPlayer::getFeatures(int slot) const {
+	const Video *video = getVideoBySlot(slot);
+
+	if (video)
+		return video->getFeatures();
+
+	return 0;
+}
+
+CoktelVideo::State VideoPlayer::getState(int slot) const {
+	const Video *video = getVideoBySlot(slot);
+	CoktelVideo::State state;
+
+	if (video)
+		state = video->getState();
+
+	return state;
+}
+
 bool VideoPlayer::hasExtraData(const char *fileName, int slot) const {
 	const Video *video = getVideoBySlot(slot);
 

Modified: scummvm/trunk/engines/gob/videoplayer.h
===================================================================
--- scummvm/trunk/engines/gob/videoplayer.h	2009-04-29 16:59:10 UTC (rev 40210)
+++ scummvm/trunk/engines/gob/videoplayer.h	2009-04-29 19:58:43 UTC (rev 40211)
@@ -57,7 +57,7 @@
 
 	bool primaryOpen(const char *videoFile, int16 x = -1, int16 y = -1,
 			int16 flags = kFlagFrontSurface, Type which = kVideoTypeTry);
-	void primaryPlay(int16 startFrame = -1, int16 lastFrame = -1, int16 breakKey = 27,
+	bool primaryPlay(int16 startFrame = -1, int16 lastFrame = -1, int16 breakKey = 27,
 			uint16 palCmd = 8, int16 palStart = 0, int16 palEnd = 255,
 			int16 palFrame = -1, int16 endFrame = -1, bool fade = false,
 			int16 reverseTo = -1, bool forceSeek = false);
@@ -76,6 +76,7 @@
 
 	bool slotIsOpen(int slot) const;
 
+	const char *getFileName(int slot = -1) const;
 	uint16 getFlags(int slot = -1) const;
 	int16 getFramesCount(int slot = -1) const;
 	int16 getCurrentFrame(int slot = -1) const;
@@ -84,6 +85,9 @@
 	int16 getDefaultX(int slot = -1) const;
 	int16 getDefaultY(int slot = -1) const;
 
+	CoktelVideo::State getState(int slot = -1) const;
+	uint32 getFeatures(int slot = -1) const;
+
 	bool hasExtraData(const char *fileName, int slot = -1) const;
 	Common::MemoryReadStream *getExtraData(const char *fileName, int slot = -1);
 
@@ -106,7 +110,9 @@
 			const char *getFileName() const;
 			CoktelVideo *getVideo();
 			const CoktelVideo *getVideo() const;
+
 			CoktelVideo::State getState() const;
+			uint32 getFeatures() const;
 
 			int16 getDefaultX() const;
 			int16 getDefaultY() const;


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