aboutsummaryrefslogtreecommitdiff
path: root/engines/sword2
diff options
context:
space:
mode:
authorFilippos Karapetis2009-02-15 13:29:48 +0000
committerFilippos Karapetis2009-02-15 13:29:48 +0000
commit781d7da6b1f0ff9ad7dd4b28b51ed1e3064d222b (patch)
tree91569e4d8abee185ba91875718afee94dc20a0f4 /engines/sword2
parent47a1cd754586a8f61381db7ac7147987bbaa27dc (diff)
downloadscummvm-rg350-781d7da6b1f0ff9ad7dd4b28b51ed1e3064d222b.tar.gz
scummvm-rg350-781d7da6b1f0ff9ad7dd4b28b51ed1e3064d222b.tar.bz2
scummvm-rg350-781d7da6b1f0ff9ad7dd4b28b51ed1e3064d222b.zip
Applied my patch for the BS1/2 video player
- Support for the MPEG2 videos in BS1/2 has been dropped. The MPEG2 videos were lossy, and support for them complicated the code a lot. - Support for the non-existing enhanced MPEG cutscene packs for BS1 has been dropped. As a consequence, the credits player and the splitted audio stream players used for these packs has been removed - The original Smacker videos for both games are now supported, using our Smacker player (which is based off publically available specs and FFMPEG) - The animations now use the common video player code. Both the Smacker videos and our DXA video packs are supported svn-id: r38236
Diffstat (limited to 'engines/sword2')
-rw-r--r--engines/sword2/animation.cpp281
-rw-r--r--engines/sword2/animation.h49
-rw-r--r--engines/sword2/sword2.cpp2
3 files changed, 52 insertions, 280 deletions
diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp
index 9375896f81..a6925e9ade 100644
--- a/engines/sword2/animation.cpp
+++ b/engines/sword2/animation.cpp
@@ -42,6 +42,8 @@
#include "sword2/sound.h"
#include "sword2/animation.h"
+#include "gui/message.h"
+
namespace Sword2 {
///////////////////////////////////////////////////////////////////////////////
@@ -91,7 +93,6 @@ MoviePlayer::MoviePlayer(Sword2Engine *vm, const char *name) {
_leadOutFrame = (uint)-1;
_seamless = false;
_framesSkipped = 0;
- _forceFrame = false;
_currentText = 0;
}
@@ -103,43 +104,6 @@ uint32 MoviePlayer::getTick() {
return _system->getMillis() - _pauseTicks;
}
-void MoviePlayer::updatePalette(byte *pal, bool packed) {
- byte palette[4 * 256];
- byte *p = palette;
-
- uint32 maxWeight = 0;
- uint32 minWeight = 0xFFFFFFFF;
-
- for (int i = 0; i < 256; i++) {
- int r = *pal++;
- int g = *pal++;
- int b = *pal++;
-
- if (!packed)
- pal++;
-
- uint32 weight = 3 * r * r + 6 * g * g + 2 * b * b;
-
- if (weight >= maxWeight) {
- _white = i;
- maxWeight = weight;
- }
-
- if (weight <= minWeight) {
- _black = i;
- minWeight = i;
- }
-
- *p++ = r;
- *p++ = g;
- *p++ = b;
- *p++ = 0;
- }
-
- _vm->_screen->setPalette(0, 256, palette, RDPAL_INSTANT);
- _forceFrame = true;
-}
-
void MoviePlayer::savePalette() {
memcpy(_originalPalette, _vm->_screen->getPalette(), sizeof(_originalPalette));
}
@@ -157,11 +121,6 @@ void MoviePlayer::updateScreen() {
}
bool MoviePlayer::checkSkipFrame() {
- if (_forceFrame) {
- _forceFrame = false;
- return false;
- }
-
if (_framesSkipped > 10) {
warning("Forced frame %d to be displayed", _currentFrame);
_framesSkipped = 0;
@@ -512,44 +471,34 @@ void MoviePlayer::pauseMovie(bool pause) {
}
}
-#ifdef USE_ZLIB
-
///////////////////////////////////////////////////////////////////////////////
-// Movie player for the new DXA movies
+// Movie player for the original SMK movies
///////////////////////////////////////////////////////////////////////////////
-MoviePlayerDXA::MoviePlayerDXA(Sword2Engine *vm, const char *name)
- : MoviePlayer(vm, name) {
- debug(0, "Creating DXA cutscene player");
+MoviePlayerSMK::MoviePlayerSMK(Sword2Engine *vm, const char *name)
+ : MoviePlayer(vm, name), SMKPlayer(vm->_mixer) {
+ debug(0, "Creating SMK cutscene player");
}
-MoviePlayerDXA::~MoviePlayerDXA() {
+MoviePlayerSMK::~MoviePlayerSMK() {
closeFile();
}
-void MoviePlayerDXA::setPalette(byte *pal) {
- updatePalette(pal);
-}
-
-bool MoviePlayerDXA::decodeFrame() {
+bool MoviePlayerSMK::decodeFrame() {
decodeNextFrame();
copyFrameToBuffer(_frameBuffer, _frameX, _frameY, _vm->_screen->getScreenWide());
return true;
}
-bool MoviePlayerDXA::load() {
+bool MoviePlayerSMK::load() {
if (!MoviePlayer::load())
return false;
char filename[20];
- snprintf(filename, sizeof(filename), "%s.dxa", _name);
+ snprintf(filename, sizeof(filename), "%s.smk", _name);
if (loadFile(filename)) {
- // The Broken Sword games always use external audio tracks.
- if (_fileStream->readUint32BE() != MKID_BE('NULL'))
- return false;
-
_frameBuffer = _vm->_screen->getScreen();
_frameWidth = getWidth();
@@ -564,197 +513,52 @@ bool MoviePlayerDXA::load() {
return false;
}
-#endif
-
-#ifdef USE_MPEG2
+#ifdef USE_ZLIB
///////////////////////////////////////////////////////////////////////////////
-// Movie player for the old MPEG movies
+// Movie player for the new DXA movies
///////////////////////////////////////////////////////////////////////////////
-MoviePlayerMPEG::MoviePlayerMPEG(Sword2Engine *vm, const char *name)
+MoviePlayerDXA::MoviePlayerDXA(Sword2Engine *vm, const char *name)
: MoviePlayer(vm, name) {
-#ifdef BACKEND_8BIT
- debug(0, "Creating MPEG cutscene player (8-bit)");
-#else
- debug(0, "Creating MPEG cutscene player (16-bit)");
-#endif
+ debug(0, "Creating DXA cutscene player");
}
-MoviePlayerMPEG::~MoviePlayerMPEG() {
- delete _anim;
- _anim = NULL;
+MoviePlayerDXA::~MoviePlayerDXA() {
+ closeFile();
}
-bool MoviePlayerMPEG::load() {
- if (!MoviePlayer::load())
- return false;
-
- _anim = new AnimationState(_vm, this);
-
- if (!_anim->init(_name)) {
- delete _anim;
- _anim = NULL;
- return false;
- }
-
-#ifdef BACKEND_8BIT
- _frameBuffer = _vm->_screen->getScreen();
-#endif
-
+bool MoviePlayerDXA::decodeFrame() {
+ decodeNextFrame();
+ copyFrameToBuffer(_frameBuffer, _frameX, _frameY, _vm->_screen->getScreenWide());
return true;
}
-bool MoviePlayerMPEG::decodeFrame() {
- bool result = _anim->decodeFrame();
-
-#ifdef BACKEND_8BIT
- _frameWidth = _anim->getFrameWidth();
- _frameHeight = _anim->getFrameHeight();
-
- _frameX = (_vm->_screen->getScreenWide() - _frameWidth) / 2;
- _frameY = (_vm->_screen->getScreenDeep() - _frameHeight) / 2;
-#endif
-
- return result;
-}
-
-AnimationState::AnimationState(Sword2Engine *vm, MoviePlayer *player)
- : BaseAnimationState(vm->_system, 640, 480) {
- _vm = vm;
- _player = player;
-}
-
-AnimationState::~AnimationState() {
-}
-
-#ifdef BACKEND_8BIT
-
-void AnimationState::setPalette(byte *pal) {
- _player->updatePalette(pal, false);
-}
-
-#else
-
-void MoviePlayerMPEG::handleScreenChanged() {
- _anim->handleScreenChanged();
-}
-
-void MoviePlayerMPEG::clearFrame() {
- _anim->clearFrame();
-}
-
-void MoviePlayerMPEG::drawFrame() {
-}
-
-void MoviePlayerMPEG::updateScreen() {
- _anim->updateScreen();
-}
-
-void MoviePlayerMPEG::drawTextObject() {
- if (_textObject.textMem && _textSurface) {
- _anim->drawTextObject(&_textObject.textSprite, _textSurface);
- }
-}
-
-void MoviePlayerMPEG::undrawTextObject() {
- // As long as we only have subtitles for full-sized cutscenes, we don't
- // really need to implement this function.
-}
-
-void AnimationState::drawTextObject(SpriteInfo *s, byte *src) {
- int moviePitch = _movieScale * _movieWidth;
- int textX = _movieScale * s->x;
- int textY = _movieScale * (_frameHeight - s->h - 12);
+bool MoviePlayerDXA::load() {
+ if (!MoviePlayer::load())
+ return false;
- OverlayColor *dst = _overlay + textY * moviePitch + textX;
+ char filename[20];
- Graphics::PixelFormat format = _sys->getOverlayFormat();
- OverlayColor pen = format.RGBToColor(255, 255, 255);
- OverlayColor border = format.RGBToColor(0, 0, 0);
+ snprintf(filename, sizeof(filename), "%s.dxa", _name);
- // TODO: Use the AdvMame scalers for the text? Pre-scale it?
+ if (loadFile(filename)) {
+ // The Broken Sword games always use external audio tracks.
+ if (_fileStream->readUint32BE() != MKID_BE('NULL'))
+ return false;
- for (int y = 0; y < s->h; y++) {
- OverlayColor *ptr = dst;
+ _frameBuffer = _vm->_screen->getScreen();
- for (int x = 0; x < s->w; x++) {
- switch (src[x]) {
- case 1:
- *ptr++ = border;
- if (_movieScale > 1) {
- *ptr++ = border;
- if (_movieScale > 2)
- *ptr++ = border;
- }
- break;
- case 255:
- *ptr++ = pen;
- if (_movieScale > 1) {
- *ptr++ = pen;
- if (_movieScale > 2)
- *ptr++ = pen;
- }
- break;
- default:
- ptr += _movieScale;
- break;
- }
- }
+ _frameWidth = getWidth();
+ _frameHeight = getHeight();
- if (_movieScale > 1) {
- memcpy(dst + moviePitch, dst, _movieScale * s->w * sizeof(OverlayColor));
- if (_movieScale > 2)
- memcpy(dst + 2 * moviePitch, dst, _movieScale * s->w * sizeof(OverlayColor));
- }
+ _frameX = (_vm->_screen->getScreenWide() - _frameWidth) / 2;
+ _frameY = (_vm->_screen->getScreenDeep() - _frameHeight) / 2;
- dst += _movieScale * moviePitch;
- src += s->w;
+ return true;
}
-}
-#endif
-
-void AnimationState::clearFrame() {
-#ifdef BACKEND_8BIT
- memset(_vm->_screen->getScreen(), 0, _movieWidth * _movieHeight);
-#else
- Graphics::PixelFormat format = _sys->getOverlayFormat();
- OverlayColor black = format.RGBToColor(0, 0, 0);
-
- for (int i = 0; i < _movieScale * _movieWidth * _movieScale * _movieHeight; i++)
- _overlay[i] = black;
-#endif
-}
-
-void AnimationState::drawYUV(int width, int height, byte *const *dat) {
- _frameWidth = width;
- _frameHeight = height;
-
-#ifdef BACKEND_8BIT
- byte *buf = _vm->_screen->getScreen() + ((480 - height) / 2) * RENDERWIDE + (640 - width) / 2;
-
- int x, y;
- int ypos = 0;
- int cpos = 0;
- int linepos = 0;
-
- for (y = 0; y < height; y += 2) {
- for (x = 0; x < width; x += 2) {
- int i = ((((dat[2][cpos] + ROUNDADD) >> SHIFT) * (BITDEPTH + 1)) + ((dat[1][cpos] + ROUNDADD) >> SHIFT)) * (BITDEPTH + 1);
- cpos++;
-
- buf[linepos ] = _lut[i + ((dat[0][ ypos ] + ROUNDADD) >> SHIFT)];
- buf[RENDERWIDE + linepos++] = _lut[i + ((dat[0][width + ypos++] + ROUNDADD) >> SHIFT)];
- buf[linepos ] = _lut[i + ((dat[0][ ypos ] + ROUNDADD) >> SHIFT)];
- buf[RENDERWIDE + linepos++] = _lut[i + ((dat[0][width + ypos++] + ROUNDADD) >> SHIFT)];
- }
- linepos += (2 * RENDERWIDE - width);
- ypos += width;
- }
-#else
- plotYUV(width, height, dat);
-#endif
+ return false;
}
#endif
@@ -802,10 +606,10 @@ bool MoviePlayerDummy::decodeFrame() {
byte msgNoCutscenesRU[] = "Po\344uk - to\344\345ko pev\345: hagmute k\344abuwy Ucke\343n, u\344u nocetute ca\343t npoekta u ckava\343te budeo po\344uku";
-#if defined(USE_MPEG2) || defined(USE_ZLIB)
+#if defined(USE_ZLIB)
byte msgNoCutscenes[] = "Cutscene - Narration Only: Press ESC to exit, or visit www.scummvm.org to download cutscene videos";
#else
- byte msgNoCutscenes[] = "Cutscene - Narration Only: Press ESC to exit, or recompile ScummVM with MPEG2 or ZLib support";
+ byte msgNoCutscenes[] = "Cutscene - Narration Only: Press ESC to exit, or recompile ScummVM with ZLib support";
#endif
byte *msg;
@@ -885,6 +689,12 @@ void MoviePlayerDummy::undrawTextObject() {
MoviePlayer *makeMoviePlayer(Sword2Engine *vm, const char *name) {
static char filename[20];
+ snprintf(filename, sizeof(filename), "%s.smk", name);
+
+ if (Common::File::exists(filename)) {
+ return new MoviePlayerSMK(vm, name);
+ }
+
#ifdef USE_ZLIB
snprintf(filename, sizeof(filename), "%s.dxa", name);
@@ -893,13 +703,12 @@ MoviePlayer *makeMoviePlayer(Sword2Engine *vm, const char *name) {
}
#endif
-#ifdef USE_MPEG2
snprintf(filename, sizeof(filename), "%s.mp2", name);
if (Common::File::exists(filename)) {
- return new MoviePlayerMPEG(vm, name);
+ GUI::MessageDialog dialog("MPEG2 cutscenes are no longer supported", "OK");
+ dialog.runModal();
}
-#endif
return new MoviePlayerDummy(vm, name);
}
diff --git a/engines/sword2/animation.h b/engines/sword2/animation.h
index da59a4c509..8b6a015037 100644
--- a/engines/sword2/animation.h
+++ b/engines/sword2/animation.h
@@ -29,7 +29,7 @@
#define SWORD2_ANIMATION_H
#include "graphics/video/dxa_player.h"
-#include "graphics/video/mpeg_player.h"
+#include "graphics/video/smk_player.h"
#include "sound/mixer.h"
#include "sword2/screen.h"
@@ -97,7 +97,6 @@ protected:
bool _seamless;
int _framesSkipped;
- bool _forceFrame;
static const MovieInfo _movies[];
@@ -126,7 +125,6 @@ public:
MoviePlayer(Sword2Engine *vm, const char *name);
virtual ~MoviePlayer();
- void updatePalette(byte *pal, bool packed = true);
virtual bool load();
bool userInterrupt();
void play(SequenceTextInfo *textList, uint32 numLines, int32 leadIn, int32 leadOut);
@@ -148,57 +146,20 @@ public:
bool load();
};
-#ifdef USE_MPEG2
-class AnimationState : public ::Graphics::BaseAnimationState {
-private:
- Sword2Engine *_vm;
- MoviePlayer *_player;
-
-public:
- AnimationState(Sword2Engine *vm, MoviePlayer *player);
- ~AnimationState();
-
-#ifndef BACKEND_8BIT
- void drawTextObject(SpriteInfo *s, byte *src);
-#endif
-
- void clearFrame();
-
-private:
- void drawYUV(int width, int height, byte *const *dat);
-
-#ifdef BACKEND_8BIT
- void setPalette(byte *pal);
-#endif
-};
-
-class MoviePlayerMPEG : public MoviePlayer {
+class MoviePlayerSMK : public MoviePlayer, ::Graphics::SMKPlayer {
protected:
- AnimationState *_anim;
-
- virtual bool decodeFrame();
-
-#ifndef BACKEND_8BIT
- void handleScreenChanged();
- void clearFrame();
- void drawFrame();
- void updateScreen();
- void drawTextObject();
- void undrawTextObject();
-#endif
+ bool decodeFrame();
public:
- MoviePlayerMPEG(Sword2Engine *vm, const char *name);
- ~MoviePlayerMPEG();
+ MoviePlayerSMK(Sword2Engine *vm, const char *name);
+ ~MoviePlayerSMK();
bool load();
};
-#endif
#ifdef USE_ZLIB
class MoviePlayerDXA : public MoviePlayer, ::Graphics::DXAPlayer {
protected:
- void setPalette(byte *pal);
bool decodeFrame();
public:
diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp
index 9fdc10123d..71a949fe88 100644
--- a/engines/sword2/sword2.cpp
+++ b/engines/sword2/sword2.cpp
@@ -252,9 +252,11 @@ Sword2Engine::Sword2Engine(OSystem *syst) : Engine(syst) {
Common::File::addDefaultDirectory(_gameDataDir.getChild("CLUSTERS"));
Common::File::addDefaultDirectory(_gameDataDir.getChild("SWORD2"));
Common::File::addDefaultDirectory(_gameDataDir.getChild("VIDEO"));
+ Common::File::addDefaultDirectory(_gameDataDir.getChild("SMACKS"));
Common::File::addDefaultDirectory(_gameDataDir.getChild("clusters"));
Common::File::addDefaultDirectory(_gameDataDir.getChild("sword2"));
Common::File::addDefaultDirectory(_gameDataDir.getChild("video"));
+ Common::File::addDefaultDirectory(_gameDataDir.getChild("smacks"));
if (0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2demo"))
_features = GF_DEMO;