diff options
author | Torbjörn Andersson | 2016-07-04 01:02:31 +0200 |
---|---|---|
committer | Torbjörn Andersson | 2016-07-04 01:03:32 +0200 |
commit | 9020002c78e8f3169d82e5dfe124f3192aa2a7ca (patch) | |
tree | f290c7e702e651ada003a2d8723e224ac5658933 /engines | |
parent | 35a5918adad70995557a439f23b5aed24f4cd248 (diff) | |
download | scummvm-rg350-9020002c78e8f3169d82e5dfe124f3192aa2a7ca.tar.gz scummvm-rg350-9020002c78e8f3169d82e5dfe124f3192aa2a7ca.tar.bz2 scummvm-rg350-9020002c78e8f3169d82e5dfe124f3192aa2a7ca.zip |
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.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/prince/module.mk | 3 | ||||
-rw-r--r-- | engines/prince/prince.cpp | 1 | ||||
-rw-r--r-- | engines/prince/prince.h | 2 | ||||
-rw-r--r-- | engines/prince/videoplayer.cpp | 84 |
4 files changed, 89 insertions, 1 deletions
diff --git a/engines/prince/module.mk b/engines/prince/module.mk index b1be123d4b..27bbc21700 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 fe5905bcd0..502a2f97bb 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 82fcb152fa..5e07de691f 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 0000000000..0d07dea10a --- /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 |