aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2009-09-25 09:48:43 +0000
committerFilippos Karapetis2009-09-25 09:48:43 +0000
commite296cef9becef7e890cd1ce33d1b0ae23007a784 (patch)
tree31aa5464f070ed17c8269380f4d7eb33b161d9ef /engines
parentadaf3ec8b4818f89e9f4d39fb2a14710b0f0bd5b (diff)
downloadscummvm-rg350-e296cef9becef7e890cd1ce33d1b0ae23007a784.tar.gz
scummvm-rg350-e296cef9becef7e890cd1ce33d1b0ae23007a784.tar.bz2
scummvm-rg350-e296cef9becef7e890cd1ce33d1b0ae23007a784.zip
Created a macro for lround(), for non-C99 compilers, and used that in places where lround() is used
svn-id: r44337
Diffstat (limited to 'engines')
-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