diff options
-rw-r--r-- | engines/agos/animation.cpp | 2 | ||||
-rw-r--r-- | engines/sword1/animation.cpp | 2 | ||||
-rw-r--r-- | engines/sword2/animation.cpp | 4 | ||||
-rw-r--r-- | graphics/dxa_player.cpp | 50 | ||||
-rw-r--r-- | graphics/dxa_player.h | 10 |
5 files changed, 63 insertions, 5 deletions
diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp index fd78c65002..942c7bb7f9 100644 --- a/engines/agos/animation.cpp +++ b/engines/agos/animation.cpp @@ -67,7 +67,7 @@ bool MoviePlayer::load(const char *filename) { // Change file extension to dxa sprintf(videoName, "%s.dxa", baseName); - if (!loadFile(videoName)) { + if (!loadFile(videoName, _vm->_screenWidth, _vm->_screenHeight)) { // Check short filename to work around // bug in a German Windows 2CD version. if (baseLen >= 8) { diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp index 2bb027ddb4..1062ce6029 100644 --- a/engines/sword1/animation.cpp +++ b/engines/sword1/animation.cpp @@ -408,7 +408,7 @@ bool MoviePlayerDXA::load(uint32 id) { char filename[20]; snprintf(filename, sizeof(filename), "%s.dxa", sequenceList[id]); - if (loadFile(filename)) { + if (loadFile(filename, 640, 480)) { // The Broken Sword games always use external audio tracks. if (_fd->readUint32BE() != MKID_BE('NULL')) return false; diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp index 082d02a88f..5e12f262cd 100644 --- a/engines/sword2/animation.cpp +++ b/engines/sword2/animation.cpp @@ -516,7 +516,9 @@ bool MoviePlayerDXA::load() { snprintf(filename, sizeof(filename), "%s.dxa", _name); - if (loadFile(filename)) { + if (loadFile(filename, + _vm->_screen->getScreenWide(), + _vm->_screen->getScreenDeep())) { // The Broken Sword games always use external audio tracks. if (_fd->readUint32BE() != MKID_BE('NULL')) return false; diff --git a/graphics/dxa_player.cpp b/graphics/dxa_player.cpp index 28a1bc4dbd..11cbc55c96 100644 --- a/graphics/dxa_player.cpp +++ b/graphics/dxa_player.cpp @@ -31,6 +31,23 @@ #include <zlib.h> #endif +static void scaleUpBy2(byte *dst, byte *src, uint16 width, uint16 h) { + uint16 x; + + while (h > 0) { + for (x = width; x > 0; x--) { + register byte v; + + v = *src++; + *dst++ = v; + *dst++ = v; + } + memcpy(dst, dst - width * 2, width * 2); + dst += width * 2; + h--; + } +} + namespace Graphics { DXAPlayer::DXAPlayer() { @@ -40,6 +57,7 @@ DXAPlayer::DXAPlayer() { _frameBuffer2 = 0; _scaledBuffer = 0; _drawBuffer = 0; + _scaledBuffer2 = 0; _inBuffer = 0; _inBufferSize = 0; @@ -58,6 +76,8 @@ DXAPlayer::DXAPlayer() { _frameTicks = 0; _scaleMode = S_NONE; + + _scaling = 1; } DXAPlayer::~DXAPlayer() { @@ -66,13 +86,13 @@ DXAPlayer::~DXAPlayer() { int DXAPlayer::getWidth() { if (!_fd) return 0; - return _width; + return _width * _scaling; } int DXAPlayer::getHeight() { if (!_fd) return 0; - return _height; + return _height * _scaling; } int DXAPlayer::getCurFrame() { @@ -87,6 +107,25 @@ int DXAPlayer::getFrameCount() { return _framesCount; } +bool DXAPlayer::loadFile(const char *filename, uint16 maxWidth, uint16 maxHeight) { + bool result = loadFile(filename); + + if (result) { + _scaling = MIN(maxWidth / _width, maxHeight / _height); + if (_scaling < 1) + _scaling = 1; + if (_scaling > 2) + _scaling = 2; + if (_scaling >= 2) { + _scaledBuffer2 = (uint8 *)malloc(_width * _height * _scaling * _scaling); + if (!_scaledBuffer2) { + _scaling = 1; + } + } + } + return result; +} + bool DXAPlayer::loadFile(const char *filename) { uint32 tag; int32 frameRate; @@ -189,6 +228,7 @@ void DXAPlayer::closeFile() { free(_frameBuffer1); free(_frameBuffer2); free(_scaledBuffer); + free(_scaledBuffer2); free(_inBuffer); free(_decompBuffer); @@ -588,6 +628,12 @@ void DXAPlayer::decodeNextFrame() { _drawBuffer = _frameBuffer1; break; } + + if (_scaling == 2) { + /* Scale up here */ + scaleUpBy2(_scaledBuffer2, _drawBuffer, _width, _height); + _drawBuffer = _scaledBuffer2; + } } } // End of namespace Graphics diff --git a/graphics/dxa_player.h b/graphics/dxa_player.h index 5415e440d2..d1d6d78c97 100644 --- a/graphics/dxa_player.h +++ b/graphics/dxa_player.h @@ -47,6 +47,7 @@ protected: byte *_frameBuffer2; byte *_scaledBuffer; byte *_drawBuffer; + byte *_scaledBuffer2; byte *_inBuffer; uint32 _inBufferSize; byte *_decompBuffer; @@ -60,6 +61,7 @@ protected: uint16 _frameSkipped; uint32 _frameTicks; ScaleMode _scaleMode; + uint32 _scaling; public: DXAPlayer(); @@ -98,6 +100,14 @@ public: bool loadFile(const char *filename); /** + * Load a DXA encoded video file and setup scaling if required + * @param filename the filename to load + * @param maxWidth the maximum width available to the film + * @param maxHeight the maximum height available to the film + */ + bool loadFile(const char *filename, uint16 maxWidth, uint16 maxHeight); + + /** * Close a DXA encoded video file */ void closeFile(); |