aboutsummaryrefslogtreecommitdiff
path: root/sword2/driver
diff options
context:
space:
mode:
authorTorbjörn Andersson2003-08-30 10:23:40 +0000
committerTorbjörn Andersson2003-08-30 10:23:40 +0000
commit23ba54ec929c745d3f1f8f126ad167245a4651b9 (patch)
tree38c4a7be7d94d1c6c157d2c972b83e0fe73a9378 /sword2/driver
parent144b9ed71ccecac2fa0070b32a084b611cf9b0fc (diff)
downloadscummvm-rg350-23ba54ec929c745d3f1f8f126ad167245a4651b9.tar.gz
scummvm-rg350-23ba54ec929c745d3f1f8f126ad167245a4651b9.tar.bz2
scummvm-rg350-23ba54ec929c745d3f1f8f126ad167245a4651b9.zip
Fixed sprite clipping issues, I hope.
svn-id: r9920
Diffstat (limited to 'sword2/driver')
-rw-r--r--sword2/driver/sprite.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/sword2/driver/sprite.cpp b/sword2/driver/sprite.cpp
index 9542956f92..b35a6df9d8 100644
--- a/sword2/driver/sprite.cpp
+++ b/sword2/driver/sprite.cpp
@@ -1439,24 +1439,32 @@ int32 DrawSprite(_spriteInfo *s) {
rd.right = rd.left + rs.right;
rd.bottom = rd.top + rs.bottom;
+ // Check if the sprite would end up completely outside the screen.
+
+ if (rd.left > 640 || rd.top > 440 || rd.right < 0 || rd.bottom < 40) {
+ if (freeSprite)
+ free(sprite);
+ return RD_OK;
+ }
+
if (rd.top < 40) {
- rs.top = (40 - rd.top) * 256 / scale;
+ rs.top = 40 - rd.top;
rd.top = 40;
clipped = true;
}
if (rd.bottom > 440) {
- rs.bottom -= ((rd.bottom - 440) * 256 / scale);
rd.bottom = 440;
+ rs.bottom = rs.top + (rd.bottom - rd.top);
clipped = true;
}
if (rd.left < 0) {
- rs.left = (0 - rd.left) * 256 / scale;
+ rs.left = -rd.left;
rd.left = 0;
clipped = true;
}
if (rd.right > 640) {
- rs.right -= ((rd.right - 640) * 256 / scale);
rd.right = 640;
+ rs.right = rs.left + (rd.right - rd.left);
clipped = true;
}
@@ -1504,7 +1512,8 @@ int32 DrawSprite(_spriteInfo *s) {
// -----------------------------------------------------------------
// The light mask is an optional layer that covers the entire room
- // and which is used to simulate light and shadows.
+ // and which is used to simulate light and shadows. Scaled sprites
+ // (actors, presumably) are always affected.
if ((renderCaps & RDBLTFX_SHADOWBLEND) && lightMask && (scale != 256 || (s->type & RDSPR_SHADOW))) {
uint8 *lightMap;