aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mads/msurface.cpp88
-rw-r--r--engines/mads/msurface.h14
-rw-r--r--engines/mads/scene_data.cpp2
-rw-r--r--engines/mads/sprites.cpp4
4 files changed, 37 insertions, 71 deletions
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 839882a354..0108b0b91f 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -259,24 +259,52 @@ void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds,
void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
DepthSurface *depthSurface, int scale, int transparentColor) {
-
int destX = destPos.x, destY = destPos.y;
- if (scale == 100) {
+ int frameWidth = src->getWidth();
+ int frameHeight = src->getHeight();
+
+ int highestDim = MAX(frameWidth, frameHeight);
+ bool lineDist[MADS_SCREEN_WIDTH];
+ int distIndex = 0;
+ int distXCount = 0, distYCount = 0;
+
+ if (scale != -1) {
+ int distCtr = 0;
+ do {
+ distCtr += scale;
+ if (distCtr < 100) {
+ lineDist[distIndex] = false;
+ } else {
+ lineDist[distIndex] = true;
+ distCtr -= 100;
+
+ if (distIndex < frameWidth)
+ ++distXCount;
+
+ if (distIndex < frameHeight)
+ ++distYCount;
+ }
+ } while (++distIndex < highestDim);
+
+ destX -= distXCount / 2;
+ destY -= distYCount - 1;
+ }
+
+ // Special case for quicker drawing of non-scaled images
+ if (scale == 100 || scale == -1) {
// Copy the specified area
Common::Rect copyRect(0, 0, src->getWidth(), src->getHeight());
if (destX < 0) {
copyRect.left += -destX;
destX = 0;
- }
- else if (destX + copyRect.width() > w) {
+ } else if (destX + copyRect.width() > w) {
copyRect.right -= destX + copyRect.width() - w;
}
if (destY < 0) {
copyRect.top += -destY;
destY = 0;
- }
- else if (destY + copyRect.height() > h) {
+ } else if (destY + copyRect.height() > h) {
copyRect.bottom -= destY + copyRect.height() - h;
}
@@ -310,33 +338,6 @@ void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
int destRight = this->getWidth() - 1;
int destBottom = this->getHeight() - 1;
bool normalFrame = true;
- int frameWidth = src->getWidth();
- int frameHeight = src->getHeight();
-
- int highestDim = MAX(frameWidth, frameHeight);
- bool lineDist[MADS_SCREEN_WIDTH];
- int distIndex = 0;
- int distXCount = 0, distYCount = 0;
-
- int distCtr = 0;
- do {
- distCtr += scale;
- if (distCtr < 100) {
- lineDist[distIndex] = false;
- } else {
- lineDist[distIndex] = true;
- distCtr -= 100;
-
- if (distIndex < frameWidth)
- ++distXCount;
-
- if (distIndex < frameHeight)
- ++distYCount;
- }
- } while (++distIndex < highestDim);
-
- destX -= distXCount / 2;
- destY -= distYCount - 1;
// Check x bounding area
int spriteLeft = 0;
@@ -419,27 +420,6 @@ 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;
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 985a097d4a..dec36e7caf 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -168,20 +168,6 @@ public:
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
*/
void copyTo(MSurface *dest, int transparentColor = -1) {
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index d53a668fd3..1494f62d7a 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -265,7 +265,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
assert(asset && _depthStyle != 2);
MSprite *spr = asset->getFrame(asset->getCount() - 1);
- bgSurface.copyFromScaled(spr, si._position, si._depth, &depthSurface,
+ bgSurface.copyFrom(spr, si._position, si._depth, &depthSurface,
si._scale, spr->getTransparencyIndex());
}
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index a229fccb89..b7688ad417 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -324,7 +324,7 @@ void SpriteSlots::drawSprites(MSurface *s) {
}
if ((slot._scale < 100) && (slot._scale != -1)) {
- // Minimalized drawing
+ // Scaled drawing
s->copyFrom(spr, slot._position, slot._depth, &scene._depthSurface,
slot._scale, sprite->getTransparencyIndex());
} else {
@@ -341,7 +341,7 @@ void SpriteSlots::drawSprites(MSurface *s) {
if (slot._depth > 1) {
// Draw the frame with depth processing
s->copyFrom(spr, Common::Point(xp, yp), slot._depth, &scene._depthSurface,
- 100, sprite->getTransparencyIndex());
+ -1, sprite->getTransparencyIndex());
} else {
// No depth, so simply draw the image
spr->copyTo(s, Common::Point(xp, yp), sprite->getTransparencyIndex());