diff options
-rw-r--r-- | engines/sherlock/people.cpp | 10 | ||||
-rw-r--r-- | engines/sherlock/people.h | 13 | ||||
-rw-r--r-- | engines/sherlock/scene.cpp | 81 | ||||
-rw-r--r-- | engines/sherlock/scene.h | 6 | ||||
-rw-r--r-- | engines/sherlock/sherlock.h | 2 | ||||
-rw-r--r-- | engines/sherlock/talk.cpp | 8 |
6 files changed, 65 insertions, 55 deletions
diff --git a/engines/sherlock/people.cpp b/engines/sherlock/people.cpp index 083e3c8d4c..bac147f489 100644 --- a/engines/sherlock/people.cpp +++ b/engines/sherlock/people.cpp @@ -114,7 +114,7 @@ People::People(SherlockEngine *vm) : _vm(vm), _player(_data[0]) { } People::~People() { - for (int idx = 0; idx < MAX_PLAYERS; ++idx) { + for (int idx = 0; idx < MAX_CHARACTERS; ++idx) { if (_data[idx]._walkLoaded) delete _data[PLAYER]._images; } @@ -127,7 +127,7 @@ void People::reset() { _data[0]._description = "Sherlock Holmes!"; // Note: Serrated Scalpel only uses a single Person slot for Sherlock.. Watson is handled by scene sprites - int count = IS_SERRATED_SCALPEL ? 1 : MAX_PLAYERS; + int count = IS_SERRATED_SCALPEL ? 1 : MAX_CHARACTERS; for (int idx = 0; idx < count; ++idx) { Sprite &p = _data[idx]; @@ -197,7 +197,7 @@ bool People::loadWalk() { result = true; } } else { - for (int idx = 0; idx < MAX_PLAYERS; ++idx) { + for (int idx = 0; idx < MAX_CHARACTERS; ++idx) { if (!_data[idx]._walkLoaded && (_data[idx]._type == CHARACTER || _data[idx]._type == HIDDEN_CHARACTER)) { if (_data[idx]._type == HIDDEN_CHARACTER) _data[idx]._type = INVALID; @@ -258,7 +258,7 @@ bool People::loadWalk() { bool People::freeWalk() { bool result = false; - for (int idx = 0; idx < MAX_PLAYERS; ++idx) { + for (int idx = 0; idx < MAX_CHARACTERS; ++idx) { if (_data[idx]._walkLoaded) { delete _data[idx]._images; _data[idx]._images = nullptr; @@ -700,7 +700,7 @@ void People::synchronize(Common::Serializer &s) { s.syncAsSint16LE(_player._position.y); s.syncAsSint16LE(_player._sequenceNumber); } else { - for (int idx = 0; idx < MAX_PLAYERS; ++idx) { + for (int idx = 0; idx < MAX_CHARACTERS; ++idx) { Person &p = _data[idx]; s.syncAsSint16LE(p._position.x); s.syncAsSint16LE(p._position.y); diff --git a/engines/sherlock/people.h b/engines/sherlock/people.h index a1968785db..72bdc515b7 100644 --- a/engines/sherlock/people.h +++ b/engines/sherlock/people.h @@ -34,7 +34,7 @@ enum PeopleId { PLAYER = 0, AL = 0, PEG = 1, - MAX_PLAYERS = 6, + MAX_CHARACTERS = 6, MAX_NPC = 5, MAX_NPC_PATH = 200 }; @@ -92,7 +92,7 @@ class SherlockEngine; class People { private: SherlockEngine *_vm; - Person _data[MAX_PLAYERS]; + Person _data[MAX_CHARACTERS]; int _oldWalkSequence; int _srcZone, _destZone; public: @@ -120,20 +120,15 @@ public: ~People(); Person &operator[](PeopleId id) { - assert(id < MAX_PLAYERS); + assert(id < MAX_CHARACTERS); return _data[id]; } Person &operator[](int idx) { - assert(idx < MAX_PLAYERS); + assert(idx < MAX_CHARACTERS); return _data[idx]; } /** - * Returns true if Sherlock is visible on the screen and enabled - */ - bool isHolmesActive() const { return _data[0]._walkLoaded && _holmesOn; } - - /** * Reset the player data */ void reset(); diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp index 989927b9ba..d7519d5c47 100644 --- a/engines/sherlock/scene.cpp +++ b/engines/sherlock/scene.cpp @@ -833,11 +833,14 @@ void Scene::transitionToScene() { updateBackground(); + // Actually do the transition if (screen._fadeStyle) screen.randomTransition(); else screen.blitFrom(screen._backBuffer1); + screen.update(); + // Start any initial animation for the scene if (cAnimNum != -1) { CAnim &c = _cAnim[cAnimNum]; Common::Point pt = c._goto; @@ -865,19 +868,26 @@ int Scene::toggleObject(const Common::String &name) { void Scene::updateBackground() { People &people = *_vm->_people; - Screen &screen = *_vm->_screen; - Sprite &player = people[AL]; - - // Restrict drawing window - screen.setDisplayBounds(Common::Rect(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCENE_HEIGHT)); // Update Holmes if he's turned on - if (people._holmesOn) - player.adjustSprite(); + for (int idx = 0; idx < MAX_CHARACTERS; ++idx) { + if (people[idx]._type == CHARACTER) + people[idx].adjustSprite(); + } // Flag the bg shapes which need to be redrawn - checkBgShapes(player._imageFrame, Common::Point(player._position.x / 100, - player._position.y / 100)); + checkBgShapes(); + + // Draw the shapes for the scene + drawAllShapes(); +} + +void Scene::drawAllShapes() { + People &people = *_vm->_people; + Screen &screen = *_vm->_screen; + + // Restrict drawing window + screen.setDisplayBounds(Common::Rect(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCENE_HEIGHT)); // Draw all active shapes which are behind the person for (uint idx = 0; idx < _bgShapes.size(); ++idx) { @@ -889,7 +899,7 @@ void Scene::updateBackground() { for (uint idx = 0; idx < _canimShapes.size(); ++idx) { if (_canimShapes[idx]._type == ACTIVE_BG_SHAPE && _canimShapes[idx]._misc == BEHIND) screen._backBuffer->transBlitFrom(*_canimShapes[idx]._imageFrame, - _canimShapes[idx]._position, _canimShapes[idx]._flags & OBJ_FLIPPED); + _canimShapes[idx]._position, _canimShapes[idx]._flags & OBJ_FLIPPED); } // Draw all active shapes which are normal and behind the person @@ -902,33 +912,37 @@ void Scene::updateBackground() { for (uint idx = 0; idx < _canimShapes.size(); ++idx) { if (_canimShapes[idx]._type == ACTIVE_BG_SHAPE && _canimShapes[idx]._misc == NORMAL_BEHIND) screen._backBuffer->transBlitFrom(*_canimShapes[idx]._imageFrame, _canimShapes[idx]._position, - _canimShapes[idx]._flags & OBJ_FLIPPED); + _canimShapes[idx]._flags & OBJ_FLIPPED); } - // Draw the player if he's active - if (player._type == CHARACTER && people.isHolmesActive()) { - bool flipped = player._sequenceNumber == WALK_LEFT || player._sequenceNumber == STOP_LEFT || - player._sequenceNumber == WALK_UPLEFT || player._sequenceNumber == STOP_UPLEFT || - player._sequenceNumber == WALK_DOWNRIGHT || player._sequenceNumber == STOP_DOWNRIGHT; + // Draw any active characters + for (int idx = 0; idx < MAX_CHARACTERS; ++idx) { + Person &p = people[idx]; + if (p._type == CHARACTER && p._walkLoaded) { + bool flipped = IS_SERRATED_SCALPEL && ( + p._sequenceNumber == WALK_LEFT || p._sequenceNumber == STOP_LEFT || + p._sequenceNumber == WALK_UPLEFT || p._sequenceNumber == STOP_UPLEFT || + p._sequenceNumber == WALK_DOWNRIGHT || p._sequenceNumber == STOP_DOWNRIGHT); - screen._backBuffer->transBlitFrom(*player._imageFrame, Common::Point(player._position.x / 100, - player._position.y / 100 - player.frameHeight()), flipped); + screen._backBuffer->transBlitFrom(*p._imageFrame, Common::Point(p._position.x / 100, + p._position.y / 100 - p.frameHeight()), flipped); + } } // Draw all static and active shapes that are NORMAL and are in front of the player for (uint idx = 0; idx < _bgShapes.size(); ++idx) { if ((_bgShapes[idx]._type == ACTIVE_BG_SHAPE || _bgShapes[idx]._type == STATIC_BG_SHAPE) && - _bgShapes[idx]._misc == NORMAL_FORWARD) + _bgShapes[idx]._misc == NORMAL_FORWARD) screen._backBuffer->transBlitFrom(*_bgShapes[idx]._imageFrame, _bgShapes[idx]._position, - _bgShapes[idx]._flags & OBJ_FLIPPED); + _bgShapes[idx]._flags & OBJ_FLIPPED); } // Draw all static and active canimations that are NORMAL and are in front of the player for (uint idx = 0; idx < _canimShapes.size(); ++idx) { if ((_canimShapes[idx]._type == ACTIVE_BG_SHAPE || _canimShapes[idx]._type == STATIC_BG_SHAPE) && - _canimShapes[idx]._misc == NORMAL_FORWARD) + _canimShapes[idx]._misc == NORMAL_FORWARD) screen._backBuffer->transBlitFrom(*_canimShapes[idx]._imageFrame, _canimShapes[idx]._position, - _canimShapes[idx]._flags & OBJ_FLIPPED); + _canimShapes[idx]._flags & OBJ_FLIPPED); } // Draw all static and active shapes that are FORWARD @@ -938,9 +952,9 @@ void Scene::updateBackground() { _bgShapes[idx].frameHeight()); if ((_bgShapes[idx]._type == ACTIVE_BG_SHAPE || _bgShapes[idx]._type == STATIC_BG_SHAPE) && - _bgShapes[idx]._misc == FORWARD) + _bgShapes[idx]._misc == FORWARD) screen._backBuffer->transBlitFrom(*_bgShapes[idx]._imageFrame, _bgShapes[idx]._position, - _bgShapes[idx]._flags & OBJ_FLIPPED); + _bgShapes[idx]._flags & OBJ_FLIPPED); } // Draw all static and active canimations that are forward @@ -948,7 +962,7 @@ void Scene::updateBackground() { if ((_canimShapes[idx]._type == ACTIVE_BG_SHAPE || _canimShapes[idx]._type == STATIC_BG_SHAPE) && _canimShapes[idx]._misc == FORWARD) screen._backBuffer->transBlitFrom(*_canimShapes[idx]._imageFrame, _canimShapes[idx]._position, - _canimShapes[idx]._flags & OBJ_FLIPPED); + _canimShapes[idx]._flags & OBJ_FLIPPED); } screen.resetDisplayBounds(); @@ -963,7 +977,11 @@ Exit *Scene::checkForExit(const Common::Rect &r) { return nullptr; } -void Scene::checkBgShapes(ImageFrame *frame, const Common::Point &pt) { +void Scene::checkBgShapes() { + People &people = *_vm->_people; + Person &holmes = people._player; + Common::Point pt(holmes._position.x / 100, holmes._position.y / 100); + // Iterate through the shapes for (uint idx = 0; idx < _bgShapes.size(); ++idx) { Object &obj = _bgShapes[idx]; @@ -986,11 +1004,9 @@ void Scene::checkBgShapes(ImageFrame *frame, const Common::Point &pt) { if ((obj._flags & 5) == 1) { obj._misc = (pt.y < (obj._position.y + obj._imageFrame->_frame.h - 1)) ? NORMAL_FORWARD : NORMAL_BEHIND; - } - else if (!(obj._flags & 1)) { + } else if (!(obj._flags & 1)) { obj._misc = BEHIND; - } - else if (obj._flags & 4) { + } else if (obj._flags & 4) { obj._misc = FORWARD; } } @@ -1345,8 +1361,7 @@ void Scene::doBgAnim() { people[AL].adjustSprite(); // Flag the bg shapes which need to be redrawn - checkBgShapes(people[AL]._imageFrame, - Common::Point(people[AL]._position.x / 100, people[AL]._position.y / 100)); + checkBgShapes(); if (_currentScene == 12 && IS_SERRATED_SCALPEL) ((Scalpel::ScalpelEngine *)_vm)->doMirror12(); @@ -1382,7 +1397,7 @@ void Scene::doBgAnim() { } // Draw the person if not animating - if (people[AL]._type == CHARACTER && people.isHolmesActive()) { + if (people[AL]._type == CHARACTER && people[AL]._walkLoaded) { // If Holmes is too far to the right, move him back so he's on-screen int xRight = SHERLOCK_SCREEN_WIDTH - 2 - people[AL]._imageFrame->_frame.w; int tempX = MIN(people[AL]._position.x / 100, xRight); diff --git a/engines/sherlock/scene.h b/engines/sherlock/scene.h index b0b5624840..806726868a 100644 --- a/engines/sherlock/scene.h +++ b/engines/sherlock/scene.h @@ -184,7 +184,7 @@ private: * it will flag it as needing to be drawn. If a non-animating shape is * colliding with another shape, it will also flag it as needing drawing */ - void checkBgShapes(ImageFrame *frame, const Common::Point &pt); + void checkBgShapes(); /** * Restores objects to the correct status. This ensures that things like being opened or moved @@ -192,6 +192,10 @@ private: */ void saveSceneStatus(); + /** + * Draw all the shapes, people and NPCs in the correct order + */ + void drawAllShapes(); public: int _currentScene; int _goToScene; diff --git a/engines/sherlock/sherlock.h b/engines/sherlock/sherlock.h index bf8c0d6aaf..467f20e381 100644 --- a/engines/sherlock/sherlock.h +++ b/engines/sherlock/sherlock.h @@ -60,7 +60,7 @@ enum GameType { #define SHERLOCK_SCREEN_WIDTH _vm->_screen->w() #define SHERLOCK_SCREEN_HEIGHT _vm->_screen->h() -#define SHERLOCK_SCENE_HEIGHT 138 +#define SHERLOCK_SCENE_HEIGHT (IS_SERRATED_SCALPEL ? 138 : 480) struct SherlockGameDescription; diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp index e3f8c7b8dd..b4be5eed8b 100644 --- a/engines/sherlock/talk.cpp +++ b/engines/sherlock/talk.cpp @@ -1578,18 +1578,14 @@ OpcodeReturn Talk::cmdGotoScene(const byte *&str) { OpcodeReturn Talk::cmdHolmesOff(const byte *&str) { People &people = *_vm->_people; - people._holmesOn = false; - if (IS_ROSE_TATTOO) - people[PLAYER]._type = REMOVE; + people[PLAYER]._type = REMOVE; return RET_SUCCESS; } OpcodeReturn Talk::cmdHolmesOn(const byte *&str) { People &people = *_vm->_people; - people._holmesOn = true; - if (IS_ROSE_TATTOO) - people[PLAYER]._type = CHARACTER; + people[PLAYER]._type = CHARACTER; return RET_SUCCESS; } |