aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorColin Snover2016-02-18 00:07:28 -0600
committerColin Snover2016-02-18 13:18:03 -0600
commit03e3f2c68cef429983787ddd38e74718db1ee8d1 (patch)
treeac137806ab11a8f332c752238971a07db9af6579 /engines/sci
parent3c9b93050643579a379249b29c36a74acf1fdaa0 (diff)
downloadscummvm-rg350-03e3f2c68cef429983787ddd38e74718db1ee8d1.tar.gz
scummvm-rg350-03e3f2c68cef429983787ddd38e74718db1ee8d1.tar.bz2
scummvm-rg350-03e3f2c68cef429983787ddd38e74718db1ee8d1.zip
SCI: Fix some rect off-by-ones
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kgraphics32.cpp4
-rw-r--r--engines/sci/graphics/frameout.cpp2
-rw-r--r--engines/sci/graphics/helpers.h19
-rw-r--r--engines/sci/graphics/plane32.cpp10
-rw-r--r--engines/sci/graphics/screen_item32.cpp6
5 files changed, 24 insertions, 17 deletions
diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp
index cf53944652..03cbd66984 100644
--- a/engines/sci/engine/kgraphics32.cpp
+++ b/engines/sci/engine/kgraphics32.cpp
@@ -204,8 +204,8 @@ reg_t kCreateTextBitmap(EngineState *s, int argc, reg_t *argv) {
Common::Rect rect(
readSelectorValue(segMan, object, SELECTOR(textLeft)),
readSelectorValue(segMan, object, SELECTOR(textTop)),
- readSelectorValue(segMan, object, SELECTOR(textRight)),
- readSelectorValue(segMan, object, SELECTOR(textBottom))
+ readSelectorValue(segMan, object, SELECTOR(textRight)) + 1,
+ readSelectorValue(segMan, object, SELECTOR(textBottom)) + 1
);
if (subop == 0) {
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index d748cc05de..0bf5b4e9fa 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -144,7 +144,7 @@ void GfxFrameout::run() {
// NOTE: This happens in SCI::InitPlane in the actual engine,
// and is a background fill plane to ensure hidden planes
// (planes with a priority of -1) are never drawn
- Plane *initPlane = new Plane(Common::Rect(_currentBuffer.scriptWidth - 1, _currentBuffer.scriptHeight - 1));
+ Plane *initPlane = new Plane(Common::Rect(_currentBuffer.scriptWidth, _currentBuffer.scriptHeight));
initPlane->_priority = 0;
_planes.add(initPlane);
}
diff --git a/engines/sci/graphics/helpers.h b/engines/sci/graphics/helpers.h
index c238e2c87b..fbad120374 100644
--- a/engines/sci/graphics/helpers.h
+++ b/engines/sci/graphics/helpers.h
@@ -142,13 +142,13 @@ inline void mul(Common::Rect &rect, const Common::Rational &ratioX, const Common
* Multiplies a number by a rational number, rounding up to
* the nearest whole number.
*/
-inline int mulru(const int value, const Common::Rational &ratio, const int extra = 0) {
- int num = (value + extra) * ratio.getNumerator();
+inline int mulru(const int value, const Common::Rational &ratio) {
+ int num = value * ratio.getNumerator();
int result = num / ratio.getDenominator();
if (num > ratio.getDenominator() && num % ratio.getDenominator()) {
++result;
}
- return result - extra;
+ return result;
}
/**
@@ -165,12 +165,19 @@ inline void mulru(Common::Point &point, const Common::Rational &ratioX, const Co
* Multiplies a point by two rational numbers for X and Y,
* rounding up to the nearest whole number. Modifies the
* rect directly.
+ *
+ * @note In SCI engine, the bottom-right corner of rects
+ * received an additional one pixel during the
+ * multiplication in order to round up to include the
+ * bottom-right corner. Since ScummVM rects do not include
+ * the bottom-right corner, doing this ends up making rects
+ * a pixel too wide/tall depending upon the remainder.
*/
-inline void mulru(Common::Rect &rect, const Common::Rational &ratioX, const Common::Rational &ratioY, const int brExtra = 0) {
+inline void mulru(Common::Rect &rect, const Common::Rational &ratioX, const Common::Rational &ratioY) {
rect.left = mulru(rect.left, ratioX);
rect.top = mulru(rect.top, ratioY);
- rect.right = mulru(rect.right, ratioX, brExtra);
- rect.bottom = mulru(rect.bottom, ratioY, brExtra);
+ rect.right = mulru(rect.right, ratioX);
+ rect.bottom = mulru(rect.bottom, ratioY);
}
struct Buffer : public Graphics::Surface {
diff --git a/engines/sci/graphics/plane32.cpp b/engines/sci/graphics/plane32.cpp
index 297c6e3d21..33c01cf828 100644
--- a/engines/sci/graphics/plane32.cpp
+++ b/engines/sci/graphics/plane32.cpp
@@ -78,8 +78,8 @@ _moved(0) {
_gameRect.left = readSelectorValue(segMan, object, SELECTOR(inLeft));
_gameRect.top = readSelectorValue(segMan, object, SELECTOR(inTop));
- _gameRect.right = readSelectorValue(segMan, object, SELECTOR(inRight));
- _gameRect.bottom = readSelectorValue(segMan, object, SELECTOR(inBottom));
+ _gameRect.right = readSelectorValue(segMan, object, SELECTOR(inRight)) + 1;
+ _gameRect.bottom = readSelectorValue(segMan, object, SELECTOR(inBottom)) + 1;
convertGameRectToPlaneRect();
_back = readSelectorValue(segMan, object, SELECTOR(back));
@@ -136,7 +136,7 @@ void Plane::convertGameRectToPlaneRect() {
const Ratio ratioY = Ratio(screenHeight, scriptHeight);
_planeRect = _gameRect;
- mulru(_planeRect, ratioX, ratioY, 1);
+ mulru(_planeRect, ratioX, ratioY);
}
void Plane::printDebugInfo(Console *con) const {
@@ -752,8 +752,8 @@ void Plane::update(const reg_t object) {
_vanishingPoint.y = readSelectorValue(segMan, object, SELECTOR(vanishingY));
_gameRect.left = readSelectorValue(segMan, object, SELECTOR(inLeft));
_gameRect.top = readSelectorValue(segMan, object, SELECTOR(inTop));
- _gameRect.right = readSelectorValue(segMan, object, SELECTOR(inRight));
- _gameRect.bottom = readSelectorValue(segMan, object, SELECTOR(inBottom));
+ _gameRect.right = readSelectorValue(segMan, object, SELECTOR(inRight)) + 1;
+ _gameRect.bottom = readSelectorValue(segMan, object, SELECTOR(inBottom)) + 1;
convertGameRectToPlaneRect();
_priority = readSelectorValue(segMan, object, SELECTOR(priority));
diff --git a/engines/sci/graphics/screen_item32.cpp b/engines/sci/graphics/screen_item32.cpp
index 300912f110..ed9adcfc2a 100644
--- a/engines/sci/graphics/screen_item32.cpp
+++ b/engines/sci/graphics/screen_item32.cpp
@@ -209,8 +209,8 @@ void ScreenItem::setFromObject(SegManager *segMan, const reg_t object, const boo
_useInsetRect = true;
_insetRect.left = readSelectorValue(segMan, object, SELECTOR(inLeft));
_insetRect.top = readSelectorValue(segMan, object, SELECTOR(inTop));
- _insetRect.right = readSelectorValue(segMan, object, SELECTOR(inRight));
- _insetRect.bottom = readSelectorValue(segMan, object, SELECTOR(inBottom));
+ _insetRect.right = readSelectorValue(segMan, object, SELECTOR(inRight)) + 1;
+ _insetRect.bottom = readSelectorValue(segMan, object, SELECTOR(inBottom)) + 1;
} else {
_useInsetRect = false;
}
@@ -376,7 +376,7 @@ void ScreenItem::calcRects(const Plane &plane) {
Ratio celXRatio(screenWidth, _celObj->_scaledWidth);
Ratio celYRatio(screenHeight, _celObj->_scaledHeight);
mulru(_scaledPosition, celXRatio, celYRatio);
- mulru(_screenItemRect, celXRatio, celYRatio, 1);
+ mulru(_screenItemRect, celXRatio, celYRatio);
}
_ratioX = newRatioX * Ratio(screenWidth, _celObj->_scaledWidth);