aboutsummaryrefslogtreecommitdiff
path: root/engines/macventure/image.cpp
diff options
context:
space:
mode:
authorBorja Lorente2016-06-22 21:48:14 +0200
committerBorja Lorente2016-08-14 18:33:25 +0200
commit1540674f7720f520bdb585999e24ceb653c9bda3 (patch)
treecffa9a277fce2df8178a87101a39e1427adb0622 /engines/macventure/image.cpp
parent0743e9531b5ef871e17cd7ca88966ea2c07b7147 (diff)
downloadscummvm-rg350-1540674f7720f520bdb585999e24ceb653c9bda3.tar.gz
scummvm-rg350-1540674f7720f520bdb585999e24ceb653c9bda3.tar.bz2
scummvm-rg350-1540674f7720f520bdb585999e24ceb653c9bda3.zip
MACVENTURE: Fix dymanic object drawing
Diffstat (limited to 'engines/macventure/image.cpp')
-rw-r--r--engines/macventure/image.cpp58
1 files changed, 51 insertions, 7 deletions
diff --git a/engines/macventure/image.cpp b/engines/macventure/image.cpp
index 47b755a829..60f491cf55 100644
--- a/engines/macventure/image.cpp
+++ b/engines/macventure/image.cpp
@@ -332,8 +332,7 @@ void ImageAsset::blitInto(Graphics::ManagedSurface *target, uint32 x, uint32 y,
blitOR(target, x, y, _maskData);
break;
}
- }
- else if (_container->getItemByteSize(_id)) {
+ } else if (_container->getItemByteSize(_id)) {
switch (mode) {
case MacVenture::kBlitBIC:
target->fillRect(Common::Rect(x, y, x + _bitWidth, y + _bitHeight * 2), kColorWhite);
@@ -343,12 +342,24 @@ void ImageAsset::blitInto(Graphics::ManagedSurface *target, uint32 x, uint32 y,
break;
}
}
+
if (_container->getItemByteSize(_id) && mode > 0) {
blitXOR(target, x, y, _imgData);
}
}
void ImageAsset::blitDirect(Graphics::ManagedSurface * target, uint32 ox, uint32 oy, const Common::Array<byte>& data) {
+ if (_bitWidth == 0 || _bitHeight == 0) return;
+ uint w = _bitWidth;
+ uint h = _bitHeight;
+ uint sx = 0;
+ uint sy = 0;
+ if (ox<0) { sx = -ox; ox = 0; }
+ if (oy<0) { sy = -oy; oy = 0; }
+ if (w + ox >= target->w) w = target->w - ox;
+ if (h + oy >= target->h) h = target->h - oy;
+ if (w == 0 || h == 0) return;
+
for (uint y = 0;y < _bitHeight; y++) {
uint bmpofs = y * _rowBytes;
byte pix = 0;
@@ -361,10 +372,21 @@ void ImageAsset::blitDirect(Graphics::ManagedSurface * target, uint32 ox, uint32
}
void ImageAsset::blitBIC(Graphics::ManagedSurface * target, uint32 ox, uint32 oy, const Common::Array<byte> &data) {
- for (uint y = 0;y < _bitHeight; y++) {
+ if (_bitWidth == 0 || _bitHeight == 0) return;
+ uint w = _bitWidth;
+ uint h = _bitHeight;
+ uint sx = 0;
+ uint sy = 0;
+ if (ox<0) { sx = -ox; ox = 0; }
+ if (oy<0) { sy = -oy; oy = 0; }
+ if (w + ox >= target->w) w = target->w - ox;
+ if (h + oy >= target->h) h = target->h - oy;
+ if (w == 0 || h == 0) return;
+
+ for (uint y = 0;y < h; y++) {
uint bmpofs = y * _rowBytes;
byte pix = 0;
- for (uint x = 0; x < _bitWidth; x++) {
+ for (uint x = 0; x < w; x++) {
pix = data[bmpofs + (x >> 3)] & (1 << (7 - (x & 7)));
if (pix) *((byte *)target->getBasePtr(ox + x, oy + y)) = kColorWhite;
@@ -373,6 +395,17 @@ void ImageAsset::blitBIC(Graphics::ManagedSurface * target, uint32 ox, uint32 oy
}
void ImageAsset::blitOR(Graphics::ManagedSurface * target, uint32 ox, uint32 oy, const Common::Array<byte> &data) {
+ if (_bitWidth == 0 || _bitHeight == 0) return;
+ uint w = _bitWidth;
+ uint h = _bitHeight;
+ uint sx = 0;
+ uint sy = 0;
+ if (ox<0) { sx = -ox; ox = 0; }
+ if (oy<0) { sy = -oy; oy = 0; }
+ if (w + ox >= target->w) w = target->w - ox;
+ if (h + oy >= target->h) h = target->h - oy;
+ if (w == 0 || h == 0) return;
+
for (uint y = 0;y < _bitHeight; y++) {
uint bmpofs = y * _rowBytes;
byte pix = 0;
@@ -385,6 +418,17 @@ void ImageAsset::blitOR(Graphics::ManagedSurface * target, uint32 ox, uint32 oy,
}
void ImageAsset::blitXOR(Graphics::ManagedSurface * target, uint32 ox, uint32 oy, const Common::Array<byte> &data) {
+ if (_bitWidth == 0 || _bitHeight == 0) return;
+ uint w = _bitWidth;
+ uint h = _bitHeight;
+ uint sx = 0;
+ uint sy = 0;
+ if (ox<0) { sx = -ox; ox = 0; }
+ if (oy<0) { sy = -oy; oy = 0; }
+ if (w + ox >= target->w) w = target->w - ox;
+ if (h + oy >= target->h) h = target->h - oy;
+ if (w == 0 || h == 0) return;
+
for (uint y = 0;y < _bitHeight; y++) {
uint bmpofs = y * _rowBytes;
byte pix = 0;
@@ -393,9 +437,9 @@ void ImageAsset::blitXOR(Graphics::ManagedSurface * target, uint32 ox, uint32 oy
if (pix) { // We need to xor
byte p = *((byte *)target->getBasePtr(ox + x, oy + y));
- if (p == kColorWhite) p = kColorBlack;
- else p = kColorWhite;
- *((byte *)target->getBasePtr(ox + x, oy + y)) = p;
+
+ *((byte *)target->getBasePtr(ox + x, oy + y)) =
+ (p == kColorWhite) ? kColorBlack : kColorWhite;
}
}
}