aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/ps2/systemps2.cpp17
1 files changed, 16 insertions, 1 deletions
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) {