diff options
author | johndoe123 | 2011-07-13 23:00:39 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:38:47 +0200 |
commit | 264777893578186cb27113f5918ef5e62fcfb836 (patch) | |
tree | 0cdc8bd3f058f512fbc34a009f085c9afb4e9b90 | |
parent | 436f8952bbd168c53481bd19f9d79372dd0561c9 (diff) | |
download | scummvm-rg350-264777893578186cb27113f5918ef5e62fcfb836.tar.gz scummvm-rg350-264777893578186cb27113f5918ef5e62fcfb836.tar.bz2 scummvm-rg350-264777893578186cb27113f5918ef5e62fcfb836.zip |
NEVERHOOD: Fix crash/corruption in clipped sprite drawing
-rw-r--r-- | engines/neverhood/neverhood.cpp | 10 | ||||
-rw-r--r-- | engines/neverhood/scene.cpp | 1 | ||||
-rw-r--r-- | engines/neverhood/screen.cpp | 20 |
3 files changed, 15 insertions, 16 deletions
diff --git a/engines/neverhood/neverhood.cpp b/engines/neverhood/neverhood.cpp index abae6eb70a..9e1475fe03 100644 --- a/engines/neverhood/neverhood.cpp +++ b/engines/neverhood/neverhood.cpp @@ -89,6 +89,7 @@ Common::Error NeverhoodEngine::run() { CursorMan.showMouse(true); { + // DEBUG: Dummy cursor byte buffer[2*2]; memset(buffer, 255, 4); CursorMan.replaceCursor(buffer, 2, 2, 0, 0, 0); @@ -166,22 +167,13 @@ Common::Error NeverhoodEngine::run() { _mouseY = event.mouse.y; _gameModule->handleMouseMove(event.mouse.x, event.mouse.y); break; - case Common::EVENT_LBUTTONDOWN: case Common::EVENT_RBUTTONDOWN: _gameModule->handleMouseDown(event.mouse.x, event.mouse.y); break; - /* - _buttonState |= kLeftButton; - break; case Common::EVENT_LBUTTONUP: - _buttonState &= ~kLeftButton; - break; - _buttonState |= kRightButton; - break; case Common::EVENT_RBUTTONUP: - _buttonState &= ~kRightButton; break; case Common::EVENT_QUIT: _system->quit(); diff --git a/engines/neverhood/scene.cpp b/engines/neverhood/scene.cpp index 7252e391a0..2b5c81b4ad 100644 --- a/engines/neverhood/scene.cpp +++ b/engines/neverhood/scene.cpp @@ -179,7 +179,6 @@ void Scene::update() { if (_smkFileHash != 0) { // TODO - //**** ALL TODO _smackerPlayer = new SmackerPlayer(_vm, this, _smkFileHash, true, 0); _savedUpdateHandlerCb = _updateHandlerCb; _savedMessageHandlerCb = _messageHandlerCb; diff --git a/engines/neverhood/screen.cpp b/engines/neverhood/screen.cpp index 7b3d4bc6e5..a88491424c 100644 --- a/engines/neverhood/screen.cpp +++ b/engines/neverhood/screen.cpp @@ -104,7 +104,7 @@ void Screen::drawSurface2(const Graphics::Surface *surface, NDrawRect &drawRect, else ddRect.x2 = drawRect.width; - if (drawRect.x <= clipRect.x1) { + if (drawRect.x < clipRect.x1) { destX = clipRect.x1; ddRect.x1 = clipRect.x1 - drawRect.x; } else { @@ -117,7 +117,7 @@ void Screen::drawSurface2(const Graphics::Surface *surface, NDrawRect &drawRect, else ddRect.y2 = drawRect.height; - if (drawRect.y <= clipRect.y1) { + if (drawRect.y < clipRect.y1) { destY = clipRect.y1; ddRect.y1 = clipRect.y1 - drawRect.y; } else { @@ -125,13 +125,16 @@ void Screen::drawSurface2(const Graphics::Surface *surface, NDrawRect &drawRect, ddRect.y1 = 0; } - debug(8, "draw: x = %d; y = %d; (%d, %d, %d, %d)", destX, destY, ddRect.x1, ddRect.y1, ddRect.x2, ddRect.y2); - + debug(2, "draw: x = %d; y = %d; (%d, %d, %d, %d)", destX, destY, ddRect.x1, ddRect.y1, ddRect.x2, ddRect.y2); + const byte *source = (const byte*)surface->getBasePtr(ddRect.x1, ddRect.y1); byte *dest = (byte*)_backScreen->getBasePtr(destX, destY); int width = ddRect.x2 - ddRect.x1; int height = ddRect.y2 - ddRect.y1; + if (width <= 0 || height <= 0) + return; + if (!transparent) { while (height--) { memcpy(dest, source, width); @@ -146,8 +149,13 @@ void Screen::drawSurface2(const Graphics::Surface *surface, NDrawRect &drawRect, source += surface->pitch; dest += _backScreen->pitch; } - } - + } + + // Useful for debugging + //_backScreen->frameRect(Common::Rect(clipRect.x1, clipRect.y1, clipRect.x2, clipRect.y2), 250); + //_backScreen->frameRect(Common::Rect(destX, destY, destX + ddRect.x2, destY + ddRect.y2), 255); + //_backScreen->frameRect(Common::Rect(drawRect.x, drawRect.y, drawRect.x + drawRect.width, drawRect.y + drawRect.height), 255); + } void Screen::drawDoubleSurface2(const Graphics::Surface *surface, NDrawRect &drawRect) { |