diff options
author | Travis Howell | 2006-06-28 14:06:54 +0000 |
---|---|---|
committer | Travis Howell | 2006-06-28 14:06:54 +0000 |
commit | dd57c5798221419ab6ac20330462fe117631aad6 (patch) | |
tree | 1b6788431742cb6df6bb522d397684018176d07b /engines/scumm | |
parent | c367dbfc36af58f589ff320ff69eb072dac518e5 (diff) | |
download | scummvm-rg350-dd57c5798221419ab6ac20330462fe117631aad6.tar.gz scummvm-rg350-dd57c5798221419ab6ac20330462fe117631aad6.tar.bz2 scummvm-rg350-dd57c5798221419ab6ac20330462fe117631aad6.zip |
Add eriktorbjorn's patch for DXA unification, with more changes
svn-id: r23332
Diffstat (limited to 'engines/scumm')
-rw-r--r-- | engines/scumm/he/animation_he.cpp | 186 | ||||
-rw-r--r-- | engines/scumm/he/animation_he.h | 26 | ||||
-rw-r--r-- | engines/scumm/he/script_v90he.cpp | 2 |
3 files changed, 19 insertions, 195 deletions
diff --git a/engines/scumm/he/animation_he.cpp b/engines/scumm/he/animation_he.cpp index 327cde6d87..3fa58cac90 100644 --- a/engines/scumm/he/animation_he.cpp +++ b/engines/scumm/he/animation_he.cpp @@ -26,71 +26,26 @@ #include "scumm/he/animation_he.h" #include "scumm/he/intern_he.h" -#ifdef USE_ZLIB -#include <zlib.h> -#endif - namespace Scumm { MoviePlayer::MoviePlayer(ScummEngine_v90he *vm) - : _vm(vm) { - - _frameBuffer1 = 0; - _frameBuffer2 = 0; - - _width = 0; - _height = 0; - - _frameSize = 0; - _framesCount = 0; - _frameNum = 0; - _framesPerSec = 0; - _frameTicks = 0; + : DXAPlayer(), _vm(vm) { _flags = 0; _wizResNum = 0; } -MoviePlayer::~MoviePlayer() { -} - -int MoviePlayer::getWidth() { - if (_fd.isOpen() == false) - return 0; - return _width; -} - -int MoviePlayer::getHeight() { - if (_fd.isOpen() == false) - return 0; - return _height; -} - -int MoviePlayer::getCurFrame() { - if (_fd.isOpen() == false) - return -1; - return _frameNum; -} - -int MoviePlayer::getFrameCount() { - if (_fd.isOpen() == false) - return 0; - return _framesCount; -} - int MoviePlayer::getImageNum() { - if (_fd.isOpen() == false) + if (!_fd.isOpen()) return 0; return _wizResNum; } int MoviePlayer::load(const char *filename, int flags, int image) { char videoName[100]; - uint32 tag; - int32 frameRate; - if (_fd.isOpen() == true) { - close(); + if (_fd.isOpen()) { + closeFile(); } // Change file extension to dxa @@ -100,173 +55,60 @@ int MoviePlayer::load(const char *filename, int flags, int image) { videoName[len++] = 'x'; videoName[len++] = 'a'; - if (_fd.open(videoName) == false) { + if (!loadFile(videoName)) { warning("Failed to load video file %s", videoName); return -1; } debug(1, "Playing video %s", videoName); - tag = _fd.readUint32BE(); - assert(tag == MKID_BE('DEXA')); - - _fd.readByte(); - _framesCount = _fd.readUint16BE(); - frameRate = _fd.readUint32BE(); - - if (frameRate > 0) - _framesPerSec = 1000 / frameRate; - else if (frameRate < 0) - _framesPerSec = 100000 / (-frameRate); - else - _framesPerSec = 10; - - if (frameRate < 0) - _frameTicks = -frameRate / 100; - else - _frameTicks = frameRate; - - _width = _fd.readUint16BE(); - _height = _fd.readUint16BE(); - // Skip sound tag _fd.readUint32BE(); - _frameSize = _width * _height; - _frameBuffer1 = (uint8 *)malloc(_frameSize); - _frameBuffer2 = (uint8 *)malloc(_frameSize); - if (!_frameBuffer1 || !_frameBuffer2) { - error("error allocating frame tables, size %d\n", _frameSize); - } - if (flags & 2) { _vm->_wiz->createWizEmptyImage(image, 0, 0, _width, _height); } - _frameNum = 0; - _flags = flags; _wizResNum = image; return 0; } -void MoviePlayer::close() { - if (_fd.isOpen() == false) - return; - - _fd.close(); - free(_frameBuffer1); - free(_frameBuffer2); -} - void MoviePlayer::handleNextFrame() { if (_fd.isOpen() == false) { return; } VirtScreen *pvs = &_vm->virtscr[kMainVirtScreen]; - uint8 *dst; + ; - decodeFrame(); + decodeNextFrame(); if (_flags & 2) { uint8 *dstPtr = _vm->getResourceAddress(rtImage, _wizResNum); assert(dstPtr); - dst = _vm->findWrappedBlock(MKID_BE('WIZD'), dstPtr, 0, 0); + uint8 *dst = _vm->findWrappedBlock(MKID_BE('WIZD'), dstPtr, 0, 0); assert(dst); - copyFrame(dst, 0, 0); + copyFrameToBuffer(dst, 0, 0, _vm->_screenWidth); } else if (_flags & 1) { - dst = pvs->getBackPixels(0, 0); - copyFrame(dst, 0, 0); + copyFrameToBuffer(pvs->getBackPixels(0, 0), 0, 0, _vm->_screenWidth); Common::Rect imageRect(_width, _height); _vm->gdi.copyVirtScreenBuffers(imageRect); } else { - dst = pvs->getPixels(0, 0); - copyFrame(dst, 0, 0); + copyFrameToBuffer(pvs->getPixels(0, 0), 0, 0, _vm->_screenWidth); _vm->markRectAsDirty(kMainVirtScreen, 0, 0, _width, _height); } _frameNum++; if (_frameNum == _framesCount) { - close(); - } -} - -void MoviePlayer::copyFrame(byte *dst, uint x, uint y) { - uint h = _height; - uint w = _width; - - dst += y * _vm->_screenWidth + x; - byte *src = _frameBuffer1; - - do { - memcpy(dst, src, w); - dst += _vm->_screenWidth; - src += _width; - } while (--h); -} - -void MoviePlayer::decodeZlib(uint8 *data, int size, int totalSize) { -#ifdef USE_ZLIB - uint8 *temp = (uint8 *)malloc(size); - if (temp) { - memcpy(temp, data, size); - z_stream d_stream; - d_stream.zalloc = (alloc_func)0; - d_stream.zfree = (free_func)0; - d_stream.opaque = (voidpf)0; - d_stream.next_in = temp; - d_stream.avail_in = size; - d_stream.total_in = size; - d_stream.next_out = data; - d_stream.avail_out = totalSize; - inflateInit(&d_stream); - inflate(&d_stream, Z_FINISH); - inflateEnd(&d_stream); - free(temp); + closeFile(); } -#endif } -void MoviePlayer::decodeFrame() { - uint32 tag; - - tag = _fd.readUint32BE(); - if (tag == MKID_BE('CMAP')) { - uint8 rgb[768]; - - _fd.read(rgb, ARRAYSIZE(rgb)); - _vm->setPaletteFromPtr(rgb, 256); - } - - tag = _fd.readUint32BE(); - if (tag == MKID_BE('FRAM')) { - uint8 type = _fd.readByte(); - uint32 size = _fd.readUint32BE(); - - _fd.read(_frameBuffer2, size); - - switch (type) { - case 2: - case 3: - decodeZlib(_frameBuffer2, size, _frameSize); - break; - default: - error("decodeFrame: Unknown compression type %d", type); - } - if (type == 2) { - memcpy(_frameBuffer1, _frameBuffer2, _frameSize); - } else { - for (int j = 0; j < _height; ++j) { - for (int i = 0; i < _width; ++i) { - const int offs = j * _width + i; - _frameBuffer1[offs] ^= _frameBuffer2[offs]; - } - } - } - } +void MoviePlayer::setPalette(byte *pal) { + _vm->setPaletteFromPtr(pal, 256); } } // End of namespace Simon diff --git a/engines/scumm/he/animation_he.h b/engines/scumm/he/animation_he.h index d55f2feb05..f1c40a65a9 100644 --- a/engines/scumm/he/animation_he.h +++ b/engines/scumm/he/animation_he.h @@ -25,46 +25,28 @@ #define ANIMATION_H #include "common/file.h" +#include "graphics/dxa_player.h" namespace Scumm { class ScummEngine_v90he; -class MoviePlayer { +class MoviePlayer : public Graphics::DXAPlayer { ScummEngine_v90he *_vm; - Common::File _fd; - uint8 *_frameBuffer1; - uint8 *_frameBuffer2; - uint16 _width; - uint16 _height; - uint16 _framesCount; - uint32 _framesPerSec; - uint16 _frameNum; - uint32 _frameSize; - uint32 _frameTicks; - uint32 _flags; uint32 _wizResNum; public: MoviePlayer(ScummEngine_v90he *vm); - ~MoviePlayer(); - int getWidth(); - int getHeight(); - int getCurFrame(); - int getFrameCount(); int getImageNum(); int load(const char *filename, int flags, int image = 0); void handleNextFrame(); - void close(); -private: - void copyFrame(byte *dst, uint x, uint y); - void decodeFrame(); - void decodeZlib(uint8 *data, int size, int totalSize); +protected: + virtual void setPalette(byte *pal); }; } // End of namespace Simon diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp index f18a049785..c8937a1035 100644 --- a/engines/scumm/he/script_v90he.cpp +++ b/engines/scumm/he/script_v90he.cpp @@ -550,7 +550,7 @@ void ScummEngine_v90he::o90_videoOps() { } } else if (_videoParams.status == 165) { // Stop video - _moviePlay->close(); + _moviePlay->closeFile(); } break; default: |