aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/sherlock/animation.cpp2
-rw-r--r--engines/sherlock/graphics.cpp54
-rw-r--r--engines/sherlock/graphics.h4
3 files changed, 49 insertions, 11 deletions
diff --git a/engines/sherlock/animation.cpp b/engines/sherlock/animation.cpp
index 581971820d..0e932b6dd2 100644
--- a/engines/sherlock/animation.cpp
+++ b/engines/sherlock/animation.cpp
@@ -129,7 +129,7 @@ bool Animation::playPrologue(const Common::String &filename, int minDelay, int f
}
// Draw the sprite
- screen.copyFrom(sprite[spriteFrame]._frame, pt);
+ screen.transBlitFrom(sprite[spriteFrame]._frame, pt);
} else {
// No sprite to show for this animation frame
if (fade == 255) {
diff --git a/engines/sherlock/graphics.cpp b/engines/sherlock/graphics.cpp
index 23d3b443e8..2bce822707 100644
--- a/engines/sherlock/graphics.cpp
+++ b/engines/sherlock/graphics.cpp
@@ -36,16 +36,9 @@ Surface::~Surface() {
}
/**
- * Draws a surface into another
- */
-void Surface::copyFrom(const Graphics::Surface &src) {
- copyFrom(src, Common::Point());
-}
-
-/**
* Draws a surface at a given position within this surface
*/
-void Surface::copyFrom(const Graphics::Surface &src, const Common::Point &pt) {
+void Surface::blitFrom(const Graphics::Surface &src, const Common::Point &pt) {
Common::Rect drawRect(0, 0, src.w, src.h);
Common::Point destPt = pt;
@@ -73,6 +66,51 @@ void Surface::copyFrom(const Graphics::Surface &src, const Common::Point &pt) {
}
}
+
+/**
+* Draws a surface at a given position within this surface with transparency
+*/
+void Surface::transBlitFrom(const Graphics::Surface &src, const Common::Point &pt) {
+ Common::Rect drawRect(0, 0, src.w, src.h);
+ Common::Point destPt = pt;
+
+ if (destPt.x < 0) {
+ drawRect.left += -destPt.x;
+ destPt.x = 0;
+ }
+ if (destPt.y < 0) {
+ drawRect.top += -destPt.y;
+ destPt.y = 0;
+ }
+ int right = destPt.x + src.w;
+ if (right > this->w) {
+ drawRect.right -= (right - this->w);
+ }
+ int bottom = destPt.y + src.h;
+ if (bottom > this->h) {
+ drawRect.bottom -= (bottom - this->h);
+ }
+
+ if (!drawRect.isValidRect())
+ return;
+
+ addDirtyRect(Common::Rect(destPt.x, destPt.y, destPt.x + drawRect.width(),
+ destPt.y + drawRect.height()));
+
+ // Draw loop
+ const int TRANSPARENCY = 0xFF;
+ for (int yp = 0; yp < drawRect.height(); ++yp) {
+ const byte *srcP = (const byte *)src.getBasePtr(drawRect.left, drawRect.top + yp);
+ byte *destP = (byte *)getBasePtr(destPt.x, destPt.y + yp);
+
+ for (int xp = 0; xp < drawRect.width(); ++xp, ++srcP, ++destP) {
+ if (*srcP != TRANSPARENCY)
+ *destP = *srcP;
+ }
+ }
+}
+
+
void Surface::fillRect(int x1, int y1, int x2, int y2, byte color) {
Graphics::Surface::fillRect(Common::Rect(x1, y1, x2, y2), color);
}
diff --git a/engines/sherlock/graphics.h b/engines/sherlock/graphics.h
index 1765cf04ae..983a22a790 100644
--- a/engines/sherlock/graphics.h
+++ b/engines/sherlock/graphics.h
@@ -35,8 +35,8 @@ public:
Surface(uint16 width, uint16 height);
~Surface();
- void copyFrom(const Graphics::Surface &src);
- void copyFrom(const Graphics::Surface &src, const Common::Point &pt);
+ void blitFrom(const Graphics::Surface &src, const Common::Point &pt);
+ void transBlitFrom(const Graphics::Surface &src, const Common::Point &pt);
void fillRect(int x1, int y1, int x2, int y2, byte color);
};