diff options
-rw-r--r-- | engines/prince/graphics.cpp | 14 | ||||
-rw-r--r-- | engines/prince/graphics.h | 1 | ||||
-rw-r--r-- | engines/prince/prince.cpp | 14 | ||||
-rw-r--r-- | engines/prince/prince.h | 25 | ||||
-rw-r--r-- | engines/prince/script.cpp | 8 |
5 files changed, 53 insertions, 9 deletions
diff --git a/engines/prince/graphics.cpp b/engines/prince/graphics.cpp index 5bcadc442a..93b558a03b 100644 --- a/engines/prince/graphics.cpp +++ b/engines/prince/graphics.cpp @@ -89,6 +89,20 @@ void GraphicsMan::drawTransparent(int32 posX, int32 posY, const Graphics::Surfac change(); } +void GraphicsMan::drawMask(int32 posX, int32 posY, int32 width, int32 height, byte *maskData, const Graphics::Surface *originalRoomSurface) { + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + if (x + posX < _frontScreen->w && x + posX >= 0) { + if (y + posY < _frontScreen->h && y + posY >= 0) { + byte orgPixel = *((byte*)originalRoomSurface->getBasePtr(x + posX, y + posY)); + *((byte*)_frontScreen->getBasePtr(x + posX, y + posY)) = orgPixel; + } + } + } + } + change(); +} + void GraphicsMan::drawAsShadow(int32 posX, int32 posY, const Graphics::Surface *s, byte *shadowTable) { for (int y = 0; y < s->h; y++) { for (int x = 0; x < s->w; x++) { diff --git a/engines/prince/graphics.h b/engines/prince/graphics.h index af2bfe716d..e6293bbeee 100644 --- a/engines/prince/graphics.h +++ b/engines/prince/graphics.h @@ -46,6 +46,7 @@ public: void draw(uint16 x, uint16 y, const Graphics::Surface *s); void drawTransparent(int32 posX, int32 poxY, const Graphics::Surface *s); void drawAsShadow(int32 posX, int32 poxY, const Graphics::Surface *s, byte *shadowTable); + void drawMask(int32 posX, int32 posY, int32 width, int32 height, byte *maskData, const Graphics::Surface *originalRoomSurface); Graphics::Surface *_frontScreen; Graphics::Surface *_backScreen; diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 36f0ea7bc8..e63986dc3c 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -770,18 +770,18 @@ void PrinceEngine::checkMasks(int x1, int y1, int sprWidth, int sprHeight, int z } // InsertNakladki -void PrinceEngine::insertMasks() { +void PrinceEngine::insertMasks(const Graphics::Surface *originalRoomSurface) { for (uint i = 0; i < _maskList.size(); i++) { if (_maskList[i]._state == 1) { - showMask(i); + showMask(i, originalRoomSurface); } } } // ShowNak -void PrinceEngine::showMask(int maskNr) { +void PrinceEngine::showMask(int maskNr, const Graphics::Surface *originalRoomSurface) { if (_maskList[maskNr]._flags == 0) { - + _graph->drawMask(_maskList[maskNr]._x1, _maskList[maskNr]._y1, _maskList[maskNr]._width, _maskList[maskNr]._height, _maskList[maskNr].getMask(), originalRoomSurface); } } @@ -971,8 +971,9 @@ void PrinceEngine::clearBackAnimList() { void PrinceEngine::drawScreen() { const Graphics::Surface *roomSurface = _roomBmp->getSurface(); + Graphics::Surface visiblePart; if (roomSurface) { - const Graphics::Surface visiblePart = roomSurface->getSubArea(Common::Rect(_picWindowX, 0, roomSurface->w, roomSurface->h)); + visiblePart = roomSurface->getSubArea(Common::Rect(_picWindowX, 0, roomSurface->w, roomSurface->h)); _graph->draw(0, 0, &visiblePart); } @@ -1002,6 +1003,9 @@ void PrinceEngine::drawScreen() { */ showBackAnims(); + if (roomSurface) { + insertMasks(&visiblePart); + } playNextFrame(); diff --git a/engines/prince/prince.h b/engines/prince/prince.h index 68a4159be2..1a6fa14e0d 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -151,7 +151,28 @@ struct Mask { int16 _y2; int16 _z; int16 _number; // number of mask for background recreating + int16 _width; + int16 _height; byte *_data; + + int16 Mask::getX() const { + return READ_LE_UINT16(_data); + } + + int16 Mask::getY() const { + return READ_LE_UINT16(_data + 2); + } + + int16 Mask::getWidth() const { + return READ_LE_UINT16(_data + 4); + } + + int16 Mask::getHeight() const { + return READ_LE_UINT16(_data + 6); + } + byte *Mask::getMask() const { + return (byte *)(_data + 8); + } }; struct DebugChannel { @@ -223,8 +244,8 @@ public: static const int16 kNormalHeight = 480; void checkMasks(int x1, int y1, int sprWidth, int sprHeight, int z); - void insertMasks(); - void showMask(int maskNr); + void insertMasks(const Graphics::Surface *originalRoomSurface); + void showMask(int maskNr, const Graphics::Surface *originalRoomSurface); int testAnimNr; int testAnimFrame; diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index 9f2f54a74e..13234971cd 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -312,7 +312,7 @@ bool Script::loadAllMasks(Common::Array<Mask> &maskList, int offset) { tempMask._z = READ_UINT32(&_data[offset + 12]); debug("tempMask._z: %d", tempMask._z); tempMask._number = READ_UINT32(&_data[offset + 14]); - debug("tempMask._number: %d\n", tempMask._number); + debug("tempMask._number: %d", tempMask._number); const Common::String msStreamName = Common::String::format("MS%02d", tempMask._number); Common::SeekableReadStream *msStream = SearchMan.createReadStreamForMember(msStreamName); @@ -321,6 +321,7 @@ bool Script::loadAllMasks(Common::Array<Mask> &maskList, int offset) { delete msStream; return false; } + uint32 dataSize = msStream->size(); if (dataSize != -1) { tempMask._data = (byte *)malloc(dataSize); @@ -331,9 +332,12 @@ bool Script::loadAllMasks(Common::Array<Mask> &maskList, int offset) { } delete msStream; } + tempMask._width = tempMask.getHeight(); + tempMask._height = tempMask.getHeight(); + debug("width: %d, height: %d\n", tempMask._width, tempMask._height); maskList.push_back(tempMask); - offset += 16; // size of tempMask (Nak) struct + offset += 16; // size of Mask (Nak) struct } debug("Mask size: %d", sizeof(tempMask)); debug("maskList size: %d", maskList.size()); |