diff options
author | lukaslw | 2014-05-28 05:13:25 +0200 |
---|---|---|
committer | lukaslw | 2014-06-22 20:08:17 +0200 |
commit | ada532cf2ead17e5e7e2483328a14d1907ad9e7b (patch) | |
tree | 0e9ab48fa49b1b8cec1b0e5c0fdc6477167e9d6b | |
parent | b92d7762df557ff03600035a5fbf862a05a47f13 (diff) | |
download | scummvm-rg350-ada532cf2ead17e5e7e2483328a14d1907ad9e7b.tar.gz scummvm-rg350-ada532cf2ead17e5e7e2483328a14d1907ad9e7b.tar.bz2 scummvm-rg350-ada532cf2ead17e5e7e2483328a14d1907ad9e7b.zip |
PRINCE: showSprite and drawTransparent update
-rw-r--r-- | engines/prince/graphics.cpp | 12 | ||||
-rw-r--r-- | engines/prince/graphics.h | 2 | ||||
-rw-r--r-- | engines/prince/prince.cpp | 51 |
3 files changed, 25 insertions, 40 deletions
diff --git a/engines/prince/graphics.cpp b/engines/prince/graphics.cpp index 5b66994b47..551ae70a34 100644 --- a/engines/prince/graphics.cpp +++ b/engines/prince/graphics.cpp @@ -73,12 +73,16 @@ void GraphicsMan::draw(uint16 posX, uint16 posY, const Graphics::Surface *s) { change(); } -void GraphicsMan::drawTransparent(uint16 posX, uint16 posY, const Graphics::Surface *s) { - for (uint y = 0; y < s->h; ++y) { - for (uint x = 0; x < s->w; ++x) { +void GraphicsMan::drawTransparent(int32 posX, int32 posY, const Graphics::Surface *s) { + 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) { - *((byte*)_frontScreen->getBasePtr(x + posX, y + posY)) = pixel; + if (x + posX < _frontScreen->w && x + posX >= 0) { + if (y + posY < _frontScreen->h && y + posY >= 0) { + *((byte*)_frontScreen->getBasePtr(x + posX, y + posY)) = pixel; + } + } } } } diff --git a/engines/prince/graphics.h b/engines/prince/graphics.h index 3e43503c58..50a0b16dbc 100644 --- a/engines/prince/graphics.h +++ b/engines/prince/graphics.h @@ -44,7 +44,7 @@ public: void makeShadowTable(int brightness, byte *shadowTable); void draw(uint16 x, uint16 y, const Graphics::Surface *s); - void drawTransparent(uint16 x, uint16 y, const Graphics::Surface *s); + void drawTransparent(int32 posX, int32 poxY, const Graphics::Surface *s); Graphics::Surface *_frontScreen; Graphics::Surface *_backScreen; diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 6abc4bf6b4..48bf932f41 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -709,51 +709,32 @@ void PrinceEngine::showTexts() { void PrinceEngine::showSprite(Graphics::Surface *backAnimSurface, int destX, int destY) { int sprWidth = backAnimSurface->w; int sprHeight = backAnimSurface->h; - int sprModulo = 0; - destX -= _picWindowX; - if (destX < 0) { // x1 on visible part of screen? - // X1 signed, we add spriteWidth for x2 - if (sprWidth + destX < 1) { - //exit - x2 is negative - out of window - return; // don't draw - } else { - //esi += -1 * destX; - sprWidth -= -1 * destX; - sprModulo += -1 * destX; - destX = 0; // x1 = 0; + destY -= _picWindowY; + + // if x1 is on visible part of screen + if (destX < 0) { + if (destX + sprWidth < 1) { + //x2 is negative - out of window + return; } } - //left_x_check_ok - if (destX >= kNormalWidth) { // x1 outside of screen on right side - return; // don't draw - } - if (destX + sprWidth > kNormalWidth) { // x2 too far? - sprWidth -= destX - kNormalWidth; - sprModulo += destX - kNormalWidth; + // if x1 is outside of screen on right side + if (destX >= kNormalWidth) { + return; } - //right_x_check_ok - destY -= _picWindowY; + if (destY < 0) { - if (sprHeight + destY < 1) { - //exit - y2 is negative - out of window - return; // don't draw - } else { - sprHeight -= -1 * destY; - //esi += (sprWidth + sprModulo) * (-1 * destY); - destY = 0; + if (destY + sprHeight < 1) { + //y2 is negative - out of window + return; } } - //upper_y_check_ok if (destY >= kNormalHeight) { - return; // don't draw - } - if (destY + sprHeight > kNormalHeight) { - sprHeight -= destY + sprHeight - kNormalHeight; + return; } - //lower_y_check_ok - _graph->drawTransparent(destX, destY, backAnimSurface); // TODO + _graph->drawTransparent(destX, destY, backAnimSurface); } void PrinceEngine::showBackAnims() { |