From 8d4e562555a5bc0bc5f9aea8ee2bbcb4f14dc18f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 13 Oct 2011 14:01:19 +0300 Subject: SCI: Implemented kBitmap(3) and kBitmap(5). Some cleanup --- engines/sci/engine/kgraphics.cpp | 56 +++++++++++++++++++++++++++++----------- engines/sci/graphics/text32.cpp | 9 ------- engines/sci/graphics/text32.h | 3 --- 3 files changed, 41 insertions(+), 27 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index ce670b21fe..5ea5132566 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -1648,12 +1648,18 @@ reg_t kBitmap(EngineState *s, int argc, reg_t *argv) { // script 64890 and TransView::init() in script 64884 uint16 width = argv[1].toUint16(); uint16 height = argv[2].toUint16(); - uint16 skip = argv[3].toUint16(); + //uint16 skip = argv[3].toUint16(); uint16 back = argv[4].toUint16(); - uint16 width2 = (argc >= 6) ? argv[5].toUint16() : 0; - uint16 height2 = (argc >= 7) ? argv[6].toUint16() : 0; - uint16 transparentFlag = (argc >= 8) ? argv[7].toUint16() : 0; - return g_sci->_gfxText32->createTextBitmapSci21(width, height, skip, back, width2, height2, transparentFlag); + //uint16 width2 = (argc >= 6) ? argv[5].toUint16() : 0; + //uint16 height2 = (argc >= 7) ? argv[6].toUint16() : 0; + //uint16 transparentFlag = (argc >= 8) ? argv[7].toUint16() : 0; + + // TODO: skip, width2, height2, transparentFlag + int entrySize = width * height; + reg_t memoryId = s->_segMan->allocateHunkEntry("TextBitmap()", entrySize); + byte *memoryPtr = s->_segMan->getHunkPointer(memoryId); + memset(memoryPtr, back, entrySize); + return memoryId; } break; case 1: // dispose text bitmap surface @@ -1667,16 +1673,29 @@ reg_t kBitmap(EngineState *s, int argc, reg_t *argv) { { // 6 params, called e.g. from TiledBitmap::resize() in Torin's Passage, // script 64869 - reg_t bitmapPtr = argv[1]; // obtained from kBitmap(0) + reg_t hunkId = argv[1]; // obtained from kBitmap(0) // The tiled view seems to always have 2 loops. // These loops need to have 1 cel in loop 0 and 8 cels in loop 1. - uint16 view = argv[2].toUint16(); // vTiles selector + uint16 viewNum = argv[2].toUint16(); // vTiles selector uint16 loop = argv[3].toUint16(); uint16 cel = argv[4].toUint16(); uint16 x = argv[5].toUint16(); uint16 y = argv[6].toUint16(); - warning("kBitmap(3): bitmap ptr %04x:%04x, view %d, loop %d, cel %d, x %d, y %d", - PRINT_REG(bitmapPtr), view, loop, cel, x, y); + + byte *bitmap = s->_segMan->getHunkPointer(hunkId); + + GfxView *view = g_sci->_gfxCache->getView(viewNum); + uint16 width = view->getWidth(loop, cel); + uint16 height = view->getHeight(loop, cel); + const byte *viewBitmap = view->getBitmap(loop, cel); + uint32 curPixel = 0; + + for (uint16 curY = y; curY < y + height; curY++) { + for (uint16 curX = x; curX < x + width; curX++) { + bitmap[curY + curX] = viewBitmap[curPixel++]; + } + } + } break; case 4: // process text @@ -1699,18 +1718,25 @@ reg_t kBitmap(EngineState *s, int argc, reg_t *argv) { PRINT_REG(bitmapPtr), font, mode, dimmed, text.c_str()); } break; - case 5: + case 5: // fill with color { // 6 params, called e.g. from TextView::init() and TextView::draw() // in Torin's Passage, script 64890 - reg_t bitmapPtr = argv[1]; // obtained from kBitmap(0) - uint16 unk1 = argv[2].toUint16(); // unknown, usually 0, judging from scripts? - uint16 unk2 = argv[3].toUint16(); // unknown, usually 0, judging from scripts? + reg_t hunkId = argv[1]; // obtained from kBitmap(0) + uint16 x = argv[2].toUint16(); + uint16 y = argv[3].toUint16(); uint16 width = argv[4].toUint16(); // width - 1 uint16 height = argv[5].toUint16(); // height - 1 uint16 back = argv[6].toUint16(); - warning("kBitmap(5): bitmap ptr %04x:%04x, unk1 %d, unk2 %d, width %d, height %d, back %d", - PRINT_REG(bitmapPtr), unk1, unk2, width, height, back); + + byte *bitmap = s->_segMan->getHunkPointer(hunkId); + + for (uint16 curY = y; curY < y + height; curY++) { + for (uint16 curX = x; curX < x + width; curX++) { + bitmap[curY + curX] = back; + } + } + } break; default: diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp index 85ede02239..52124fda6d 100644 --- a/engines/sci/graphics/text32.cpp +++ b/engines/sci/graphics/text32.cpp @@ -100,15 +100,6 @@ reg_t GfxText32::createTextBitmap(reg_t textObject, uint16 maxWidth, uint16 maxH return memoryId; } -reg_t GfxText32::createTextBitmapSci21(uint16 width, uint16 height, byte skip, byte back, uint16 width2, uint16 height2, byte transparentFlag) { - // TODO: skip, width2, height2, transparentFlag - int entrySize = width * height; - reg_t memoryId = _segMan->allocateHunkEntry("TextBitmap()", entrySize); - byte *memoryPtr = _segMan->getHunkPointer(memoryId); - memset(memoryPtr, back, entrySize); - return memoryId; -} - void GfxText32::disposeTextBitmap(reg_t hunkId) { _segMan->freeHunkEntry(hunkId); } diff --git a/engines/sci/graphics/text32.h b/engines/sci/graphics/text32.h index 43395f6517..5a069958d9 100644 --- a/engines/sci/graphics/text32.h +++ b/engines/sci/graphics/text32.h @@ -26,8 +26,6 @@ #ifndef SCI_GRAPHICS_TEXT32_H #define SCI_GRAPHICS_TEXT32_H -#include "common/hashmap.h" - namespace Sci { /** @@ -38,7 +36,6 @@ public: GfxText32(SegManager *segMan, GfxCache *fonts, GfxScreen *screen); ~GfxText32(); reg_t createTextBitmap(reg_t textObject, uint16 maxWidth = 0, uint16 maxHeight = 0); - reg_t createTextBitmapSci21(uint16 width, uint16 height, byte skip, byte back, uint16 width2, uint16 height2, byte transparentFlag); void disposeTextBitmap(reg_t hunkId); void drawTextBitmap(reg_t textObject); int16 GetLongest(const char *text, int16 maxWidth, GfxFont *font); -- cgit v1.2.3