diff options
author | lukaslw | 2014-05-30 19:07:45 +0200 |
---|---|---|
committer | lukaslw | 2014-06-22 20:08:21 +0200 |
commit | 5df6b9a4f48a10a397cf4642f8695beece4e5704 (patch) | |
tree | 9b7dc4a96fcc1a9c0df3a1c90ddc6940a35bf485 | |
parent | b1eeeb63ba8811a318c200c667e6bf2862993bea (diff) | |
download | scummvm-rg350-5df6b9a4f48a10a397cf4642f8695beece4e5704.tar.gz scummvm-rg350-5df6b9a4f48a10a397cf4642f8695beece4e5704.tar.bz2 scummvm-rg350-5df6b9a4f48a10a397cf4642f8695beece4e5704.zip |
PRINCE: Shadow drawing for background animations
-rw-r--r-- | engines/prince/graphics.cpp | 17 | ||||
-rw-r--r-- | engines/prince/graphics.h | 1 | ||||
-rw-r--r-- | engines/prince/prince.cpp | 44 | ||||
-rw-r--r-- | engines/prince/prince.h | 4 | ||||
-rw-r--r-- | engines/prince/script.h | 1 |
5 files changed, 56 insertions, 11 deletions
diff --git a/engines/prince/graphics.cpp b/engines/prince/graphics.cpp index 551ae70a34..6265d94766 100644 --- a/engines/prince/graphics.cpp +++ b/engines/prince/graphics.cpp @@ -89,6 +89,23 @@ void GraphicsMan::drawTransparent(int32 posX, int32 posY, const Graphics::Surfac 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++) { + byte pixel = *((byte*)s->getBasePtr(x, y)); + if (pixel != 255) { + if (x + posX < _frontScreen->w && x + posX >= 0) { + if (y + posY < _frontScreen->h && y + posY >= 0) { + byte *background = (byte *)_frontScreen->getBasePtr(x + posX, y + posY); + *background = *(shadowTable + *background); + } + } + } + } + } + change(); +} + void GraphicsMan::makeShadowTable(int brightness, byte *shadowPalette) { int32 redFirstOrg, greenFirstOrg, blueFirstOrg; int32 redSecondOrg, greenSecondOrg, blueSecondOrg; diff --git a/engines/prince/graphics.h b/engines/prince/graphics.h index 50a0b16dbc..fea7d14744 100644 --- a/engines/prince/graphics.h +++ b/engines/prince/graphics.h @@ -45,6 +45,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); Graphics::Surface *_frontScreen; Graphics::Surface *_backScreen; diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 1a6cd70f07..8b294eb335 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -115,9 +115,9 @@ PrinceEngine::~PrinceEngine() { } _objList.clear(); - for (uint32 i = 0; i < _backAnimList.size(); i++) { + for (uint i = 0; i < _backAnimList.size(); i++) { int anims = _backAnimList[i]._seq._anims != 0 ? _backAnimList[i]._seq._anims : 1; - for (uint32 j = 0; j < anims; j++) { + for (uint j = 0; j < anims; j++) { delete _backAnimList[i].backAnims[j]._animData; delete _backAnimList[i].backAnims[j]._shadowData; } @@ -716,7 +716,7 @@ void PrinceEngine::showTexts() { } } -void PrinceEngine::showSprite(Graphics::Surface *backAnimSurface, int destX, int destY) { +bool PrinceEngine::spriteCheck(Graphics::Surface *backAnimSurface, int destX, int destY) { int sprWidth = backAnimSurface->w; int sprHeight = backAnimSurface->h; destX -= _picWindowX; @@ -726,25 +726,41 @@ void PrinceEngine::showSprite(Graphics::Surface *backAnimSurface, int destX, int if (destX < 0) { if (destX + sprWidth < 1) { //x2 is negative - out of window - return; + return false; } } // if x1 is outside of screen on right side if (destX >= kNormalWidth) { - return; + return false; } if (destY < 0) { if (destY + sprHeight < 1) { //y2 is negative - out of window - return; + return false; } } if (destY >= kNormalHeight) { - return; + return false; } - _graph->drawTransparent(destX, destY, backAnimSurface); + return true; +} + +void PrinceEngine::showSprite(Graphics::Surface *backAnimSurface, int destX, int destY) { + if (spriteCheck(backAnimSurface, destX, destY)) { + destX -= _picWindowX; + destY -= _picWindowY; + _graph->drawTransparent(destX, destY, backAnimSurface); + } +} + +void PrinceEngine::showSpriteShadow(Graphics::Surface *shadowSurface, int destX, int destY) { + if (spriteCheck(shadowSurface, destX, destY)) { + destX -= _picWindowX; + destY -= _picWindowY; + _graph->drawAsShadow(destX, destY, shadowSurface, _graph->_shadowTable70); + } } void PrinceEngine::showBackAnims() { @@ -873,6 +889,7 @@ void PrinceEngine::showBackAnims() { _backAnimList[i].backAnims[activeSubAnim]._showFrame = _backAnimList[i].backAnims[activeSubAnim]._frame; //ShowFrameCode + //ShowAnimFrame int phaseCount = _backAnimList[i].backAnims[activeSubAnim]._animData->getPhaseCount(); int frameCount = _backAnimList[i].backAnims[activeSubAnim]._animData->getFrameCount(); int phase = _backAnimList[i].backAnims[activeSubAnim]._showFrame; @@ -886,7 +903,18 @@ void PrinceEngine::showBackAnims() { backAnimSurface->free(); delete backAnimSurface; } + //ShowFrameCodeShadow + //ShowAnimFrameShadow + if (_backAnimList[i].backAnims[activeSubAnim]._shadowData != nullptr) { + int shadowPhaseFrameIndex = _backAnimList[i].backAnims[activeSubAnim]._shadowData->getPhaseFrameIndex(phase); + int shadowX = _backAnimList[i].backAnims[activeSubAnim]._shadowData->getBaseX() + _backAnimList[i].backAnims[activeSubAnim]._shadowData->getPhaseOffsetX(phase); + int shadowY = _backAnimList[i].backAnims[activeSubAnim]._shadowData->getBaseY() + _backAnimList[i].backAnims[activeSubAnim]._shadowData->getPhaseOffsetY(phase); + Graphics::Surface *shadowSurface = _backAnimList[i].backAnims[activeSubAnim]._shadowData->getFrame(shadowPhaseFrameIndex); //still with memory leak + showSpriteShadow(shadowSurface, shadowX, shadowY); + shadowSurface->free(); + delete shadowSurface; + } } } } diff --git a/engines/prince/prince.h b/engines/prince/prince.h index 0ced4b6503..034255290b 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -110,7 +110,6 @@ struct BASA { struct Anim { BASA _basaData; int32 _addr; //animation adress - //int32 _seq; int16 _usage; int16 _state; // state of animation: 0 - turning on, 1 - turning off int16 _flags; @@ -128,7 +127,6 @@ struct Anim { int16 _currW; int16 _currH; int16 _packFlag; - int32 _shadow; int32 _currShadowFrame; int16 _packShadowFlag; int32 _shadowBack; @@ -225,7 +223,9 @@ private: void init(); void showLogo(); void showBackAnims(); + bool spriteCheck(Graphics::Surface *backAnimSurface, int destX, int destY); void showSprite(Graphics::Surface *backAnimSurface, int destX, int destY); + void showSpriteShadow(Graphics::Surface *shadowSurface, int destX, int destY); void makeShadowTable(int brightness); uint32 getTextWidth(const char *s); diff --git a/engines/prince/script.h b/engines/prince/script.h index b05d5ca84d..5f0f1e139e 100644 --- a/engines/prince/script.h +++ b/engines/prince/script.h @@ -64,7 +64,6 @@ public: int _pullClose; int _talk; int _give; - //Room_Pad db 64-(Room_Pad-Room_Mobs) dup (0) ??? bool loadFromStream(Common::SeekableReadStream &stream); bool loadRoom(byte *roomData); |