From 4c9e67ccfa709a74f2c78580f42bb642b258cd22 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sun, 7 Jun 2015 17:05:26 +0200 Subject: SHERLOCK: 3DO animation support --- engines/sherlock/surface.cpp | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'engines/sherlock/surface.cpp') diff --git a/engines/sherlock/surface.cpp b/engines/sherlock/surface.cpp index 006b31ecda..3bbaf4677e 100644 --- a/engines/sherlock/surface.cpp +++ b/engines/sherlock/surface.cpp @@ -30,8 +30,8 @@ namespace Sherlock { const int TRANSPARENCY = 0xFF; -Surface::Surface(uint16 width, uint16 height) : _freePixels(true) { - create(width, height); +Surface::Surface(uint16 width, uint16 height, Common::Platform platform) : _freePixels(true) { + create(width, height, platform); } Surface::Surface() : _freePixels(false) { @@ -42,11 +42,15 @@ Surface::~Surface() { _surface.free(); } -void Surface::create(uint16 width, uint16 height) { +void Surface::create(uint16 width, uint16 height, Common::Platform platform) { if (_freePixels) _surface.free(); - _surface.create(width, height, Graphics::PixelFormat::createFormatCLUT8()); + if (platform == Common::kPlatform3DO) { + _surface.create(width, height, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); + } else { + _surface.create(width, height, Graphics::PixelFormat::createFormatCLUT8()); + } _freePixels = true; } @@ -185,6 +189,34 @@ void Surface::transBlitFromUnscaled(const Graphics::Surface &src, const Common:: } } +// TODO: Needs to get implemented properly +void Surface::transBlitFromUnscaled3DO(const Graphics::Surface &src, const Common::Point &pt) { + Common::Rect drawRect(0, 0, src.w, src.h); + Common::Rect destRect(pt.x, pt.y, pt.x + src.w, pt.y + src.h); + + // Clip the display area to on-screen + if (!clip(drawRect, destRect)) + // It's completely off-screen + return; + + Common::Point destPt(destRect.left, destRect.top); + addDirtyRect(Common::Rect(destPt.x, destPt.y, destPt.x + drawRect.width(), + destPt.y + drawRect.height())); + + // Draw loop + for (int yp = 0; yp < drawRect.height(); ++yp) { + const uint16 *srcP = (const uint16 *)src.getBasePtr(drawRect.left, drawRect.top + yp); + uint16 *destP = (uint16 *)getBasePtr(destPt.x, destPt.y + yp); + + for (int xp = 0; xp < drawRect.width(); ++xp, ++destP) { + if (*srcP) // 0 = transparent on 3DO + *destP = *srcP; + + srcP = srcP + 1; + } + } +} + void Surface::fillRect(int x1, int y1, int x2, int y2, byte color) { fillRect(Common::Rect(x1, y1, x2, y2), color); } -- cgit v1.2.3