aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/draci/draci.h3
-rw-r--r--engines/draci/game.cpp4
-rw-r--r--engines/draci/sprite.cpp8
3 files changed, 9 insertions, 6 deletions
diff --git a/engines/draci/draci.h b/engines/draci/draci.h
index e2b5390c44..168d48733f 100644
--- a/engines/draci/draci.h
+++ b/engines/draci/draci.h
@@ -88,6 +88,9 @@ enum {
kDraciAnimationDebugLevel = 1 << 4
};
+// Macro to simulate lround() for non-C99 compilers
+static inline long scummvm_lround(double val) { return (long)floor(val + 0.5); }
+
} // End of namespace Draci
#endif // DRACI_H
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index 6ebfb2729c..5348b7c7fc 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -1045,8 +1045,8 @@ void Game::walkHero(int x, int y) {
uint height = frame->getHeight();
uint width = frame->getWidth();
- _persons[kDragonObject]._x = x + (floor(scaleX) * width) / 2;
- _persons[kDragonObject]._y = y - floor(scaleY) * height;
+ _persons[kDragonObject]._x = x + (scummvm_lround(scaleX) * width) / 2;
+ _persons[kDragonObject]._y = y - scummvm_lround(scaleY) * height;
// Set the per-animation scaling factor
anim->setScaleFactors(scaleX, scaleY);
diff --git a/engines/draci/sprite.cpp b/engines/draci/sprite.cpp
index 69465307a4..d256d9ffae 100644
--- a/engines/draci/sprite.cpp
+++ b/engines/draci/sprite.cpp
@@ -140,8 +140,8 @@ int Sprite::getPixel(int x, int y) const {
double scaleX = double(_scaledWidth) / _width;
double scaleY = double(_scaledHeight) / _height;
- int sy = floor(dy * scaleY);
- int sx = floor(dx * scaleX);
+ int sy = scummvm_lround(dy * scaleY);
+ int sx = scummvm_lround(dx * scaleX);
if (_mirror)
return _data[sy * _width + (_width - sx)];
@@ -190,11 +190,11 @@ void Sprite::drawScaled(Surface *surface, bool markDirty) const {
// Precalculate pixel indexes
for (int i = 0; i < rows; ++i) {
- rowIndices[i] = floor(i / scaleY);
+ rowIndices[i] = scummvm_lround(i / scaleY);
}
for (int j = 0; j < columns; ++j) {
- columnIndices[j] = floor(j / scaleX);
+ columnIndices[j] = scummvm_lround(j / scaleX);
}
// Blit the sprite to the surface