aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorTorbjörn Andersson2006-03-22 10:32:32 +0000
committerTorbjörn Andersson2006-03-22 10:32:32 +0000
commite4664606f78b6a5054abff3ff51acf6c42657c9f (patch)
treecff19fdef59a8a4f169c759c31fac8a9c65ef6e5 /engines
parent60732d70f50339650d831ff0712e902bb08292af (diff)
downloadscummvm-rg350-e4664606f78b6a5054abff3ff51acf6c42657c9f.tar.gz
scummvm-rg350-e4664606f78b6a5054abff3ff51acf6c42657c9f.tar.bz2
scummvm-rg350-e4664606f78b6a5054abff3ff51acf6c42657c9f.zip
Preliminary (weasel-word for "probably buggy") implementation of the remaining
parts of scaleClip(). I do see a scaled image of Feeble, but it's very glitchy. On the other hand, I get the same kindof glitches when drawing him unscaled, so maybe there is garbage left in the scale buffer from previous frames. svn-id: r21404
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) {