aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2015-01-17 09:11:05 -0500
committerPaul Gilbert2015-01-17 09:11:05 -0500
commitb860745a8e1a89bfd34e1c3f263597bef59126ca (patch)
tree5193af897d148b31f587a602e63b66b8bdb27603 /engines
parente0305aa9d94b44aa7d1061e0782f071181f7f7e7 (diff)
downloadscummvm-rg350-b860745a8e1a89bfd34e1c3f263597bef59126ca.tar.gz
scummvm-rg350-b860745a8e1a89bfd34e1c3f263597bef59126ca.tar.bz2
scummvm-rg350-b860745a8e1a89bfd34e1c3f263597bef59126ca.zip
XEEN: Add support for horizontally flipped sprites
Diffstat (limited to 'engines')
-rw-r--r--engines/xeen/interface_map.cpp1
-rw-r--r--engines/xeen/map.cpp4
-rw-r--r--engines/xeen/screen.cpp2
-rw-r--r--engines/xeen/sprites.cpp54
-rw-r--r--engines/xeen/sprites.h2
5 files changed, 33 insertions, 30 deletions
diff --git a/engines/xeen/interface_map.cpp b/engines/xeen/interface_map.cpp
index 45751f8b34..ba6288eacb 100644
--- a/engines/xeen/interface_map.cpp
+++ b/engines/xeen/interface_map.cpp
@@ -1913,6 +1913,7 @@ void InterfaceMap::drawIndoors() {
// WORKAROUND: Original did an array lookup on _skySprites.
// Was this a feature for multiple skys that was abandoned?
+ assert(!map._currentSky);
_indoorList[0]._sprites = &map._skySprites;
_indoorList[0]._flags = _flipSky ? SPRFLAG_HORIZ_FLIPPED : 0;
diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp
index 3e4139628e..86f60852f6 100644
--- a/engines/xeen/map.cpp
+++ b/engines/xeen/map.cpp
@@ -1062,7 +1062,7 @@ void Map::load(int mapId) {
if (_isOutdoors) {
warning("TODO"); // Sound loading
- _skySprites.load(isDarkCc ? "sky.sky" : "night.sky");
+ _skySprites.load(isDarkCc ? "night.sky" : "sky.sky");
_groundSprites.load("water.out");
_tileSprites.load("outdoor.til");
outdoorList._skySprite._sprites = &_skySprites;
@@ -1082,7 +1082,7 @@ void Map::load(int mapId) {
} else {
warning("TODO"); // Sound loading
- _skySprites.load(isDarkCc ? "sky.sky" : "night.sky");
+ _skySprites.load(isDarkCc ? "night.sky" : "sky.sky");
_mazeSkySprites.load(Common::String::format("%s.sky",
TERRAIN_TYPES[_mazeData[0]._wallKind]));
_groundSprites.load(Common::String::format("%s.gnd",
diff --git a/engines/xeen/screen.cpp b/engines/xeen/screen.cpp
index 7b6f972268..b1b42ac551 100644
--- a/engines/xeen/screen.cpp
+++ b/engines/xeen/screen.cpp
@@ -178,7 +178,7 @@ void Window::drawList(DrawStruct *items, int count) {
// TODO: There are two sprite calls in this method. Figure out why
items->_sprites->draw(screen, items->_frame,
- Common::Point(items->_x, items->_y));
+ Common::Point(items->_x, items->_y), items->_flags);
}
}
diff --git a/engines/xeen/sprites.cpp b/engines/xeen/sprites.cpp
index df1debab21..85ca91bde3 100644
--- a/engines/xeen/sprites.cpp
+++ b/engines/xeen/sprites.cpp
@@ -85,7 +85,7 @@ void SpriteResource::clear() {
_filesize = 0;
}
-void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Point &destPos) const {
+void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Point &destPos, int flags) const {
// Get cell header
Common::MemoryReadStream f(_data, _filesize);
f.seek(offset);
@@ -94,6 +94,9 @@ void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Poi
int yOffset = f.readUint16LE();
int height = f.readUint16LE();
+ bool flipped = (flags & SPRFLAG_HORIZ_FLIPPED) != 0;
+ int xInc = flipped ? -1 : 1;
+
if (dest.w < (xOffset + width) || dest.h < (yOffset + height))
dest.create(xOffset + width, yOffset + height);
@@ -116,9 +119,11 @@ void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Poi
} else {
// Skip the transparent pixels at the beginning of the scan line
int xPos = f.readByte() + xOffset; ++byteCount;
- byte *destP = (byte *)dest.getBasePtr(destPos.x + xPos, destPos.y + yPos);
const byte *lineStartP = (const byte *)dest.getBasePtr(0, destPos.y + yPos);
const byte *lineEndP = (const byte *)dest.getBasePtr(dest.w, destPos.y + yPos);
+ byte *destP = !flipped ?
+ (byte *)dest.getBasePtr(destPos.x + xPos, destPos.y + yPos) :
+ (byte *)dest.getBasePtr(destPos.x + width - xPos, destPos.y + yPos);
while (byteCount < lineLength) {
// The next byte is an opcode that determines what
@@ -134,21 +139,20 @@ void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Poi
case 1: // The following len + 33 bytes are stored as indexes into the color table.
for (int i = 0; i < opcode + 1; ++i, ++xPos) {
byte b = f.readByte();
- if (destP < lineStartP || destP >= lineEndP)
- ++destP;
- else
- *destP++ = b;
++byteCount;
+
+ if (destP >= lineStartP && destP < lineEndP)
+ *destP = b;
+ destP += xInc;
}
break;
case 2: // The following byte is an index into the color table, draw it len + 3 times.
opr1 = f.readByte(); ++byteCount;
for (int i = 0; i < len + 3; ++i, ++xPos) {
- if (destP < lineStartP || destP >= lineEndP)
- ++destP;
- else
- *destP++ = opr1;
+ if (destP >= lineStartP && destP < lineEndP)
+ *destP = opr1;
+ destP += xInc;
}
break;
@@ -159,10 +163,9 @@ void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Poi
for (int i = 0; i < len + 4; ++i, ++xPos) {
byte b = f.readByte();
- if (destP < lineStartP || destP >= lineEndP)
- ++destP;
- else
- *destP++ = b;
+ if (destP >= lineStartP && destP < lineEndP)
+ *destP = b;
+ destP += xInc;
}
f.seek(pos, SEEK_SET);
@@ -173,17 +176,19 @@ void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Poi
opr2 = f.readByte(); ++byteCount;
for (int i = 0; i < len + 2; ++i, xPos += 2) {
if (destP < lineStartP || destP >= (lineEndP - 1)) {
- destP += 2;
+ destP += 2 * xInc;
} else {
- *destP++ = opr1;
- *destP++ = opr2;
+ *destP = opr1;
+ destP += xInc;
+ *destP = opr2;
+ destP += xInc;
}
}
break;
case 5: // Skip len + 1 pixels filling them with the transparent color.
xPos += len + 1;
- destP += len + 1;
+ destP += (len + 1) * xInc;
break;
case 6: // Pattern command.
@@ -194,10 +199,9 @@ void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Poi
opr1 = f.readByte(); ++byteCount;
for (int i = 0; i < len + 3; ++i, ++xPos) {
- if (destP < lineStartP || destP >= lineEndP)
- ++destP;
- else
- *destP++ = opr1;
+ if (destP >= lineStartP && destP < lineEndP)
+ *destP = opr1;
+ destP += xInc;
opr1 += patternSteps[cmd + (i % 2)];
}
break;
@@ -219,11 +223,9 @@ void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Poi
void SpriteResource::draw(XSurface &dest, int frame, const Common::Point &destPos, int flags) const {
// TODO: Support the different flags
- assert(!flags);
-
- drawOffset(dest, _index[frame]._offset1, destPos);
+ drawOffset(dest, _index[frame]._offset1, destPos, flags);
if (_index[frame]._offset2)
- drawOffset(dest, _index[frame]._offset2, destPos);
+ drawOffset(dest, _index[frame]._offset2, destPos, flags);
}
void SpriteResource::draw(XSurface &dest, int frame) const {
diff --git a/engines/xeen/sprites.h b/engines/xeen/sprites.h
index 59c1ed1d48..c240059c15 100644
--- a/engines/xeen/sprites.h
+++ b/engines/xeen/sprites.h
@@ -45,7 +45,7 @@ private:
int32 _filesize;
byte *_data;
- void drawOffset(XSurface &dest, uint16 offset, const Common::Point &destPos) const;
+ void drawOffset(XSurface &dest, uint16 offset, const Common::Point &destPos, int flags) const;
public:
SpriteResource();
SpriteResource(const Common::String &filename);