mirror of
https://github.com/scummvm/scummvm.git
synced 2026-11-18 21:34:48 +00:00
ULTIMA8: Add intrinsic for playing in-game Crusader avis
This commit is contained in:
1 parent
7c9596d78b
commit
26a94e2bdc
4 files changed
+81
-10
No files matched your search
@@ -33,9 +33,9 @@
|
||||
namespace Ultima {
|
||||
namespace Ultima8 {
|
||||
|
||||
AVIPlayer::AVIPlayer(Common::SeekableReadStream *rs, int width, int height)
|
||||
AVIPlayer::AVIPlayer(Common::SeekableReadStream *rs, int width, int height, const byte *overridePal)
|
||||
: MoviePlayer(), _playing(false), _width(width), _height(height),
|
||||
_doubleSize(false) {
|
||||
_doubleSize(false), _overridePal(overridePal) {
|
||||
_decoder = new Video::AVIDecoder();
|
||||
_decoder->loadStream(rs);
|
||||
uint32 vidWidth = _decoder->getWidth();
|
||||
@@ -77,7 +77,12 @@ void AVIPlayer::paint(RenderSurface *surf, int /*lerp*/) {
|
||||
return;
|
||||
}
|
||||
if (frame->format.bytesPerPixel == 1) {
|
||||
const byte *pal = _decoder->getPalette();
|
||||
const byte *pal;
|
||||
if (_overridePal)
|
||||
pal = _overridePal;
|
||||
else
|
||||
pal = _decoder->getPalette();
|
||||
|
||||
_currentFrame.loadSurface8Bit(frame, pal);
|
||||
} else {
|
||||
_currentFrame.loadSurface(frame);
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Ultima8 {
|
||||
|
||||
class AVIPlayer : public MoviePlayer {
|
||||
public:
|
||||
AVIPlayer(Common::SeekableReadStream *rs, int width, int height);
|
||||
AVIPlayer(Common::SeekableReadStream *rs, int width, int height, const byte *overridePal);
|
||||
~AVIPlayer();
|
||||
|
||||
void run() override;
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
bool isPlaying() const override{
|
||||
bool isPlaying() const override {
|
||||
return _playing;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ private:
|
||||
uint32 _xoff;
|
||||
uint32 _yoff;
|
||||
bool _doubleSize;
|
||||
const byte *_overridePal;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -26,9 +26,14 @@
|
||||
#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/palette_manager.h"
|
||||
#include "ultima/ultima8/graphics/fade_to_modal_process.h"
|
||||
#include "ultima/ultima8/ultima8.h"
|
||||
#include "ultima/ultima8/kernel/kernel.h"
|
||||
#include "ultima/ultima8/usecode/intrinsics.h"
|
||||
#include "ultima/ultima8/usecode/uc_machine.h"
|
||||
#include "ultima/ultima8/world/get_object.h"
|
||||
#include "ultima/ultima8/world/item.h"
|
||||
#include "ultima/ultima8/gumps/desktop_gump.h"
|
||||
#include "ultima/ultima8/gumps/gump_notify_process.h"
|
||||
|
||||
@@ -39,17 +44,18 @@ namespace Ultima8 {
|
||||
|
||||
DEFINE_RUNTIME_CLASSTYPE_CODE(MovieGump)
|
||||
|
||||
MovieGump::MovieGump() : ModalGump(), _player(0) {
|
||||
MovieGump::MovieGump() : ModalGump(), _player(nullptr) {
|
||||
|
||||
}
|
||||
|
||||
MovieGump::MovieGump(int width, int height, Common::SeekableReadStream *rs,
|
||||
bool introMusicHack, uint32 flags, int32 layer)
|
||||
bool introMusicHack, const byte *overridePal,
|
||||
uint32 flags, int32 layer)
|
||||
: 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);
|
||||
_player = new AVIPlayer(rs, width, height, overridePal);
|
||||
} else {
|
||||
_player = new SKFPlayer(rs, width, height, introMusicHack);
|
||||
}
|
||||
@@ -115,7 +121,7 @@ ProcId MovieGump::U8MovieViewer(Common::SeekableReadStream *rs, bool fade, bool
|
||||
}
|
||||
else
|
||||
{
|
||||
gump->InitGump(0);
|
||||
gump->InitGump(nullptr);
|
||||
gump->setRelativePosition(CENTER);
|
||||
gump->CreateNotifier();
|
||||
return gump->GetNotifyProcess()->getPid();
|
||||
@@ -130,5 +136,60 @@ void MovieGump::saveData(Common::WriteStream *ws) {
|
||||
|
||||
}
|
||||
|
||||
static Std::string _fixCrusaderMovieName(const Std::string &s) {
|
||||
/*
|
||||
HACK! The game comes with movies MVA01.AVI etc, but the usecode mentions both
|
||||
MVA01 and MVA1. We do a translation here. These are the strings we need to fix:
|
||||
008E: 0D push string "mva1"
|
||||
036D: 0D push string "mva3a"
|
||||
04E3: 0D push string "mva4"
|
||||
0656: 0D push string "mva5a"
|
||||
07BD: 0D push string "mva6"
|
||||
0944: 0D push string "mva7"
|
||||
0A68: 0D push string "mva8"
|
||||
0B52: 0D push string "mva9"
|
||||
*/
|
||||
if (s.size() == 4)
|
||||
return Std::string::format("mva0%c", s[3]);
|
||||
else if (s.equals("mva3a"))
|
||||
return "mva03a";
|
||||
else if (s.equals("mva5a"))
|
||||
return "mva05a";
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
uint32 MovieGump::I_playMovieOverlay(const uint8 *args,
|
||||
unsigned int /*argsize*/) {
|
||||
ARG_ITEM_FROM_PTR(item);
|
||||
ARG_STRING(name);
|
||||
ARG_UINT16(x);
|
||||
ARG_UINT16(y);
|
||||
|
||||
PaletteManager *palman = PaletteManager::get_instance();
|
||||
|
||||
if (item && palman) {
|
||||
if (name.hasPrefix("mva")) {
|
||||
name = _fixCrusaderMovieName(name);
|
||||
}
|
||||
|
||||
const Palette *pal = palman->getPalette(PaletteManager::Pal_Game);
|
||||
assert(pal);
|
||||
|
||||
const Std::string filename = Std::string::format("@game/flics/%s.avi", name.c_str());
|
||||
FileSystem *filesys = FileSystem::get_instance();
|
||||
Common::SeekableReadStream *rs = filesys->ReadFile(filename);
|
||||
if (!rs) {
|
||||
warning("couldn't create gump for unknown movie %s", name.c_str());
|
||||
return 0;
|
||||
}
|
||||
Gump *gump = new MovieGump(x, y, rs, false, pal->_palette);
|
||||
gump->InitGump(nullptr, true);
|
||||
gump->setRelativePosition(CENTER);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // End of namespace Ultima8
|
||||
} // End of namespace Ultima
|
||||
@@ -24,6 +24,7 @@
|
||||
#define ULTIMA8_GUMPS_MOVIEGUMP_H
|
||||
|
||||
#include "ultima/ultima8/gumps/modal_gump.h"
|
||||
#include "ultima/ultima8/usecode/intrinsics.h"
|
||||
#include "ultima/ultima8/misc/p_dynamic_cast.h"
|
||||
|
||||
namespace Ultima {
|
||||
@@ -37,7 +38,8 @@ public:
|
||||
ENABLE_RUNTIME_CLASSTYPE()
|
||||
|
||||
MovieGump();
|
||||
MovieGump(int width, int height, Common::SeekableReadStream *rs, bool introMusicHack = false,
|
||||
MovieGump(int width, int height, Common::SeekableReadStream *rs,
|
||||
bool introMusicHack = false, const byte *overridePal = nullptr,
|
||||
uint32 flags = 0, int32 layer = LAYER_MODAL);
|
||||
~MovieGump() override;
|
||||
|
||||
@@ -57,6 +59,8 @@ public:
|
||||
bool loadData(Common::ReadStream *rs);
|
||||
void saveData(Common::WriteStream *ws) override;
|
||||
|
||||
INTRINSIC(I_playMovieOverlay);
|
||||
|
||||
protected:
|
||||
MoviePlayer *_player;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user