aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/psp/osys_psp_gu.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/backends/psp/osys_psp_gu.cpp b/backends/psp/osys_psp_gu.cpp
index e5e63763ba..31b658af94 100644
--- a/backends/psp/osys_psp_gu.cpp
+++ b/backends/psp/osys_psp_gu.cpp
@@ -227,6 +227,31 @@ void OSystem_PSP_GU::setPalette(const byte *colors, uint start, uint num) {
void OSystem_PSP_GU::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h)
{
+ //Clip the coordinates
+ if (x < 0) {
+ w += x;
+ buf -= x;
+ x = 0;
+ }
+
+ if (y < 0) {
+ h += y;
+ buf -= y * pitch;
+ y = 0;
+ }
+
+ if (w > _screenWidth - x) {
+ w = _screenWidth - x;
+ }
+
+ if (h > _screenHeight - y) {
+ h = _screenHeight - y;
+ }
+
+ if (w <= 0 || h <= 0)
+ return;
+
+
byte *dst = _offscreen + y * _screenWidth + x;
if (_screenWidth == pitch && pitch == w)