mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-09 12:22:51 +00:00
SHERLOCK: Implement screen clipping for sprite drawing
This commit is contained in:
parent
0ee3f1895f
commit
cb874522e4
@ -101,7 +101,7 @@ bool Animation::playPrologue(const Common::String &filename, int minDelay, int f
|
||||
events.delay(minDelay);
|
||||
if (fade != 0 && fade != 255)
|
||||
screen.fadeToBlack();
|
||||
fade = 0; //***DEBUG****
|
||||
|
||||
if (setPalette) {
|
||||
if (fade != 255)
|
||||
screen.setPalette(sprite._palette);
|
||||
@ -112,19 +112,26 @@ bool Animation::playPrologue(const Common::String &filename, int minDelay, int f
|
||||
Common::Point pt;
|
||||
bool skipped = false;
|
||||
while (!_vm->shouldQuit()) {
|
||||
// Get the next sprite to display
|
||||
spriteFrame = stream->readSint16LE();
|
||||
if (spriteFrame != -1) {
|
||||
|
||||
if (spriteFrame == -2) {
|
||||
// End of animation reached
|
||||
break;
|
||||
} else if (spriteFrame != -1) {
|
||||
// Read position from either animation stream or the sprite frame itself
|
||||
if (spriteFrame < 0) {
|
||||
spriteFrame = ABS(spriteFrame);
|
||||
spriteFrame += 32769;
|
||||
pt.x = stream->readUint16LE();
|
||||
pt.y = stream->readUint16LE();
|
||||
} else {
|
||||
pt = sprite[spriteFrame]._position;
|
||||
}
|
||||
|
||||
screen.copyFrom(sprite[spriteFrame]._frame);
|
||||
events.pollEventsAndWait();
|
||||
// Draw the sprite
|
||||
screen.copyFrom(sprite[spriteFrame]._frame, pt);
|
||||
} else {
|
||||
// No sprite to show for this animation frame
|
||||
if (fade == 255) {
|
||||
// Gradual fade in
|
||||
if (screen.equalizePalette(sprite._palette) == 0)
|
||||
@ -144,11 +151,6 @@ bool Animation::playPrologue(const Common::String &filename, int minDelay, int f
|
||||
}
|
||||
|
||||
events.delay(speed);
|
||||
|
||||
if (stream->readSint16LE() == -2)
|
||||
// End of animation
|
||||
break;
|
||||
stream->seek(-2, SEEK_CUR);
|
||||
}
|
||||
|
||||
if (events.isKeyPressed()) {
|
||||
|
@ -35,6 +35,44 @@ Surface::~Surface() {
|
||||
free();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a surface into another
|
||||
*/
|
||||
void Surface::copyFrom(const Graphics::Surface &src) {
|
||||
copyFrom(src, Common::Point());
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a surface at a given position within this surface
|
||||
*/
|
||||
void Surface::copyFrom(const Graphics::Surface &src, const Common::Point &pt) {
|
||||
Common::Rect drawRect(0, 0, src.w, src.h);
|
||||
Common::Point destPt = pt;
|
||||
|
||||
if (destPt.x < 0) {
|
||||
drawRect.left += -destPt.x;
|
||||
destPt.x = 0;
|
||||
}
|
||||
if (destPt.y < 0) {
|
||||
drawRect.top += -destPt.y;
|
||||
destPt.y = 0;
|
||||
}
|
||||
int right = destPt.x + src.w;
|
||||
if (right > this->w) {
|
||||
drawRect.right -= (right - this->w);
|
||||
}
|
||||
int bottom = destPt.y + src.h;
|
||||
if (bottom > this->h) {
|
||||
drawRect.bottom -= (bottom - this->h);
|
||||
}
|
||||
|
||||
if (drawRect.isValidRect()) {
|
||||
addDirtyRect(Common::Rect(destPt.x, destPt.y, destPt.x + drawRect.width(),
|
||||
destPt.y + drawRect.height()));
|
||||
copyRectToSurface(src, destPt.x, destPt.y, drawRect);
|
||||
}
|
||||
}
|
||||
|
||||
void Surface::fillRect(int x1, int y1, int x2, int y2, byte color) {
|
||||
Graphics::Surface::fillRect(Common::Rect(x1, y1, x2, y2), color);
|
||||
}
|
||||
|
@ -36,9 +36,15 @@ namespace Sherlock {
|
||||
class SherlockEngine;
|
||||
|
||||
class Surface : public Graphics::Surface {
|
||||
protected:
|
||||
virtual void addDirtyRect(const Common::Rect &r) {}
|
||||
public:
|
||||
Surface(uint16 width, uint16 height);
|
||||
~Surface();
|
||||
|
||||
void copyFrom(const Graphics::Surface &src);
|
||||
void copyFrom(const Graphics::Surface &src, const Common::Point &pt);
|
||||
|
||||
void fillRect(int x1, int y1, int x2, int y2, byte color);
|
||||
void drawSprite(int x, int y, SpriteFrame *spriteFrame, bool flipped = false, bool altFlag = false);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user