[Scummvm-cvs-logs] scummvm master -> 9020002c78e8f3169d82e5dfe124f3192aa2a7ca

eriktorbjorn eriktorbjorn at telia.com
Mon Jul 4 01:03:56 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
9020002c78 PRINCE: Add video player for topware.avi logo


Commit: 9020002c78e8f3169d82e5dfe124f3192aa2a7ca
    https://github.com/scummvm/scummvm/commit/9020002c78e8f3169d82e5dfe124f3192aa2a7ca
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2016-07-04T01:03:32+02:00

Commit Message:
PRINCE: Add video player for topware.avi logo

The sound is rather bad, but I assume that's something with our
CinePak video decoder so I'll leave it like this for now. The player
itself is based on the BBVS engine.

Changed paths:
  A engines/prince/videoplayer.cpp
    engines/prince/module.mk
    engines/prince/prince.cpp
    engines/prince/prince.h



diff --git a/engines/prince/module.mk b/engines/prince/module.mk
index b1be123..27bbc21 100644
--- a/engines/prince/module.mk
+++ b/engines/prince/module.mk
@@ -19,7 +19,8 @@ MODULE_OBJS = \
 	saveload.o \
 	script.o \
 	sound.o \
-	variatxt.o
+	variatxt.o \
+	videoplayer.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_PRINCE), DYNAMIC_PLUGIN)
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index fe5905b..502a2f9 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -447,6 +447,7 @@ Common::Error PrinceEngine::run() {
 	int startGameSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;
 	init();
 	if (startGameSlot == -1) {
+		playVideo("topware.avi");
 		showLogo();
 	} else {
 		loadLocation(59); // load intro location - easiest way to set everything up
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
index 82fcb15..5e07de6 100644
--- a/engines/prince/prince.h
+++ b/engines/prince/prince.h
@@ -262,6 +262,8 @@ public:
 	virtual Common::Error saveGameState(int slot, const Common::String &desc);
 	virtual Common::Error loadGameState(int slot);
 
+	void playVideo(Common::String videoFilename);
+
 	static bool readSavegameHeader(Common::InSaveFile *in, SavegameHeader &header);
 	Common::String generateSaveName(int slot);
 	void writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &header);
diff --git a/engines/prince/videoplayer.cpp b/engines/prince/videoplayer.cpp
new file mode 100644
index 0000000..0d07dea
--- /dev/null
+++ b/engines/prince/videoplayer.cpp
@@ -0,0 +1,84 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "prince/prince.h"
+#include "engines/util.h"
+#include "graphics/palette.h"
+#include "graphics/surface.h"
+#include "video/avi_decoder.h"
+
+namespace Prince {
+
+void PrinceEngine::playVideo(Common::String videoFilename) {
+        // Set the correct video mode
+        initGraphics(640, 480, true, 0);
+        if (_system->getScreenFormat().bytesPerPixel == 1) {
+                warning("Couldn't switch to a RGB color video mode to play a video.");
+                return;
+        }
+
+        debug(2, "Screen format: %s", _system->getScreenFormat().toString().c_str());
+
+	Video::VideoDecoder *videoDecoder = new Video::AVIDecoder();
+	if (!videoDecoder->loadFile(videoFilename)) {
+		delete videoDecoder;
+		warning("Unable to open video %s", videoFilename.c_str());
+		initGraphics(640, 480, true);
+		return;
+	}
+
+	videoDecoder->start();
+
+	bool skipVideo = false;
+
+	while (!shouldQuit() && !videoDecoder->endOfVideo() && !skipVideo) {
+		if (videoDecoder->needsUpdate()) {
+			const Graphics::Surface *frame = videoDecoder->decodeNextFrame();
+			if (frame) {
+				if (frame->format.bytesPerPixel > 1) {
+					Graphics::Surface *frame1 = frame->convertTo(_system->getScreenFormat());
+					_system->copyRectToScreen(frame1->getPixels(), frame1->pitch, 0, 0, frame1->w, frame1->h);
+					frame1->free();
+					delete frame1;
+				} else {
+					_system->copyRectToScreen(frame->getPixels(), frame->pitch, 0, 0, frame->w, frame->h);
+				}
+				_system->updateScreen();
+			}
+		}
+
+		Common::Event event;
+		while (_system->getEventManager()->pollEvent(event)) {
+			if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) ||
+				event.type == Common::EVENT_LBUTTONUP)
+				skipVideo = true;
+		}
+
+		_system->delayMillis(10);
+	}
+
+	delete videoDecoder;
+
+	initGraphics(640, 480, true);
+}
+
+} // End of namespace Prince






More information about the Scummvm-git-logs mailing list