Skip to content

Commit

Permalink
SHERLOCK: Fix People data initialization and general start fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed May 25, 2015
1 parent 1f9f01c commit 8331fa8
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 80 deletions.
2 changes: 2 additions & 0 deletions engines/sherlock/events.cpp
Expand Up @@ -42,6 +42,8 @@ Events::Events(SherlockEngine *vm) {
_pressed = _released = false;
_rightPressed = _rightReleased = false;
_oldButtons = _oldRightButton = false;

loadCursors("rmouse.vgs");
}

Events::~Events() {
Expand Down
121 changes: 74 additions & 47 deletions engines/sherlock/objects.h
Expand Up @@ -116,12 +116,43 @@ struct WalkSequence {
void load(Common::SeekableReadStream &s);
};

enum { REVERSE_DIRECTION = 0x80 };
#define NAMES_COUNT 4

struct ActionType {
int _cAnimNum;
int _cAnimSpeed;
Common::String _names[NAMES_COUNT];

/**
* Load the data for the action
*/
void load(Common::SeekableReadStream &s);
};

struct UseType {
int _cAnimNum;
int _cAnimSpeed;
Common::String _names[NAMES_COUNT];
int _useFlag; // Which flag USE will set (if any)
Common::String _target;
Common::String _verb;

UseType();

/**
* Load the data for the UseType
*/
void load(Common::SeekableReadStream &s, bool isRoseTattoo);
};


class Sprite {
private:
static SherlockEngine *_vm;
public:
Common::String _name;
Common::String _description;
Common::String _name;
Common::String _description;
Common::String _examine; // Examine in-depth description
Common::String _pickUp; // Message for if you can't pick up object

Expand All @@ -142,73 +173,69 @@ class Sprite {
int _status; // Status: open/closed, moved/not moved
int8 _misc; // Miscellaneous use
int _numFrames; // How many frames the object has
ImageFile *_altImages;
bool _altSequences;

// Rose Tattoo fields
int _startSeq; // Frame sequence starts at
int _flags; // Flags for the sprite
int _aType; // Tells if this is an object, person, talk, etc.
int _lookFrames; // How many frames to play of a canim before pausing
int _seqCounter; // How many times the sequence has been run
Common::Point _lookPosition; // Where to look when examining object
int _lookFacing; // Direction to face when examining object
int _lookCAnim;
int _seqStack; // Allow gosubs to return to calling frame
int _seqTo; // Allows 1-5, 8-3 type sequences encoded in 2 bytes
uint _descOffset; // Tells where description starts in description text for scene
int _seqCounter2; // Counter of calling frame sequence
uint _seqSize; // Size of sequence
UseType _use[6];
int _quickDraw; // Flag telling whether to use quick draw routine or not
int _scaleVal; // Tells how to scale the sprite
int _requiredFlags1; // This flag must also be set, or the sprite is hidden
int _gotoSeq; // Used by Talk to tell which sequence to goto when able
int _talkSeq; // Tells which talk sequence currently in use (Talk or Listen)
int _restoreSlot; // Used when talk returns to the previous sequence

ImageFrame *_stopFrames[8]; // Stop/rest frame for each direction
ImageFile *_altImages; // Images used for alternate NPC sequences
bool _altSequences; // Which of the sequences the alt graphics apply to (0: main, 1=NPC seq)
int _centerWalk; // Flag telling the walk code to offset the walk destination
Common::Point _adjust; // Fine tuning adjustment to position when drawn
int _oldWalkSequence;
public:
Sprite() { clear(); }

static void setVm(SherlockEngine *vm) { _vm = vm; }

/**
* Reset the data for the sprite
*/
* Reset the data for the sprite
*/
void clear();

/**
* Updates the image frame poiner for the sprite
*/
* Updates the image frame poiner for the sprite
*/
void setImageFrame();

/**
* This adjusts the sprites position, as well as it's animation sequence:
*/
* This adjusts the sprites position, as well as it's animation sequence:
*/
void adjustSprite();

/**
* Checks the sprite's position to see if it's collided with any special objects
*/
* Checks the sprite's position to see if it's collided with any special objects
*/
void checkSprite();

/**
* Return frame width
*/
* Return frame width
*/
int frameWidth() const { return _imageFrame ? _imageFrame->_frame.w : 0; }

/**
* Return frame height
*/
int frameHeight() const { return _imageFrame ? _imageFrame->_frame.h : 0; }
};

enum { REVERSE_DIRECTION = 0x80 };
#define NAMES_COUNT 4

struct ActionType {
int _cAnimNum;
int _cAnimSpeed;
Common::String _names[NAMES_COUNT];

/**
* Load the data for the action
*/
void load(Common::SeekableReadStream &s);
};

struct UseType {
int _cAnimNum;
int _cAnimSpeed;
Common::String _names[NAMES_COUNT];
int _useFlag; // Which flag USE will set (if any)
Common::String _target;
Common::String _verb;

UseType();

/**
* Load the data for the UseType
*/
void load(Common::SeekableReadStream &s, bool isRoseTattoo);
* Return frame height
*/
int frameHeight() const { return _imageFrame ? _imageFrame->_frame.h : 0; }
};

enum { OBJ_BEHIND = 1, OBJ_FLIPPED = 2, OBJ_FORWARD = 4, TURNON_OBJ = 0x20, TURNOFF_OBJ = 0x40 };
Expand Down
79 changes: 49 additions & 30 deletions engines/sherlock/people.cpp
Expand Up @@ -124,36 +124,55 @@ People::~People() {
}

void People::reset() {
// Note: The engine has theoretical support for two player characters but only the first one is used.
// Watson is, instead, handled by a different sprite in each scene, with a very simple initial movement, if any
Sprite &p = _data[PLAYER];

p._description = "Sherlock Holmes!";
p._type = CHARACTER;
p._position = Common::Point(10000, 11000);
p._sequenceNumber = STOP_DOWNRIGHT;
p._imageFrame = nullptr;
p._frameNumber = 1;
p._delta = Common::Point(0, 0);
p._oldPosition = Common::Point(0, 0);
p._oldSize = Common::Point(0, 0);
p._misc = 0;
p._walkCount = 0;
p._pickUp = "";
p._allow = 0;
p._noShapeSize = Common::Point(0, 0);
p._goto = Common::Point(0, 0);
p._status = 0;

// Load the default walk sequences
p._walkSequences.resize(MAX_HOLMES_SEQUENCE);
for (int idx = 0; idx < MAX_HOLMES_SEQUENCE; ++idx) {
p._walkSequences[idx]._sequences.clear();

const byte *pSrc = &CHARACTER_SEQUENCES[idx][0];
do {
p._walkSequences[idx]._sequences.push_back(*pSrc);
} while (*pSrc++);
_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;
for (int idx = 0; idx < count; ++idx) {
Sprite &p = _data[idx];

p._type = (idx == 0) ? CHARACTER : INVALID;
if (IS_SERRATED_SCALPEL)
p._position = Point32(10000, 11000);
else
p._position = Point32(36000, 29000);

p._sequenceNumber = STOP_DOWNRIGHT;
p._imageFrame = nullptr;
p._frameNumber = 1;
p._delta = Common::Point(0, 0);
p._oldPosition = Common::Point(0, 0);
p._oldSize = Common::Point(0, 0);
p._misc = 0;
p._walkCount = 0;
p._pickUp = "";
p._allow = 0;
p._noShapeSize = Common::Point(0, 0);
p._goto = Common::Point(0, 0);
p._status = 0;
p._seqTo = 0;
p._seqCounter = p._seqCounter2 = 0;
p._seqStack = 0;
p._gotoSeq = p._talkSeq = 0;
p._restoreSlot = 0;
p._startSeq = 0;
p._walkSequences.clear();
p._altImages = nullptr;
p._altSequences = 0;
p._centerWalk = true;
p._adjust = Common::Point(0, 0);

// Load the default walk sequences
p._oldWalkSequence = -1;
p._walkSequences.resize(MAX_HOLMES_SEQUENCE);
for (int idx = 0; idx < MAX_HOLMES_SEQUENCE; ++idx) {
p._walkSequences[idx]._sequences.clear();

const byte *pSrc = &CHARACTER_SEQUENCES[idx][0];
do {
p._walkSequences[idx]._sequences.push_back(*pSrc);
} while (*pSrc++);
}
}

// Reset any walk path in progress when Sherlock leaves scenes
Expand Down
1 change: 0 additions & 1 deletion engines/sherlock/scalpel/scalpel.cpp
Expand Up @@ -813,7 +813,6 @@ void ScalpelEngine::startScene() {
break;
}

_events->loadCursors("rmouse.vgs");
_events->setCursor(ARROW);

if (_scene->_goToScene == 99) {
Expand Down
12 changes: 10 additions & 2 deletions engines/sherlock/talk.cpp
Expand Up @@ -1577,12 +1577,20 @@ OpcodeReturn Talk::cmdGotoScene(const byte *&str) {
}

OpcodeReturn Talk::cmdHolmesOff(const byte *&str) {
_vm->_people->_holmesOn = false;
People &people = *_vm->_people;
people._holmesOn = false;
if (IS_ROSE_TATTOO)
people[PLAYER]._type = REMOVE;

return RET_SUCCESS;
}

OpcodeReturn Talk::cmdHolmesOn(const byte *&str) {
_vm->_people->_holmesOn = true;
People &people = *_vm->_people;
people._holmesOn = true;
if (IS_ROSE_TATTOO)
people[PLAYER]._type = CHARACTER;

return RET_SUCCESS;
}

Expand Down

0 comments on commit 8331fa8

Please sign in to comment.