aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/simon/vga.cpp55
1 files changed, 52 insertions, 3 deletions
diff --git a/engines/simon/vga.cpp b/engines/simon/vga.cpp
index fe49f8c699..83cdaac264 100644
--- a/engines/simon/vga.cpp
+++ b/engines/simon/vga.cpp
@@ -1026,9 +1026,9 @@ void SimonEngine::scaleClip(int16 h, int16 w, int16 y, int16 x, int16 scrollY) {
srcRect.bottom = h;
if (scrollY > _baseY)
- factor= 1+ ((scrollY - _baseY) * _scale);
+ factor = 1 + ((scrollY - _baseY) * _scale);
else
- factor= 1 - ((_baseY - scrollY) * _scale);
+ factor = 1 - ((_baseY - scrollY) * _scale);
xscale = ((w * factor) / 2);
@@ -1049,7 +1049,56 @@ void SimonEngine::scaleClip(int16 h, int16 w, int16 y, int16 x, int16 scrollY) {
_variableArray[22] = _feebleRect.bottom;
_variableArray[23] = _feebleRect.right;
- // TODO
+ // Oddly enough, _feebleRect is sometimes (always?) "inverted". I do
+ // not know what effect, in any, this has in DirectDraw. For now,
+ // simply un-invert it. It does make the preliminary clipping above
+ // look rather strange, so it could be a bug in our code.
+
+ int top, bottom, left, right;
+
+ if (_feebleRect.top < _feebleRect.bottom) {
+ top = _feebleRect.top;
+ bottom = _feebleRect.bottom;
+ } else {
+ top = _feebleRect.bottom;
+ bottom = _feebleRect.top;
+ }
+
+ if (_feebleRect.left < _feebleRect.right) {
+ left = _feebleRect.left;
+ right = _feebleRect.right;
+ } else {
+ left = _feebleRect.right;
+ right = _feebleRect.left;
+ }
+
+ // Unlike normal rectangles in ScummVM, it seems that in the case of
+ // the destination rectangle the bottom and right coordinates are
+ // considered to be inside the rectangle. For the source rectangle,
+ // I believe that they are not.
+
+ int scaledW = right - left + 1;
+ int scaledH = bottom - top + 1;
+
+ byte *src = getScaleBuf();
+ byte *dst = getBackBuf();
+
+ dst = dst + _dxSurfacePitch * top + left;
+
+ for (int dstY = 0; dstY < h; dstY++) {
+ if (top + dstY >= 0 && top + dstY < 480) {
+ int srcY = (dstY * h) / scaledH;
+ byte *srcPtr = src + _dxSurfacePitch * srcY;
+ byte *dstPtr = dst + _dxSurfacePitch * dstY;
+ for (int dstX = 0; dstX < w; dstX++) {
+ if (left + dstX >= 0 && left + dstX < 640) {
+ int srcX = (dstX * w) / scaledW;
+ if (srcPtr[srcX])
+ dstPtr[dstX] = srcPtr[srcX];
+ }
+ }
+ }
+ }
}
void SimonEngine::drawImages(VC10_state *state) {