From 6f19bd82f48ffb7c9f772c8b3112449df36ce6eb Mon Sep 17 00:00:00 2001 From: lukaslw Date: Sun, 1 Jun 2014 02:58:27 +0200 Subject: [PATCH] PRINCE: Object class update, showObjects() beginning --- engines/prince/graphics.cpp | 1 + engines/prince/object.cpp | 8 +++--- engines/prince/object.h | 10 +++++++- engines/prince/prince.cpp | 49 +++++++++++++++++++++++++++++++------ engines/prince/prince.h | 2 ++ 5 files changed, 58 insertions(+), 12 deletions(-) diff --git a/engines/prince/graphics.cpp b/engines/prince/graphics.cpp index 46c52a86ca2c..679885f7b83c 100644 --- a/engines/prince/graphics.cpp +++ b/engines/prince/graphics.cpp @@ -101,6 +101,7 @@ void GraphicsMan::drawMask(int32 posX, int32 posY, int32 width, int32 height, by if ((maskData[tempMaskPostion] & maskCounter) != 0) { byte orgPixel = *((byte*)originalRoomSurface->getBasePtr(x + posX, y + posY)); *((byte*)_frontScreen->getBasePtr(x + posX, y + posY)) = orgPixel; + //*((byte*)_frontScreen->getBasePtr(x + posX, y + posY)) = 0; // for debugging } } } diff --git a/engines/prince/object.cpp b/engines/prince/object.cpp index 9386eaa4963d..11c553ffbc3d 100644 --- a/engines/prince/object.cpp +++ b/engines/prince/object.cpp @@ -32,7 +32,9 @@ namespace Prince { -Object::Object() : _surface(NULL), _x(0), _y(0), _z(0), _overlay(0) { +Object::Object() : _surface(NULL), _x(0), _y(0), _z(0), _mask(0), + _zoomInSource(0), _zoomInLen(0), _zoomInAddr(0), _zoomInTime(0) +{ } Object::~Object() { @@ -73,12 +75,12 @@ bool Object::loadFromStream(Common::SeekableReadStream &stream) { loadSurface(*obStream); delete obStream; - _overlay = stream.readUint16LE(); + _mask = stream.readUint16LE(); _z = stream.readUint16LE(); stream.seek(pos + 16); - debug("Object x %d, y %d, z %d overlay %d", _x, _y, _z, _overlay); + debug("Object x %d, y %d, z %d overlay %d", _x, _y, _z, _mask); return true; } diff --git a/engines/prince/object.h b/engines/prince/object.h index 66f2a725f834..5bc7c580daad 100644 --- a/engines/prince/object.h +++ b/engines/prince/object.h @@ -33,9 +33,17 @@ class Object { Object(); ~Object(); + int32 _x; + int32 _y; + int32 _z; + int32 _mask; // or flags + int32 _zoomInSource; + int32 _zoomInLen; + int32 _zoomInAddr; + int32 _zoomInTime; + bool loadFromStream(Common::SeekableReadStream &stream); const Graphics::Surface *getSurface() const { return _surface; } - uint16 _x, _y, _z, _overlay; private: void loadSurface(Common::SeekableReadStream &stream); Graphics::Surface *_surface; diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 6a65ee162b5b..a82fe9569dfc 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -977,6 +977,44 @@ void PrinceEngine::clearBackAnimList() { _backAnimList.clear(); } +void PrinceEngine::showObjects() { + if (!_objList.empty()) { + for (uint i = 0; i < _objList.size(); i++) { + if ((_objList[i]->_mask & 32768) != 0) { // 8000h + _objList[i]->_zoomInTime--; + if (_objList[i]->_zoomInTime == 0) { + _objList[i]->_mask &= 32767; //7FFFh + } else { + // doZoomIn(); + // mov edx, d [esi.Obj_ZoomInAddr] + } + } + if ((_objList[i]->_mask & 16384) != 0) { // 4000h + _objList[i]->_zoomInTime--; + if (_objList[i]->_zoomInTime == 0) { + _objList[i]->_mask &= 49151; //0BFFFh + } else { + // doZoomOut(); + // mov edx, d [esi.Obj_ZoomInAddr] + } + } + const Graphics::Surface *objSurface = _objList[i]->getSurface(); + if (spriteCheck(objSurface->w, objSurface->h, _objList[i]->_x, _objList[i]->_y)) { + if ((_objList[i]->_mask & 512) == 0) { // 0200h + int destX = _objList[i]->_x - _picWindowX; + int destY = _objList[i]->_y - _picWindowY; + _graph->drawTransparent(destX, destY, objSurface); + } else { + // showBackSprite(); + } + } + if ((_objList[i]->_mask & 1) != 0) { + checkMasks(_objList[i]->_x, _objList[i]->_y, objSurface->w, objSurface->h, _objList[i]->_z); + } + } + } +} + void PrinceEngine::drawScreen() { const Graphics::Surface *roomSurface = _roomBmp->getSurface(); Graphics::Surface visiblePart; @@ -1002,15 +1040,10 @@ void PrinceEngine::drawScreen() { delete mainHeroSurface; } - /* - if (!_objList.empty()) { - for (int i = 0; i < _objList.size(); i++) { - _graph->drawTransparent(_objList[i]->_x, _objList[i]->_y, _objList[i]->getSurface()); - } - } - */ - showBackAnims(); + + showObjects(); + if (roomSurface) { insertMasks(&visiblePart); } diff --git a/engines/prince/prince.h b/engines/prince/prince.h index 443a5bd1482b..15dfdb4b7b21 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -171,6 +171,7 @@ struct Mask { int16 getHeight() const { return READ_LE_UINT16(_data + 6); } + byte *getMask() const { return (byte *)(_data + 8); } @@ -266,6 +267,7 @@ class PrinceEngine : public Engine { bool spriteCheck(int sprWidth, int sprHeight, int destX, int destY); void showSprite(Graphics::Surface *backAnimSurface, int destX, int destY); void showSpriteShadow(Graphics::Surface *shadowSurface, int destX, int destY); + void showObjects(); void makeShadowTable(int brightness); uint32 getTextWidth(const char *s);