mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-05 17:57:14 +00:00
MADS: Fixes for handling horizontally flipped frames
This commit is contained in:
parent
de09300fdd
commit
2090987b81
@ -78,6 +78,7 @@ void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) {
|
||||
|
||||
int numColors = palStream->readUint16LE();
|
||||
assert(numColors <= 252);
|
||||
_colorCount = numColors;
|
||||
|
||||
// Load in the palette
|
||||
palette.resize(numColors);
|
||||
|
@ -498,7 +498,7 @@ MSurface *MSurface::flipHorizontal() const {
|
||||
|
||||
for (int y = 0; y < this->h; ++y) {
|
||||
const byte *srcP = getBasePtr(this->w - 1, y);
|
||||
byte *destP = dest->getData();
|
||||
byte *destP = dest->getBasePtr(0, y);
|
||||
|
||||
for (int x = 0; x < this->w; ++x)
|
||||
*destP++ = *srcP--;
|
||||
|
@ -91,13 +91,12 @@ void DirtyArea::setSpriteSlot(const SpriteSlot *spriteSlot) {
|
||||
_bounds.top = spriteSlot->_position.y - scene._posAdjust.y;
|
||||
|
||||
SpriteAsset &spriteSet = *scene._sprites[spriteSlot->_spritesIndex];
|
||||
MSprite *frame = spriteSet.getFrame(((spriteSlot->_frameNumber & 0x7fff) - 1) & 0x7f);
|
||||
MSprite *frame = spriteSet.getFrame(ABS(spriteSlot->_frameNumber) - 1);
|
||||
|
||||
if (spriteSlot->_scale == -1) {
|
||||
width = frame->w;
|
||||
height = frame->h;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
width = frame->w * spriteSlot->_scale / 100;
|
||||
height = frame->h * spriteSlot->_scale / 100;
|
||||
|
||||
@ -380,8 +379,10 @@ void ScreenSurface::init() {
|
||||
void ScreenSurface::copyRectToScreen(const Common::Point &destPos,
|
||||
const Common::Rect &bounds) {
|
||||
byte *buf = getBasePtr(destPos.x, destPos.y);
|
||||
g_system->copyRectToScreen(buf, this->pitch, bounds.left, bounds.top,
|
||||
bounds.width(), bounds.height());
|
||||
|
||||
if (bounds.width() != 0 && bounds.height() != 0)
|
||||
g_system->copyRectToScreen(buf, this->pitch, bounds.left, bounds.top,
|
||||
bounds.width(), bounds.height());
|
||||
}
|
||||
|
||||
void ScreenSurface::copyRectToScreen(const Common::Rect &bounds) {
|
||||
|
@ -187,15 +187,14 @@ void SequenceList::setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot) {
|
||||
spriteSlot._SlotType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND;
|
||||
spriteSlot._seqIndex = seqIndex;
|
||||
spriteSlot._spritesIndex = timerEntry._spritesIndex;
|
||||
spriteSlot._frameNumber = (timerEntry._flipped ? 0x8000 : 0) | timerEntry._frameIndex;
|
||||
spriteSlot._frameNumber = timerEntry._flipped ? -timerEntry._frameIndex : timerEntry._frameIndex;
|
||||
spriteSlot._depth = timerEntry._depth;
|
||||
spriteSlot._scale = timerEntry._scale;
|
||||
|
||||
if (!timerEntry._nonFixed) {
|
||||
spriteSlot._position = timerEntry._msgPos;
|
||||
} else {
|
||||
assert(spriteSlot._frameNumber > 0);
|
||||
MSprite *sprite = spriteSet.getFrame(spriteSlot._frameNumber - 1);
|
||||
MSprite *sprite = spriteSet.getFrame(timerEntry._frameIndex - 1);
|
||||
spriteSlot._position = sprite->_offset;
|
||||
}
|
||||
}
|
||||
|
@ -322,8 +322,8 @@ void SpriteSlots::drawForeground(MSurface *s) {
|
||||
SpriteAsset &spriteSet = *scene._sprites[slot._spritesIndex];
|
||||
|
||||
// Get the sprite frame
|
||||
int frameNumber = slot._frameNumber & 0x7fff;
|
||||
bool flipped = (slot._frameNumber & 0x8000) != 0;
|
||||
int frameNumber = ABS(slot._frameNumber);
|
||||
bool flipped = slot._frameNumber < 0;
|
||||
|
||||
assert(frameNumber > 0);
|
||||
MSprite *sprite = spriteSet.getFrame(frameNumber - 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user