aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorD G Turner2018-10-11 10:18:48 +0100
committerD G Turner2018-10-11 10:18:48 +0100
commitc8b98dd41cb395d56de15f447b28f6b8b3c3e2e3 (patch)
tree34a9dd4ecc54cf91efe8d27aea1917cda9ec4636 /engines/agi
parentc5db13d5e0ed07ca7467c017e2264d0341a00088 (diff)
downloadscummvm-rg350-c8b98dd41cb395d56de15f447b28f6b8b3c3e2e3.tar.gz
scummvm-rg350-c8b98dd41cb395d56de15f447b28f6b8b3c3e2e3.tar.bz2
scummvm-rg350-c8b98dd41cb395d56de15f447b28f6b8b3c3e2e3.zip
AGI: Clamp Graphics Blit into Screen Area.
Some games, especially fangames appear to blit to co-ordinates outside the screen area, which caused an assertion in the graphics backend. To prevent this and allow further debugging in these cases, we clamp this to the screen area. Note that there are several other locations which do backend graphics calls, so this may need to be applied elsewhere in the general case. This fixes bug Trac #10736.
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/graphics.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp
index 119ccfea1d..d08e9bb99a 100644
--- a/engines/agi/graphics.cpp
+++ b/engines/agi/graphics.cpp
@@ -316,6 +316,13 @@ uint32 GfxMgr::getDisplayOffsetToVisualScreenPos(int16 x, int16 y) {
// Attention: uses display screen coordinates!
void GfxMgr::copyDisplayRectToScreen(int16 x, int16 y, int16 width, int16 height) {
+ // Clamp to sane values to prevent off screen blits causing exceptions in backend
+ // FIXME: Add warnings / debug of clamping?
+ width = CLIP<int16>(width, 0, _displayScreenWidth);
+ height = CLIP<int16>(height, 0, _displayScreenHeight);
+ x = CLIP<int16>(x, 0, _displayScreenWidth-width);
+ y = CLIP<int16>(y, 0, _displayScreenHeight-height);
+
g_system->copyRectToScreen(_displayScreen + y * _displayScreenWidth + x, _displayScreenWidth, x, y, width, height);
}
void GfxMgr::copyDisplayRectToScreen(int16 x, int16 adjX, int16 y, int16 adjY, int16 width, int16 adjWidth, int16 height, int16 adjHeight) {