ACCESS: Implemented playVideo
This commit is contained in:
parent
819cad3a17
commit
e57d7e8782
8 changed files with 74 additions and 28 deletions
|
@ -71,7 +71,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
|
||||||
_scaleI = 0;
|
_scaleI = 0;
|
||||||
_scaleFlag = false;
|
_scaleFlag = false;
|
||||||
_eseg = nullptr;
|
_eseg = nullptr;
|
||||||
_plotBuffer = nullptr;
|
|
||||||
|
|
||||||
_conversation = 0;
|
_conversation = 0;
|
||||||
_currentMan = 0;
|
_currentMan = 0;
|
||||||
|
@ -130,7 +129,6 @@ AccessEngine::~AccessEngine() {
|
||||||
delete _music;
|
delete _music;
|
||||||
delete _title;
|
delete _title;
|
||||||
delete _eseg;
|
delete _eseg;
|
||||||
delete _plotBuffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccessEngine::setVGA() {
|
void AccessEngine::setVGA() {
|
||||||
|
|
|
@ -129,7 +129,6 @@ public:
|
||||||
ASurface *_current;
|
ASurface *_current;
|
||||||
ASurface _buffer1;
|
ASurface _buffer1;
|
||||||
ASurface _buffer2;
|
ASurface _buffer2;
|
||||||
byte *_plotBuffer;
|
|
||||||
Common::Array<CharEntry *> _charTable;
|
Common::Array<CharEntry *> _charTable;
|
||||||
SpriteResource *_objectsTable[100];
|
SpriteResource *_objectsTable[100];
|
||||||
bool _establishTable[100];
|
bool _establishTable[100];
|
||||||
|
|
|
@ -103,7 +103,7 @@ void Scripts::executeCommand(int commandIndex) {
|
||||||
&Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc,
|
&Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc,
|
||||||
&Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetTimer,
|
&Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetTimer,
|
||||||
&Scripts::cmdSetTimer, &Scripts::cmdCheckTimer, &Scripts::cmdSetTravel,
|
&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::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer,
|
||||||
&Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT,
|
&Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT,
|
||||||
&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast,
|
&Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast,
|
||||||
|
@ -112,7 +112,7 @@ void Scripts::executeCommand(int commandIndex) {
|
||||||
&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::CMDWAIT,
|
&Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::CMDWAIT,
|
||||||
&Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice,
|
&Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice,
|
||||||
&Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound,
|
&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::CMDPUSHLOCATION,
|
||||||
&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff,
|
&Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff,
|
||||||
&Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut,
|
&Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut,
|
||||||
|
@ -426,7 +426,9 @@ void Scripts::cmdSetVideo() {
|
||||||
_vm->_video->setVideo(_vm->_screen, pt, _vm->_extraCells[cellIndex]._vid, rate);
|
_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() {
|
void Scripts::cmdPlotImage() {
|
||||||
_vm->_destIn = _vm->_current;
|
_vm->_destIn = _vm->_current;
|
||||||
|
@ -667,11 +669,19 @@ void Scripts::cmdSetVideoSound() {
|
||||||
cmdSetVideo();
|
cmdSetVideo();
|
||||||
|
|
||||||
_data->skip(2);
|
_data->skip(2);
|
||||||
_vm->_sound->_soundFrame = _data->readUint16LE();
|
_vm->_video->_soundFrame = _data->readUint16LE();
|
||||||
_vm->_sound->_soundFlag = false;
|
_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::CMDPUSHLOCATION() { error("TODO CMDPUSHLOCATION"); }
|
||||||
|
|
||||||
void Scripts::cmdPlayerOff() {
|
void Scripts::cmdPlayerOff() {
|
||||||
|
|
|
@ -91,7 +91,7 @@ protected:
|
||||||
void cmdCheckTimer();
|
void cmdCheckTimer();
|
||||||
void cmdSetTravel();
|
void cmdSetTravel();
|
||||||
void cmdSetVideo();
|
void cmdSetVideo();
|
||||||
void CMDPLAYVID();
|
void cmdPlayVideo();
|
||||||
void cmdPlotImage();
|
void cmdPlotImage();
|
||||||
void cmdSetDisplay();
|
void cmdSetDisplay();
|
||||||
void cmdSetBuffer();
|
void cmdSetBuffer();
|
||||||
|
@ -114,7 +114,7 @@ protected:
|
||||||
void cmdClearBlock();
|
void cmdClearBlock();
|
||||||
void cmdLoadSound();
|
void cmdLoadSound();
|
||||||
void cmdSetVideoSound();
|
void cmdSetVideoSound();
|
||||||
void CMDPLAYVIDSND();
|
void cmdPlayVideoSound();
|
||||||
void CMDPUSHLOCATION();
|
void CMDPUSHLOCATION();
|
||||||
void cmdPlayerOff();
|
void cmdPlayerOff();
|
||||||
void cmdPlayerOn();
|
void cmdPlayerOn();
|
||||||
|
|
|
@ -35,8 +35,6 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) :
|
||||||
|
|
||||||
_music = nullptr;
|
_music = nullptr;
|
||||||
_musicRepeat = false;
|
_musicRepeat = false;
|
||||||
_soundFrame = 0;
|
|
||||||
_soundFlag = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundManager::~SoundManager() {
|
SoundManager::~SoundManager() {
|
||||||
|
|
|
@ -45,8 +45,6 @@ public:
|
||||||
int _soundPriority[MAX_SOUNDS];
|
int _soundPriority[MAX_SOUNDS];
|
||||||
Resource *_music;
|
Resource *_music;
|
||||||
bool _musicRepeat;
|
bool _musicRepeat;
|
||||||
int _soundFrame;
|
|
||||||
bool _soundFlag;
|
|
||||||
public:
|
public:
|
||||||
SoundManager(AccessEngine *vm, Audio::Mixer *mixer);
|
SoundManager(AccessEngine *vm, Audio::Mixer *mixer);
|
||||||
~SoundManager();
|
~SoundManager();
|
||||||
|
|
|
@ -27,10 +27,13 @@ namespace Access {
|
||||||
|
|
||||||
VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) {
|
VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) {
|
||||||
_vidSurface = nullptr;
|
_vidSurface = nullptr;
|
||||||
|
_videoFrame = 0;
|
||||||
|
_soundFlag = false;
|
||||||
|
_soundFrame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoPlayer::~VideoPlayer() {
|
VideoPlayer::~VideoPlayer() {
|
||||||
freeVideo();
|
closeVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,37 +58,33 @@ void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, FileId
|
||||||
_frameCount = _header._frameCount - 2;
|
_frameCount = _header._frameCount - 2;
|
||||||
_xCount = _header._width;
|
_xCount = _header._width;
|
||||||
_scanCount = _header._height;
|
_scanCount = _header._height;
|
||||||
_vidFrame = 0;
|
_videoFrame = 0;
|
||||||
|
|
||||||
getFrame();
|
getFrame();
|
||||||
|
|
||||||
if (_header._flags == VIDEOFLAG_BG) {
|
if (_header._flags == VIDEOFLAG_BG) {
|
||||||
// Draw the background
|
// Draw the background
|
||||||
const byte *pSrc = _vm->_plotBuffer;
|
|
||||||
for (int y = 0; y < _scanCount; ++y) {
|
for (int y = 0; y < _scanCount; ++y) {
|
||||||
byte *pDest = (byte *)vidSurface->getBasePtr(pt.x, pt.y + y);
|
byte *pDest = (byte *)vidSurface->getBasePtr(pt.x, pt.y + y);
|
||||||
Common::copy(pSrc, pSrc + _xCount, pDest);
|
_videoData->_stream->read(pDest, _xCount);
|
||||||
pSrc += _xCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vidSurface == _vm->_screen)
|
if (vidSurface == _vm->_screen)
|
||||||
_vm->_newRects.push_back(Common::Rect(pt.x, pt.y, pt.x + _xCount, pt.y + _scanCount));
|
_vm->_newRects.push_back(Common::Rect(pt.x, pt.y, pt.x + _xCount, pt.y + _scanCount));
|
||||||
|
|
||||||
|
|
||||||
getFrame();
|
getFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
_videoEnd = false;
|
_videoEnd = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoPlayer::freeVideo() {
|
void VideoPlayer::closeVideo() {
|
||||||
delete _videoData;
|
delete _videoData;
|
||||||
_videoData = nullptr;
|
_videoData = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoPlayer::getFrame() {
|
void VideoPlayer::getFrame() {
|
||||||
_frameSize = _videoData->_stream->readUint16LE();
|
_frameSize = _videoData->_stream->readUint16LE();
|
||||||
_videoData->_stream->read(_vm->_plotBuffer, _frameSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoPlayer::playVideo() {
|
void VideoPlayer::playVideo() {
|
||||||
|
@ -93,7 +92,39 @@ void VideoPlayer::playVideo() {
|
||||||
return;
|
return;
|
||||||
++_vm->_timers[31]._flag;
|
++_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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,20 +47,32 @@ private:
|
||||||
int _frameCount;
|
int _frameCount;
|
||||||
int _xCount;
|
int _xCount;
|
||||||
int _scanCount;
|
int _scanCount;
|
||||||
int _vidFrame;
|
|
||||||
int _frameSize;
|
int _frameSize;
|
||||||
bool _videoEnd;
|
bool _videoEnd;
|
||||||
|
|
||||||
void getFrame();
|
void getFrame();
|
||||||
|
public:
|
||||||
void playVideo();
|
int _videoFrame;
|
||||||
|
bool _soundFlag;
|
||||||
|
int _soundFrame;
|
||||||
public:
|
public:
|
||||||
VideoPlayer(AccessEngine *vm);
|
VideoPlayer(AccessEngine *vm);
|
||||||
~VideoPlayer();
|
~VideoPlayer();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start up a video
|
||||||
|
*/
|
||||||
void setVideo(ASurface *vidSurface, const Common::Point &pt, FileIdent &videoFile, int rate);
|
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
|
} // End of namespace Access
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue