mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-22 20:21:06 +00:00
Added support for horizontally flipped foreground sprites, which are indicated by setting the high bit of frame numbers
svn-id: r50638
This commit is contained in:
parent
5872f5bb1f
commit
10e7581fe1
@ -65,6 +65,15 @@ void RGBList::setRange(int start, int count, const RGB8 *src) {
|
||||
Common::copy(&src[0], &src[count], &_data[start]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a duplicate of the given rgb list
|
||||
*/
|
||||
RGBList *RGBList::clone() const {
|
||||
RGBList *dest = new RGBList(_size, _data, false);
|
||||
_madsVm->_palette->addRange(dest);
|
||||
return dest;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
#define VGA_COLOR_TRANS(x) (x == 0x3f ? 255 : x << 2)
|
||||
@ -931,6 +940,21 @@ void M4Surface::translate(RGBList *list, bool isTransparent) {
|
||||
freeData();
|
||||
}
|
||||
|
||||
M4Surface *M4Surface::flipHorizontal() const {
|
||||
M4Surface *dest = new M4Surface(width(), height());
|
||||
dest->_rgbList = (this->_rgbList == NULL) ? NULL : this->_rgbList->clone();
|
||||
|
||||
byte *destP = dest->getBasePtr();
|
||||
|
||||
for (int y = 0; y < height(); ++y) {
|
||||
const byte *srcP = getBasePtr(width() - 1, y);
|
||||
for (int x = 0; x < width(); ++x)
|
||||
*destP++ = *srcP--;
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Palette class
|
||||
//
|
||||
|
@ -75,6 +75,7 @@ public:
|
||||
int size() { return _size; }
|
||||
RGB8 &operator[](int idx) { return _data[idx]; }
|
||||
void setRange(int start, int count, const RGB8 *src);
|
||||
RGBList *clone() const;
|
||||
};
|
||||
|
||||
// M4Surface
|
||||
@ -203,6 +204,7 @@ public:
|
||||
void scrollY(int yAmount);
|
||||
|
||||
void translate(RGBList *list, bool isTransparent = false);
|
||||
M4Surface *flipHorizontal() const;
|
||||
};
|
||||
|
||||
enum FadeType {FT_TO_GREY, FT_TO_COLOR, FT_TO_BLOCK};
|
||||
|
@ -201,15 +201,23 @@ void MadsSpriteSlots::drawForeground(M4Surface *viewport) {
|
||||
assert(slot.spriteListIndex < (int)_sprites.size());
|
||||
SpriteAsset &spriteSet = *_sprites[slot.spriteListIndex];
|
||||
|
||||
// Get the sprite frame
|
||||
int frameNumber = slot.frameNumber & 0x7fff;
|
||||
bool flipped = (slot.frameNumber & 0x8000) != 0;
|
||||
M4Sprite *sprite = spriteSet.getFrame(frameNumber - 1);
|
||||
|
||||
M4Surface *spr = sprite;
|
||||
if (flipped) {
|
||||
// Create a flipped copy of the sprite temporarily
|
||||
spr = sprite->flipHorizontal();
|
||||
}
|
||||
|
||||
if ((slot.scale < 100) && (slot.scale != -1)) {
|
||||
// Minimalised drawing
|
||||
assert(slot.spriteListIndex < (int)_sprites.size());
|
||||
M4Sprite *spr = spriteSet.getFrame((slot.frameNumber & 0x7fff) - 1);
|
||||
viewport->copyFrom(spr, slot.xp, slot.yp, slot.depth, _owner._depthSurface, slot.scale,
|
||||
spr->getTransparencyIndex());
|
||||
sprite->getTransparencyIndex());
|
||||
} else {
|
||||
int xp, yp;
|
||||
M4Sprite *spr = spriteSet.getFrame(slot.frameNumber - 1);
|
||||
|
||||
if (slot.scale == -1) {
|
||||
xp = slot.xp - _owner._posAdjust.x;
|
||||
@ -221,12 +229,16 @@ void MadsSpriteSlots::drawForeground(M4Surface *viewport) {
|
||||
|
||||
if (slot.depth > 1) {
|
||||
// Draw the frame with depth processing
|
||||
viewport->copyFrom(spr, xp, yp, slot.depth, _owner._depthSurface, 100, spr->getTransparencyIndex());
|
||||
viewport->copyFrom(spr, xp, yp, slot.depth, _owner._depthSurface, 100, sprite->getTransparencyIndex());
|
||||
} else {
|
||||
// No depth, so simply draw the image
|
||||
spr->copyTo(viewport, xp, yp, spr->getTransparencyIndex());
|
||||
spr->copyTo(viewport, xp, yp, sprite->getTransparencyIndex());
|
||||
}
|
||||
}
|
||||
|
||||
// Free sprite if it was a flipped one
|
||||
if (flipped)
|
||||
delete spr;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user