Skip to content

Commit

Permalink
SHERLOCK: Fix loading/handling of sprite offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Apr 24, 2015
1 parent ecd5099 commit 51eb601
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 33 deletions.
4 changes: 2 additions & 2 deletions engines/sherlock/objects.cpp
Expand Up @@ -691,8 +691,8 @@ bool Object::checkEndOfSequence() {

if (seq == 99) {
--_frameNumber;
screen._backBuffer1.transBlitFrom(_imageFrame->_frame, _position);
screen._backBuffer2.transBlitFrom(_imageFrame->_frame, _position);
screen._backBuffer1.transBlitFrom(*_imageFrame, _position);
screen._backBuffer2.transBlitFrom(*_imageFrame, _position);
_type = INVALID;
} else {
setObjSequence(seq, false);
Expand Down
4 changes: 2 additions & 2 deletions engines/sherlock/resources.cpp
Expand Up @@ -298,8 +298,8 @@ void ImageFile::load(Common::SeekableReadStream &stream, bool skipPalette) {
frame._width = stream.readUint16LE() + 1;
frame._height = stream.readUint16LE() + 1;
frame._paletteBase = stream.readByte();
frame._offset.x = stream.readUint16LE();
frame._rleEncoded = ((frame._offset.x & 0xFF) == 1);
frame._rleEncoded = stream.readByte() == 1;
frame._offset.x = stream.readByte();
frame._offset.y = stream.readByte();

frame._rleEncoded = !skipPalette && frame._rleEncoded;
Expand Down
53 changes: 24 additions & 29 deletions engines/sherlock/scene.cpp
Expand Up @@ -710,29 +710,27 @@ void Scene::updateBackground() {
// Draw all active shapes which are behind the person
for (uint idx = 0; idx < _bgShapes.size(); ++idx) {
if (_bgShapes[idx]._type == ACTIVE_BG_SHAPE && _bgShapes[idx]._misc == BEHIND)
surface.transBlitFrom(_bgShapes[idx]._imageFrame->_frame,
_bgShapes[idx]._position, _bgShapes[idx]._flags & 2);
surface.transBlitFrom(*_bgShapes[idx]._imageFrame, _bgShapes[idx]._position, _bgShapes[idx]._flags & 2);
}

// Draw all canimations which are behind the person
for (uint idx = 0; idx < _canimShapes.size(); ++idx) {
if (_canimShapes[idx]._type == ACTIVE_BG_SHAPE && _canimShapes[idx]._misc == BEHIND)
surface.transBlitFrom(_canimShapes[idx]._imageFrame->_frame,
surface.transBlitFrom(*_canimShapes[idx]._imageFrame,
_canimShapes[idx]._position, _canimShapes[idx]._flags & 2);
}

// Draw all active shapes which are normal and behind the person
for (uint idx = 0; idx < _bgShapes.size(); ++idx) {
if (_bgShapes[idx]._type == ACTIVE_BG_SHAPE && _bgShapes[idx]._misc == NORMAL_BEHIND)
surface.transBlitFrom(_bgShapes[idx]._imageFrame->_frame,
_bgShapes[idx]._position, _bgShapes[idx]._flags & 2);
surface.transBlitFrom(*_bgShapes[idx]._imageFrame, _bgShapes[idx]._position, _bgShapes[idx]._flags & 2);
}

// Draw all canimations which are normal and behind the person
for (uint idx = 0; idx < _canimShapes.size(); ++idx) {
if (_canimShapes[idx]._type == ACTIVE_BG_SHAPE && _canimShapes[idx]._misc == NORMAL_BEHIND)
surface.transBlitFrom(_canimShapes[idx]._imageFrame->_frame,
_canimShapes[idx]._position, _canimShapes[idx]._flags & 2);
surface.transBlitFrom(*_canimShapes[idx]._imageFrame, _canimShapes[idx]._position,
_canimShapes[idx]._flags & 2);
}

// Draw the player if he's active
Expand All @@ -741,25 +739,23 @@ void Scene::updateBackground() {
player._sequenceNumber == WALK_UPLEFT || player._sequenceNumber == STOP_UPLEFT ||
player._sequenceNumber == WALK_DOWNRIGHT || player._sequenceNumber == STOP_DOWNRIGHT;

surface.transBlitFrom(player._imageFrame->_frame,
Common::Point(player._position.x / 100,
player._position.y / 100 - player.frameHeight()), flipped);
surface.transBlitFrom(*player._imageFrame, Common::Point(player._position.x / 100,
player._position.y / 100 - player.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)
surface.transBlitFrom(_bgShapes[idx]._imageFrame->_frame,
_bgShapes[idx]._position, _bgShapes[idx]._flags & 2);
surface.transBlitFrom(*_bgShapes[idx]._imageFrame, _bgShapes[idx]._position, _bgShapes[idx]._flags & 2);
}

// 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)
surface.transBlitFrom(_canimShapes[idx]._imageFrame->_frame,
_canimShapes[idx]._position, _canimShapes[idx]._flags & 2);
surface.transBlitFrom(*_canimShapes[idx]._imageFrame, _canimShapes[idx]._position,
_canimShapes[idx]._flags & 2);
}

// Draw all static and active shapes that are FORWARD
Expand All @@ -770,16 +766,15 @@ void Scene::updateBackground() {

if ((_bgShapes[idx]._type == ACTIVE_BG_SHAPE || _bgShapes[idx]._type == STATIC_BG_SHAPE) &&
_bgShapes[idx]._misc == FORWARD)
surface.transBlitFrom(_bgShapes[idx]._imageFrame->_frame,
_bgShapes[idx]._position, _bgShapes[idx]._flags & 2);
surface.transBlitFrom(*_bgShapes[idx]._imageFrame, _bgShapes[idx]._position, _bgShapes[idx]._flags & 2);
}

// Draw all static and active canimations that are forward
for (uint idx = 0; idx < _canimShapes.size(); ++idx) {
if ((_canimShapes[idx]._type == ACTIVE_BG_SHAPE || _canimShapes[idx]._type == STATIC_BG_SHAPE) &&
_canimShapes[idx]._misc == FORWARD)
surface.transBlitFrom(_canimShapes[idx]._imageFrame->_frame,
_canimShapes[idx]._position, _canimShapes[idx]._flags & 2);
surface.transBlitFrom(*_canimShapes[idx]._imageFrame, _canimShapes[idx]._position,
_canimShapes[idx]._flags & 2);
}
}

Expand Down Expand Up @@ -1196,29 +1191,29 @@ void Scene::doBgAnim() {
for (uint idx = 0; idx < _bgShapes.size(); ++idx) {
Object &o = _bgShapes[idx];
if (o._type == ACTIVE_BG_SHAPE && o._misc == BEHIND)
screen._backBuffer1.transBlitFrom(o._imageFrame->_frame, o._position, o._flags & 2);
screen._backBuffer1.transBlitFrom(*o._imageFrame, o._position, o._flags & 2);
}

// Draw all canimations which are behind the person
for (uint idx = 0; idx < _canimShapes.size(); ++idx) {
Object &o = _canimShapes[idx];
if (o._type == ACTIVE_BG_SHAPE && o._misc == BEHIND) {
screen._backBuffer1.transBlitFrom(o._imageFrame->_frame, o._position, o._flags & 2);
screen._backBuffer1.transBlitFrom(*o._imageFrame, o._position, o._flags & 2);
}
}

// Draw all active shapes which are HAPPEN and behind the person
for (uint idx = 0; idx < _bgShapes.size(); ++idx) {
Object &o = _bgShapes[idx];
if (o._type == ACTIVE_BG_SHAPE && o._misc == NORMAL_BEHIND)
screen._backBuffer1.transBlitFrom(o._imageFrame->_frame, o._position, o._flags & 2);
screen._backBuffer1.transBlitFrom(*o._imageFrame, o._position, o._flags & 2);
}

// Draw all canimations which are NORMAL and behind the person
for (uint idx = 0; idx < _canimShapes.size(); ++idx) {
Object &o = _canimShapes[idx];
if (o._type == ACTIVE_BG_SHAPE && o._misc == NORMAL_BEHIND) {
screen._backBuffer1.transBlitFrom(o._imageFrame->_frame, o._position, o._flags & 2);
screen._backBuffer1.transBlitFrom(*o._imageFrame, o._position, o._flags & 2);
}
}

Expand All @@ -1231,50 +1226,50 @@ void Scene::doBgAnim() {
bool flipped = people[AL]._sequenceNumber == WALK_LEFT || people[AL]._sequenceNumber == STOP_LEFT ||
people[AL]._sequenceNumber == WALK_UPLEFT || people[AL]._sequenceNumber == STOP_UPLEFT ||
people[AL]._sequenceNumber == WALK_DOWNRIGHT || people[AL]._sequenceNumber == STOP_DOWNRIGHT;
screen._backBuffer1.transBlitFrom(people[AL]._imageFrame->_frame,
screen._backBuffer1.transBlitFrom(*people[AL]._imageFrame,
Common::Point(tempX, people[AL]._position.y / 100 - people[AL]._imageFrame->_frame.h), flipped);
}

// Draw all static and active shapes are NORMAL and are in front of the person
for (uint idx = 0; idx < _bgShapes.size(); ++idx) {
Object &o = _bgShapes[idx];
if ((o._type == ACTIVE_BG_SHAPE || o._type == STATIC_BG_SHAPE) && o._misc == NORMAL_FORWARD)
screen._backBuffer1.transBlitFrom(o._imageFrame->_frame, o._position, o._flags & 2);
screen._backBuffer1.transBlitFrom(*o._imageFrame, o._position, o._flags & 2);
}

// Draw all static and active canimations that are NORMAL and are in front of the person
for (uint idx = 0; idx < _canimShapes.size(); ++idx) {
Object &o = _canimShapes[idx];
if ((o._type == ACTIVE_BG_SHAPE || o._type == STATIC_BG_SHAPE) && o._misc == NORMAL_BEHIND) {
screen._backBuffer1.transBlitFrom(o._imageFrame->_frame, o._position, o._flags & 2);
screen._backBuffer1.transBlitFrom(*o._imageFrame, o._position, o._flags & 2);
}
}

// Draw all static and active shapes that are in front of the person
for (uint idx = 0; idx < _bgShapes.size(); ++idx) {
Object &o = _bgShapes[idx];
if ((o._type == ACTIVE_BG_SHAPE || o._type == STATIC_BG_SHAPE) && o._misc == FORWARD)
screen._backBuffer1.transBlitFrom(o._imageFrame->_frame, o._position, o._flags & 2);
screen._backBuffer1.transBlitFrom(*o._imageFrame, o._position, o._flags & 2);
}

// Draw any active portrait
if (people._portraitLoaded && people._portrait._type == ACTIVE_BG_SHAPE)
screen._backBuffer1.transBlitFrom(people._portrait._imageFrame->_frame,
screen._backBuffer1.transBlitFrom(*people._portrait._imageFrame,
people._portrait._position, people._portrait._flags & 2);

// Draw all static and active canimations that are in front of the person
for (uint idx = 0; idx < _canimShapes.size(); ++idx) {
Object &o = _canimShapes[idx];
if ((o._type == ACTIVE_BG_SHAPE || o._type == STATIC_BG_SHAPE) && o._misc == FORWARD) {
screen._backBuffer1.transBlitFrom(o._imageFrame->_frame, o._position, o._flags & 2);
screen._backBuffer1.transBlitFrom(*o._imageFrame, o._position, o._flags & 2);
}
}

// Draw all NO_SHAPE shapes which have flag bit 0 clear
for (uint idx = 0; idx < _bgShapes.size(); ++idx) {
Object &o = _bgShapes[idx];
if (o._type == NO_SHAPE && (o._flags & 1) == 0)
screen._backBuffer1.transBlitFrom(o._imageFrame->_frame, o._position, o._flags & 2);
screen._backBuffer1.transBlitFrom(*o._imageFrame, o._position, o._flags & 2);
}

// Bring the newly built picture to the screen
Expand Down

0 comments on commit 51eb601

Please sign in to comment.