aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sherlock/map.cpp8
-rw-r--r--engines/sherlock/objects.cpp34
-rw-r--r--engines/sherlock/objects.h10
-rw-r--r--engines/sherlock/people.cpp55
-rw-r--r--engines/sherlock/people.h4
-rw-r--r--engines/sherlock/scalpel/scalpel.cpp6
-rw-r--r--engines/sherlock/scalpel/scalpel_user_interface.cpp6
-rw-r--r--engines/sherlock/scene.cpp9
-rw-r--r--engines/sherlock/talk.cpp6
9 files changed, 76 insertions, 62 deletions
diff --git a/engines/sherlock/map.cpp b/engines/sherlock/map.cpp
index ffbca3fb42..dfc9798822 100644
--- a/engines/sherlock/map.cpp
+++ b/engines/sherlock/map.cpp
@@ -392,8 +392,8 @@ void Map::updateMap(bool flushScreen) {
people[AL].adjustSprite();
- _lDrawnPos.x = hPos.x = people[AL]._position.x / 100 - _bigPos.x;
- _lDrawnPos.y = hPos.y = people[AL]._position.y / 100 - people[AL].frameHeight() - _bigPos.y;
+ _lDrawnPos.x = hPos.x = people[AL]._position.x / FIXED_INT_MULTIPLIER - _bigPos.x;
+ _lDrawnPos.y = hPos.y = people[AL]._position.y / FIXED_INT_MULTIPLIER - people[AL].frameHeight() - _bigPos.y;
// Draw the person icon
saveIcon(people[AL]._imageFrame, hPos);
@@ -407,8 +407,8 @@ void Map::updateMap(bool flushScreen) {
screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
} else if (!_drawMap) {
if (hPos.x > 0 && hPos.y >= 0 && hPos.x < SHERLOCK_SCREEN_WIDTH && hPos.y < SHERLOCK_SCREEN_HEIGHT)
- screen.flushImage(people[AL]._imageFrame, Common::Point(people[AL]._position.x / 100 - _bigPos.x,
- people[AL]._position.y / 100 - people[AL].frameHeight() - _bigPos.y),
+ screen.flushImage(people[AL]._imageFrame, Common::Point(people[AL]._position.x / FIXED_INT_MULTIPLIER - _bigPos.x,
+ people[AL]._position.y / FIXED_INT_MULTIPLIER - people[AL].frameHeight() - _bigPos.y),
&people[AL]._oldPosition.x, &people[AL]._oldPosition.y, &people[AL]._oldSize.x, &people[AL]._oldSize.y);
if (osPos.x != -1)
diff --git a/engines/sherlock/objects.cpp b/engines/sherlock/objects.cpp
index 0b3c294376..625371267f 100644
--- a/engines/sherlock/objects.cpp
+++ b/engines/sherlock/objects.cpp
@@ -146,18 +146,18 @@ void Sprite::adjustSprite() {
}
if (_type == CHARACTER && !map._active) {
- if ((_position.y / 100) > LOWER_LIMIT) {
- _position.y = LOWER_LIMIT * 100;
+ if ((_position.y / FIXED_INT_MULTIPLIER) > LOWER_LIMIT) {
+ _position.y = LOWER_LIMIT * FIXED_INT_MULTIPLIER;
people.gotoStand(*this);
}
- if ((_position.y / 100) < UPPER_LIMIT) {
- _position.y = UPPER_LIMIT * 100;
+ if ((_position.y / FIXED_INT_MULTIPLIER) < UPPER_LIMIT) {
+ _position.y = UPPER_LIMIT * FIXED_INT_MULTIPLIER;
people.gotoStand(*this);
}
- if ((_position.x / 100) < LEFT_LIMIT) {
- _position.x = LEFT_LIMIT * 100;
+ if ((_position.x / FIXED_INT_MULTIPLIER) < LEFT_LIMIT) {
+ _position.x = LEFT_LIMIT * FIXED_INT_MULTIPLIER;
people.gotoStand(*this);
}
} else if (!map._active) {
@@ -196,8 +196,8 @@ void Sprite::adjustSprite() {
// Check to see if character has entered an exit zone
if (!_walkCount && scene._walkedInScene && scene._goToScene == -1) {
- Common::Rect charRect(_position.x / 100 - 5, _position.y / 100 - 2,
- _position.x / 100 + 5, _position.y / 100 + 2);
+ Common::Rect charRect(_position.x / FIXED_INT_MULTIPLIER - 5, _position.y / FIXED_INT_MULTIPLIER - 2,
+ _position.x / FIXED_INT_MULTIPLIER + 5, _position.y / FIXED_INT_MULTIPLIER + 2);
Exit *exit = scene.checkForExit(charRect);
if (exit) {
@@ -222,7 +222,7 @@ void Sprite::checkSprite() {
Talk &talk = *_vm->_talk;
Point32 pt;
Common::Rect objBounds;
- Common::Point spritePt(_position.x / 100, _position.y / 100);
+ Common::Point spritePt(_position.x / FIXED_INT_MULTIPLIER, _position.y / FIXED_INT_MULTIPLIER);
if (!talk._talkCounter && _type == CHARACTER) {
pt = _walkCount ? _position + _delta : _position;
@@ -657,8 +657,13 @@ void Object::load(Common::SeekableReadStream &s, bool isRoseTattoo) {
_oldPosition.y = s.readSint16LE();
_oldSize.x = s.readUint16LE();
_oldSize.y = s.readUint16LE();
+
_goto.x = s.readSint16LE();
_goto.y = s.readSint16LE();
+ if (!isRoseTattoo) {
+ _goto.x = _goto.x * FIXED_INT_MULTIPLIER / 100;
+ _goto.y = _goto.y * FIXED_INT_MULTIPLIER / 100;
+ }
_pickup = isRoseTattoo ? 0 : s.readByte();
_defaultCommand = isRoseTattoo ? 0 : s.readByte();
@@ -678,8 +683,8 @@ void Object::load(Common::SeekableReadStream &s, bool isRoseTattoo) {
_aType = (AType)s.readByte();
_lookFrames = s.readByte();
_seqCounter = s.readByte();
- _lookPosition.x = s.readUint16LE();
- _lookPosition.y = isRoseTattoo ? s.readSint16LE() : s.readByte();
+ _lookPosition.x = s.readUint16LE() * FIXED_INT_MULTIPLIER / 100;
+ _lookPosition.y = (isRoseTattoo ? s.readSint16LE() : s.readByte()) * FIXED_INT_MULTIPLIER;
_lookFacing = s.readByte();
_lookcAnim = s.readByte();
@@ -1418,6 +1423,13 @@ void CAnim::load(Common::SeekableReadStream &s, bool isRoseTattoo) {
_gotoDir = s.readSint16LE();
_teleportPos.x = s.readSint16LE();
_teleportPos.y = s.readSint16LE();
+ if (!isRoseTattoo) {
+ _goto.x = _goto.x * FIXED_INT_MULTIPLIER / 100;
+ _goto.y = _goto.y * FIXED_INT_MULTIPLIER / 100;
+ _teleportPos.x = _teleportPos.x * FIXED_INT_MULTIPLIER / 100;
+ _teleportPos.y = _teleportPos.y * FIXED_INT_MULTIPLIER / 100;
+ }
+
_teleportDir = s.readSint16LE();
}
diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h
index 65840af532..88e9db116e 100644
--- a/engines/sherlock/objects.h
+++ b/engines/sherlock/objects.h
@@ -76,7 +76,7 @@ enum {
#define MAX_HOLMES_SEQUENCE 16
#define MAX_FRAME 30
-#define FIXED_INT_MULTIPLIER 100
+#define FIXED_INT_MULTIPLIER 1000
// code put into sequences to defines 1-10 type seqs
#define SEQ_TO_CODE 67
@@ -328,7 +328,7 @@ public:
Common::Point _delta; // Momvement amount
Common::Point _oldPosition; // Old position
Common::Point _oldSize; // Image's old size
- Common::Point _goto; // Walk destination
+ Point32 _goto; // Walk destination
int _pickup;
int _defaultCommand; // Default right-click command
@@ -342,7 +342,7 @@ public:
AType _aType; // Tells if this is an object, person, talk, etc.
int _lookFrames; // How many frames to play of the look anim before pausing
int _seqCounter; // How many times this sequence has been executed
- Common::Point _lookPosition; // Where to walk when examining object
+ Point32 _lookPosition; // Where to walk when examining object
int _lookFacing; // Direction to face when examining object
int _lookcAnim;
int _seqStack; // Allows gosubs to return to calling frame
@@ -439,9 +439,9 @@ struct CAnim {
Common::Point _position; // Position
int _size; // Size of uncompressed animation
int _flags; // Tells if can be walked behind
- Common::Point _goto; // coords holmes should walk to before starting canim
+ Point32 _goto; // coords holmes should walk to before starting canim
int _gotoDir;
- Common::Point _teleportPos; // Location Holmes shoul teleport to after
+ Point32 _teleportPos; // Location Holmes shoul teleport to after
int _teleportDir; // playing canim
// Scalpel specific
diff --git a/engines/sherlock/people.cpp b/engines/sherlock/people.cpp
index ec67b4469f..f4060f65da 100644
--- a/engines/sherlock/people.cpp
+++ b/engines/sherlock/people.cpp
@@ -98,7 +98,7 @@ People::People(SherlockEngine *vm) : _vm(vm), _player(_data[0]) {
_speakerFlip = false;
_holmesFlip = false;
_holmesQuotient = 0;
- _hSavedPos = Common::Point(-1, -1);
+ _hSavedPos = Point32(-1, -1);
_hSavedFacing = -1;
_forceWalkReload = false;
_useWalkLib = false;
@@ -134,7 +134,7 @@ void People::reset() {
p._sequenceNumber = STOP_DOWNRIGHT;
p._imageFrame = nullptr;
p._frameNumber = 1;
- p._delta = Common::Point(0, 0);
+ p._delta = Point32(0, 0);
p._oldPosition = Common::Point(0, 0);
p._oldSize = Common::Point(0, 0);
p._misc = 0;
@@ -297,8 +297,8 @@ void People::setWalking() {
_walkDest.x -= temp;
delta = Common::Point(
- ABS(_player._position.x / 100 - _walkDest.x),
- ABS(_player._position.y / 100 - _walkDest.y)
+ ABS(_player._position.x / FIXED_INT_MULTIPLIER - _walkDest.x),
+ ABS(_player._position.y / FIXED_INT_MULTIPLIER - _walkDest.y)
);
// If we're ready to move a sufficient distance, that's it. Otherwise,
@@ -316,20 +316,20 @@ void People::setWalking() {
if (delta.x >= delta.y) {
// Set the initial frame sequence for the left and right, as well
// as setting the delta x depending on direction
- if (_walkDest.x < (_player._position.x / 100)) {
+ if (_walkDest.x < (_player._position.x / FIXED_INT_MULTIPLIER)) {
_player._sequenceNumber = (map._active ? (int)MAP_LEFT : (int)WALK_LEFT);
- _player._delta.x = speed.x * -100;
+ _player._delta.x = speed.x * -FIXED_INT_MULTIPLIER;
} else {
_player._sequenceNumber = (map._active ? (int)MAP_RIGHT : (int)WALK_RIGHT);
- _player._delta.x = speed.x * 100;
+ _player._delta.x = speed.x * FIXED_INT_MULTIPLIER;
}
// See if the x delta is too small to be divided by the speed, since
// this would cause a divide by zero error
if (delta.x >= speed.x) {
// Det the delta y
- _player._delta.y = (delta.y * 100) / (delta.x / speed.x);
- if (_walkDest.y < (_player._position.y / 100))
+ _player._delta.y = (delta.y * FIXED_INT_MULTIPLIER) / (delta.x / speed.x);
+ if (_walkDest.y < (_player._position.y / FIXED_INT_MULTIPLIER))
_player._delta.y = -_player._delta.y;
// Set how many times we should add the delta to the player's position
@@ -337,8 +337,9 @@ void People::setWalking() {
} else {
// The delta x was less than the speed (ie. we're really close to
// the destination). So set delta to 0 so the player won't move
- _player._delta = Common::Point(0, 0);
- _player._position = Common::Point(_walkDest.x * 100, _walkDest.y * 100);
+ _player._delta = Point32(0, 0);
+ _player._position = Point32(_walkDest.x * FIXED_INT_MULTIPLIER, _walkDest.y * FIXED_INT_MULTIPLIER);
+assert(_player._position.y >= 10000);/***DEBUG****/
_player._walkCount = 1;
}
@@ -369,12 +370,12 @@ void People::setWalking() {
} else {
// Major movement is vertical, so set the sequence for up and down,
// and set the delta Y depending on the direction
- if (_walkDest.y < (_player._position.y / 100)) {
+ if (_walkDest.y < (_player._position.y / FIXED_INT_MULTIPLIER)) {
_player._sequenceNumber = WALK_UP;
- _player._delta.y = speed.y * -100;
+ _player._delta.y = speed.y * -FIXED_INT_MULTIPLIER;
} else {
_player._sequenceNumber = WALK_DOWN;
- _player._delta.y = speed.y * 100;
+ _player._delta.y = speed.y * FIXED_INT_MULTIPLIER;
}
// If we're on the overhead map, set the sequence so we keep moving
@@ -383,8 +384,8 @@ void People::setWalking() {
_player._sequenceNumber = (oldDirection == -1) ? MAP_RIGHT : oldDirection;
// Set the delta x
- _player._delta.x = (delta.x * 100) / (delta.y / speed.y);
- if (_walkDest.x < (_player._position.x / 100))
+ _player._delta.x = (delta.x * FIXED_INT_MULTIPLIER) / (delta.y / speed.y);
+ if (_walkDest.x < (_player._position.x / FIXED_INT_MULTIPLIER))
_player._delta.x = -_player._delta.x;
_player._walkCount = delta.y / speed.y;
@@ -451,15 +452,15 @@ void People::gotoStand(Sprite &sprite) {
if (map._active) {
sprite._sequenceNumber = 0;
- _player._position.x = (map[map._charPoint].x - 6) * 100;
- _player._position.y = (map[map._charPoint].y + 10) * 100;
+ _player._position.x = (map[map._charPoint].x - 6) * FIXED_INT_MULTIPLIER;
+ _player._position.y = (map[map._charPoint].y + 10) * FIXED_INT_MULTIPLIER;
}
_oldWalkSequence = -1;
_allowWalkAbort = true;
}
-void People::walkToCoords(const Common::Point &destPos, int destDir) {
+void People::walkToCoords(const Point32 &destPos, int destDir) {
Events &events = *_vm->_events;
Scene &scene = *_vm->_scene;
Talk &talk = *_vm->_talk;
@@ -467,7 +468,7 @@ void People::walkToCoords(const Common::Point &destPos, int destDir) {
CursorId oldCursor = events.getCursor();
events.setCursor(WAIT);
- _walkDest = Common::Point(destPos.x / 100 + 10, destPos.y / 100);
+ _walkDest = Common::Point(destPos.x / FIXED_INT_MULTIPLIER + 10, destPos.y / FIXED_INT_MULTIPLIER);
_allowWalkAbort = true;
goAllTheWay();
@@ -480,6 +481,8 @@ void People::walkToCoords(const Common::Point &destPos, int destDir) {
if (!talk._talkToAbort) {
// Put player exactly on destination position, and set direction
_player._position = destPos;
+assert(_player._position.y >= 10000);/***DEBUG****/
+
_player._sequenceNumber = destDir;
gotoStand(_player);
@@ -493,8 +496,8 @@ void People::walkToCoords(const Common::Point &destPos, int destDir) {
void People::goAllTheWay() {
Scene &scene = *_vm->_scene;
- Common::Point srcPt(_player._position.x / 100 + _player.frameWidth() / 2,
- _player._position.y / 100);
+ Common::Point srcPt(_player._position.x / FIXED_INT_MULTIPLIER + _player.frameWidth() / 2,
+ _player._position.y / FIXED_INT_MULTIPLIER);
// Get the zone the player is currently in
_srcZone = scene.whichZone(srcPt);
@@ -516,17 +519,17 @@ void People::goAllTheWay() {
const Common::Point destCenter((destRect.left + destRect.right) / 2,
(destRect.top + destRect.bottom) / 2);
const Common::Point delta = _walkDest - destCenter;
- Common::Point pt(destCenter.x * 100, destCenter.y * 100);
+ Point32 pt(destCenter.x * FIXED_INT_MULTIPLIER, destCenter.y * FIXED_INT_MULTIPLIER);
// Move along the line until the zone is left
do {
pt += delta;
- } while (destRect.contains(pt.x / 100, pt.y / 100));
+ } while (destRect.contains(pt.x / FIXED_INT_MULTIPLIER, pt.y / FIXED_INT_MULTIPLIER));
// Set the new walk destination to the last point that was in the
// zone just before it was left
- _walkDest = Common::Point((pt.x - delta.x * 2) / 100,
- (pt.y - delta.y * 2) / 100);
+ _walkDest = Common::Point((pt.x - delta.x * 2) / FIXED_INT_MULTIPLIER,
+ (pt.y - delta.y * 2) / FIXED_INT_MULTIPLIER);
}
// Only do a walk if both zones are acceptable
diff --git a/engines/sherlock/people.h b/engines/sherlock/people.h
index 102d740fb5..c26630c431 100644
--- a/engines/sherlock/people.h
+++ b/engines/sherlock/people.h
@@ -110,7 +110,7 @@ public:
Common::Array<PersonData> _characters;
ImageFile *_talkPics;
Common::Point _walkDest;
- Common::Point _hSavedPos;
+ Point32 _hSavedPos;
int _hSavedFacing;
Common::Queue<Common::Point> _walkTo;
Person &_player;
@@ -172,7 +172,7 @@ public:
/**
* Walk to the co-ordinates passed, and then face the given direction
*/
- void walkToCoords(const Common::Point &destPos, int destDir);
+ void walkToCoords(const Point32 &destPos, int destDir);
/**
* Called to set the character walking to the current cursor location.
diff --git a/engines/sherlock/scalpel/scalpel.cpp b/engines/sherlock/scalpel/scalpel.cpp
index ed531a06c5..39d4437918 100644
--- a/engines/sherlock/scalpel/scalpel.cpp
+++ b/engines/sherlock/scalpel/scalpel.cpp
@@ -687,7 +687,7 @@ void ScalpelEngine::startScene() {
}
void ScalpelEngine::eraseMirror12() {
- Common::Point pt((*_people)[AL]._position.x / 100, (*_people)[AL]._position.y / 100);
+ Common::Point pt((*_people)[AL]._position.x / FIXED_INT_MULTIPLIER, (*_people)[AL]._position.y / FIXED_INT_MULTIPLIER);
// If player is in range of the mirror, then restore background from the secondary back buffer
if (Common::Rect(70, 100, 200, 200).contains(pt)) {
@@ -700,7 +700,7 @@ void ScalpelEngine::doMirror12() {
People &people = *_people;
Person &player = people._player;
- Common::Point pt((*_people)[AL]._position.x / 100, (*_people)[AL]._position.y / 100);
+ Common::Point pt((*_people)[AL]._position.x / FIXED_INT_MULTIPLIER, (*_people)[AL]._position.y / FIXED_INT_MULTIPLIER);
int frameNum = player._walkSequences[player._sequenceNumber][player._frameNumber] +
player._walkSequences[player._sequenceNumber][0] - 2;
@@ -772,7 +772,7 @@ void ScalpelEngine::doMirror12() {
}
void ScalpelEngine::flushMirror12() {
- Common::Point pt((*_people)[AL]._position.x / 100, (*_people)[AL]._position.y / 100);
+ Common::Point pt((*_people)[AL]._position.x / FIXED_INT_MULTIPLIER, (*_people)[AL]._position.y / FIXED_INT_MULTIPLIER);
// If player is in range of the mirror, then draw the entire mirror area to the screen
if (Common::Rect(70, 100, 200, 200).contains(pt))
diff --git a/engines/sherlock/scalpel/scalpel_user_interface.cpp b/engines/sherlock/scalpel/scalpel_user_interface.cpp
index 16f16594f1..e2c66789ad 100644
--- a/engines/sherlock/scalpel/scalpel_user_interface.cpp
+++ b/engines/sherlock/scalpel/scalpel_user_interface.cpp
@@ -500,7 +500,7 @@ void ScalpelUserInterface::examine() {
scene.startCAnim(_cNum, canimSpeed);
} else if (obj._lookPosition.y != 0) {
// Need to walk to the object to be examined
- people.walkToCoords(Common::Point(obj._lookPosition.x, obj._lookPosition.y * 100), obj._lookFacing);
+ people.walkToCoords(obj._lookPosition, obj._lookFacing);
}
if (!talk._talkToAbort) {
@@ -2158,7 +2158,7 @@ void ScalpelUserInterface::checkAction(ActionType &action, const char *const mes
Scene &scene = *_vm->_scene;
Screen &screen = *_vm->_screen;
Talk &talk = *_vm->_talk;
- Common::Point pt(-1, -1);
+ Point32 pt(-1, -1);
if (objNum >= 1000)
// Ignore actions done on characters
@@ -2197,7 +2197,7 @@ void ScalpelUserInterface::checkAction(ActionType &action, const char *const mes
}
}
} else {
- pt = Common::Point(-1, -1);
+ pt = Point32(-1, -1);
dir = -1;
}
diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp
index edb52f3640..ec189ee270 100644
--- a/engines/sherlock/scene.cpp
+++ b/engines/sherlock/scene.cpp
@@ -756,7 +756,7 @@ void Scene::transitionToScene() {
SaveManager &saves = *_vm->_saves;
Screen &screen = *_vm->_screen;
Talk &talk = *_vm->_talk;
- Common::Point &hSavedPos = people._hSavedPos;
+ Point32 &hSavedPos = people._hSavedPos;
int &hSavedFacing = people._hSavedFacing;
if (hSavedPos.x < 1) {
@@ -764,7 +764,7 @@ void Scene::transitionToScene() {
if (_entrance._startPosition.x < 1) {
// No entrance info either, so use defaults
if (IS_SERRATED_SCALPEL) {
- hSavedPos = Common::Point(160 * FIXED_INT_MULTIPLIER, 100 * FIXED_INT_MULTIPLIER);
+ hSavedPos = Point32(160 * FIXED_INT_MULTIPLIER, 100 * FIXED_INT_MULTIPLIER);
hSavedFacing = 4;
} else {
hSavedPos = people[PLAYER]._position;
@@ -772,7 +772,8 @@ void Scene::transitionToScene() {
}
} else {
// setup entrance info
- hSavedPos = _entrance._startPosition;
+ hSavedPos.x = _entrance._startPosition.x * FIXED_INT_MULTIPLIER / 100;
+ hSavedPos.y = _entrance._startPosition.y * FIXED_INT_MULTIPLIER / 100;
hSavedFacing = _entrance._startDir;
}
} else {
@@ -919,7 +920,7 @@ int Scene::startCAnim(int cAnimNum, int playRate) {
Resources &res = *_vm->_res;
Talk &talk = *_vm->_talk;
UserInterface &ui = *_vm->_ui;
- Common::Point tpPos, walkPos;
+ Point32 tpPos, walkPos;
int tpDir, walkDir;
int tFrames = 0;
int gotoCode = -1;
diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp
index d48b66cf8b..dd00d47fb2 100644
--- a/engines/sherlock/talk.cpp
+++ b/engines/sherlock/talk.cpp
@@ -636,8 +636,7 @@ void Talk::talk(int objNum) {
events.setCursor(WAIT);
if (obj._lookPosition.y != 0)
// Need to walk to character first
- people.walkToCoords(Common::Point(obj._lookPosition.x, obj._lookPosition.y * 100),
- obj._lookFacing);
+ people.walkToCoords(obj._lookPosition, obj._lookFacing);
events.setCursor(ARROW);
if (!_talkToAbort)
@@ -652,8 +651,7 @@ void Talk::talk(int objNum) {
events.setCursor(WAIT);
if (obj._lookPosition.y != 0)
// Walk over to person to talk to
- people.walkToCoords(Common::Point(obj._lookPosition.x, obj._lookPosition.y * 100),
- obj._lookFacing);
+ people.walkToCoords(obj._lookPosition, obj._lookFacing);
events.setCursor(ARROW);
if (!_talkToAbort) {