From 89386900bb4b633356da05cd22aac7e4009a28c1 Mon Sep 17 00:00:00 2001 From: uruk Date: Wed, 5 Feb 2014 10:16:05 +0100 Subject: AVALANCHE: Add ghostDrawGlerk(). --- engines/avalanche/graphics.cpp | 28 +++++++++++++++++++++++++++- engines/avalanche/graphics.h | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp index 1a06ebc3c6..dd08eac7f0 100644 --- a/engines/avalanche/graphics.cpp +++ b/engines/avalanche/graphics.cpp @@ -527,6 +527,32 @@ void GraphicManager::ghostDrawGhost(byte ghostArr[2][66][26], uint16 destX, uint ghostPic.free(); } +void GraphicManager::ghostDrawGlerk(byte glerkArr[4][35][9], uint16 destX, uint16 destY) { + // Constants from the original code. + uint16 height = 35; + uint16 width = 9 * 8; + + Graphics::Surface glerkPic; + glerkPic.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 = glerkArr[plane][y][x]; + for (int bit = 0; bit < 8; bit++) { + byte pixelBit = (pixel >> bit) & 1; + if (pixelBit != 0) + *(byte *)glerkPic.getBasePtr(x * 8 + 7 - bit, y) += (pixelBit << plane); + } + } + } + } + + drawPicture(_surface, glerkPic, destX, destY); + + glerkPic.free(); +} + /** * With the use of the second argument, it replaces get_meg_aargh as well. * @remarks Originally called 'get_me' and was located in Ghostroom. @@ -538,7 +564,7 @@ Graphics::Surface GraphicManager::ghostLoadPicture(Common::File &file, Common::P coord.y = cb._y; Graphics::Surface picture = loadPictureGraphic(file); - + int bytesPerRow = (picture.w / 8); if ((picture.w % 8) > 0) bytesPerRow += 1; diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h index 791e04ac1e..485da1f4ee 100644 --- a/engines/avalanche/graphics.h +++ b/engines/avalanche/graphics.h @@ -93,6 +93,7 @@ public: // Ghostroom's functions: void ghostDrawGhost(byte ghostArr[2][66][26], uint16 destX, uint16 destY); // Very similar to loadPictureSign(). TODO: Unify the two later if possible. + void ghostDrawGlerk(byte glerkArr[4][35][9], uint16 destX, uint16 destY); // Very similar to ghostDrawGhost(), but not enough to unify the two. Graphics::Surface ghostLoadPicture(Common::File &file, Common::Point &coord); void ghostDrawPicture(const Graphics::Surface &picture, uint16 destX, uint16 destY); void ghostDrawBackgroundItems(Common::File &file); -- cgit v1.2.3