Skip to content

Commit

Permalink
MADS: Fix positioning of teleporter window backgrounds
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed May 30, 2014
1 parent d361552 commit 06387c2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
21 changes: 21 additions & 0 deletions engines/mads/msurface.cpp
Expand Up @@ -419,6 +419,27 @@ void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
}
}

void MSurface::copyFromScaled(MSurface *src, const Common::Point &destPos, int depth,
DepthSurface *depthSurface, int scale, int transparentColor) {
int distXCount = 0, distYCount = 0;
int highestDim = MAX(src->w, src->h);
int accum = 0;

for (int idx = 0; idx < highestDim; ++idx) {
accum += scale;
if (accum >= 100) {
accum -= 100;
if (idx < src->w)
++distXCount;
if (idx < src->h)
++distYCount;
}
}

Common::Point newPos(destPos.x - distXCount / 2, destPos.y - distYCount);
copyFrom(src, src->getBounds(), newPos, transparentColor);
}

void MSurface::scrollX(int xAmount) {
if (xAmount == 0)
return;
Expand Down
15 changes: 15 additions & 0 deletions engines/mads/msurface.h
Expand Up @@ -161,11 +161,26 @@ class MSurface : public Graphics::Surface {
* @param destPos Destination position to draw in current surface
* @param depth Depth of sprite
* @param depthSurface Depth surface to use with sprite depth
* @param scale Scale for image
* @param transparentColor Transparency palette index
*/
void copyFrom(MSurface *src, const Common::Point &destPos, int depth, DepthSurface *depthSurface,
int scale, int transparentColor = -1);

/**
* Copys a sub-section of another surface into the current one, taking into
* account variation in the destination copy position based on item size
* and scaling.
* @param src Source surface
* @param destPos Destination position to draw in current surface
* @param depth Depth of sprite
* @param depthSurface Depth surface to use with sprite depth
* @param scale Scale for image
* @param transparentColor Transparency palette index
*/
void copyFromScaled(MSurface *src, const Common::Point &destPos, int depth, DepthSurface *depthSurface,
int scale, int transparentColor = -1);

/**
* Copies the surface to a given destination surface
*/
Expand Down
6 changes: 3 additions & 3 deletions engines/mads/scene_data.cpp
Expand Up @@ -265,13 +265,13 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
assert(asset && _depthStyle != 2);

MSprite *spr = asset->getFrame(asset->getCount() - 1);
bgSurface.copyFrom(spr, si._position, si._depth, &depthSurface, si._scale,
spr->getTransparencyIndex());
bgSurface.copyFromScaled(spr, si._position, si._depth, &depthSurface,
si._scale, spr->getTransparencyIndex());
}

// Free the sprite sets
for (int i = (int)spriteSets.size() - 1; i >= 0; --i) {
warning("TODO: sub_201C8 SPRITE_SET.field_6");
_vm->_palette->_paletteUsage.resetPalFlags(spriteSets[i]->_usageIndex);
delete spriteSets[i];
}
}
Expand Down

0 comments on commit 06387c2

Please sign in to comment.