Add support for pausing/resume cutscenes shown on the OmniTV in The Feeble Files.

svn-id: r27371
This commit is contained in:
Travis Howell 2007-06-12 06:08:47 +00:00
parent 9c07235a93
commit 12c9fb0382
7 changed files with 67 additions and 40 deletions

View File

@ -44,6 +44,8 @@ MoviePlayer::MoviePlayer(AGOSEngine *vm, Audio::Mixer *mixer)
: DXAPlayer(), _vm(vm), _mixer(mixer) {
_omniTV = false;
_omniTVFile = 0;
_leftButtonDown = false;
_rightButtonDown = false;
@ -103,14 +105,21 @@ bool MoviePlayer::load(const char *filename) {
void MoviePlayer::playOmniTV() {
// Load OmniTV video
if (!_fd.isOpen()) {
_vm->_variableArray[254] = 6747;
return;
} else {
if (_fd) {
_vm->setBitFlag(42, false);
_omniTV = true;
startSound();
return;
} else {
if (_omniTVFile) {
// Restore state
_fd = _omniTVFile;
_mixer->pauseHandle(_omniTVSound, false);
_vm->setBitFlag(42, false);
_omniTV = true;
} else {
_vm->_variableArray[254] = 6747;
}
}
}
@ -120,7 +129,7 @@ void MoviePlayer::play() {
return;
}
if (!_fd.isOpen()) {
if (!_fd) {
return;
}
@ -161,14 +170,14 @@ void MoviePlayer::startSound() {
byte *buffer;
uint32 offset, size, tag;
tag = _fd.readUint32BE();
tag = _fd->readUint32BE();
if (tag == MKID_BE('WAVE')) {
size = _fd.readUint32BE();
size = _fd->readUint32BE();
if (_sequenceNum) {
Common::File in;
_fd.seek(size, SEEK_CUR);
_fd->seek(size, SEEK_CUR);
in.open((const char *)"audio.wav");
if (!in.isOpen()) {
@ -185,7 +194,7 @@ void MoviePlayer::startSound() {
in.close();
} else {
buffer = (byte *)malloc(size);
_fd.read(buffer, size);
_fd->read(buffer, size);
}
Common::MemoryReadStream stream(buffer, size);
@ -196,8 +205,13 @@ void MoviePlayer::startSound() {
}
if (_bgSoundStream != NULL) {
_mixer->stopHandle(_bgSound);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSound, _bgSoundStream);
if (_omniTV) {
_mixer->stopHandle(_omniTVSound);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_omniTVSound, _bgSoundStream);
} else {
_mixer->stopHandle(_bgSound);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSound, _bgSoundStream);
}
}
}
@ -206,8 +220,12 @@ void MoviePlayer::nextFrame() {
return;
if (_vm->getBitFlag(42)) {
// Save state
_omniTVFile = _fd;
_mixer->pauseHandle(_omniTVSound, true);
_fd = 0;
_omniTV = false;
closeFile();
return;
}
@ -222,6 +240,7 @@ void MoviePlayer::nextFrame() {
_frameNum++;
} else {
_omniTV = false;
_omniTVFile = 0;
closeFile();
_vm->_variableArray[254] = 6747;
}

View File

@ -44,6 +44,9 @@ class MoviePlayer : public Graphics::DXAPlayer {
Audio::SoundHandle _bgSound;
Audio::AudioStream *_bgSoundStream;
Audio::SoundHandle _omniTVSound;
Common::SeekableReadStream *_omniTVFile;
bool _omniTV;
bool _leftButtonDown;
bool _rightButtonDown;

View File

@ -40,7 +40,7 @@ MoviePlayer::MoviePlayer(ScummEngine_v90he *vm, Audio::Mixer *mixer)
}
int MoviePlayer::getImageNum() {
if (!_fd.isOpen())
if (!_fd)
return 0;
return _wizResNum;
}
@ -48,7 +48,7 @@ int MoviePlayer::getImageNum() {
int MoviePlayer::load(const char *filename, int flags, int image) {
char videoName[100];
if (_fd.isOpen()) {
if (_fd) {
closeFile();
}
@ -66,7 +66,7 @@ int MoviePlayer::load(const char *filename, int flags, int image) {
debug(1, "Playing video %s", videoName);
// Skip sound tag
_fd.readUint32BE();
_fd->readUint32BE();
if (flags & 2) {
_vm->_wiz->createWizEmptyImage(image, 0, 0, _width, _height);
@ -85,7 +85,7 @@ int MoviePlayer::load(const char *filename, int flags, int image) {
}
void MoviePlayer::handleNextFrame() {
if (_fd.isOpen() == false) {
if (_fd == false) {
return;
}

View File

@ -410,7 +410,7 @@ bool MoviePlayerDXA::load(uint32 id) {
snprintf(filename, sizeof(filename), "%s.dxa", sequenceList[id]);
if (loadFile(filename)) {
// The Broken Sword games always use external audio tracks.
if (_fd.readUint32BE() != MKID_BE('NULL'))
if (_fd->readUint32BE() != MKID_BE('NULL'))
return false;
_frameWidth = getWidth();
_frameHeight = getHeight();

View File

@ -518,7 +518,7 @@ bool MoviePlayerDXA::load() {
if (loadFile(filename)) {
// The Broken Sword games always use external audio tracks.
if (_fd.readUint32BE() != MKID_BE('NULL'))
if (_fd->readUint32BE() != MKID_BE('NULL'))
return false;
_frameBuffer = _vm->_screen->getScreen();

View File

@ -35,6 +35,8 @@
namespace Graphics {
DXAPlayer::DXAPlayer() {
_fd = 0;
_frameBuffer1 = 0;
_frameBuffer2 = 0;
_scaledBuffer = 0;
@ -57,25 +59,25 @@ DXAPlayer::~DXAPlayer() {
}
int DXAPlayer::getWidth() {
if (!_fd.isOpen())
if (!_fd)
return 0;
return _width;
}
int DXAPlayer::getHeight() {
if (!_fd.isOpen())
if (!_fd)
return 0;
return _height;
}
int DXAPlayer::getCurFrame() {
if (!_fd.isOpen())
if (!_fd)
return -1;
return _frameNum;
}
int DXAPlayer::getFrameCount() {
if (!_fd.isOpen())
if (!_fd)
return 0;
return _framesCount;
}
@ -84,16 +86,19 @@ bool DXAPlayer::loadFile(const char *filename) {
uint32 tag;
int32 frameRate;
if (!_fd.open(filename)) {
Common::File *file = new Common::File();
if (!file->open(filename)) {
return 0;
}
tag = _fd.readUint32BE();
_fd = file;
tag = _fd->readUint32BE();
assert(tag == MKID_BE('DEXA'));
uint8 flags = _fd.readByte();
_framesCount = _fd.readUint16BE();
frameRate = _fd.readUint32BE();
uint8 flags = _fd->readByte();
_framesCount = _fd->readUint16BE();
frameRate = _fd->readUint32BE();
if (frameRate > 0)
_framesPerSec = 1000 / frameRate;
@ -107,8 +112,8 @@ bool DXAPlayer::loadFile(const char *filename) {
else
_frameTicks = frameRate;
_width = _fd.readUint16BE();
_height = _fd.readUint16BE();
_width = _fd->readUint16BE();
_height = _fd->readUint16BE();
if (flags & 0x80) {
_scaleMode = S_INTERLACED;
@ -143,10 +148,10 @@ bool DXAPlayer::loadFile(const char *filename) {
}
void DXAPlayer::closeFile() {
if (!_fd.isOpen())
if (!_fd)
return;
_fd.close();
delete _fd;
free(_frameBuffer1);
free(_frameBuffer2);
free(_scaledBuffer);
@ -478,20 +483,20 @@ void DXAPlayer::decode13(byte *data, int size, int totalSize) {
void DXAPlayer::decodeNextFrame() {
uint32 tag;
tag = _fd.readUint32BE();
tag = _fd->readUint32BE();
if (tag == MKID_BE('CMAP')) {
byte rgb[768];
_fd.read(rgb, ARRAYSIZE(rgb));
_fd->read(rgb, ARRAYSIZE(rgb));
setPalette(rgb);
}
tag = _fd.readUint32BE();
tag = _fd->readUint32BE();
if (tag == MKID_BE('FRAM')) {
byte type = _fd.readByte();
uint32 size = _fd.readUint32BE();
byte type = _fd->readByte();
uint32 size = _fd->readUint32BE();
_fd.read(_frameBuffer2, size);
_fd->read(_frameBuffer2, size);
switch (type) {
case 2:

View File

@ -43,8 +43,6 @@ enum ScaleMode {
class DXAPlayer {
protected:
Common::File _fd;
byte *_frameBuffer1;
byte *_frameBuffer2;
byte *_scaledBuffer;
@ -63,6 +61,8 @@ public:
DXAPlayer();
virtual ~DXAPlayer();
Common::SeekableReadStream *_fd;
/**
* Returns the width of the video
* @return the width of the video