From ffc31b880243f886ef265e9f4b9906328116cdd2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 18 Sep 2016 20:47:37 -0400 Subject: [PATCH] XEEN: Extra space in sprite line decoding as workaround for bad data --- engines/xeen/sprites.cpp | 11 ++++++----- engines/xeen/sprites.h | 7 +++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/engines/xeen/sprites.cpp b/engines/xeen/sprites.cpp index 3758a0f4ad4..d0e9f07aee1 100644 --- a/engines/xeen/sprites.cpp +++ b/engines/xeen/sprites.cpp @@ -171,10 +171,11 @@ void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Poi // Initialize the array to hold the temporary data for the line. We do this to make it simpler // to handle both deciding which pixels to draw in a scaled image, as well as when images - // have been horizontally flipped - int tempLine[SCREEN_WIDTH]; - Common::fill(&tempLine[0], &tempLine[SCREEN_WIDTH], -1); - int *lineP = flipped ? &tempLine[width - 1 - xOffset] : &tempLine[xOffset]; + // have been horizontally flipped. Note that we allocate an extra line for before and after our + // work line, just in case the sprite is screwed up and overruns the line + int tempLine[SCREEN_WIDTH * 3]; + Common::fill(&tempLine[SCREEN_WIDTH], &tempLine[SCREEN_WIDTH * 3], -1); + int *lineP = flipped ? &tempLine[SCREEN_WIDTH + width - 1 - xOffset] : &tempLine[SCREEN_WIDTH + xOffset]; // Build up the line int byteCount, opr1, opr2; @@ -259,7 +260,7 @@ void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Poi // Handle drawing out the line byte *destP = (byte *)dest.getBasePtr(destPos.x, destPos.y); int16 xp = destPos.x; - lineP = &tempLine[0]; + lineP = &tempLine[SCREEN_WIDTH]; for (int xCtr = 0; xCtr < width; ++xCtr, ++lineP) { bit = (scaleMaskX >> 15) & 1; diff --git a/engines/xeen/sprites.h b/engines/xeen/sprites.h index f660daa0536..025c8db2191 100644 --- a/engines/xeen/sprites.h +++ b/engines/xeen/sprites.h @@ -35,8 +35,11 @@ namespace Xeen { class XeenEngine; class Window; -enum SpriteFlags { SPRFLAG_SCENE_CLIPPED = 0x2000, SPRFLAG_4000 = 0x4000, - SPRFLAG_HORIZ_FLIPPED = 0x8000, SPRFLAG_RESIZE = 0x10000 }; +enum SpriteFlags { + SPRFLAG_800 = 0x800, SPRFLAG_SCENE_CLIPPED = 0x2000, + SPRFLAG_4000 = 0x4000, SPRFLAG_HORIZ_FLIPPED = 0x8000, + SPRFLAG_RESIZE = 0x10000 +}; class SpriteResource { private: