aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sherlock/inventory.cpp27
-rw-r--r--engines/sherlock/inventory.h18
-rw-r--r--engines/sherlock/module.mk1
-rw-r--r--engines/sherlock/objects.cpp6
-rw-r--r--engines/sherlock/objects.h3
-rw-r--r--engines/sherlock/people.cpp18
-rw-r--r--engines/sherlock/people.h4
-rw-r--r--engines/sherlock/scalpel/scalpel.cpp16
-rw-r--r--engines/sherlock/scene.cpp96
-rw-r--r--engines/sherlock/scene.h10
-rw-r--r--engines/sherlock/sherlock.cpp24
-rw-r--r--engines/sherlock/sherlock.h9
12 files changed, 218 insertions, 14 deletions
diff --git a/engines/sherlock/inventory.cpp b/engines/sherlock/inventory.cpp
new file mode 100644
index 0000000000..634e664f5a
--- /dev/null
+++ b/engines/sherlock/inventory.cpp
@@ -0,0 +1,27 @@
+/* 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 "sherlock/inventory.h"
+
+namespace Sherlock {
+
+} // End of namespace Sherlock
diff --git a/engines/sherlock/inventory.h b/engines/sherlock/inventory.h
index de4a2d7758..dc56e93841 100644
--- a/engines/sherlock/inventory.h
+++ b/engines/sherlock/inventory.h
@@ -24,15 +24,23 @@
#define SHERLOCK_INVENTORY_H
#include "common/scummsys.h"
+#include "common/array.h"
namespace Sherlock {
struct InventoryItem {
- int stringIndex;
- char name[12];
- char description[41];
- char name2[9];
- uint16 value;
+ int _requiredFlag;
+ Common::String _name;
+ Common::String _description;;
+ Common::String _examine;
+ int _lookFlag;
+};
+
+class Inventory : public Common::Array<InventoryItem> {
+public:
+ uint _holdings;
+
+ Inventory() : Common::Array<InventoryItem>(), _holdings(0) {}
};
} // End of namespace Sherlock
diff --git a/engines/sherlock/module.mk b/engines/sherlock/module.mk
index dc88ab3f5f..aa8f495742 100644
--- a/engines/sherlock/module.mk
+++ b/engines/sherlock/module.mk
@@ -11,6 +11,7 @@ MODULE_OBJS = \
detection.o \
events.o \
graphics.o \
+ inventory.o \
journal.o \
objects.o \
people.o \
diff --git a/engines/sherlock/objects.cpp b/engines/sherlock/objects.cpp
index aa9b391f96..d696954cda 100644
--- a/engines/sherlock/objects.cpp
+++ b/engines/sherlock/objects.cpp
@@ -51,6 +51,12 @@ void Sprite::clear() {
_numFrames = 0;
}
+void Sprite::setImageFrame() {
+ // TODO: check this
+ int imageNumber = (*_sequences)[_sequenceNumber][_frameNumber];
+ _imageFrame = &(*_images)[imageNumber];
+}
+
/*----------------------------------------------------------------*/
void ActionType::synchronize(Common::SeekableReadStream &s) {
diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h
index f3879b1143..d43b70f4e9 100644
--- a/engines/sherlock/objects.h
+++ b/engines/sherlock/objects.h
@@ -100,7 +100,10 @@ struct Sprite {
int _numFrames; // How many frames the object has
Sprite() { clear(); }
+
void clear();
+
+ void setImageFrame();
};
struct ActionType {
diff --git a/engines/sherlock/people.cpp b/engines/sherlock/people.cpp
index cdb498e5e6..b4bbef2e1a 100644
--- a/engines/sherlock/people.cpp
+++ b/engines/sherlock/people.cpp
@@ -46,6 +46,12 @@ static const uint8 CHARACTER_SEQUENCES[MAX_HOLMES_SEQUENCE][MAX_FRAME] = {
People::People(SherlockEngine *vm) : _vm(vm) {
+ _walkLoaded = false;
+}
+
+People::~People() {
+ if (_walkLoaded)
+ delete _data[PLAYER]._images;
}
void People::reset() {
@@ -70,4 +76,16 @@ void People::reset() {
p._status = 0;
}
+bool People::loadWalk() {
+ if (_walkLoaded) {
+ return false;
+ } else {
+ _data[PLAYER]._images = new ImageFile("walk.vgs");
+ _data[PLAYER].setImageFrame();
+ _walkLoaded = true;
+
+ return true;
+ }
+}
+
} // End of namespace Sherlock
diff --git a/engines/sherlock/people.h b/engines/sherlock/people.h
index 3f639a6d44..4bdc6a88f0 100644
--- a/engines/sherlock/people.h
+++ b/engines/sherlock/people.h
@@ -46,10 +46,14 @@ class People {
private:
SherlockEngine *_vm;
Sprite _data[MAX_PEOPLE];
+ bool _walkLoaded;
public:
People(SherlockEngine *vm);
+ ~People();
void reset();
+
+ bool loadWalk();
};
} // End of namespace Sherlock
diff --git a/engines/sherlock/scalpel/scalpel.cpp b/engines/sherlock/scalpel/scalpel.cpp
index ca04153594..40ca9736d6 100644
--- a/engines/sherlock/scalpel/scalpel.cpp
+++ b/engines/sherlock/scalpel/scalpel.cpp
@@ -27,6 +27,18 @@ namespace Sherlock {
namespace Scalpel {
+#define NUM_PLACES 100
+const int MAP_X[NUM_PLACES] = {
+ 0, 368, 0, 219, 0, 282, 0, 43, 0, 0, 396, 408, 0, 0, 0, 568, 37, 325,
+ 28, 0, 263, 36, 148, 469, 342, 143, 443, 229, 298, 0, 157, 260, 432,
+ 174, 0, 351, 0, 528, 0, 136, 0, 0, 0, 555, 165, 0, 506, 0, 0, 344, 0, 0
+};
+const int MAP_Y[NUM_PLACES] = {
+ 0, 147, 0, 166, 0, 109, 0, 61, 0, 0, 264, 70, 0, 0, 0, 266, 341, 30, 275,
+ 0, 294, 146, 311, 230, 184, 268, 133, 94, 207, 0, 142, 142, 330, 255, 0,
+ 37, 0, 70, 0, 116, 0, 0, 0, 50, 21, 0, 303, 0, 0, 229, 0, 0
+};
+
ScalpelEngine::ScalpelEngine(OSystem *syst, const SherlockGameDescription *gameDesc) :
SherlockEngine(syst, gameDesc) {
_chess = nullptr;
@@ -53,6 +65,10 @@ void ScalpelEngine::initialize() {
_flags[3] = true; // Turn on Alley
_flags[39] = true; // Turn on Baker Street
+ // Load the map co-ordinates for each scene
+ for (int idx = 0; idx < NUM_PLACES; ++idx)
+ _map.push_back(Common::Point(MAP_X[idx], MAP_Y[idx]));
+
// Starting scene
_scene->_goToRoom = 4;
}
diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp
index 86e347d011..4ec5c29134 100644
--- a/engines/sherlock/scene.cpp
+++ b/engines/sherlock/scene.cpp
@@ -136,7 +136,9 @@ void Scene::selectScene() {
* The _misc field of the structures contains the number of the graphic image
* that it should point to after loading; _misc is then set to 0.
*/
-void Scene::loadScene(const Common::String &filename) {
+bool Scene::loadScene(const Common::String &filename) {
+ EventsManager &events = *_vm->_events;
+ People &people = *_vm->_people;
Screen &screen = *_vm->_screen;
Sound &sound = *_vm->_sound;
bool flag;
@@ -367,7 +369,28 @@ void Scene::loadScene(const Common::String &filename) {
checkSceneFlags(false);
checkInventory();
- // TODO
+ // Handle starting any music for the scene
+ if (sound._musicEnabled && sound.loadSong(_currentScene)) {
+ if (sound._music)
+ sound.startSong();
+ }
+
+ // Load walking images if not already loaded
+ people.loadWalk();
+
+ // Transition to the scene and setup entrance co-ordinates and animations
+ transitionToScene();
+
+ // Player has not yet walked in this scene
+ _walkedInScene = false;
+
+ // Reset the position on the overland map
+ _vm->_oldCharPoint = _currentScene;
+ _vm->_over.x = _vm->_map[_currentScene].x * 100 - 600;
+ _vm->_over.y = _vm->_map[_currentScene].y * 100 + 900;
+
+ events.clearEvents();
+ return flag;
}
/**
@@ -410,11 +433,55 @@ void Scene::checkSceneStatus() {
* is in use (ie. not just loaded)
*/
void Scene::checkSceneFlags(bool flag) {
- int mode = mode ? HIDE_SHAPE : HIDDEN;
+ SpriteType mode = flag ? HIDE_SHAPE : HIDDEN;
for (uint idx = 0; idx < _bgShapes.size(); ++idx) {
Object &o = _bgShapes[idx];
- // TODO: read_flags calls
+
+ if (o._requiredFlag) {
+ if (!_vm->readFlags(_bgShapes[idx]._requiredFlag)) {
+ // Kill object
+ if (o._type != HIDDEN && o._type != INVALID) {
+ if (o._images == nullptr || o._images->size() == 0)
+ // No shape to erase, so flag as hidden
+ o._type = HIDDEN;
+ else
+ // Flag it as needing to be hidden after first erasing it
+ o._type = mode;
+ }
+ } else if (_bgShapes[idx]._requiredFlag) {
+ // Restore object
+ if (o._images == nullptr || o._images->size() == 0)
+ o._type = NO_SHAPE;
+ else
+ o._type = ACTIVE_BG_SHAPE;
+ }
+ }
+ }
+
+ // Check inventory
+ for (uint idx = 0; idx < _vm->_inventory->_holdings; ++idx) {
+ InventoryItem &ii = (*_vm->_inventory)[idx];
+ if (ii._requiredFlag && !_vm->readFlags(ii._requiredFlag)) {
+ // Kill object: move it after the active holdings
+ InventoryItem tempItem = (*_vm->_inventory)[idx];
+ _vm->_inventory->insert_at(_vm->_inventory->_holdings, tempItem);
+ _vm->_inventory->remove_at(idx);
+ _vm->_inventory->_holdings--;
+ break;
+ }
+ }
+
+ for (uint idx = _vm->_inventory->_holdings; idx < _vm->_inventory->size(); ++idx) {
+ InventoryItem &ii = (*_vm->_inventory)[idx];
+ if (ii._requiredFlag && _vm->readFlags(ii._requiredFlag)) {
+ // Restore object: move it after the active holdings
+ InventoryItem tempItem = (*_vm->_inventory)[idx];
+ _vm->_inventory->remove_at(idx);
+ _vm->_inventory->insert_at(_vm->_inventory->_holdings, tempItem);
+ _vm->_inventory->_holdings++;
+ break;
+ }
}
}
@@ -424,7 +491,28 @@ void Scene::checkSceneFlags(bool flag) {
* be hidden in the scene.
*/
void Scene::checkInventory() {
+ for (uint shapeIdx = 0; shapeIdx < _bgShapes.size(); ++shapeIdx) {
+ for (uint invIdx = 0; invIdx < _vm->_inventory->size(); ++invIdx) {
+ if (scumm_stricmp(_bgShapes[shapeIdx]._name.c_str(),
+ (*_vm->_inventory)[invIdx]._name.c_str()) == 0) {
+ _bgShapes[shapeIdx]._type = INVALID;
+ break;
+ }
+ }
+ }
+}
+
+/**
+ * Set up any entrance co-ordinates or entrance canimations, and then transition
+ * in the scene
+ */
+void Scene::transitionToScene() {
+ const int FS_TRANS[8] = {
+ STOP_UP, STOP_UPRIGHT, STOP_RIGHT, STOP_DOWNRIGHT, STOP_DOWN,
+ STOP_DOWNLEFT, STOP_LEFT, STOP_UPLEFT
+ };
+ // TODO
}
} // End of namespace Sherlock
diff --git a/engines/sherlock/scene.h b/engines/sherlock/scene.h
index ae4fcfdb45..d51856b508 100644
--- a/engines/sherlock/scene.h
+++ b/engines/sherlock/scene.h
@@ -89,15 +89,13 @@ class Scene {
private:
SherlockEngine *_vm;
- void loadScene();
-
- void loadScene(const Common::String &filename);
+ bool loadScene(const Common::String &filename);
void checkSceneStatus();
- void checkSceneFlags(bool mode);
-
void checkInventory();
+
+ void transitionToScene();
public:
int _currentScene;
int _goToRoom;
@@ -137,6 +135,8 @@ public:
void clear();
void selectScene();
+
+ void checkSceneFlags(bool mode);
};
} // End of namespace Sherlock
diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp
index 115d9f0130..65dc6c80a5 100644
--- a/engines/sherlock/sherlock.cpp
+++ b/engines/sherlock/sherlock.cpp
@@ -33,6 +33,7 @@ SherlockEngine::SherlockEngine(OSystem *syst, const SherlockGameDescription *gam
_animation = nullptr;
_debugger = nullptr;
_events = nullptr;
+ _inventory = nullptr;
_journal = nullptr;
_people = nullptr;
_res = nullptr;
@@ -50,6 +51,7 @@ SherlockEngine::~SherlockEngine() {
delete _animation;
delete _debugger;
delete _events;
+ delete _inventory;
delete _journal;
delete _people;
delete _res;
@@ -82,6 +84,7 @@ void SherlockEngine::initialize() {
_animation = new Animation(this);
_debugger = new Debugger(this);
_events = new EventsManager(this);
+ _inventory = new Inventory();
_journal = new Journal();
_people = new People(this);
_scene = new Scene(this);
@@ -116,4 +119,25 @@ Common::Error SherlockEngine::run() {
return Common::kNoError;
}
+/**
+ * Read the state of a global flag
+ */
+bool SherlockEngine::readFlags(int flagNum) {
+ bool value = _flags[ABS(flagNum)];
+ if (flagNum < 0)
+ value = !value;
+
+ return value;
+}
+
+/**
+ * Sets a global flag to either true or false depending on whether the specified
+ * flag is positive or negative
+ */
+void SherlockEngine::setFlags(int flagNum) {
+ _flags[ABS(flagNum)] = flagNum >= 0;
+
+ _scene->checkSceneFlags(true);
+}
+
} // End of namespace Comet
diff --git a/engines/sherlock/sherlock.h b/engines/sherlock/sherlock.h
index c31416f91e..a8ca9abbfd 100644
--- a/engines/sherlock/sherlock.h
+++ b/engines/sherlock/sherlock.h
@@ -34,6 +34,7 @@
#include "sherlock/animation.h"
#include "sherlock/debugger.h"
#include "sherlock/events.h"
+#include "sherlock/inventory.h"
#include "sherlock/journal.h"
#include "sherlock/people.h"
#include "sherlock/resources.h"
@@ -78,6 +79,7 @@ public:
Animation *_animation;
Debugger *_debugger;
EventsManager *_events;
+ Inventory *_inventory;
Journal *_journal;
People *_people;
Resources *_res;
@@ -93,6 +95,9 @@ public:
Common::Point _hsavedPos;
int _hsavedFs;
bool _justLoaded;
+ int _oldCharPoint; // Old scene
+ Common::Point _over; // Old map position
+ Common::Array<Common::Point> _map; // Map locations for each scene
public:
SherlockEngine(OSystem *syst, const SherlockGameDescription *gameDesc);
virtual ~SherlockEngine();
@@ -108,6 +113,10 @@ public:
Common::String getGameFile(int fileType);
int getRandomNumber(int limit) { return _randomSource.getRandomNumber(limit - 1); }
+
+ bool readFlags(int flagNum);
+
+ void setFlags(int flagNum);
};
} // End of namespace Sherlock