2007-05-30 21:56:52 +00:00
|
|
|
/* 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.
|
2006-05-08 10:21:17 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-08-12 00:53:35 +00:00
|
|
|
#ifdef ENABLE_HE
|
2006-05-08 10:21:17 +00:00
|
|
|
|
|
|
|
#include "scumm/he/animation_he.h"
|
|
|
|
#include "scumm/he/intern_he.h"
|
|
|
|
|
2011-02-09 01:09:01 +00:00
|
|
|
#include "audio/audiostream.h"
|
2011-07-02 14:55:36 -04:00
|
|
|
#include "video/smk_decoder.h"
|
2006-11-02 10:01:32 +00:00
|
|
|
|
2011-07-13 12:08:26 -04:00
|
|
|
#ifdef USE_BINK
|
|
|
|
#include "video/bink_decoder.h"
|
|
|
|
#endif
|
|
|
|
|
2006-05-08 10:21:17 +00:00
|
|
|
namespace Scumm {
|
|
|
|
|
2011-07-02 14:55:36 -04:00
|
|
|
MoviePlayer::MoviePlayer(ScummEngine_v90he *vm, Audio::Mixer *mixer) : _vm(vm) {
|
2011-07-13 12:08:26 -04:00
|
|
|
#ifdef USE_BINK
|
2011-07-02 16:37:41 -04:00
|
|
|
if (_vm->_game.heversion >= 100 && (_vm->_game.features & GF_16BIT_COLOR))
|
|
|
|
_video = new Video::BinkDecoder();
|
|
|
|
else
|
2011-07-13 12:08:26 -04:00
|
|
|
#endif
|
2011-07-02 16:37:41 -04:00
|
|
|
_video = new Video::SmackerDecoder(mixer);
|
|
|
|
|
2006-05-08 10:21:17 +00:00
|
|
|
_flags = 0;
|
|
|
|
_wizResNum = 0;
|
|
|
|
}
|
|
|
|
|
2011-07-02 14:55:36 -04:00
|
|
|
MoviePlayer::~MoviePlayer() {
|
|
|
|
delete _video;
|
|
|
|
}
|
|
|
|
|
2006-05-08 10:21:17 +00:00
|
|
|
int MoviePlayer::getImageNum() {
|
2011-07-02 14:55:36 -04:00
|
|
|
if (!_video->isVideoLoaded())
|
2006-05-08 10:21:17 +00:00
|
|
|
return 0;
|
2011-07-02 14:55:36 -04:00
|
|
|
|
2006-05-08 10:21:17 +00:00
|
|
|
return _wizResNum;
|
|
|
|
}
|
|
|
|
|
|
|
|
int MoviePlayer::load(const char *filename, int flags, int image) {
|
2011-07-02 14:55:36 -04:00
|
|
|
if (_video->isVideoLoaded())
|
|
|
|
_video->close();
|
2006-05-08 10:21:17 +00:00
|
|
|
|
2011-07-02 14:55:36 -04:00
|
|
|
if (!_video->loadFile(filename)) {
|
2008-12-14 23:41:48 +00:00
|
|
|
warning("Failed to load video file %s", filename);
|
2006-05-08 10:21:17 +00:00
|
|
|
return -1;
|
2007-09-19 08:40:12 +00:00
|
|
|
}
|
2010-05-18 14:17:24 +00:00
|
|
|
|
2008-12-14 23:41:48 +00:00
|
|
|
debug(1, "Playing video %s", filename);
|
2006-05-08 10:21:17 +00:00
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
if (flags & 2)
|
2011-07-02 14:55:36 -04:00
|
|
|
_vm->_wiz->createWizEmptyImage(image, 0, 0, _video->getWidth(), _video->getHeight());
|
2006-05-08 10:21:17 +00:00
|
|
|
|
|
|
|
_flags = flags;
|
|
|
|
_wizResNum = image;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-22 09:39:55 +00:00
|
|
|
void MoviePlayer::copyFrameToBuffer(byte *dst, int dstType, uint x, uint y, uint pitch) {
|
2011-07-02 14:55:36 -04:00
|
|
|
uint h = _video->getHeight();
|
|
|
|
uint w = _video->getWidth();
|
2009-06-04 01:05:47 +00:00
|
|
|
|
2011-07-02 14:55:36 -04:00
|
|
|
const Graphics::Surface *surface = _video->decodeNextFrame();
|
2011-07-02 16:37:41 -04:00
|
|
|
|
|
|
|
if (!surface)
|
|
|
|
return;
|
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
byte *src = (byte *)surface->pixels;
|
|
|
|
|
2011-07-02 14:55:36 -04:00
|
|
|
if (_video->hasDirtyPalette())
|
|
|
|
_vm->setPaletteFromPtr(_video->getPalette(), 256);
|
2009-06-04 01:05:47 +00:00
|
|
|
|
|
|
|
if (_vm->_game.features & GF_16BIT_COLOR) {
|
2011-07-02 16:37:41 -04:00
|
|
|
if (surface->format.bytesPerPixel == 1) {
|
|
|
|
dst += y * pitch + x * 2;
|
|
|
|
do {
|
|
|
|
for (uint i = 0; i < w; i++) {
|
|
|
|
uint16 color = READ_LE_UINT16(_vm->_hePalettes + _vm->_hePaletteSlot + 768 + src[i] * 2);
|
|
|
|
switch (dstType) {
|
|
|
|
case kDstScreen:
|
|
|
|
WRITE_UINT16(dst + i * 2, color);
|
|
|
|
break;
|
|
|
|
case kDstResource:
|
|
|
|
WRITE_LE_UINT16(dst + i * 2, color);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("copyFrameToBuffer: Unknown dstType %d", dstType);
|
|
|
|
}
|
2009-08-22 09:39:55 +00:00
|
|
|
}
|
2011-07-02 16:37:41 -04:00
|
|
|
dst += pitch;
|
|
|
|
src += w;
|
|
|
|
} while (--h);
|
|
|
|
} else {
|
|
|
|
dst += y * pitch + x * 2;
|
|
|
|
do {
|
|
|
|
for (uint i = 0; i < w; i++) {
|
|
|
|
uint16 color = *((uint16 *)src + i);
|
|
|
|
switch (dstType) {
|
|
|
|
case kDstScreen:
|
|
|
|
WRITE_UINT16(dst + i * 2, color);
|
|
|
|
break;
|
|
|
|
case kDstResource:
|
|
|
|
WRITE_LE_UINT16(dst + i * 2, color);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("copyFrameToBuffer: Unknown dstType %d", dstType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dst += pitch;
|
|
|
|
src += surface->pitch;
|
|
|
|
} while (--h);
|
|
|
|
}
|
2009-06-04 01:05:47 +00:00
|
|
|
} else {
|
|
|
|
dst += y * pitch + x;
|
|
|
|
do {
|
|
|
|
memcpy(dst, src, w);
|
|
|
|
dst += pitch;
|
|
|
|
src += w;
|
|
|
|
} while (--h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-08 10:21:17 +00:00
|
|
|
void MoviePlayer::handleNextFrame() {
|
2011-07-02 14:55:36 -04:00
|
|
|
if (!_video->isVideoLoaded())
|
2006-05-08 10:21:17 +00:00
|
|
|
return;
|
|
|
|
|
2007-09-08 11:15:27 +00:00
|
|
|
VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen];
|
2006-05-08 10:21:17 +00:00
|
|
|
|
|
|
|
if (_flags & 2) {
|
|
|
|
uint8 *dstPtr = _vm->getResourceAddress(rtImage, _wizResNum);
|
|
|
|
assert(dstPtr);
|
2011-04-12 16:53:15 +02:00
|
|
|
uint8 *dst = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dstPtr, 0, 0);
|
2006-05-08 10:21:17 +00:00
|
|
|
assert(dst);
|
2009-09-25 09:13:33 +00:00
|
|
|
copyFrameToBuffer(dst, kDstResource, 0, 0, _vm->_screenWidth * _vm->_bytesPerPixel);
|
2006-05-08 10:21:17 +00:00
|
|
|
} else if (_flags & 1) {
|
2009-08-22 09:39:55 +00:00
|
|
|
copyFrameToBuffer(pvs->getBackPixels(0, 0), kDstScreen, 0, 0, pvs->pitch);
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2011-07-02 14:55:36 -04:00
|
|
|
Common::Rect imageRect(_video->getWidth(), _video->getHeight());
|
2006-09-17 23:35:09 +00:00
|
|
|
_vm->restoreBackgroundHE(imageRect);
|
2006-05-08 10:21:17 +00:00
|
|
|
} else {
|
2009-08-22 09:39:55 +00:00
|
|
|
copyFrameToBuffer(pvs->getPixels(0, 0), kDstScreen, 0, 0, pvs->pitch);
|
2006-05-08 10:21:17 +00:00
|
|
|
|
2011-07-02 14:55:36 -04:00
|
|
|
Common::Rect imageRect(_video->getWidth(), _video->getHeight());
|
2008-12-27 02:36:08 +00:00
|
|
|
_vm->markRectAsDirty(kMainVirtScreen, imageRect);
|
2006-05-08 10:21:17 +00:00
|
|
|
}
|
|
|
|
|
2011-07-02 14:55:36 -04:00
|
|
|
if (_video->endOfVideo())
|
|
|
|
_video->close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MoviePlayer::close() {
|
|
|
|
_video->close();
|
|
|
|
}
|
|
|
|
|
|
|
|
int MoviePlayer::getWidth() const {
|
|
|
|
return _video->getWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
int MoviePlayer::getHeight() const {
|
|
|
|
return _video->getHeight();
|
|
|
|
}
|
|
|
|
|
|
|
|
int MoviePlayer::getFrameCount() const {
|
|
|
|
return _video->getFrameCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
int MoviePlayer::getCurFrame() const {
|
|
|
|
return _video->endOfVideo() ? -1 : _video->getCurFrame() + 1;
|
2006-05-08 10:21:17 +00:00
|
|
|
}
|
|
|
|
|
2006-11-03 06:16:11 +00:00
|
|
|
} // End of namespace Scumm
|
2009-08-12 00:53:35 +00:00
|
|
|
|
|
|
|
#endif // ENABLE_HE
|