diff options
author | Colin Snover | 2017-01-12 12:41:27 -0600 |
---|---|---|
committer | Colin Snover | 2017-01-12 13:14:10 -0600 |
commit | dd13fdfe1740ac847f7dfb4a332d3f5948b1a782 (patch) | |
tree | 82520ccf5175d2cf6ae80208d7c204301b49dd4f /engines | |
parent | 54e94c572aeb58e160537e2145c0fff44e862be3 (diff) | |
download | scummvm-rg350-dd13fdfe1740ac847f7dfb4a332d3f5948b1a782.tar.gz scummvm-rg350-dd13fdfe1740ac847f7dfb4a332d3f5948b1a782.tar.bz2 scummvm-rg350-dd13fdfe1740ac847f7dfb4a332d3f5948b1a782.zip |
SCI32: "Fix" renderer for PQ4CD
PQ4CD and several other games contain a hack in two renderer
methods to avoid rendering invalid screen items with zero or
negative-dimension target rects. This prevents PQ4CD from
crashing during the fifth phase of target practice.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/features.h | 13 | ||||
-rw-r--r-- | engines/sci/graphics/celobj32.cpp | 20 | ||||
-rw-r--r-- | engines/sci/graphics/frameout.cpp | 9 |
3 files changed, 39 insertions, 3 deletions
diff --git a/engines/sci/engine/features.h b/engines/sci/engine/features.h index ee978be033..8f84bbacad 100644 --- a/engines/sci/engine/features.h +++ b/engines/sci/engine/features.h @@ -132,6 +132,19 @@ public: inline bool usesAlternateSelectors() const { return g_sci->getGameId() == GID_PHANTASMAGORIA2; } + + inline bool hasEmptyScaleDrawHack() const { + // Yes: KQ7 (all), PQ4CD, QFG4CD, SQ6, Phant1 + // No: All SCI2, all SCI3, GK2, LSL6hires, PQ:SWAT, Torin + // Unknown: Hoyle5, MGDX, Shivers + const SciGameId &gid = g_sci->getGameId(); + return getSciVersion() > SCI_VERSION_2 && + getSciVersion() < SCI_VERSION_2_1_LATE && + gid != GID_LSL6HIRES && + gid != GID_GK2 && + gid != GID_PQSWAT && + gid != GID_TORIN; + } #endif /** diff --git a/engines/sci/graphics/celobj32.cpp b/engines/sci/graphics/celobj32.cpp index fe0fbf7cc4..8540b636fc 100644 --- a/engines/sci/graphics/celobj32.cpp +++ b/engines/sci/graphics/celobj32.cpp @@ -176,6 +176,10 @@ struct SCALER_Scale { // so just always make the reader decompress an entire // line of source data when scaling _reader(celObj, celObj._width) { +#ifndef NDEBUG + assert(_minX <= _maxX); +#endif + // In order for scaling ratios to apply equally across objects that // start at different positions on the screen (like the cels of a // picture), the pixels that are read from the source bitmap must all @@ -773,6 +777,14 @@ void CelObj::drawUncompHzFlipNoMDNoSkip(Buffer &target, const Common::Rect &targ } void CelObj::scaleDrawNoMD(Buffer &target, const Ratio &scaleX, const Ratio &scaleY, const Common::Rect &targetRect, const Common::Point &scaledPosition) const { + // In SSCI the checks are > because their rects are BR-inclusive; + // our checks are >= because our rects are BR-exclusive + if (g_sci->_features->hasEmptyScaleDrawHack() && + (targetRect.left >= targetRect.right || + targetRect.top >= targetRect.bottom)) { + return; + } + if (_drawMirrored) render<MAPPER_NoMD, SCALER_Scale<true, READER_Compressed> >(target, targetRect, scaledPosition, scaleX, scaleY); else @@ -780,6 +792,14 @@ void CelObj::scaleDrawNoMD(Buffer &target, const Ratio &scaleX, const Ratio &sca } void CelObj::scaleDrawUncompNoMD(Buffer &target, const Ratio &scaleX, const Ratio &scaleY, const Common::Rect &targetRect, const Common::Point &scaledPosition) const { + // In SSCI the checks are > because their rects are BR-inclusive; + // our checks are >= because our rects are BR-exclusive + if (g_sci->_features->hasEmptyScaleDrawHack() && + (targetRect.left >= targetRect.right || + targetRect.top >= targetRect.bottom)) { + return; + } + if (_drawMirrored) { render<MAPPER_NoMD, SCALER_Scale<true, READER_Uncompressed> >(target, targetRect, scaledPosition, scaleX, scaleY); } else { diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp index 749403093f..464b28a2ba 100644 --- a/engines/sci/graphics/frameout.cpp +++ b/engines/sci/graphics/frameout.cpp @@ -1168,10 +1168,13 @@ void GfxFrameout::showBits() { byte *sourceBuffer = (byte *)_currentBuffer.getPixels() + rounded.top * _currentBuffer.screenWidth + rounded.left; - // TODO: Sometimes transition screen items generate zero-dimension - // show rectangles. Is this a bug? + // Sometimes screen items (especially from SCI2.1early transitions, like + // in the asteroids minigame in PQ4) generate zero-dimension show + // rectangles. In SSCI, zero-dimension rectangles are OK (they just + // result in no copy), but OSystem::copyRectToScreen will assert on + // them, so we need to check for zero-dimensions rectangles and ignore + // them explicitly if (rounded.width() == 0 || rounded.height() == 0) { - warning("Zero-dimension show rectangle ignored"); continue; } |