aboutsummaryrefslogtreecommitdiff
path: root/sword1
diff options
context:
space:
mode:
authorRobert Göffringmann2004-01-03 10:49:08 +0000
committerRobert Göffringmann2004-01-03 10:49:08 +0000
commitedea972b4be9dbeb8ff500a07e3fa58d301b5e36 (patch)
treed1373578ff3713b7042284f90a91890e492f591a /sword1
parent74f958fdf141dfb08d076e5aadc82b917ddd1c22 (diff)
downloadscummvm-rg350-edea972b4be9dbeb8ff500a07e3fa58d301b5e36.tar.gz
scummvm-rg350-edea972b4be9dbeb8ff500a07e3fa58d301b5e36.tar.bz2
scummvm-rg350-edea972b4be9dbeb8ff500a07e3fa58d301b5e36.zip
eriktorbjorn's fix for a crash when sprite were completely outside of the screen
svn-id: r12106
Diffstat (limited to 'sword1')
-rw-r--r--sword1/screen.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/sword1/screen.cpp b/sword1/screen.cpp
index b452e83037..b85d7c4836 100644
--- a/sword1/screen.cpp
+++ b/sword1/screen.cpp
@@ -709,21 +709,24 @@ void SwordScreen::spriteClipAndSet(uint16 *pSprX, uint16 *pSprY, uint16 *pSprWid
*pSprWidth = (uint16)sprW;
*pSprX = (uint16)sprX;
*pSprY = (uint16)sprY;
-
- uint16 gridH = (*pSprHeight + SCRNGRID_Y - 1) / SCRNGRID_Y;
- uint16 gridW = (*pSprWidth + SCRNGRID_X - 1) / SCRNGRID_X;
- uint16 gridX = sprX / SCRNGRID_X;
- uint16 gridY = sprY / SCRNGRID_Y;
- uint8 *gridBuf = _screenGrid + gridX + gridY * _gridSizeX;
- if (gridX + gridW > _gridSizeX)
- gridW = _gridSizeX - gridX;
- if (gridY + gridH > _gridSizeY)
- gridH = _gridSizeY - gridY;
-
- for (uint16 cnty = 0; cnty < gridH; cnty++) {
- for (uint16 cntx = 0; cntx < gridW; cntx++)
- gridBuf[cntx] |= 0x80;
- gridBuf += _gridSizeX;
+
+ if (*pSprWidth && *pSprHeight) {
+ // sprite will be drawn, so mark it in the grid buffer
+ uint16 gridH = (*pSprHeight + SCRNGRID_Y - 1) / SCRNGRID_Y;
+ uint16 gridW = (*pSprWidth + SCRNGRID_X - 1) / SCRNGRID_X;
+ uint16 gridX = sprX / SCRNGRID_X;
+ uint16 gridY = sprY / SCRNGRID_Y;
+ uint8 *gridBuf = _screenGrid + gridX + gridY * _gridSizeX;
+ if (gridX + gridW > _gridSizeX)
+ gridW = _gridSizeX - gridX;
+ if (gridY + gridH > _gridSizeY)
+ gridH = _gridSizeY - gridY;
+
+ for (uint16 cnty = 0; cnty < gridH; cnty++) {
+ for (uint16 cntx = 0; cntx < gridW; cntx++)
+ gridBuf[cntx] |= 0x80;
+ gridBuf += _gridSizeX;
+ }
}
}