[Scummvm-git-logs] scummvm master -> 993f708dd013c982562065662a98fab4f4befe81
fracturehill
76959842+fracturehill at users.noreply.github.com
Sat Apr 24 21:06:51 UTC 2021
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
75d9fa1abd NANCY: Accurate viewport edge sizes
90c4f0c4dc NANCY: Move hardcoded data
8b8d3b38de NANCY: Fix curtains in The Vampire Diaries
c86d46fcde NANCY: Fix The Vampire Diaries's cursors
993f708dd0 NANCY: Don't adjust rects in The Vampire Diaries
Commit: 75d9fa1abdeeed3374a9dc2eeb54efa551a1586b
https://github.com/scummvm/scummvm/commit/75d9fa1abdeeed3374a9dc2eeb54efa551a1586b
Author: fracturehill (strahy at outlook.com)
Date: 2021-04-24T23:59:03+03:00
Commit Message:
NANCY: Accurate viewport edge sizes
The sizes of the hotspots at the edges of the viewport are now
consistent with the original engine.
Changed paths:
engines/nancy/nancy.cpp
engines/nancy/nancy.h
engines/nancy/state/map.cpp
engines/nancy/state/scene.cpp
engines/nancy/ui/viewport.cpp
engines/nancy/ui/viewport.h
diff --git a/engines/nancy/nancy.cpp b/engines/nancy/nancy.cpp
index acebb13e6a..5d7a58ab26 100644
--- a/engines/nancy/nancy.cpp
+++ b/engines/nancy/nancy.cpp
@@ -70,6 +70,8 @@ NancyEngine::NancyEngine(OSystem *syst, const NancyGameDescription *gd) : Engine
_startTimeHours = 0;
_overrideMovementTimeDeltas = false;
_cheatTypeIsEventFlag = false;
+ _horizontalEdgesSize = 0;
+ _verticalEdgesSize = 0;
}
NancyEngine::~NancyEngine() {
@@ -460,7 +462,10 @@ void NancyEngine::readBootSummary(const IFF &boot) {
readChunkList(boot, ser, "OB");
}
- ser.skip(0x99, kGameTypeNancy1, kGameTypeNancy1);
+ ser.skip(0x79, kGameTypeNancy1, kGameTypeNancy1);
+ ser.syncAsUint16LE(_horizontalEdgesSize, kGameTypeNancy1, kGameTypeNancy1);
+ ser.syncAsUint16LE(_verticalEdgesSize, kGameTypeNancy1, kGameTypeNancy1);
+ ser.skip(0x1C, kGameTypeNancy1, kGameTypeNancy1);
int16 time = 0;
ser.syncAsSint16LE(time, kGameTypeNancy1, kGameTypeNancy1);
_playerTimeMinuteLength = time;
diff --git a/engines/nancy/nancy.h b/engines/nancy/nancy.h
index d602a02bcf..892f783aef 100644
--- a/engines/nancy/nancy.h
+++ b/engines/nancy/nancy.h
@@ -127,6 +127,9 @@ public:
Time _fastMovementTimeDelta;
Time _playerTimeMinuteLength;
+ uint _horizontalEdgesSize;
+ uint _verticalEdgesSize;
+
private:
struct GameFlow {
NancyState::NancyState curState = NancyState::kNone;
diff --git a/engines/nancy/state/map.cpp b/engines/nancy/state/map.cpp
index 9cfcd125a0..6cdf903860 100644
--- a/engines/nancy/state/map.cpp
+++ b/engines/nancy/state/map.cpp
@@ -105,7 +105,7 @@ void Map::init() {
readFilename(*chunk, videoName);
_viewport.loadVideo(videoName, 0, 0);
- _viewport.setEdgesSize(0, 0, 0, 0);
+ _viewport.disableEdges(kLeft | kRight | kUp | kDown);
// Load the audio
chunk->seek(0x18 + _mapID * 0x20, SEEK_SET);
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index 7b2cbf0b21..d00c47c4bf 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -494,9 +494,6 @@ void Scene::load() {
_sceneState.summary.videoFormat,
_sceneState.summary.videoPaletteFile);
- // TODO TEMPORARY
- _viewport.setEdgesSize(25, 25, 25, 25);
-
if (_viewport.getFrameCount() <= 1) {
_viewport.disableEdges(kLeft | kRight);
}
diff --git a/engines/nancy/ui/viewport.cpp b/engines/nancy/ui/viewport.cpp
index 47a34c7515..6619888cd7 100644
--- a/engines/nancy/ui/viewport.cpp
+++ b/engines/nancy/ui/viewport.cpp
@@ -51,10 +51,8 @@ void Viewport::init() {
_upHotspot = _downHotspot = _leftHotspot = _rightHotspot = _screenPosition;
_downHotspot.translate(0, _screenPosition.height());
_rightHotspot.translate(_screenPosition.width(), 0);
- _upHotspot.setHeight(0);
- _downHotspot.setHeight(0);
- _leftHotspot.setWidth(0);
- _rightHotspot.setWidth(0);
+
+ setEdgesSize(g_nancy->_verticalEdgesSize, g_nancy->_horizontalEdgesSize + 5, g_nancy->_horizontalEdgesSize, g_nancy->_horizontalEdgesSize);
RenderObject::init();
}
diff --git a/engines/nancy/ui/viewport.h b/engines/nancy/ui/viewport.h
index 5566e4e730..e4cc3b68a5 100644
--- a/engines/nancy/ui/viewport.h
+++ b/engines/nancy/ui/viewport.h
@@ -74,11 +74,12 @@ public:
Common::Rect convertViewportToScreen(const Common::Rect &viewportRect) const;
Common::Rect convertScreenToViewport(const Common::Rect &viewportRect) const;
- // 0 is inactive, -1 is keep unchanged
- void setEdgesSize(uint16 upSize, uint16 downSize, uint16 leftSize, uint16 rightSize);
void disableEdges(byte edges);
void enableEdges(byte edges);
+protected:
+ void setEdgesSize(uint16 upSize, uint16 downSize, uint16 leftSize, uint16 rightSize);
+
Common::Rect _upHotspot;
Common::Rect _downHotspot;
Common::Rect _leftHotspot;
Commit: 90c4f0c4dce11f25557cbff2ca9d9fd240b10df7
https://github.com/scummvm/scummvm/commit/90c4f0c4dce11f25557cbff2ca9d9fd240b10df7
Author: fracturehill (strahy at outlook.com)
Date: 2021-04-24T23:59:03+03:00
Commit Message:
NANCY: Move hardcoded data
Moved all hardcoded engine data that changes between games (e.g. number
of items, number of event flags) to a dedicated file and added a function for
accessing it in NancyEngine.
Changed paths:
A engines/nancy/constants.cpp
A engines/nancy/constants.h
engines/nancy/module.mk
engines/nancy/nancy.cpp
engines/nancy/nancy.h
engines/nancy/sound.cpp
engines/nancy/state/scene.cpp
engines/nancy/state/scene.h
engines/nancy/ui/inventorybox.cpp
engines/nancy/ui/inventorybox.h
diff --git a/engines/nancy/constants.cpp b/engines/nancy/constants.cpp
new file mode 100644
index 0000000000..9b4bef7b6b
--- /dev/null
+++ b/engines/nancy/constants.cpp
@@ -0,0 +1,57 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "engines/nancy/constants.h"
+
+namespace Nancy {
+
+const GameConstants gameConstants[] {
+ // The Vampire Diaries
+ {
+ 24,
+ 120,
+ { 0, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 125, 219, 220, -1 },
+ { 110, 111, 112, 113, 114, -1 }
+ },
+
+ // Nancy Drew: Secrets Can Kill
+ {
+ 11,
+ 168,
+ { 9, 10, 11, 666, 888, 1200, 1250, 1666, -1 },
+ { 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
+ 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
+ 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, -1 }
+ },
+
+ // Nancy Drew: Stay Tuned For Danger
+ {
+ 18,
+ 240,
+ { -1 }, // No dedicated Map state
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
+ 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, -1 }
+ }
+};
+
+} // End of namespace Nancy
diff --git a/engines/nancy/constants.h b/engines/nancy/constants.h
new file mode 100644
index 0000000000..67b49581c4
--- /dev/null
+++ b/engines/nancy/constants.h
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef NANCY_CONSTANTS_H
+#define NANCY_CONSTANTS_H
+
+#include "common/scummsys.h"
+
+namespace Nancy {
+
+// A struct containing various data that was hardcoded in the original engine but changed between titles
+struct GameConstants {
+ uint numItems;
+ uint numEventFlags;
+ int mapAccessSceneIDs[18];
+ int eventFlagsToClearOnSceneChange[32];
+};
+
+extern const GameConstants gameConstants[];
+
+} // End of namespace Nancy
+
+#endif // NANCY_CONSTANTS_H
diff --git a/engines/nancy/module.mk b/engines/nancy/module.mk
index 1f71a8c133..32e84cfc2e 100644
--- a/engines/nancy/module.mk
+++ b/engines/nancy/module.mk
@@ -29,6 +29,7 @@ MODULE_OBJS = \
state/scene.o \
commontypes.o \
console.o \
+ constants.o \
cursor.o \
decompress.o \
dialogs.o \
diff --git a/engines/nancy/nancy.cpp b/engines/nancy/nancy.cpp
index 5d7a58ab26..eb62ef795f 100644
--- a/engines/nancy/nancy.cpp
+++ b/engines/nancy/nancy.cpp
@@ -36,6 +36,7 @@
#include "engines/nancy/graphics.h"
#include "engines/nancy/dialogs.h"
#include "engines/nancy/console.h"
+#include "engines/nancy/constants.h"
#include "engines/nancy/action/primaryvideo.h"
@@ -156,6 +157,10 @@ Common::Platform NancyEngine::getPlatform() const {
return _gameDescription->desc.platform;
}
+const GameConstants &NancyEngine::getConstants() const {
+ return gameConstants[getGameType() - 1];
+}
+
void NancyEngine::setState(NancyState::NancyState state, NancyState::NancyState overridePrevious) {
// Handle special cases first
switch (state) {
diff --git a/engines/nancy/nancy.h b/engines/nancy/nancy.h
index 892f783aef..c349334774 100644
--- a/engines/nancy/nancy.h
+++ b/engines/nancy/nancy.h
@@ -71,6 +71,7 @@ class GraphicsManager;
class CursorManager;
class CheatDialog;
class NancyConsole;
+struct GameConstants;
namespace State {
class State;
@@ -99,6 +100,8 @@ public:
GameType getGameType() const;
Common::Platform getPlatform() const;
+ const GameConstants &getConstants() const;
+
void setState(NancyState::NancyState state, NancyState::NancyState overridePrevious = NancyState::kNone);
NancyState::NancyState getState() { return _gameFlow.curState; }
void setToPreviousState();
diff --git a/engines/nancy/sound.cpp b/engines/nancy/sound.cpp
index 1f1f9e8b59..7e8dcc6ee5 100644
--- a/engines/nancy/sound.cpp
+++ b/engines/nancy/sound.cpp
@@ -37,7 +37,7 @@ enum SoundType {
kSoundTypeOgg
};
-// Table extracted from nancy1, could be (and probably is) different between games
+// Table valid for vampire diaries and nancy1, could be (and probably is) different between games
static const Audio::Mixer::SoundType channelSoundTypes[] = {
Audio::Mixer::kMusicSoundType, // channel 0
Audio::Mixer::kMusicSoundType,
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index d00c47c4bf..4845f77333 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -30,6 +30,7 @@
#include "engines/nancy/graphics.h"
#include "engines/nancy/cursor.h"
#include "engines/nancy/util.h"
+#include "engines/nancy/constants.h"
#include "engines/nancy/state/scene.h"
@@ -221,7 +222,7 @@ void Scene::setHeldItem(int16 id) {
}
void Scene::setEventFlag(int16 label, NancyFlag flag) {
- if (label > -1 && label < 168) {
+ if (label > -1 && (uint)label < g_nancy->getConstants().numEventFlags) {
_flags.eventFlags[label] = flag;
}
}
@@ -231,7 +232,7 @@ void Scene::setEventFlag(EventFlagDescription eventFlag) {
}
bool Scene::getEventFlag(int16 label, NancyFlag flag) const {
- if (label > -1) {
+ if (label > -1 && (uint)label < g_nancy->getConstants().numEventFlags) {
return _flags.eventFlags[label] == flag;
} else {
return false;
@@ -315,7 +316,7 @@ void Scene::synchronize(Common::Serializer &ser) {
// TODO hardcoded inventory size
auto &order = getInventoryBox()._order;
uint prevSize = getInventoryBox()._order.size();
- getInventoryBox()._order.resize(11);
+ getInventoryBox()._order.resize(g_nancy->getConstants().numItems);
if (ser.isSaving()) {
for (uint i = prevSize; i < order.size(); ++i) {
@@ -323,7 +324,7 @@ void Scene::synchronize(Common::Serializer &ser) {
}
}
- ser.syncArray(order.data(), 11, Common::Serializer::Sint16LE);
+ ser.syncArray(order.data(), g_nancy->getConstants().numItems, Common::Serializer::Sint16LE);
while (order.size() && order.back() == -1) {
order.pop_back();
@@ -335,7 +336,7 @@ void Scene::synchronize(Common::Serializer &ser) {
}
// TODO hardcoded inventory size
- ser.syncArray(_flags.items, 11, Common::Serializer::Byte);
+ ser.syncArray(_flags.items.data(), g_nancy->getConstants().numItems, Common::Serializer::Byte);
ser.syncAsSint16LE(_flags.heldItem);
g_nancy->_cursorManager->setCursorItemID(_flags.heldItem);
@@ -350,7 +351,7 @@ void Scene::synchronize(Common::Serializer &ser) {
g_nancy->setTotalPlayTime((uint32)_timers.lastTotalTime);
// TODO hardcoded number of event flags
- ser.syncArray(_flags.eventFlags, 168, Common::Serializer::Byte);
+ ser.syncArray(_flags.eventFlags.data(), g_nancy->getConstants().numEventFlags, Common::Serializer::Byte);
ser.syncArray<uint16>(_flags.sceneHitCount, (uint16)2001, Common::Serializer::Uint16LE);
@@ -384,18 +385,14 @@ void Scene::synchronize(Common::Serializer &ser) {
}
void Scene::init() {
- for (uint i = 0; i < 168; ++i) {
- _flags.eventFlags[i] = kFalse;
- }
+ _flags.eventFlags = Common::Array<NancyFlag>(g_nancy->getConstants().numEventFlags, kFalse);
// Does this ever get used?
for (uint i = 0; i < 2001; ++i) {
_flags.sceneHitCount[i] = 0;
}
- for (uint i = 0; i < 11; ++i) {
- _flags.items[i] = kFalse;
- }
+ _flags.items = Common::Array<NancyFlag>(g_nancy->getConstants().numItems, kFalse);
_timers.lastTotalTime = 0;
_timers.playerTime = g_nancy->_startTimeHours * 3600000;
@@ -589,8 +586,12 @@ void Scene::run() {
_sceneState.currentScene.verticalOffset = _viewport.getCurVerticalScroll();
// Handle invisible map button
- for (uint i = 0; i < _mapAccessSceneIDs.size(); ++i) {
- if (_sceneState.currentScene.sceneID == _mapAccessSceneIDs[i]) {
+ for (uint i = 0; i < ARRAYSIZE(g_nancy->getConstants().mapAccessSceneIDs); ++i) {
+ if (g_nancy->getConstants().mapAccessSceneIDs[i] == -1) {
+ break;
+ }
+
+ if ((int)_sceneState.currentScene.sceneID == g_nancy->getConstants().mapAccessSceneIDs[i]) {
if (_mapHotspot.contains(input.mousePos)) {
g_nancy->_cursorManager->setCursorType(CursorManager::kHotspotArrow);
@@ -609,18 +610,6 @@ void Scene::initStaticData() {
chunk->seek(0x8A);
readRect(*chunk, _mapHotspot);
- // Hardcoded by original engine
- _mapAccessSceneIDs.clear();
- _mapAccessSceneIDs.reserve(8);
- _mapAccessSceneIDs.push_back(9);
- _mapAccessSceneIDs.push_back(10);
- _mapAccessSceneIDs.push_back(11);
- _mapAccessSceneIDs.push_back(0x4B0);
- _mapAccessSceneIDs.push_back(0x378);
- _mapAccessSceneIDs.push_back(0x29A);
- _mapAccessSceneIDs.push_back(0x4E2);
- _mapAccessSceneIDs.push_back(0x682);
-
chunk = g_nancy->getBootChunkStream("FR0");
chunk->seek(0);
@@ -648,16 +637,12 @@ void Scene::initStaticData() {
void Scene::clearSceneData() {
// only clear select flags
- for (uint i = 44; i < 54; ++i) {
- _flags.eventFlags[i] = kFalse;
- }
-
- for (uint i = 63; i < 74; ++i) {
- _flags.eventFlags[i] = kFalse;
- }
+ for (uint i = 0; i < ARRAYSIZE(g_nancy->getConstants().eventFlagsToClearOnSceneChange); ++i) {
+ if (g_nancy->getConstants().eventFlagsToClearOnSceneChange[i] == -1) {
+ break;
+ }
- for (uint i = 75; i < 85; ++i) {
- _flags.eventFlags[i] = kFalse;
+ _flags.eventFlags[g_nancy->getConstants().eventFlagsToClearOnSceneChange[i]] = kFalse;
}
clearLogicConditions();
diff --git a/engines/nancy/state/scene.h b/engines/nancy/state/scene.h
index c4c36db9ff..3710183203 100644
--- a/engines/nancy/state/scene.h
+++ b/engines/nancy/state/scene.h
@@ -213,9 +213,9 @@ private:
};
LogicCondition logicConditions[30];
- NancyFlag eventFlags[168];
+ Common::Array<NancyFlag> eventFlags;
uint16 sceneHitCount[2001];
- NancyFlag items[11];
+ Common::Array<NancyFlag> items;
int16 heldItem = -1;
int16 primaryVideoResponsePicked = -1;
};
@@ -245,7 +245,6 @@ private:
NancyState::NancyState _gameStateRequested;
Common::Rect _mapHotspot;
- Common::Array<uint16> _mapAccessSceneIDs;
Action::ActionManager _actionManager;
Action::PlayPrimaryVideoChan0 *_activePrimaryVideo;
diff --git a/engines/nancy/ui/inventorybox.cpp b/engines/nancy/ui/inventorybox.cpp
index 1cf5928541..33279c6330 100644
--- a/engines/nancy/ui/inventorybox.cpp
+++ b/engines/nancy/ui/inventorybox.cpp
@@ -27,6 +27,7 @@
#include "engines/nancy/sound.h"
#include "engines/nancy/input.h"
#include "engines/nancy/util.h"
+#include "engines/nancy/constants.h"
#include "engines/nancy/ui/inventorybox.h"
@@ -80,18 +81,20 @@ void InventoryBox::init() {
char itemName[0x14];
- for (uint i = 0; i < 11; ++i) {
+ _itemDescriptions.reserve(g_nancy->getConstants().numItems);
+ for (uint i = 0; i < g_nancy->getConstants().numItems; ++i) {
stream.read(itemName, 0x14);
itemName[0x13] = '\0';
- _itemDescriptions[i].name = Common::String(itemName);
- _itemDescriptions[i].oneTimeUse = stream.readUint16LE();
- readRect(stream, _itemDescriptions[i].sourceRect);
+ _itemDescriptions.push_back(ItemDescription());
+ ItemDescription &desc = _itemDescriptions.back();
+ desc.name = Common::String(itemName);
+ desc.oneTimeUse = stream.readUint16LE();
+ readRect(stream, desc.sourceRect);
}
g_nancy->_resource->loadImage(inventoryBoxIconsImageName, _iconsSurface);
- uint numItems = 11; // TODO
- _fullInventorySurface.create(_screenPosition.width(), _screenPosition.height() * ((numItems / 4) + 1), g_nancy->_graphicsManager->getScreenPixelFormat());
+ _fullInventorySurface.create(_screenPosition.width(), _screenPosition.height() * ((g_nancy->getConstants().numItems / 4) + 1), g_nancy->_graphicsManager->getScreenPixelFormat());
Common::Rect sourceRect = _screenPosition;
sourceRect.moveTo(0, 0);
_drawSurface.create(_fullInventorySurface, sourceRect);
diff --git a/engines/nancy/ui/inventorybox.h b/engines/nancy/ui/inventorybox.h
index 9188316454..98bbdba171 100644
--- a/engines/nancy/ui/inventorybox.h
+++ b/engines/nancy/ui/inventorybox.h
@@ -121,7 +121,7 @@ private:
Common::String _inventoryCursorsImageName; // 0x1D2, should this be here?
Common::Rect _emptySpace; // 0x1E4
- ItemDescription _itemDescriptions[11]; // 0x1F4
+ Common::Array<ItemDescription> _itemDescriptions; // 0x1F4
};
Commit: 8b8d3b38de7af6906c38aab9b6b93dc4105260c8
https://github.com/scummvm/scummvm/commit/8b8d3b38de7af6906c38aab9b6b93dc4105260c8
Author: fracturehill (strahy at outlook.com)
Date: 2021-04-24T23:59:03+03:00
Commit Message:
NANCY: Fix curtains in The Vampire Diaries
Fixed the visual artifacts in the inventory box curtains in The Vampire
Diaries. Renamed the Shades class to Curtains to reflect their name in
the original engine.
Changed paths:
engines/nancy/constants.cpp
engines/nancy/constants.h
engines/nancy/ui/inventorybox.cpp
engines/nancy/ui/inventorybox.h
diff --git a/engines/nancy/constants.cpp b/engines/nancy/constants.cpp
index 9b4bef7b6b..58f7861678 100644
--- a/engines/nancy/constants.cpp
+++ b/engines/nancy/constants.cpp
@@ -30,7 +30,8 @@ const GameConstants gameConstants[] {
24,
120,
{ 0, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 125, 219, 220, -1 },
- { 110, 111, 112, 113, 114, -1 }
+ { 110, 111, 112, 113, 114, -1 },
+ 10
},
// Nancy Drew: Secrets Can Kill
@@ -40,7 +41,8 @@ const GameConstants gameConstants[] {
{ 9, 10, 11, 666, 888, 1200, 1250, 1666, -1 },
{ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
- 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, -1 }
+ 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, -1 },
+ 7
},
// Nancy Drew: Stay Tuned For Danger
@@ -50,7 +52,8 @@ const GameConstants gameConstants[] {
{ -1 }, // No dedicated Map state
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
- 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, -1 }
+ 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, -1 },
+ 7 // TODO
}
};
diff --git a/engines/nancy/constants.h b/engines/nancy/constants.h
index 67b49581c4..15d711966e 100644
--- a/engines/nancy/constants.h
+++ b/engines/nancy/constants.h
@@ -33,6 +33,7 @@ struct GameConstants {
uint numEventFlags;
int mapAccessSceneIDs[18];
int eventFlagsToClearOnSceneChange[32];
+ uint numCurtainAnimationFrames;
};
extern const GameConstants gameConstants[];
diff --git a/engines/nancy/ui/inventorybox.cpp b/engines/nancy/ui/inventorybox.cpp
index 33279c6330..38f545615f 100644
--- a/engines/nancy/ui/inventorybox.cpp
+++ b/engines/nancy/ui/inventorybox.cpp
@@ -41,9 +41,9 @@ namespace UI {
InventoryBox::InventoryBox(RenderObject &redrawFrom) :
RenderObject(redrawFrom, 6),
_scrollbar(nullptr),
- _shades(*this, this),
+ _curtains(*this, this),
_scrollbarPos(0),
- _shadesFrameTime(0) {}
+ _curtainsFrameTime(0) {}
InventoryBox::~InventoryBox() {
_fullInventorySurface.free();
@@ -65,12 +65,14 @@ void InventoryBox::init() {
stream.seek(0xD6, SEEK_SET);
- for (uint i = 0; i < 14; ++i) {
- readRect(stream, _shadesSrc[i]);
+ uint numFrames = g_nancy->getConstants().numCurtainAnimationFrames;
+ _curtainsSrc.resize(numFrames * 2);
+ for (uint i = 0; i < numFrames * 2; ++i) {
+ readRect(stream, _curtainsSrc[i]);
}
readRect(stream, _screenPosition);
- _shadesFrameTime = stream.readUint16LE();
+ _curtainsFrameTime = stream.readUint16LE();
Common::String inventoryBoxIconsImageName;
readFilename(stream, inventoryBoxIconsImageName);
@@ -111,7 +113,7 @@ void InventoryBox::init() {
_scrollbar = new Scrollbar(NancySceneState.getFrame(), 9, scrollbarSrcBounds, scrollbarDefaultPos, scrollbarMaxScroll - scrollbarDefaultPos.y);
_scrollbar->init();
- _shades.init();
+ _curtains.init();
}
void InventoryBox::updateGraphics() {
@@ -125,7 +127,7 @@ void InventoryBox::updateGraphics() {
void InventoryBox::registerGraphics() {
RenderObject::registerGraphics();
_scrollbar->registerGraphics();
- _shades.registerGraphics();
+ _curtains.registerGraphics();
}
void InventoryBox::handleInput(NancyInput &input) {
@@ -155,8 +157,8 @@ void InventoryBox::handleInput(NancyInput &input) {
void InventoryBox::addItem(int16 itemID) {
if (_order.size() == 0) {
- // Adds first item, start shades animation
- _shades.setOpen(true);
+ // Adds first item, start curtains animation
+ _curtains.setOpen(true);
}
Common::Array<int16> back = _order;
_order.clear();
@@ -191,9 +193,9 @@ void InventoryBox::onReorder() {
}
if (_order.size() > 0) {
- _shades.setOpen(true);
+ _curtains.setOpen(true);
} else {
- _shades.setOpen(false);
+ _curtains.setOpen(false);
}
_needsRedraw = true;
@@ -225,9 +227,14 @@ void InventoryBox::onScrollbarMove() {
_needsRedraw = true;
}
-void InventoryBox::Shades::init() {
+void InventoryBox::Curtains::init() {
Common::Rect bounds = _parent->getBounds();
- _drawSurface.create(bounds.width(), bounds.height(), g_nancy->_graphicsManager->getScreenPixelFormat());
+ _drawSurface.create(bounds.width(), bounds.height(), g_nancy->_graphicsManager->getInputPixelFormat());
+
+ if (g_nancy->getGameFlags() & NGF_8BITCOLOR) {
+ _drawSurface.setPalette(g_nancy->_graphicsManager->_object0.getPalette(), 0, 256);
+ }
+
_screenPosition = _parent->getScreenPosition();
_nextFrameTime = 0;
setAnimationFrame(_curFrame);
@@ -237,12 +244,12 @@ void InventoryBox::Shades::init() {
RenderObject::init();
}
-void InventoryBox::Shades::updateGraphics() {
+void InventoryBox::Curtains::updateGraphics() {
Time time = g_nancy->getTotalPlayTime();
if (_areOpen) {
- if (_curFrame < 7 && time > _nextFrameTime) {
+ if (_curFrame < g_nancy->getConstants().numCurtainAnimationFrames && time > _nextFrameTime) {
setAnimationFrame(++_curFrame);
- _nextFrameTime = time + _parent->_shadesFrameTime;
+ _nextFrameTime = time + _parent->_curtainsFrameTime;
if (!_soundTriggered) {
_soundTriggered = true;
@@ -252,7 +259,7 @@ void InventoryBox::Shades::updateGraphics() {
} else {
if (_curFrame > 0 && time > _nextFrameTime) {
setAnimationFrame(--_curFrame);
- _nextFrameTime = time + _parent->_shadesFrameTime;
+ _nextFrameTime = time + _parent->_curtainsFrameTime;
if (!_soundTriggered) {
_soundTriggered = true;
@@ -261,17 +268,17 @@ void InventoryBox::Shades::updateGraphics() {
}
}
- if (_curFrame == 0 || _curFrame == 7) {
+ if (_curFrame == 0 || _curFrame == g_nancy->getConstants().numCurtainAnimationFrames) {
_soundTriggered = false;
}
}
-void InventoryBox::Shades::setAnimationFrame(uint frame) {
+void InventoryBox::Curtains::setAnimationFrame(uint frame) {
Graphics::ManagedSurface &_object0 = g_nancy->_graphicsManager->_object0;
Common::Rect srcRect;
Common::Point destPoint;
- if (frame > 6) {
+ if (frame > g_nancy->getConstants().numCurtainAnimationFrames - 1) {
setVisible(false);
return;
} else {
@@ -281,11 +288,11 @@ void InventoryBox::Shades::setAnimationFrame(uint frame) {
_drawSurface.clear(g_nancy->_graphicsManager->getTransColor());
// Draw left shade
- srcRect = _parent->_shadesSrc[frame * 2];
+ srcRect = _parent->_curtainsSrc[frame * 2];
_drawSurface.blitFrom(_object0, srcRect, destPoint);
// Draw right shade
- srcRect = _parent->_shadesSrc[frame * 2 + 1];
+ srcRect = _parent->_curtainsSrc[frame * 2 + 1];
destPoint.x = getBounds().width() - srcRect.width();
_drawSurface.blitFrom(_object0, srcRect, destPoint);
diff --git a/engines/nancy/ui/inventorybox.h b/engines/nancy/ui/inventorybox.h
index 98bbdba171..35cb087926 100644
--- a/engines/nancy/ui/inventorybox.h
+++ b/engines/nancy/ui/inventorybox.h
@@ -72,15 +72,15 @@ private:
void onReorder();
void setHotspots(uint pageNr);
- class Shades : public RenderObject {
+ class Curtains : public RenderObject {
public:
- Shades(RenderObject &redrawFrom, InventoryBox *parent) :
+ Curtains(RenderObject &redrawFrom, InventoryBox *parent) :
RenderObject(redrawFrom, 9),
_parent(parent),
_soundTriggered(false),
_areOpen(false),
_curFrame(0) {}
- virtual ~Shades() = default;
+ virtual ~Curtains() = default;
virtual void init() override;
virtual void updateGraphics() override;
@@ -106,7 +106,7 @@ private:
Graphics::ManagedSurface _fullInventorySurface;
Scrollbar *_scrollbar;
- Shades _shades;
+ Curtains _curtains;
float _scrollbarPos;
@@ -115,14 +115,13 @@ private:
// INV contents
//...
- Common::Rect _shadesSrc[14]; // 0xD6
+ Common::Array<Common::Rect> _curtainsSrc; // 0xD6
// _screenPosition 0x1B6
- uint16 _shadesFrameTime; // 0x1C6
+ uint16 _curtainsFrameTime; // 0x1C6
Common::String _inventoryCursorsImageName; // 0x1D2, should this be here?
Common::Rect _emptySpace; // 0x1E4
Common::Array<ItemDescription> _itemDescriptions; // 0x1F4
-
};
} // End of namespace UI
Commit: c86d46fcded61913a42314e2dd8896174167ffa9
https://github.com/scummvm/scummvm/commit/c86d46fcded61913a42314e2dd8896174167ffa9
Author: fracturehill (strahy at outlook.com)
Date: 2021-04-24T23:59:03+03:00
Commit Message:
NANCY: Fix The Vampire Diaries's cursors
Fixed the cursors in The Vampire Diaries so they display correctly.
Changed paths:
engines/nancy/constants.cpp
engines/nancy/constants.h
engines/nancy/cursor.cpp
engines/nancy/cursor.h
diff --git a/engines/nancy/constants.cpp b/engines/nancy/constants.cpp
index 58f7861678..923c996183 100644
--- a/engines/nancy/constants.cpp
+++ b/engines/nancy/constants.cpp
@@ -31,6 +31,7 @@ const GameConstants gameConstants[] {
120,
{ 0, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 125, 219, 220, -1 },
{ 110, 111, 112, 113, 114, -1 },
+ 8,
10
},
@@ -42,7 +43,8 @@ const GameConstants gameConstants[] {
{ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
75, 76, 77, 78, 79, 80, 81, 82, 83, 84, -1 },
- 7
+ 12,
+ 7
},
// Nancy Drew: Stay Tuned For Danger
@@ -53,7 +55,8 @@ const GameConstants gameConstants[] {
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, -1 },
- 7 // TODO
+ 12, // TODO
+ 7 // TODO
}
};
diff --git a/engines/nancy/constants.h b/engines/nancy/constants.h
index 15d711966e..4a9b66b098 100644
--- a/engines/nancy/constants.h
+++ b/engines/nancy/constants.h
@@ -33,6 +33,7 @@ struct GameConstants {
uint numEventFlags;
int mapAccessSceneIDs[18];
int eventFlagsToClearOnSceneChange[32];
+ uint numNonItemCursors;
uint numCurtainAnimationFrames;
};
diff --git a/engines/nancy/cursor.cpp b/engines/nancy/cursor.cpp
index 17dc936fed..b8605a37cf 100644
--- a/engines/nancy/cursor.cpp
+++ b/engines/nancy/cursor.cpp
@@ -27,23 +27,27 @@
#include "engines/nancy/graphics.h"
#include "engines/nancy/resource.h"
#include "engines/nancy/util.h"
+#include "engines/nancy/constants.h"
namespace Nancy {
void CursorManager::init() {
Common::SeekableReadStream *chunk = g_nancy->getBootChunkStream("INV");
- chunk->seek(0x1D2); // TODO
+ chunk->seek(0xD6 + g_nancy->getConstants().numCurtainAnimationFrames * 0x20 + 0x1C);
Common::String inventoryCursorsImageName = chunk->readString();
chunk = g_nancy->getBootChunkStream("CURS");
- _cursors.reserve(56);
- for (uint i = 0; i < 56; ++i) {
+ chunk->seek(0);
+ uint numCursors = g_nancy->getConstants().numNonItemCursors + g_nancy->getConstants().numItems * 4;
+ _cursors.reserve(numCursors);
+ for (uint i = 0; i < numCursors; ++i) {
_cursors.push_back(Cursor());
chunk->seek(i * 16, SEEK_SET);
- readRect(*chunk, _cursors[i].bounds);
- chunk->seek(0x380 + i * 8, SEEK_SET);
- _cursors[i].hotspot.x = chunk->readUint32LE();
- _cursors[i].hotspot.y = chunk->readUint32LE();
+ Cursor &cur = _cursors.back();
+ readRect(*chunk, cur.bounds);
+ chunk->seek(numCursors * 16 + i * 8, SEEK_SET);
+ cur.hotspot.x = chunk->readUint32LE();
+ cur.hotspot.y = chunk->readUint32LE();
}
readRect(*chunk, _primaryVideoInactiveZone);
@@ -103,17 +107,29 @@ void CursorManager::setCursor(CursorType type, int16 itemID) {
surf = &g_nancy->_graphicsManager->_object0;
}
- // TODO this is ridiculous, figure out why just calling
- // GetBasePtr() results in garbage
- Graphics::Surface s;
- s.create(bounds.width(), bounds.height(), surf->format);
- s.copyRectToSurface(*surf, 0, 0, bounds);
-
- // TODO hotspots are terrible for arrow cursors, fix that??
- CursorMan.replaceCursor(s.getPixels(), s.w, s.h, hotspot.x, hotspot.y, g_nancy->_graphicsManager->getTransColor(), false, &g_nancy->_graphicsManager->getInputPixelFormat());
-
- s.free();
+ // Create a temporary surface to hold the cursor since giving replaceCursor() a pointer
+ // to the original surface results in garbage. This also makes it so we don't have to deal
+ // with TVD's palettes
+ Graphics::ManagedSurface temp;
+ temp.create(bounds.width(), bounds.height(), g_nancy->_graphicsManager->getScreenPixelFormat());
+ temp.blitFrom(*surf, bounds, Common::Point());
+
+ // Convert the trans color from the original format to the screen format
+ uint transColor;
+ if (g_nancy->getGameFlags() & NGF_8BITCOLOR) {
+ uint8 r, g, b;
+ uint32 input = surf->getPalette()[1];
+ r = input & 0xFF;
+ g = (input & 0xFF00) >> 8;
+ b = (input & 0xFF0000) >> 16;
+ transColor = temp.format.RGBToColor(r, g, b);
+ } else {
+ uint8 r, g, b;
+ surf->format.colorToRGB(g_nancy->_graphicsManager->getTransColor(), r, g, b);
+ transColor = temp.format.RGBToColor(r, g, b);
+ }
+ CursorMan.replaceCursor(temp.getPixels(), temp.w, temp.h, hotspot.x, hotspot.y, transColor, false, &temp.format);
}
void CursorManager::setCursorType(CursorType type) {
diff --git a/engines/nancy/cursor.h b/engines/nancy/cursor.h
index 29fab7d365..c8a7b42fe2 100644
--- a/engines/nancy/cursor.h
+++ b/engines/nancy/cursor.h
@@ -65,6 +65,7 @@ private:
Common::Point _primaryVideoInitialPos;
Graphics::ManagedSurface _invCursorsSurface;
+ Graphics::ManagedSurface _object0Copy;
CursorType _curCursorType;
int16 _curItemID;
Commit: 993f708dd013c982562065662a98fab4f4befe81
https://github.com/scummvm/scummvm/commit/993f708dd013c982562065662a98fab4f4befe81
Author: fracturehill (strahy at outlook.com)
Date: 2021-04-25T00:04:53+03:00
Commit Message:
NANCY: Don't adjust rects in The Vampire Diaries
readRect() no longer adds a pixel to the right and bottom for
The Vampire Diaries, since rects in that game are non-inclusive.
Changed paths:
A engines/nancy/util.cpp
engines/nancy/module.mk
engines/nancy/util.h
diff --git a/engines/nancy/module.mk b/engines/nancy/module.mk
index 32e84cfc2e..21d49ca320 100644
--- a/engines/nancy/module.mk
+++ b/engines/nancy/module.mk
@@ -42,6 +42,7 @@ MODULE_OBJS = \
renderobject.o \
resource.o \
sound.o \
+ util.o \
video.o
# This module can be built as a plugin
diff --git a/engines/nancy/util.cpp b/engines/nancy/util.cpp
new file mode 100644
index 0000000000..ef5a472f33
--- /dev/null
+++ b/engines/nancy/util.cpp
@@ -0,0 +1,48 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "engines/nancy/nancy.h"
+#include "engines/nancy/util.h"
+
+namespace Nancy {
+
+void readRect(Common::SeekableReadStream &stream, Common::Rect &inRect) {
+ inRect.left = stream.readSint32LE();
+ inRect.top = stream.readSint32LE();
+ inRect.right = stream.readSint32LE();
+ inRect.bottom = stream.readSint32LE();
+
+ // TVD's rects are non-inclusive
+ if (g_nancy->getGameType() > kGameTypeVampire) {
+ ++inRect.right;
+ ++inRect.bottom;
+ }
+}
+
+// Reads an 8-character filename from a 10-character source
+void readFilename(Common::SeekableReadStream &stream, Common::String &inString) {
+ char buf[10];
+ stream.read(buf, 10);
+ buf[9] = '\0';
+ inString = buf;
+}
+
+} // End of namespace Nancy
diff --git a/engines/nancy/util.h b/engines/nancy/util.h
index 50489c78fc..e7df5f31a0 100644
--- a/engines/nancy/util.h
+++ b/engines/nancy/util.h
@@ -27,20 +27,8 @@
namespace Nancy {
-inline void readRect(Common::SeekableReadStream &stream, Common::Rect &inRect) {
- inRect.left = stream.readSint32LE();
- inRect.top = stream.readSint32LE();
- inRect.right = stream.readSint32LE() + 1;
- inRect.bottom = stream.readSint32LE() + 1;
-}
-
-// Reads an 8-character filename from a 10-character source
-inline void readFilename(Common::SeekableReadStream &stream, Common::String &inString) {
- char buf[10];
- stream.read(buf, 10);
- buf[9] = '\0';
- inString = buf;
-}
+void readRect(Common::SeekableReadStream &stream, Common::Rect &inRect);
+void readFilename(Common::SeekableReadStream &stream, Common::String &inString);
} // End of namespace Nancy
More information about the Scummvm-git-logs
mailing list