From 9a08e0459c7544050bd18a637562ec444b5875a7 Mon Sep 17 00:00:00 2001 From: uruk Date: Tue, 4 Feb 2014 08:58:48 +0100 Subject: AVALANCHE: Implement loading and drawing of the picture of the ghost. --- engines/avalanche/graphics.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'engines/avalanche/graphics.cpp') diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp index a8efc4be9b..a85d7ebbf4 100644 --- a/engines/avalanche/graphics.cpp +++ b/engines/avalanche/graphics.cpp @@ -500,6 +500,33 @@ void GraphicManager::nimFree() { _nimLogo.free(); } +void GraphicManager::ghostDrawPicture(byte ghostArr[2][66][26], uint16 destX, uint16 destY) { + const byte kPlaneToUse[4] = { 0, 0, 0, 1 }; + // Constants from the original code. + uint16 height = 66; + uint16 width = 26 * 8; + + Graphics::Surface ghostPic; + ghostPic.create(width, height, Graphics::PixelFormat::createFormatCLUT8()); + + for (int y = 0; y < height; y++) { + for (int plane = 0; plane < 4; plane++) { + for (uint16 x = 0; x < width / 8; x ++) { + byte pixel = ghostArr[kPlaneToUse[plane]][y][x]; + for (int bit = 0; bit < 8; bit++) { + byte pixelBit = (pixel >> bit) & 1; + if (pixelBit != 0) + *(byte *)ghostPic.getBasePtr(x * 8 + 7 - bit, y) += (pixelBit << plane); + } + } + } + } + + drawPicture(_surface, ghostPic, destX, destY); + + ghostPic.free(); +} + /** * This function mimics Pascal's getimage(). */ -- cgit v1.2.3