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

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Sat Jun 6 21:06:47 CEST 2009


Revision: 41294
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41294&view=rev
Author:   drmccoy
Date:     2009-06-06 19:06:47 +0000 (Sat, 06 Jun 2009)

Log Message:
-----------
Demoplayer:
- Fixing the flawed double mode
- Adding an "auto" double mode, where the videos get scaled if possible

Modified Paths:
--------------
    scummvm/trunk/engines/gob/demos/demoplayer.cpp
    scummvm/trunk/engines/gob/demos/demoplayer.h
    scummvm/trunk/engines/gob/util.cpp
    scummvm/trunk/engines/gob/util.h
    scummvm/trunk/engines/gob/videoplayer.cpp
    scummvm/trunk/engines/gob/videoplayer.h

Modified: scummvm/trunk/engines/gob/demos/demoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/demos/demoplayer.cpp	2009-06-06 19:04:09 UTC (rev 41293)
+++ scummvm/trunk/engines/gob/demos/demoplayer.cpp	2009-06-06 19:06:47 UTC (rev 41294)
@@ -153,6 +153,13 @@
 		bool videoSupportsDouble =
 			((_vm->_vidPlayer->getFeatures() & Graphics::CoktelVideo::kFeaturesSupportsDouble) != 0);
 
+		if (_autoDouble) {
+			int16 width  = _vm->_vidPlayer->getWidth();
+			int16 height = _vm->_vidPlayer->getHeight();
+
+			_doubleMode = ((width <= 320) && (height <= 200));
+		}
+
 		if (_doubleMode) {
 			if (videoSupportsDouble) {
 				_vm->_vidPlayer->slotSetDoubleMode(-1, true);
@@ -177,13 +184,14 @@
 }
 
 void DemoPlayer::playVideoDoubled() {
-	const char *fileNameOpened = _vm->_vidPlayer->getFileName();
+	Common::String fileNameOpened = _vm->_vidPlayer->getFileName();
 	_vm->_vidPlayer->primaryClose();
 
-	if (_vm->_vidPlayer->primaryOpen(fileNameOpened, 0, -1, VideoPlayer::kFlagOtherSurface)) {
+	if (_vm->_vidPlayer->primaryOpen(fileNameOpened.c_str(), 0, -1,
+				VideoPlayer::kFlagScreenSurface)) {
+
 		for (int i = 0; i < _vm->_vidPlayer->getFramesCount(); i++) {
-			if (_vm->_vidPlayer->primaryPlay(i, i))
-				break;
+			_vm->_vidPlayer->playFrame(i);
 
 			Graphics::CoktelVideo::State state = _vm->_vidPlayer->getState();
 
@@ -197,6 +205,21 @@
 			_vm->_draw->dirtiedRect(_vm->_draw->_frontSurface,
 					state.left * 2, state.top * 2, wD, hD);
 			_vm->_video->retrace();
+
+			_vm->_util->processInput();
+			if (_vm->shouldQuit())
+				break;
+
+			int16 key;
+			bool end = false;
+			while (_vm->_util->checkKey(key))
+				if (key == 0x011B)
+					end = true;
+			if (end)
+				break;
+
+			_vm->_vidPlayer->slotWaitEndFrame();
+
 		}
 	}
 }
@@ -204,10 +227,16 @@
 void DemoPlayer::evaluateVideoMode(const char *mode) {
 	debugC(2, kDebugDemo, "Video mode \"%s\"", mode);
 
-	if (!scumm_strnicmp(mode, "VESA", 4))
-		_doubleMode = false;
-	else if (!scumm_strnicmp(mode, "VGA", 3) && _vm->is640())
-		_doubleMode = true;
+	_autoDouble = false;
+	_doubleMode = false;
+
+	// Only applicable when we actually can double
+	if (_vm->is640()) {
+		if (!scumm_strnicmp(mode, "AUTO", 4))
+			_autoDouble = true;
+		else if (!scumm_strnicmp(mode, "VGA", 3) && _vm->is640())
+			_doubleMode = true;
+	}
 }
 
 } // End of namespace Gob

Modified: scummvm/trunk/engines/gob/demos/demoplayer.h
===================================================================
--- scummvm/trunk/engines/gob/demos/demoplayer.h	2009-06-06 19:04:09 UTC (rev 41293)
+++ scummvm/trunk/engines/gob/demos/demoplayer.h	2009-06-06 19:06:47 UTC (rev 41294)
@@ -45,6 +45,7 @@
 protected:
 	GobEngine *_vm;
 	bool _doubleMode;
+	bool _autoDouble;
 
 	virtual bool playStream(Common::SeekableReadStream &stream) = 0;
 

Modified: scummvm/trunk/engines/gob/util.cpp
===================================================================
--- scummvm/trunk/engines/gob/util.cpp	2009-06-06 19:04:09 UTC (rev 41293)
+++ scummvm/trunk/engines/gob/util.cpp	2009-06-06 19:06:47 UTC (rev 41294)
@@ -235,6 +235,17 @@
 	return translateKey(key);
 }
 
+bool Util::checkKey(int16 &key) {
+	Common::KeyState keyS;
+
+	if (!getKeyFromBuffer(keyS))
+		return false;
+
+	key = translateKey(keyS);
+
+	return true;
+}
+
 void Util::getMouseState(int16 *pX, int16 *pY, int16 *pButtons) {
 	Common::Point mouse = g_system->getEventManager()->getMousePos();
 	*pX = mouse.x + _vm->_video->_scrollOffsetX - _vm->_video->_screenDeltaX;

Modified: scummvm/trunk/engines/gob/util.h
===================================================================
--- scummvm/trunk/engines/gob/util.h	2009-06-06 19:04:09 UTC (rev 41293)
+++ scummvm/trunk/engines/gob/util.h	2009-06-06 19:06:47 UTC (rev 41294)
@@ -64,6 +64,7 @@
 	void clearKeyBuf(void);
 	int16 getKey(void);
 	int16 checkKey(void);
+	bool checkKey(int16 &key);
 
 	void getMouseState(int16 *pX, int16 *pY, int16 *pButtons);
 	void setMousePos(int16 x, int16 y);

Modified: scummvm/trunk/engines/gob/videoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/videoplayer.cpp	2009-06-06 19:04:09 UTC (rev 41293)
+++ scummvm/trunk/engines/gob/videoplayer.cpp	2009-06-06 19:06:47 UTC (rev 41294)
@@ -150,8 +150,10 @@
 	return _state;
 }
 
+
 VideoPlayer::VideoPlayer(GobEngine *vm) : _vm(vm) {
 	_primaryVideo = new Video(vm);
+	_ownSurf = false;
 	_backSurf = false;
 	_needBlit = false;
 	_noCursorSwitch = false;
@@ -251,10 +253,13 @@
 				_noCursorSwitch = true;
 		}
 
+		_ownSurf = false;
+
 		if (!(flags & kFlagNoVideo)) {
 			SurfaceDesc::Ptr surf;
 
 			if (flags & kFlagOtherSurface) {
+				_ownSurf = true;
 				_backSurf = false;
 
 				surf = _vm->_video->initSurfDesc(_vm->_global->_videoMode,
@@ -263,6 +268,14 @@
 				_vm->_draw->_spritesArray[x] = surf;
 
 				x = 0;
+			} else if (flags & kFlagScreenSurface) {
+				_ownSurf = true;
+				_backSurf = false;
+
+				surf = _vm->_video->initSurfDesc(_vm->_global->_videoMode,
+						_vm->_width, _vm->_height, 0);
+				_vm->_draw->_spritesArray[x] = surf;
+				x = 0;
 			} else {
 				_backSurf = ((flags & kFlagFrontSurface) == 0);
 				surf = _vm->_draw->_spritesArray[_backSurf ? 21 : 20];
@@ -459,13 +472,14 @@
 }
 
 void VideoPlayer::slotWaitEndFrame(int slot, bool onlySound) {
-	if ((slot < 0) || (((uint) slot) >= _videoSlots.size()) || !_videoSlots[slot])
-		return;
+	Video *video = getVideoBySlot(slot);
 
-	Graphics::CoktelVideo &video = *(_videoSlots[slot]->getVideo());
+	if (video) {
+		Graphics::CoktelVideo &cVideo = *video->getVideo();
 
-	if (!onlySound || (video.getFeatures() & Graphics::CoktelVideo::kFeaturesSound))
-		video.waitEndFrame();
+		if (!onlySound || (cVideo.getFeatures() & Graphics::CoktelVideo::kFeaturesSound))
+			cVideo.waitEndFrame();
+	}
 }
 
 bool VideoPlayer::slotIsOpen(int slot) const {
@@ -611,10 +625,24 @@
 	return 0;
 }
 
-bool VideoPlayer::doPlay(int16 frame, int16 breakKey,
+void VideoPlayer::playFrame(int16 frame, int16 breakKey,
 		uint16 palCmd, int16 palStart, int16 palEnd,
 		int16 palFrame, int16 endFrame) {
 
+	if (!_primaryVideo)
+		return;
+
+	Video &video = *_primaryVideo;
+	Graphics::CoktelVideo &cVideo = *video.getVideo();
+
+	if (cVideo.getCurrentFrame() != frame)
+		cVideo.seekFrame(frame);
+	if (palFrame < 0)
+		palFrame = 0;
+	if (endFrame < 0)
+		endFrame = cVideo.getFramesCount() - 1;
+
+
 	bool modifiedPal = false;
 
 	if ((frame == palFrame) || ((frame == endFrame) && (palCmd == 8))) {
@@ -622,7 +650,7 @@
 		_vm->_draw->_applyPal = true;
 
 		if (palCmd >= 4)
-			copyPalette(*(_primaryVideo->getVideo()), palStart, palEnd);
+			copyPalette(cVideo, palStart, palEnd);
 	}
 
 	if (modifiedPal && (palCmd == 8) && !_backSurf)
@@ -632,7 +660,7 @@
 	if (_needBlit)
 		_vm->_draw->forceBlit();
 
-	Graphics::CoktelVideo::State state = _primaryVideo->nextFrame();
+	Graphics::CoktelVideo::State state = video.nextFrame();
 	WRITE_VAR(11, frame);
 
 	if (_needBlit)
@@ -648,7 +676,7 @@
 	}
 
 	if ((state.flags & Graphics::CoktelVideo::kStatePalette) && (palCmd > 1)) {
-		copyPalette(*(_primaryVideo->getVideo()), palStart, palEnd);
+		copyPalette(cVideo, palStart, palEnd);
 
 		if (!_backSurf)
 			_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
@@ -660,18 +688,26 @@
 		_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
 
 
-	if (_backSurf) {
-		_vm->_draw->invalidateRect(state.left, state.top, state.right, state.bottom);
-		_vm->_draw->blitInvalidated();
-	} else
-		_vm->_video->dirtyRectsAdd(state.left, state.top, state.right, state.bottom);
-	_vm->_video->retrace();
+	if (!_ownSurf) {
+		if (_backSurf) {
+			_vm->_draw->invalidateRect(state.left, state.top, state.right, state.bottom);
+			_vm->_draw->blitInvalidated();
+		} else
+			_vm->_video->dirtyRectsAdd(state.left, state.top, state.right, state.bottom);
+		_vm->_video->retrace();
+	}
 
 
 	if (modifiedPal && ((palCmd == 2) || (palCmd == 4)))
 		_vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0);
+}
 
+bool VideoPlayer::doPlay(int16 frame, int16 breakKey,
+		uint16 palCmd, int16 palStart, int16 palEnd,
+		int16 palFrame, int16 endFrame) {
 
+	playFrame(frame, breakKey, palCmd, palStart, palEnd, palFrame, endFrame);
+
 	_vm->_util->processInput();
 
 	if (_vm->shouldQuit()) {

Modified: scummvm/trunk/engines/gob/videoplayer.h
===================================================================
--- scummvm/trunk/engines/gob/videoplayer.h	2009-06-06 19:04:09 UTC (rev 41293)
+++ scummvm/trunk/engines/gob/videoplayer.h	2009-06-06 19:06:47 UTC (rev 41294)
@@ -44,7 +44,8 @@
 		kFlagUseBackSurfaceContent = 0x40,
 		kFlagFrontSurface = 0x80,
 		kFlagNoVideo = 0x100,
-		kFlagOtherSurface = 0x800
+		kFlagOtherSurface = 0x800,
+		kFlagScreenSurface = 0x1000
 	};
 
 	enum Type {
@@ -65,6 +66,10 @@
 			int16 reverseTo = -1, bool forceSeek = false);
 	void primaryClose();
 
+	void playFrame(int16 frame, int16 breakKey = 27,
+			uint16 palCmd = 8, int16 palStart = 0, int16 palEnd = 255,
+			int16 palFrame = -1 , int16 endFrame = -1);
+
 	int slotOpen(const char *videoFile, Type which = kVideoTypeTry);
 	void slotPlay(int slot, int16 frame = -1);
 	void slotClose(int slot);
@@ -72,7 +77,7 @@
 			uint16 left, uint16 top, uint16 width, uint16 height,
 			uint16 x, uint16 y, uint16 pitch, int16 transp = -1);
 	void slotCopyPalette(int slot, int16 palStart = -1, int16 palEnd = -1);
-	void slotWaitEndFrame(int slot, bool onlySound = false);
+	void slotWaitEndFrame(int slot = -1, bool onlySound = false);
 
 	void slotSetDoubleMode(int slot, bool doubleMode);
 
@@ -140,6 +145,7 @@
 
 	Common::Array<Video *> _videoSlots;
 	Video *_primaryVideo;
+	bool _ownSurf;
 	bool _backSurf;
 	bool _needBlit;
 	bool _noCursorSwitch;


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