From 87fcd3c93d40b76ca75a8cf24a4197b39d3f2278 Mon Sep 17 00:00:00 2001 From: Kaloyan Chehlarski Date: Sat, 25 Mar 2023 19:08:20 +0200 Subject: [PATCH] NANCY: Add support for small format secondary video Secondary videos with a small video format now get displayed properly. Added constants for small and large video formats. --- engines/nancy/action/primaryvideo.cpp | 2 +- engines/nancy/action/primaryvideo.h | 2 +- engines/nancy/action/secondaryvideo.cpp | 7 +++++-- engines/nancy/action/secondaryvideo.h | 1 + engines/nancy/commontypes.h | 10 +++++++--- engines/nancy/state/scene.cpp | 8 ++++---- engines/nancy/ui/viewport.cpp | 2 +- engines/nancy/ui/viewport.h | 2 +- 8 files changed, 21 insertions(+), 13 deletions(-) diff --git a/engines/nancy/action/primaryvideo.cpp b/engines/nancy/action/primaryvideo.cpp index b11c5422f00..4aab0e3c96f 100644 --- a/engines/nancy/action/primaryvideo.cpp +++ b/engines/nancy/action/primaryvideo.cpp @@ -153,7 +153,7 @@ void PlayPrimaryVideoChan0::updateGraphics() { } if (_decoder.needsUpdate()) { - GraphicsManager::copyToManaged(*_decoder.decodeNextFrame(), _drawSurface, _videoFormat == 1); + GraphicsManager::copyToManaged(*_decoder.decodeNextFrame(), _drawSurface, _videoFormat == kSmallVideoFormat); _needsRedraw = true; } diff --git a/engines/nancy/action/primaryvideo.h b/engines/nancy/action/primaryvideo.h index 2e7d7054c1e..80839f99606 100644 --- a/engines/nancy/action/primaryvideo.h +++ b/engines/nancy/action/primaryvideo.h @@ -96,7 +96,7 @@ public: Common::String _videoName; Common::String _paletteName; - uint _videoFormat = 2; + uint _videoFormat = kLargeVideoFormat; Common::String _text; SoundDescription _sound; diff --git a/engines/nancy/action/secondaryvideo.cpp b/engines/nancy/action/secondaryvideo.cpp index b0daf1a7b2d..5d788259a8a 100644 --- a/engines/nancy/action/secondaryvideo.cpp +++ b/engines/nancy/action/secondaryvideo.cpp @@ -103,7 +103,7 @@ void PlaySecondaryVideo::updateGraphics() { if (_decoder.isPlaying()) { if (_decoder.needsUpdate()) { - GraphicsManager::copyToManaged(*_decoder.decodeNextFrame(), _fullFrame, _paletteFilename.size() > 0); + GraphicsManager::copyToManaged(*_decoder.decodeNextFrame(), _fullFrame, _paletteFilename.size(), _videoFormat == kSmallVideoFormat); _needsRedraw = true; } @@ -165,7 +165,10 @@ void PlaySecondaryVideo::readData(Common::SeekableReadStream &stream) { readFilename(stream, _paletteFilename); ser.skip(10); // video overlay bitmap filename - ser.skip(12, kGameTypeVampire, kGameTypeVampire); + ser.skip(2, kGameTypeVampire, kGameTypeVampire); + ser.syncAsUint16LE(_videoFormat, kGameTypeVampire, kGameTypeVampire); + ser.skip(8, kGameTypeVampire, kGameTypeVampire); + ser.syncAsUint16LE(_videoHotspots, kGameTypeVampire, kGameTypeVampire); ser.syncAsUint16LE(_loopFirstFrame); diff --git a/engines/nancy/action/secondaryvideo.h b/engines/nancy/action/secondaryvideo.h index 9054f8684bf..7bf8279c463 100644 --- a/engines/nancy/action/secondaryvideo.h +++ b/engines/nancy/action/secondaryvideo.h @@ -55,6 +55,7 @@ public: // Common::String _bitmapOverlayFilename // TVD only + uint16 _videoFormat = kLargeVideoFormat; uint16 _videoHotspots = kVideoHotspots; uint16 _loopFirstFrame = 0; // 0x1E diff --git a/engines/nancy/commontypes.h b/engines/nancy/commontypes.h index 9c181137b26..3b72b9dafd4 100644 --- a/engines/nancy/commontypes.h +++ b/engines/nancy/commontypes.h @@ -76,9 +76,13 @@ static const byte kAbsoluteClockBump = 1; static const byte kRelativeClockBump = 2; // Time of day -static const byte kPlayerDay = 0; -static const byte kPlayerNight = 1; -static const byte kPlayerDuskDawn = 2; +static const byte kPlayerDay = 0; +static const byte kPlayerNight = 1; +static const byte kPlayerDuskDawn = 2; + +// Video +static const byte kSmallVideoFormat = 1; +static const byte kLargeVideoFormat = 2; enum MovementDirection : byte { kUp = 1, kDown = 2, kLeft = 4, kRight = 8, kMoveFast = 16 }; diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp index 75a484dee5b..a60f3aa8df1 100644 --- a/engines/nancy/state/scene.cpp +++ b/engines/nancy/state/scene.cpp @@ -595,18 +595,18 @@ void Scene::load() { _viewport.disableEdges(kLeft | kRight); } - if (_sceneState.summary.videoFormat == 1) { + if (_sceneState.summary.videoFormat == kSmallVideoFormat) { // TODO - } else if (_sceneState.summary.videoFormat == 2) { + } else if (_sceneState.summary.videoFormat == kLargeVideoFormat) { // always start from the bottom _sceneState.currentScene.verticalOffset = _viewport.getMaxScroll(); } else { error("Unrecognized Scene summary chunk video file format"); } - if (_sceneState.summary.videoFormat == 1) { + if (_sceneState.summary.videoFormat == kSmallVideoFormat) { // TODO - } else if (_sceneState.summary.videoFormat == 2) { + } else if (_sceneState.summary.videoFormat == kLargeVideoFormat) { if (_viewport.getMaxScroll() == 0) { _viewport.disableEdges(kUp | kDown); } diff --git a/engines/nancy/ui/viewport.cpp b/engines/nancy/ui/viewport.cpp index 5742a27de17..8256d1acac1 100644 --- a/engines/nancy/ui/viewport.cpp +++ b/engines/nancy/ui/viewport.cpp @@ -213,7 +213,7 @@ void Viewport::setFrame(uint frameNr) { // Format 1 uses quarter-size images, while format 2 uses full-size ones // Videos in TVD are always upside-down - GraphicsManager::copyToManaged(*newFrame, _fullFrame, g_nancy->getGameType() == kGameTypeVampire, _videoFormat == 1); + GraphicsManager::copyToManaged(*newFrame, _fullFrame, g_nancy->getGameType() == kGameTypeVampire, _videoFormat == kSmallVideoFormat); _needsRedraw = true; _currentFrame = frameNr; diff --git a/engines/nancy/ui/viewport.h b/engines/nancy/ui/viewport.h index feabc7ad882..137050c1646 100644 --- a/engines/nancy/ui/viewport.h +++ b/engines/nancy/ui/viewport.h @@ -49,7 +49,7 @@ public: _movementLastFrame(0), _edgesMask(0), _currentFrame(0), - _videoFormat(0), + _videoFormat(kLargeVideoFormat), _stickyCursorPos(-1, -1), _panningType(kPanNone) {}