[Scummvm-git-logs] scummvm master -> 9d962d92b74bb9a0ce641aff2da029335ea7cfc2
mduggan
mgithub at guarana.org
Fri May 1 04:05:15 UTC 2020
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:
9d962d92b7 ULTIMA8: Add engine support for crusader movies
Commit: 9d962d92b74bb9a0ce641aff2da029335ea7cfc2
https://github.com/scummvm/scummvm/commit/9d962d92b74bb9a0ce641aff2da029335ea7cfc2
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-05-01T13:00:40+09:00
Commit Message:
ULTIMA8: Add engine support for crusader movies
Changed paths:
A engines/ultima/ultima8/graphics/avi_player.cpp
A engines/ultima/ultima8/graphics/avi_player.h
A engines/ultima/ultima8/graphics/movie_player.h
engines/ultima/module.mk
engines/ultima/ultima8/games/remorse_game.cpp
engines/ultima/ultima8/games/u8_game.cpp
engines/ultima/ultima8/graphics/skf_player.cpp
engines/ultima/ultima8/graphics/skf_player.h
engines/ultima/ultima8/graphics/texture.cpp
engines/ultima/ultima8/graphics/texture.h
engines/ultima/ultima8/gumps/movie_gump.cpp
engines/ultima/ultima8/gumps/movie_gump.h
engines/ultima/ultima8/misc/debugger.cpp
engines/ultima/ultima8/usecode/usecode.cpp
diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index d3489d2edc..620de1ed25 100644
--- a/engines/ultima/module.mk
+++ b/engines/ultima/module.mk
@@ -415,6 +415,7 @@ MODULE_OBJS := \
ultima8/games/treasure_loader.o \
ultima8/games/u8_game.o \
ultima8/graphics/anim_dat.o \
+ ultima8/graphics/avi_player.o \
ultima8/graphics/base_soft_render_surface.o \
ultima8/graphics/frame_id.o \
ultima8/graphics/fade_to_modal_process.o \
diff --git a/engines/ultima/ultima8/games/remorse_game.cpp b/engines/ultima/ultima8/games/remorse_game.cpp
index e1c09bae76..5742a247c6 100644
--- a/engines/ultima/ultima8/games/remorse_game.cpp
+++ b/engines/ultima/ultima8/games/remorse_game.cpp
@@ -26,7 +26,10 @@
#include "ultima/ultima8/filesys/file_system.h"
#include "ultima/ultima8/filesys/idata_source.h"
#include "ultima/ultima8/graphics/palette_manager.h"
+#include "ultima/ultima8/gumps/movie_gump.h"
#include "ultima/ultima8/kernel/object_manager.h"
+#include "ultima/ultima8/kernel/process.h"
+#include "ultima/ultima8/kernel/kernel.h"
#include "ultima/ultima8/world/world.h"
#include "ultima/ultima8/graphics/xform_blend.h"
#include "ultima/ultima8/games/game_data.h"
@@ -121,19 +124,40 @@ bool RemorseGame::startGame() {
}
bool RemorseGame::startInitialUsecode(int saveSlot) {
-// Process* proc = new StartU8Process();
+ ProcId moviepid = Game::get_instance()->playIntroMovie(false);
+ Process *movieproc = Kernel::get_instance()->getProcess(moviepid);
+
+ //if (movieproc) {
+ // waitFor(movieproc);
+ // return;
+ //}
+
+// Process* proc = new StartCrusaderProcess();
// Kernel::get_instance()->addProcess(proc);
return true;
}
+static ProcId playMovie(const char *movieID, bool fade) {
+ const Std::string filename = Std::string::format("@game/flics/%s.avi", movieID);
+ FileSystem *filesys = FileSystem::get_instance();
+ Common::SeekableReadStream *rs = filesys->ReadFile(filename);
+ if (!rs) {
+ pout << "RemorseGame::playIntro: movie not found." << Std::endl;
+ return 0;
+ }
+ // TODO: Add support for subtitles (.txt file). The format is very simple.
+ return MovieGump::U8MovieViewer(rs, fade);
+}
+
ProcId RemorseGame::playIntroMovie(bool fade) {
- return 0;
+ return playMovie("T01", fade);
+ // TODO: also play T02
}
ProcId RemorseGame::playEndgameMovie(bool fade) {
- return 0;
+ return playMovie("O01", fade);
}
void RemorseGame::playCredits() {
diff --git a/engines/ultima/ultima8/games/u8_game.cpp b/engines/ultima/ultima8/games/u8_game.cpp
index 27b2d76c63..62926ad63c 100644
--- a/engines/ultima/ultima8/games/u8_game.cpp
+++ b/engines/ultima/ultima8/games/u8_game.cpp
@@ -175,8 +175,7 @@ ProcId U8Game::playIntroMovie(bool fade) {
return 0;
}
- RawArchive *flex = new RawArchive(skf);
- return MovieGump::U8MovieViewer(flex, fade, true);
+ return MovieGump::U8MovieViewer(skf, fade, true);
}
ProcId U8Game::playEndgameMovie(bool fade) {
@@ -188,8 +187,7 @@ ProcId U8Game::playEndgameMovie(bool fade) {
return 0;
}
- RawArchive *flex = new RawArchive(skf);
- return MovieGump::U8MovieViewer(flex, fade);
+ return MovieGump::U8MovieViewer(skf, fade);
}
void U8Game::playCredits() {
diff --git a/engines/ultima/ultima8/graphics/avi_player.cpp b/engines/ultima/ultima8/graphics/avi_player.cpp
new file mode 100644
index 0000000000..f4d80498c4
--- /dev/null
+++ b/engines/ultima/ultima8/graphics/avi_player.cpp
@@ -0,0 +1,107 @@
+/* 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 "ultima/ultima8/misc/pent_include.h"
+#include "ultima/ultima8/graphics/avi_player.h"
+#include "ultima/ultima8/graphics/render_surface.h"
+#include "ultima/ultima8/graphics/texture.h"
+#include "ultima/ultima8/ultima8.h"
+#include "graphics/surface.h"
+#include "common/system.h"
+#include "common/stream.h"
+#include "video/avi_decoder.h"
+
+namespace Ultima {
+namespace Ultima8 {
+
+AVIPlayer::AVIPlayer(Common::SeekableReadStream *rs, int width, int height)
+ : MoviePlayer(), _playing(false), _width(width), _height(height),
+ _doubleSize(false) {
+ _decoder = new Video::AVIDecoder();
+ _decoder->loadStream(rs);
+ uint32 vidWidth = _decoder->getWidth();
+ uint32 vidHeight = _decoder->getHeight();
+ if (vidWidth <= _width / 2 && vidHeight <= _height / 2) {
+ _doubleSize = true;
+ vidHeight *= 2;
+ vidWidth *= 2;
+ }
+ _xoff = _width / 2 - (vidWidth / 2);
+ _yoff = _height / 2 - (vidHeight / 2);
+}
+
+AVIPlayer::~AVIPlayer() {
+ delete _decoder;
+}
+
+void AVIPlayer::start() {
+ _playing = true;
+ _decoder->start();
+}
+
+void AVIPlayer::stop() {
+ _playing = false;
+ _decoder->stop();
+}
+
+void AVIPlayer::paint(RenderSurface *surf, int /*lerp*/) {
+ if (_decoder->endOfVideo()) {
+ _playing = false;
+ return;
+ }
+ if (_decoder->needsUpdate())
+ {
+ const Graphics::Surface *frame = _decoder->decodeNextFrame();
+ if (!frame) {
+ // Some sort of decoding error?
+ _playing = false;
+ return;
+ }
+ if (frame->format.bytesPerPixel == 1) {
+ const byte *pal = _decoder->getPalette();
+ _currentFrame.loadSurface8Bit(frame, pal);
+ } else {
+ _currentFrame.loadSurface(frame);
+ }
+ }
+
+ // TODO: Crusader has a CRT-like scaling which it uses in some
+ // movies too (eg, T02 for the intro). For now just point-scale.
+ if (_doubleSize) {
+ const Scaler *pointScaler = &Ultima8Engine::get_instance()->point_scaler;
+ surf->ScalerBlit(&_currentFrame, 0, 0, _currentFrame.w, _currentFrame.h,
+ _xoff, _yoff, _currentFrame.w * 2, _currentFrame.h * 2,
+ pointScaler, false);
+ } else {
+ surf->Blit(&_currentFrame, 0, 0, _currentFrame.w, _currentFrame.h,
+ _xoff, _yoff);
+ }
+}
+
+void AVIPlayer::run() {
+ if (_decoder->endOfVideo()) {
+ _playing = false;
+ }
+}
+
+} // End of namespace Ultima8
+} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/graphics/avi_player.h b/engines/ultima/ultima8/graphics/avi_player.h
new file mode 100644
index 0000000000..f490730bca
--- /dev/null
+++ b/engines/ultima/ultima8/graphics/avi_player.h
@@ -0,0 +1,69 @@
+/* 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.
+ *
+ */
+
+#ifndef ULTIMA8_GRAPHICS_AVIPLAYER_H
+#define ULTIMA8_GRAPHICS_AVIPLAYER_H
+
+#include "ultima/shared/std/containers.h"
+#include "ultima/ultima8/graphics/movie_player.h"
+#include "ultima/ultima8/graphics/texture.h"
+
+namespace Video {
+class AVIDecoder;
+}
+
+namespace Ultima {
+namespace Ultima8 {
+
+class AVIPlayer : public MoviePlayer {
+public:
+ AVIPlayer(Common::SeekableReadStream *rs, int width, int height);
+ ~AVIPlayer();
+
+ void run() override;
+ void paint(RenderSurface *surf, int lerp) override;
+
+ void start() override;
+ void stop() override;
+ bool isPlaying() const override{
+ return _playing;
+ }
+
+private:
+
+ bool _playing;
+ Video::AVIDecoder *_decoder;
+ Texture _currentFrame;
+ // Width and height of the area we've been given to play back in
+ uint32 _width;
+ uint32 _height;
+ // Xoff and Yoff into that playback area
+ uint32 _xoff;
+ uint32 _yoff;
+ bool _doubleSize;
+
+};
+
+} // End of namespace Ultima8
+} // End of namespace Ultima
+
+#endif
diff --git a/engines/ultima/ultima8/graphics/movie_player.h b/engines/ultima/ultima8/graphics/movie_player.h
new file mode 100644
index 0000000000..de63050c4e
--- /dev/null
+++ b/engines/ultima/ultima8/graphics/movie_player.h
@@ -0,0 +1,48 @@
+/* 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.
+ *
+ */
+
+#ifndef ULTIMA8_GRAPHICS_MOVIEPLAYER_H
+#define ULTIMA8_GRAPHICS_MOVIEPLAYER_H
+
+namespace Ultima {
+namespace Ultima8 {
+
+class RenderSurface;
+
+class MoviePlayer {
+public:
+ MoviePlayer() {};
+ virtual ~MoviePlayer() {};
+
+ virtual void run() = 0;
+ virtual void paint(RenderSurface *surf, int lerp) = 0;
+
+ virtual void start() = 0;
+ virtual void stop() = 0;
+ virtual bool isPlaying() const = 0;
+
+};
+
+} // End of namespace Ultima8
+} // End of namespace Ultima
+
+#endif
diff --git a/engines/ultima/ultima8/graphics/skf_player.cpp b/engines/ultima/ultima8/graphics/skf_player.cpp
index 01ee01aa32..977550b94e 100644
--- a/engines/ultima/ultima8/graphics/skf_player.cpp
+++ b/engines/ultima/ultima8/graphics/skf_player.cpp
@@ -65,12 +65,12 @@ struct SKFEvent {
static const int FADESTEPS = 16; // HACK: half speed
-SKFPlayer::SKFPlayer(RawArchive *movie, int width, int height, bool introMusicHack)
- : _width(width), _height(height), _skf(movie),
- _curFrame(0), _curObject(0), _curAction(0), _curEvent(0), _playing(false),
- _timer(0), _frameRate(15), _fadeColour(0), _fadeLevel(0), _buffer(nullptr),
- _subs(nullptr), _introMusicHack(introMusicHack), _lastUpdate(0),
- _subtitleY(0) {
+SKFPlayer::SKFPlayer(Common::SeekableReadStream *rs, int width, int height, bool introMusicHack)
+ : _width(width), _height(height), _curFrame(0), _curObject(0), _curAction(0),
+ _curEvent(0), _playing(false), _timer(0), _frameRate(15), _fadeColour(0),
+ _fadeLevel(0), _buffer(nullptr), _subs(nullptr), _introMusicHack(introMusicHack),
+ _lastUpdate(0), _subtitleY(0) {
+ _skf = new RawArchive(rs);
Common::ReadStream *eventlist = _skf->get_datasource(0);
if (!eventlist) {
perr << "No eventlist found in SKF" << Std::endl;
diff --git a/engines/ultima/ultima8/graphics/skf_player.h b/engines/ultima/ultima8/graphics/skf_player.h
index 31a4f04b18..f7e42925b5 100644
--- a/engines/ultima/ultima8/graphics/skf_player.h
+++ b/engines/ultima/ultima8/graphics/skf_player.h
@@ -24,6 +24,7 @@
#define ULTIMA8_GRAPHICS_SKFPLAYER_H
#include "ultima/shared/std/containers.h"
+#include "ultima/ultima8/graphics/movie_player.h"
namespace Ultima {
namespace Ultima8 {
@@ -34,9 +35,9 @@ class RenderSurface;
class RenderedText;
struct Palette;
-class SKFPlayer {
+class SKFPlayer : public MoviePlayer {
public:
- SKFPlayer(RawArchive *movie, int width, int height, bool introMusicHack = false);
+ SKFPlayer(Common::SeekableReadStream *rs, int width, int height, bool introMusicHack = false);
~SKFPlayer();
void run();
diff --git a/engines/ultima/ultima8/graphics/texture.cpp b/engines/ultima/ultima8/graphics/texture.cpp
index 0c99aec0aa..e36810ee26 100644
--- a/engines/ultima/ultima8/graphics/texture.cpp
+++ b/engines/ultima/ultima8/graphics/texture.cpp
@@ -119,5 +119,34 @@ void Texture::loadSurface(const Graphics::Surface *surf) {
}
}
+void Texture::loadSurface8Bit(const Graphics::Surface *surf, const byte *pal) {
+ assert(surf->format.bytesPerPixel == 1 && pal);
+ create(surf->w, surf->h, Texture::getPixelFormat());
+ this->_format = TEX_FMT_STANDARD;
+ this->_wlog2 = -1;
+ this->_hlog2 = -1;
+
+ // Repack RGBA
+ uint32 *buffer = (uint32 *)getPixels();
+ uint32 i = 0;
+ const byte a = 0xff;
+ for (int y = 0; y < surf->h; ++y) {
+ const byte *srcP = (const byte *)surf->getBasePtr(0, y);
+
+ for (int x = 0; x < surf->w; ++x, srcP++) {
+ const byte p = *srcP;
+ const byte r = pal[p*3+0];
+ const byte g = pal[p*3+1];
+ const byte b = pal[p*3+2];
+
+ buffer[i++] = (r << TEX32_R_SHIFT)
+ | (g << TEX32_G_SHIFT)
+ | (b << TEX32_B_SHIFT)
+ | (a << TEX32_A_SHIFT);
+ }
+ }
+}
+
+
} // End of namespace Ultima8
} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/graphics/texture.h b/engines/ultima/ultima8/graphics/texture.h
index 154b77d0d9..694b9c8c96 100644
--- a/engines/ultima/ultima8/graphics/texture.h
+++ b/engines/ultima/ultima8/graphics/texture.h
@@ -134,6 +134,9 @@ public:
// Loads the data from the passed surfcae
void loadSurface(const Graphics::Surface *surf);
+
+ // Load data from a passed 8bit surface
+ void loadSurface8Bit(const Graphics::Surface *surf, const byte *pal);
protected:
// Read from a File. No filetype supported by this class
diff --git a/engines/ultima/ultima8/gumps/movie_gump.cpp b/engines/ultima/ultima8/gumps/movie_gump.cpp
index 0ebc29fcf5..e58cd0534e 100644
--- a/engines/ultima/ultima8/gumps/movie_gump.cpp
+++ b/engines/ultima/ultima8/gumps/movie_gump.cpp
@@ -24,6 +24,7 @@
#include "ultima/ultima8/gumps/movie_gump.h"
#include "ultima/ultima8/filesys/raw_archive.h"
+#include "ultima/ultima8/graphics/avi_player.h"
#include "ultima/ultima8/graphics/skf_player.h"
#include "ultima/ultima8/graphics/fade_to_modal_process.h"
#include "ultima/ultima8/ultima8.h"
@@ -42,10 +43,16 @@ MovieGump::MovieGump() : ModalGump(), _player(0) {
}
-MovieGump::MovieGump(int width, int height, RawArchive *movie,
+MovieGump::MovieGump(int width, int height, Common::SeekableReadStream *rs,
bool introMusicHack, uint32 flags, int32 layer)
- : ModalGump(50, 50, width, height, 0, flags, layer) {
- _player = new SKFPlayer(movie, width, height, introMusicHack);
+ : ModalGump(50, 50, width, height, 0, flags, layer) {
+ uint32 stream_id = rs->readUint32BE();
+ rs->seek(-4, SEEK_CUR);
+ if (stream_id == 0x52494646) {// 'RIFF' - crusader AVIs
+ _player = new AVIPlayer(rs, width, height);
+ } else {
+ _player = new SKFPlayer(rs, width, height, introMusicHack);
+ }
}
MovieGump::~MovieGump() {
@@ -54,6 +61,7 @@ MovieGump::~MovieGump() {
void MovieGump::InitGump(Gump *newparent, bool take_focus) {
ModalGump::InitGump(newparent, take_focus);
+
_player->start();
Mouse::get_instance()->pushMouseCursor();
@@ -93,8 +101,13 @@ bool MovieGump::OnKeyDown(int key, int mod) {
}
//static
-ProcId MovieGump::U8MovieViewer(RawArchive *movie, bool fade, bool introMusicHack) {
- ModalGump *gump = new MovieGump(320, 200, movie, introMusicHack);
+ProcId MovieGump::U8MovieViewer(Common::SeekableReadStream *rs, bool fade, bool introMusicHack) {
+ ModalGump *gump;
+ if (GAME_IS_U8)
+ gump = new MovieGump(320, 200, rs, introMusicHack);
+ else
+ gump = new MovieGump(640, 480, rs, introMusicHack);
+
if (fade) {
FadeToModalProcess *p = new FadeToModalProcess(gump);
Kernel::get_instance()->addProcess(p);
diff --git a/engines/ultima/ultima8/gumps/movie_gump.h b/engines/ultima/ultima8/gumps/movie_gump.h
index 149f0a60d2..e090c766e6 100644
--- a/engines/ultima/ultima8/gumps/movie_gump.h
+++ b/engines/ultima/ultima8/gumps/movie_gump.h
@@ -30,14 +30,14 @@ namespace Ultima {
namespace Ultima8 {
class RawArchive;
-class SKFPlayer;
+class MoviePlayer;
class MovieGump : public ModalGump {
public:
ENABLE_RUNTIME_CLASSTYPE()
MovieGump();
- MovieGump(int width, int height, RawArchive *skf, bool introMusicHack = false,
+ MovieGump(int width, int height, Common::SeekableReadStream *rs, bool introMusicHack = false,
uint32 flags = 0, int32 layer = LAYER_MODAL);
~MovieGump() override;
@@ -52,13 +52,13 @@ public:
bool OnKeyDown(int key, int mod) override;
- static ProcId U8MovieViewer(RawArchive *skf, bool fade, bool introMusicHack = false);
+ static ProcId U8MovieViewer(Common::SeekableReadStream *rs, bool fade, bool introMusicHack = false);
bool loadData(Common::ReadStream *rs);
protected:
void saveData(Common::WriteStream *ws) override;
- SKFPlayer *_player;
+ MoviePlayer *_player;
};
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/misc/debugger.cpp b/engines/ultima/ultima8/misc/debugger.cpp
index 3a4594b568..1f07ed0041 100644
--- a/engines/ultima/ultima8/misc/debugger.cpp
+++ b/engines/ultima/ultima8/misc/debugger.cpp
@@ -1452,8 +1452,7 @@ bool Debugger::cmdPlayMovie(int argc, const char **argv) {
return true;
}
- RawArchive *flex = new RawArchive(skf);
- MovieGump::U8MovieViewer(flex, false);
+ MovieGump::U8MovieViewer(skf, false);
return false;
}
diff --git a/engines/ultima/ultima8/usecode/usecode.cpp b/engines/ultima/ultima8/usecode/usecode.cpp
index cedb89ea8d..fd272c1e14 100644
--- a/engines/ultima/ultima8/usecode/usecode.cpp
+++ b/engines/ultima/ultima8/usecode/usecode.cpp
@@ -44,7 +44,7 @@ uint32 Usecode::get_class_event(uint32 classid, uint32 eventid) {
offset += data[12 + (eventid * 4) + 1] << 8;
offset += data[12 + (eventid * 4) + 2] << 16;
offset += data[12 + (eventid * 4) + 3] << 24;
- } else if (GAME_IS_REMORSE) {
+ } else if (GAME_IS_CRUSADER) {
offset = data[20 + (eventid * 6) + 2];
offset += data[20 + (eventid * 6) + 3] << 8;
offset += data[20 + (eventid * 6) + 4] << 16;
More information about the Scummvm-git-logs
mailing list