aboutsummaryrefslogtreecommitdiff
path: root/engines/illusions
diff options
context:
space:
mode:
authorjohndoe1232014-03-30 10:46:12 +0200
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commite0e4d2ffa92fccdef1ea3eae0228ec812c7dbac5 (patch)
treef6b50b0ee1af1d45e0734db71b6d21eabdd4ea4e /engines/illusions
parentbabe997295dbadd95ab497bc6b88e7a0021567e5 (diff)
downloadscummvm-rg350-e0e4d2ffa92fccdef1ea3eae0228ec812c7dbac5.tar.gz
scummvm-rg350-e0e4d2ffa92fccdef1ea3eae0228ec812c7dbac5.tar.bz2
scummvm-rg350-e0e4d2ffa92fccdef1ea3eae0228ec812c7dbac5.zip
ILLUSIONS: Implement sprite scaling
Diffstat (limited to 'engines/illusions')
-rw-r--r--engines/illusions/illusions.cpp2
-rw-r--r--engines/illusions/screen.cpp62
2 files changed, 61 insertions, 3 deletions
diff --git a/engines/illusions/illusions.cpp b/engines/illusions/illusions.cpp
index 99b7b19a16..4748634e1c 100644
--- a/engines/illusions/illusions.cpp
+++ b/engines/illusions/illusions.cpp
@@ -280,7 +280,7 @@ int IllusionsEngine::updateGraphics() {
uint32 priority = control->getPriority();
_screen->_drawQueue->insertSprite(&actor->_drawFlags, actor->_surface,
actor->_surfInfo._dimensions, drawPosition, control->_position,
- priority, 100/*actor->_scale TODO DEBUG*/, actor->_spriteFlags);
+ priority, actor->_scale, actor->_spriteFlags);
}
}
}
diff --git a/engines/illusions/screen.cpp b/engines/illusions/screen.cpp
index 694382d94b..d8e6a12d29 100644
--- a/engines/illusions/screen.cpp
+++ b/engines/illusions/screen.cpp
@@ -111,10 +111,68 @@ void Screen::drawSurface20(Common::Rect &dstRect, Graphics::Surface *surface, Co
//debug("Screen::drawSurface20");
}
+static uint16 average(const uint16 a, const uint16 b) {
+ byte r1, g1, b1, r2, g2, b2;
+ g_system->getScreenFormat().colorToRGB(a, r1, g1, b1);
+ g_system->getScreenFormat().colorToRGB(b, r2, g2, b2);
+ return g_system->getScreenFormat().RGBToColor((r1 + r1 + r2) / 3, (g1 + g1 + g2) / 3, (b1 + b1 + b2) / 3);
+}
+
void Screen::drawSurface21(Common::Rect &dstRect, Graphics::Surface *surface, Common::Rect &srcRect) {
// Scaled
- // TODO
- //debug("Screen::drawSurface21");
+ const int dstWidth = dstRect.width(), dstHeight = dstRect.height();
+ const int srcWidth = srcRect.width(), srcHeight = srcRect.height();
+ const int errYStart = srcHeight / dstHeight;
+ const int errYIncr = srcHeight % dstHeight;
+ const int midY = dstHeight / 2;
+ const int errXStart = srcWidth / dstWidth;
+ const int errXIncr = srcWidth % dstWidth;
+ const int midX = dstWidth / 2;
+ int h = dstHeight, errY = 0, skipY, srcY = srcRect.top;
+ byte *dst = (byte*)_backSurface->getBasePtr(dstRect.left, dstRect.top);
+ skipY = (dstHeight < srcHeight) ? 0 : dstHeight / (2*srcHeight) + 1;
+ h -= skipY;
+ while (h-- > 0) {
+ int w = dstWidth, errX = 0, skipX;
+ skipX = (dstWidth < srcWidth) ? 0 : dstWidth / (2*srcWidth) + 1;
+ w -= skipX;
+ byte *src = (byte*)surface->getBasePtr(srcRect.left, srcY);
+ byte *dstRow = dst;
+ while (w-- > 0) {
+ uint16 pixel = READ_LE_UINT16(src);
+ if (pixel != _colorKey1) {
+ if (errX >= midX) {
+ uint16 npixel = READ_LE_UINT16(src + 2);
+ if (npixel == _colorKey1)
+ npixel = READ_LE_UINT16(dstRow);
+ pixel = average(pixel, npixel);
+ }
+ WRITE_LE_UINT16(dstRow, pixel);
+ }
+ dstRow += 2;
+ src += 2 * errXStart;
+ errX += errXIncr;
+ if (errX >= dstWidth) {
+ errX -= dstWidth;
+ src += 2;
+ }
+ }
+ while (skipX-- > 0) {
+ uint16 pixel = READ_LE_UINT16(src);
+ if (pixel != _colorKey1)
+ WRITE_LE_UINT16(dstRow, pixel);
+ src += 2;
+ dstRow += 2;
+ }
+ dst += _backSurface->pitch;
+ srcY += errYStart;
+ errY += errYIncr;
+ if (errY >= dstHeight) {
+ errY -= dstHeight;
+ ++srcY;
+ }
+ }
+
}
} // End of namespace Illusions