From 9f6b266049f6cf2a62d9e23bc7457e781d74f5d0 Mon Sep 17 00:00:00 2001 From: sluicebox <22204938+sluicebox@users.noreply.github.com> Date: Fri, 5 Jul 2024 16:21:20 -0700 Subject: [PATCH] SCI: Fix SCI1.1 view displacement scaling Fixes negative displacements being scaled to the wrong value, causing views to be drawn at the wrong location. Example: LB2 floppy Act 3 room 430 scaled O'Riley's x displacement to -2 instead of -1, placing him one pixel too far to the left. Confirmed in disassembly that this calculation is a signed divide and not an unsigned shift. --- engines/sci/graphics/view.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/sci/graphics/view.cpp b/engines/sci/graphics/view.cpp index 96a49f18fa7..c27f90a201e 100644 --- a/engines/sci/graphics/view.cpp +++ b/engines/sci/graphics/view.cpp @@ -433,8 +433,8 @@ void GfxView::getCelScaledRect(int16 loopNo, int16 celNo, int16 x, int16 y, int1 const CelInfo *celInfo = getCelInfo(loopNo, celNo); // Scaling displaceX/Y, Width/Height - int16 scaledDisplaceX = (celInfo->displaceX * scaleX) >> 7; - int16 scaledDisplaceY = (celInfo->displaceY * scaleY) >> 7; + int16 scaledDisplaceX = (celInfo->displaceX * scaleX) / 128; + int16 scaledDisplaceY = (celInfo->displaceY * scaleY) / 128; int16 scaledWidth = (celInfo->width * scaleX) >> 7; int16 scaledHeight = (celInfo->height * scaleY) >> 7; scaledWidth = CLIP(scaledWidth, 0, _screen->getWidth());