From 65596240d70869900df61ece1812d080c5acd22f Mon Sep 17 00:00:00 2001 From: Robert Göffringmann Date: Fri, 1 Apr 2005 03:00:51 +0000 Subject: ps2: clip coordinates in copyRectToScreen, necessary for The Dig svn-id: r17318 --- backends/ps2/systemps2.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/ps2/systemps2.cpp b/backends/ps2/systemps2.cpp index 619e842fa6..64636baf48 100644 --- a/backends/ps2/systemps2.cpp +++ b/backends/ps2/systemps2.cpp @@ -367,7 +367,22 @@ void OSystem_PS2::setPalette(const byte *colors, uint start, uint num) { } void OSystem_PS2::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { - _screen->copyScreenRect((const uint8*)buf, (uint16)pitch, (uint16)x, (uint16)y, (uint16)w, (uint16)h); + if (x < 0) { + w += x; + buf -= x; + x = 0; + } + if (y < 0) { + h += y; + buf -= y * pitch; + y = 0; + } + if (w > x + _width) + w = _width - x; + if (h > y + _height) + h = _height - y; + if ((w > 0) && (h > 0)) + _screen->copyScreenRect((const uint8*)buf, (uint16)pitch, (uint16)x, (uint16)y, (uint16)w, (uint16)h); } void OSystem_PS2::updateScreen(void) { -- cgit v1.2.3