aboutsummaryrefslogtreecommitdiff
path: root/engines/gob
diff options
context:
space:
mode:
authorSven Hesse2009-06-06 19:06:47 +0000
committerSven Hesse2009-06-06 19:06:47 +0000
commit2901694486712f6012152f7192afa10d08ffc561 (patch)
tree5691199e79c2f55d7352c34a07133e4189920529 /engines/gob
parent6c44c7764c3776e6189cd1dfb519709c4864d7fa (diff)
downloadscummvm-rg350-2901694486712f6012152f7192afa10d08ffc561.tar.gz
scummvm-rg350-2901694486712f6012152f7192afa10d08ffc561.tar.bz2
scummvm-rg350-2901694486712f6012152f7192afa10d08ffc561.zip
Demoplayer:
- Fixing the flawed double mode - Adding an "auto" double mode, where the videos get scaled if possible svn-id: r41294
Diffstat (limited to 'engines/gob')
-rw-r--r--engines/gob/demos/demoplayer.cpp45
-rw-r--r--engines/gob/demos/demoplayer.h1
-rw-r--r--engines/gob/util.cpp11
-rw-r--r--engines/gob/util.h1
-rw-r--r--engines/gob/videoplayer.cpp66
-rw-r--r--engines/gob/videoplayer.h10
6 files changed, 109 insertions, 25 deletions
diff --git a/engines/gob/demos/demoplayer.cpp b/engines/gob/demos/demoplayer.cpp
index 08bd93753c..c1fde0b637 100644
--- a/engines/gob/demos/demoplayer.cpp
+++ b/engines/gob/demos/demoplayer.cpp
@@ -153,6 +153,13 @@ void DemoPlayer::playVideo(const char *fileName) {
bool videoSupportsDouble =
((_vm->_vidPlayer->getFeatures() & Graphics::CoktelVideo::kFeaturesSupportsDouble) != 0);
+ if (_autoDouble) {
+ int16 width = _vm->_vidPlayer->getWidth();
+ int16 height = _vm->_vidPlayer->getHeight();
+
+ _doubleMode = ((width <= 320) && (height <= 200));
+ }
+
if (_doubleMode) {
if (videoSupportsDouble) {
_vm->_vidPlayer->slotSetDoubleMode(-1, true);
@@ -177,13 +184,14 @@ void DemoPlayer::playVideoNormal() {
}
void DemoPlayer::playVideoDoubled() {
- const char *fileNameOpened = _vm->_vidPlayer->getFileName();
+ Common::String fileNameOpened = _vm->_vidPlayer->getFileName();
_vm->_vidPlayer->primaryClose();
- if (_vm->_vidPlayer->primaryOpen(fileNameOpened, 0, -1, VideoPlayer::kFlagOtherSurface)) {
+ if (_vm->_vidPlayer->primaryOpen(fileNameOpened.c_str(), 0, -1,
+ VideoPlayer::kFlagScreenSurface)) {
+
for (int i = 0; i < _vm->_vidPlayer->getFramesCount(); i++) {
- if (_vm->_vidPlayer->primaryPlay(i, i))
- break;
+ _vm->_vidPlayer->playFrame(i);
Graphics::CoktelVideo::State state = _vm->_vidPlayer->getState();
@@ -197,6 +205,21 @@ void DemoPlayer::playVideoDoubled() {
_vm->_draw->dirtiedRect(_vm->_draw->_frontSurface,
state.left * 2, state.top * 2, wD, hD);
_vm->_video->retrace();
+
+ _vm->_util->processInput();
+ if (_vm->shouldQuit())
+ break;
+
+ int16 key;
+ bool end = false;
+ while (_vm->_util->checkKey(key))
+ if (key == 0x011B)
+ end = true;
+ if (end)
+ break;
+
+ _vm->_vidPlayer->slotWaitEndFrame();
+
}
}
}
@@ -204,10 +227,16 @@ void DemoPlayer::playVideoDoubled() {
void DemoPlayer::evaluateVideoMode(const char *mode) {
debugC(2, kDebugDemo, "Video mode \"%s\"", mode);
- if (!scumm_strnicmp(mode, "VESA", 4))
- _doubleMode = false;
- else if (!scumm_strnicmp(mode, "VGA", 3) && _vm->is640())
- _doubleMode = true;
+ _autoDouble = false;
+ _doubleMode = false;
+
+ // Only applicable when we actually can double
+ if (_vm->is640()) {
+ if (!scumm_strnicmp(mode, "AUTO", 4))
+ _autoDouble = true;
+ else if (!scumm_strnicmp(mode, "VGA", 3) && _vm->is640())
+ _doubleMode = true;
+ }
}
} // End of namespace Gob
diff --git a/engines/gob/demos/demoplayer.h b/engines/gob/demos/demoplayer.h
index 52c089c8f1..9d475512fb 100644
--- a/engines/gob/demos/demoplayer.h
+++ b/engines/gob/demos/demoplayer.h
@@ -45,6 +45,7 @@ public:
protected:
GobEngine *_vm;
bool _doubleMode;
+ bool _autoDouble;
virtual bool playStream(Common::SeekableReadStream &stream) = 0;
diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp
index d89368b898..e1148dacb9 100644
--- a/engines/gob/util.cpp
+++ b/engines/gob/util.cpp
@@ -235,6 +235,17 @@ int16 Util::checkKey(void) {
return translateKey(key);
}
+bool Util::checkKey(int16 &key) {
+ Common::KeyState keyS;
+
+ if (!getKeyFromBuffer(keyS))
+ return false;
+
+ key = translateKey(keyS);
+
+ return true;
+}
+
void Util::getMouseState(int16 *pX, int16 *pY, int16 *pButtons) {
Common::Point mouse = g_system->getEventManager()->getMousePos();
*pX = mouse.x + _vm->_video->_scrollOffsetX - _vm->_video->_screenDeltaX;
diff --git a/engines/gob/util.h b/engines/gob/util.h
index 19b11801bc..3d7520fe69 100644
--- a/engines/gob/util.h
+++ b/engines/gob/util.h
@@ -64,6 +64,7 @@ public:
void clearKeyBuf(void);
int16 getKey(void);
int16 checkKey(void);
+ bool checkKey(int16 &key);
void getMouseState(int16 *pX, int16 *pY, int16 *pButtons);
void setMousePos(int16 x, int16 y);
diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp
index 88a6cb1a8e..21cec36231 100644
--- a/engines/gob/videoplayer.cpp
+++ b/engines/gob/videoplayer.cpp
@@ -150,8 +150,10 @@ Graphics::CoktelVideo::State VideoPlayer::Video::nextFrame() {
return _state;
}
+
VideoPlayer::VideoPlayer(GobEngine *vm) : _vm(vm) {
_primaryVideo = new Video(vm);
+ _ownSurf = false;
_backSurf = false;
_needBlit = false;
_noCursorSwitch = false;
@@ -251,10 +253,13 @@ bool VideoPlayer::primaryOpen(const char *videoFile, int16 x, int16 y,
_noCursorSwitch = true;
}
+ _ownSurf = false;
+
if (!(flags & kFlagNoVideo)) {
SurfaceDesc::Ptr surf;
if (flags & kFlagOtherSurface) {
+ _ownSurf = true;
_backSurf = false;
surf = _vm->_video->initSurfDesc(_vm->_global->_videoMode,
@@ -263,6 +268,14 @@ bool VideoPlayer::primaryOpen(const char *videoFile, int16 x, int16 y,
_vm->_draw->_spritesArray[x] = surf;
x = 0;
+ } else if (flags & kFlagScreenSurface) {
+ _ownSurf = true;
+ _backSurf = false;
+
+ surf = _vm->_video->initSurfDesc(_vm->_global->_videoMode,
+ _vm->_width, _vm->_height, 0);
+ _vm->_draw->_spritesArray[x] = surf;
+ x = 0;
} else {
_backSurf = ((flags & kFlagFrontSurface) == 0);
surf = _vm->_draw->_spritesArray[_backSurf ? 21 : 20];
@@ -459,13 +472,14 @@ void VideoPlayer::slotCopyPalette(int slot, int16 palStart, int16 palEnd) {
}
void VideoPlayer::slotWaitEndFrame(int slot, bool onlySound) {
- if ((slot < 0) || (((uint) slot) >= _videoSlots.size()) || !_videoSlots[slot])
- return;
+ Video *video = getVideoBySlot(slot);
- Graphics::CoktelVideo &video = *(_videoSlots[slot]->getVideo());
+ if (video) {
+ Graphics::CoktelVideo &cVideo = *video->getVideo();
- if (!onlySound || (video.getFeatures() & Graphics::CoktelVideo::kFeaturesSound))
- video.waitEndFrame();
+ if (!onlySound || (cVideo.getFeatures() & Graphics::CoktelVideo::kFeaturesSound))
+ cVideo.waitEndFrame();
+ }
}
bool VideoPlayer::slotIsOpen(int slot) const {
@@ -611,10 +625,24 @@ Common::MemoryReadStream *VideoPlayer::getExtraData(const char *fileName, int sl
return 0;
}
-bool VideoPlayer::doPlay(int16 frame, int16 breakKey,
+void VideoPlayer::playFrame(int16 frame, int16 breakKey,
uint16 palCmd, int16 palStart, int16 palEnd,
int16 palFrame, int16 endFrame) {
+ if (!_primaryVideo)
+ return;
+
+ Video &video = *_primaryVideo;
+ Graphics::CoktelVideo &cVideo = *video.getVideo();
+
+ if (cVideo.getCurrentFrame() != frame)
+ cVideo.seekFrame(frame);
+ if (palFrame < 0)
+ palFrame = 0;
+ if (endFrame < 0)
+ endFrame = cVideo.getFramesCount() - 1;
+
+
bool modifiedPal = false;
if ((frame == palFrame) || ((frame == endFrame) && (palCmd == 8))) {
@@ -622,7 +650,7 @@ bool VideoPlayer::doPlay(int16 frame, int16 breakKey,
_vm->_draw->_applyPal = true;
if (palCmd >= 4)
- copyPalette(*(_primaryVideo->getVideo()), palStart, palEnd);
+ copyPalette(cVideo, palStart, palEnd);
}
if (modifiedPal && (palCmd == 8) && !_backSurf)
@@ -632,7 +660,7 @@ bool VideoPlayer::doPlay(int16 frame, int16 breakKey,
if (_needBlit)
_vm->_draw->forceBlit();
- Graphics::CoktelVideo::State state = _primaryVideo->nextFrame();
+ Graphics::CoktelVideo::State state = video.nextFrame();
WRITE_VAR(11, frame);
if (_needBlit)
@@ -648,7 +676,7 @@ bool VideoPlayer::doPlay(int16 frame, int16 breakKey,
}
if ((state.flags & Graphics::CoktelVideo::kStatePalette) && (palCmd > 1)) {
- copyPalette(*(_primaryVideo->getVideo()), palStart, palEnd);
+ copyPalette(cVideo, palStart, palEnd);
if (!_backSurf)
_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
@@ -660,17 +688,25 @@ bool VideoPlayer::doPlay(int16 frame, int16 breakKey,
_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
- if (_backSurf) {
- _vm->_draw->invalidateRect(state.left, state.top, state.right, state.bottom);
- _vm->_draw->blitInvalidated();
- } else
- _vm->_video->dirtyRectsAdd(state.left, state.top, state.right, state.bottom);
- _vm->_video->retrace();
+ if (!_ownSurf) {
+ if (_backSurf) {
+ _vm->_draw->invalidateRect(state.left, state.top, state.right, state.bottom);
+ _vm->_draw->blitInvalidated();
+ } else
+ _vm->_video->dirtyRectsAdd(state.left, state.top, state.right, state.bottom);
+ _vm->_video->retrace();
+ }
if (modifiedPal && ((palCmd == 2) || (palCmd == 4)))
_vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0);
+}
+
+bool VideoPlayer::doPlay(int16 frame, int16 breakKey,
+ uint16 palCmd, int16 palStart, int16 palEnd,
+ int16 palFrame, int16 endFrame) {
+ playFrame(frame, breakKey, palCmd, palStart, palEnd, palFrame, endFrame);
_vm->_util->processInput();
diff --git a/engines/gob/videoplayer.h b/engines/gob/videoplayer.h
index eaa0418b68..086173dd66 100644
--- a/engines/gob/videoplayer.h
+++ b/engines/gob/videoplayer.h
@@ -44,7 +44,8 @@ public:
kFlagUseBackSurfaceContent = 0x40,
kFlagFrontSurface = 0x80,
kFlagNoVideo = 0x100,
- kFlagOtherSurface = 0x800
+ kFlagOtherSurface = 0x800,
+ kFlagScreenSurface = 0x1000
};
enum Type {
@@ -65,6 +66,10 @@ public:
int16 reverseTo = -1, bool forceSeek = false);
void primaryClose();
+ void playFrame(int16 frame, int16 breakKey = 27,
+ uint16 palCmd = 8, int16 palStart = 0, int16 palEnd = 255,
+ int16 palFrame = -1 , int16 endFrame = -1);
+
int slotOpen(const char *videoFile, Type which = kVideoTypeTry);
void slotPlay(int slot, int16 frame = -1);
void slotClose(int slot);
@@ -72,7 +77,7 @@ public:
uint16 left, uint16 top, uint16 width, uint16 height,
uint16 x, uint16 y, uint16 pitch, int16 transp = -1);
void slotCopyPalette(int slot, int16 palStart = -1, int16 palEnd = -1);
- void slotWaitEndFrame(int slot, bool onlySound = false);
+ void slotWaitEndFrame(int slot = -1, bool onlySound = false);
void slotSetDoubleMode(int slot, bool doubleMode);
@@ -140,6 +145,7 @@ private:
Common::Array<Video *> _videoSlots;
Video *_primaryVideo;
+ bool _ownSurf;
bool _backSurf;
bool _needBlit;
bool _noCursorSwitch;