ACCESS: Implemented playVideo

This commit is contained in:
Paul Gilbert 2014-08-28 20:02:35 -04:00
parent 819cad3a17
commit e57d7e8782
8 changed files with 74 additions and 28 deletions

View File

@ -71,7 +71,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_scaleI = 0;
_scaleFlag = false;
_eseg = nullptr;
_plotBuffer = nullptr;
_conversation = 0;
_currentMan = 0;
@ -130,7 +129,6 @@ AccessEngine::~AccessEngine() {
delete _music;
delete _title;
delete _eseg;
delete _plotBuffer;
}
void AccessEngine::setVGA() {

View File

@ -129,7 +129,6 @@ public:
ASurface *_current;
ASurface _buffer1;
ASurface _buffer2;
byte *_plotBuffer;
Common::Array<CharEntry *> _charTable;
SpriteResource *_objectsTable[100];
bool _establishTable[100];

View File

@ -103,7 +103,7 @@ void Scripts::executeCommand(int commandIndex) {
&Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc,
&Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetTimer,
&Scripts::cmdSetTimer, &Scripts::cmdCheckTimer, &Scripts::cmdSetTravel,
&Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::CMDPLAYVID,
&Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo,
&Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer,
&Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT,
&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast,
@ -112,7 +112,7 @@ void Scripts::executeCommand(int commandIndex) {
&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::CMDWAIT,
&Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice,
&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound,
&Scripts::CMDFREESOUND, &Scripts::cmdSetVideoSound, &Scripts::CMDPLAYVIDSND,
&Scripts::CMDFREESOUND, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound,
&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION,
&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff,
&Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut,
@ -426,7 +426,9 @@ void Scripts::cmdSetVideo() {
_vm->_video->setVideo(_vm->_screen, pt, _vm->_extraCells[cellIndex]._vid, rate);
}
void Scripts::CMDPLAYVID() { error("TODO CMDPLAYVID"); }
void Scripts::cmdPlayVideo() {
_vm->_video->playVideo();
}
void Scripts::cmdPlotImage() {
_vm->_destIn = _vm->_current;
@ -667,11 +669,19 @@ void Scripts::cmdSetVideoSound() {
cmdSetVideo();
_data->skip(2);
_vm->_sound->_soundFrame = _data->readUint16LE();
_vm->_sound->_soundFlag = false;
_vm->_video->_soundFrame = _data->readUint16LE();
_vm->_video->_soundFlag = false;
}
void Scripts::cmdPlayVideoSound() {
_vm->_video->playVideo();
if (_vm->_video->_soundFrame == _vm->_video->_videoFrame &&
!_vm->_video->_soundFlag) {
_vm->_sound->playSound(0);
_vm->_video->_soundFlag = true;
}
}
void Scripts::CMDPLAYVIDSND() { error("TODO CMDPLAYVIDSND"); }
void Scripts::CMDPUSHLOCATION() { error("TODO CMDPUSHLOCATION"); }
void Scripts::cmdPlayerOff() {

View File

@ -91,7 +91,7 @@ protected:
void cmdCheckTimer();
void cmdSetTravel();
void cmdSetVideo();
void CMDPLAYVID();
void cmdPlayVideo();
void cmdPlotImage();
void cmdSetDisplay();
void cmdSetBuffer();
@ -114,7 +114,7 @@ protected:
void cmdClearBlock();
void cmdLoadSound();
void cmdSetVideoSound();
void CMDPLAYVIDSND();
void cmdPlayVideoSound();
void CMDPUSHLOCATION();
void cmdPlayerOff();
void cmdPlayerOn();

View File

@ -35,8 +35,6 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) :
_music = nullptr;
_musicRepeat = false;
_soundFrame = 0;
_soundFlag = false;
}
SoundManager::~SoundManager() {

View File

@ -45,8 +45,6 @@ public:
int _soundPriority[MAX_SOUNDS];
Resource *_music;
bool _musicRepeat;
int _soundFrame;
bool _soundFlag;
public:
SoundManager(AccessEngine *vm, Audio::Mixer *mixer);
~SoundManager();

View File

@ -27,10 +27,13 @@ namespace Access {
VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) {
_vidSurface = nullptr;
_videoFrame = 0;
_soundFlag = false;
_soundFrame = 0;
}
VideoPlayer::~VideoPlayer() {
freeVideo();
closeVideo();
}
@ -55,37 +58,33 @@ void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, FileId
_frameCount = _header._frameCount - 2;
_xCount = _header._width;
_scanCount = _header._height;
_vidFrame = 0;
_videoFrame = 0;
getFrame();
if (_header._flags == VIDEOFLAG_BG) {
// Draw the background
const byte *pSrc = _vm->_plotBuffer;
for (int y = 0; y < _scanCount; ++y) {
byte *pDest = (byte *)vidSurface->getBasePtr(pt.x, pt.y + y);
Common::copy(pSrc, pSrc + _xCount, pDest);
pSrc += _xCount;
_videoData->_stream->read(pDest, _xCount);
}
if (vidSurface == _vm->_screen)
_vm->_newRects.push_back(Common::Rect(pt.x, pt.y, pt.x + _xCount, pt.y + _scanCount));
getFrame();
}
_videoEnd = false;
}
void VideoPlayer::freeVideo() {
void VideoPlayer::closeVideo() {
delete _videoData;
_videoData = nullptr;
}
void VideoPlayer::getFrame() {
_frameSize = _videoData->_stream->readUint16LE();
_videoData->_stream->read(_vm->_plotBuffer, _frameSize);
}
void VideoPlayer::playVideo() {
@ -93,7 +92,39 @@ void VideoPlayer::playVideo() {
return;
++_vm->_timers[31]._flag;
byte *pDest = _startCoord;
byte *pLine = _startCoord;
uint32 frameEnd = _videoData->_stream->pos() + _frameSize;
while ((uint32)_videoData->_stream->pos() < frameEnd) {
int count = _videoData->_stream->readByte();
if (count & 0x80) {
count &= 0x7f;
// Skip count number of pixels
// Loop across lines if necessary
while ((pDest - pLine + count) >= _xCount) {
pLine += _vidSurface->pitch;
pDest = pLine;
count -= _xCount;
}
// Skip any remaining pixels in the new line
pDest += count;
} else {
// Readcount number of pixels
assert(count <= (pDest - pLine));
_videoData->_stream->read(pDest, count);
pDest += count;
}
}
getFrame();
if (++_videoFrame == _frameCount) {
closeVideo();
_videoEnd = true;
}
}

View File

@ -47,20 +47,32 @@ private:
int _frameCount;
int _xCount;
int _scanCount;
int _vidFrame;
int _frameSize;
bool _videoEnd;
void getFrame();
void playVideo();
public:
int _videoFrame;
bool _soundFlag;
int _soundFrame;
public:
VideoPlayer(AccessEngine *vm);
~VideoPlayer();
/**
* Start up a video
*/
void setVideo(ASurface *vidSurface, const Common::Point &pt, FileIdent &videoFile, int rate);
void freeVideo();
/**
* Decodes a frame of the video
*/
void playVideo();
/**
* Frees the data for a previously loaded video
*/
void closeVideo();
};
} // End of namespace Access