[Scummvm-cvs-logs] scummvm master -> 78b8ca5c7fd7296d88c381695534844879673b75

digitall digitall at scummvm.org
Thu Jun 28 08:09:10 CEST 2012


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
78b8ca5c7f TOON: Replace remaining int32 x,y,w and h coordinates with int16.


Commit: 78b8ca5c7fd7296d88c381695534844879673b75
    https://github.com/scummvm/scummvm/commit/78b8ca5c7fd7296d88c381695534844879673b75
Author: D G Turner (digitall at scummvm.org)
Date: 2012-06-27T23:07:08-07:00

Commit Message:
TOON: Replace remaining int32 x,y,w and h coordinates with int16.

Changed paths:
    engines/toon/anim.cpp
    engines/toon/anim.h
    engines/toon/character.cpp
    engines/toon/font.cpp
    engines/toon/font.h
    engines/toon/hotspot.cpp
    engines/toon/hotspot.h
    engines/toon/picture.cpp
    engines/toon/picture.h
    engines/toon/toon.cpp



diff --git a/engines/toon/anim.cpp b/engines/toon/anim.cpp
index a4eb1f2..8097b18 100644
--- a/engines/toon/anim.cpp
+++ b/engines/toon/anim.cpp
@@ -132,7 +132,7 @@ Common::Rect Animation::getRect() {
 	return Common::Rect(_x1, _y1, _x2, _y2);
 }
 
-void Animation::drawFrame(Graphics::Surface &surface, int32 frame, int32 xx, int32 yy) {
+void Animation::drawFrame(Graphics::Surface &surface, int32 frame, int16 xx, int16 yy) {
 	debugC(3, kDebugAnim, "drawFrame(surface, %d, %d, %d)", frame, xx, yy);
 	if (frame < 0)
 		frame = 0;
@@ -149,10 +149,10 @@ void Animation::drawFrame(Graphics::Surface &surface, int32 frame, int32 xx, int
 	if (!_frames[frame]._data)
 		return;
 
-	int32 rectX = _frames[frame]._x2 - _frames[frame]._x1;
-	int32 rectY = _frames[frame]._y2 - _frames[frame]._y1;
-	int32 offsX = 0;
-	int32 offsY = 0;
+	int16 rectX = _frames[frame]._x2 - _frames[frame]._x1;
+	int16 rectY = _frames[frame]._y2 - _frames[frame]._y1;
+	int16 offsX = 0;
+	int16 offsY = 0;
 
 	_vm->addDirtyRect(xx + _x1 + _frames[frame]._x1, yy + _y1 + _frames[frame]._y1, xx + rectX + _x1 + _frames[frame]._x1 , yy + rectY + _y1 + _frames[frame]._y1);
 
@@ -189,10 +189,10 @@ void Animation::drawFrame(Graphics::Surface &surface, int32 frame, int32 xx, int
 	int32 destPitch = surface.pitch;
 	uint8 *srcRow = _frames[frame]._data + offsX + (_frames[frame]._x2 - _frames[frame]._x1) * offsY;
 	uint8 *curRow = (uint8 *)surface.pixels + (yy + _frames[frame]._y1 + _y1 + offsY) * destPitch + (xx + _x1 + _frames[frame]._x1 + offsX);
-	for (int32 y = 0; y < rectY; y++) {
+	for (int16 y = 0; y < rectY; y++) {
 		uint8 *cur = curRow;
 		uint8 *c = srcRow + y * (_frames[frame]._x2 - _frames[frame]._x1);
-		for (int32 x = 0; x < rectX; x++) {
+		for (int16 x = 0; x < rectX; x++) {
 			if (*c)
 				*cur = *c;
 			c++;
@@ -202,27 +202,27 @@ void Animation::drawFrame(Graphics::Surface &surface, int32 frame, int32 xx, int
 	}
 }
 
-void Animation::drawFrameWithMask(Graphics::Surface &surface, int32 frame, int32 xx, int32 yy, int32 zz, Picture *mask) {
+void Animation::drawFrameWithMask(Graphics::Surface &surface, int32 frame, int16 xx, int16 yy, int32 zz, Picture *mask) {
 	debugC(1, kDebugAnim, "drawFrameWithMask(surface, %d, %d, %d, %d, mask)", frame, xx, yy, zz);
 	warning("STUB: drawFrameWithMask()");
 }
 
-void Animation::drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 frame, int32 xx, int32 yy, int32 zz, Picture *mask, int32 scale) {
+void Animation::drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 frame, int16 xx, int16 yy, int32 zz, Picture *mask, int32 scale) {
 	debugC(5, kDebugAnim, "drawFrameWithMaskAndScale(surface, %d, %d, %d, %d, mask, %d)", frame, xx, yy, zz, scale);
 	if (_frames[frame]._ref != -1)
 		frame = _frames[frame]._ref;
-	int32 rectX = _frames[frame]._x2 - _frames[frame]._x1;
-	int32 rectY = _frames[frame]._y2 - _frames[frame]._y1;
+	int16 rectX = _frames[frame]._x2 - _frames[frame]._x1;
+	int16 rectY = _frames[frame]._y2 - _frames[frame]._y1;
 
-	int32 finalWidth = rectX * scale / 1024;
-	int32 finalHeight = rectY * scale / 1024;
+	int16 finalWidth = rectX * scale / 1024;
+	int16 finalHeight = rectY * scale / 1024;
 
 	// compute final x1, y1, x2, y2
-	int32 xx1 = xx + _x1 + _frames[frame]._x1 * scale / 1024;
-	int32 yy1 = yy + _y1 + _frames[frame]._y1 * scale / 1024;
-	int32 xx2 = xx1 + finalWidth;
-	int32 yy2 = yy1 + finalHeight;
-	int32 w = _frames[frame]._x2 - _frames[frame]._x1;
+	int16 xx1 = xx + _x1 + _frames[frame]._x1 * scale / 1024;
+	int16 yy1 = yy + _y1 + _frames[frame]._y1 * scale / 1024;
+	int16 xx2 = xx1 + finalWidth;
+	int16 yy2 = yy1 + finalHeight;
+	int16 w = _frames[frame]._x2 - _frames[frame]._x1;
 
 	_vm->addDirtyRect(xx1, yy1, xx2, yy2);
 
@@ -236,8 +236,8 @@ void Animation::drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 fram
 	if (strstr(_name, "SHADOW"))
 		shadowFlag = true;
 
-	for (int32 y = yy1; y < yy2; y++) {
-		for (int32 x = xx1; x < xx2; x++) {
+	for (int16 y = yy1; y < yy2; y++) {
+		for (int16 x = xx1; x < xx2; x++) {
 			if (x < 0 || x >= 1280 || y < 0 || y >= 400)
 				continue;
 
@@ -245,8 +245,8 @@ void Animation::drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 fram
 			uint8 *curMask = curRowMask + x + y * destPitchMask;
 
 			// find the good c
-			int32 xs = (x - xx1) * 1024 / scale;
-			int32 ys = (y - yy1) * 1024 / scale;
+			int16 xs = (x - xx1) * 1024 / scale;
+			int16 ys = (y - yy1) * 1024 / scale;
 			uint8 *cc = &c[ys * w + xs];
 			if (*cc && ((*curMask) >= zz)) {
 				if (shadowFlag)
@@ -275,7 +275,7 @@ Common::Rect Animation::getFrameRect(int32 frame) {
 	return Common::Rect(_frames[frame]._x1, _frames[frame]._y1, _frames[frame]._x2, _frames[frame]._y2);
 }
 
-int32 Animation::getFrameWidth(int32 frame) {
+int16 Animation::getFrameWidth(int32 frame) {
 	debugC(4, kDebugAnim, "getFrameWidth(%d)", frame);
 	if ((frame < 0) || (frame >= _numFrames))
 		return 0;
@@ -286,7 +286,7 @@ int32 Animation::getFrameWidth(int32 frame) {
 	return _frames[frame]._x2 - _frames[frame]._x1;
 }
 
-int32 Animation::getFrameHeight(int32 frame) {
+int16 Animation::getFrameHeight(int32 frame) {
 	debugC(4, kDebugAnim, "getFrameHeight(%d)", frame);
 	if (frame < 0 || frame >= _numFrames)
 		return 0;
@@ -297,15 +297,15 @@ int32 Animation::getFrameHeight(int32 frame) {
 	return _frames[frame]._y2 - _frames[frame]._y1;
 }
 
-int32 Animation::getWidth() const {
+int16 Animation::getWidth() const {
 	return _x2 - _x1;
 }
 
-int32 Animation::getHeight() const {
+int16 Animation::getHeight() const {
 	return _y2 - _y1;
 }
 
-void Animation::drawFontFrame(Graphics::Surface &surface, int32 frame, int32 xx, int32 yy, byte *colorMap) {
+void Animation::drawFontFrame(Graphics::Surface &surface, int32 frame, int16 xx, int16 yy, byte *colorMap) {
 	debugC(4, kDebugAnim, "drawFontFrame(surface, %d, %d, %d, colorMap)", frame, xx, yy);
 	if (frame < 0)
 		frame = 0;
@@ -319,8 +319,8 @@ void Animation::drawFontFrame(Graphics::Surface &surface, int32 frame, int32 xx,
 	if (_frames[frame]._ref != -1)
 		frame = _frames[frame]._ref;
 
-	int32 rectX = _frames[frame]._x2 - _frames[frame]._x1;
-	int32 rectY = _frames[frame]._y2 - _frames[frame]._y1;
+	int16 rectX = _frames[frame]._x2 - _frames[frame]._x1;
+	int16 rectY = _frames[frame]._y2 - _frames[frame]._y1;
 
 	if ((xx + _x1 + _frames[frame]._x1 < 0) || (yy + _y1 + _frames[frame]._y1 < 0))
 		return;
@@ -340,9 +340,9 @@ void Animation::drawFontFrame(Graphics::Surface &surface, int32 frame, int32 xx,
 	int32 destPitch = surface.pitch;
 	uint8 *c = _frames[frame]._data;
 	uint8 *curRow = (uint8 *)surface.pixels + (yy + _frames[frame]._y1 + _y1) * destPitch + (xx + _x1 + _frames[frame]._x1);
-	for (int32 y = 0; y < rectY; y++) {
+	for (int16 y = 0; y < rectY; y++) {
 		unsigned char *cur = curRow;
-		for (int32 x = 0; x < rectX; x++) {
+		for (int16 x = 0; x < rectX; x++) {
 			if (*c && *c < 4)
 				*cur = colorMap[*c];
 			c++;
@@ -352,7 +352,7 @@ void Animation::drawFontFrame(Graphics::Surface &surface, int32 frame, int32 xx,
 	}
 }
 
-void Animation::drawFrameOnPicture(int32 frame, int32 xx, int32 yy) {
+void Animation::drawFrameOnPicture(int32 frame, int16 xx, int16 yy) {
 	debugC(1, kDebugAnim, "drawFrameOnPicture(%d, %d, %d)", frame, xx, yy);
 	if (frame < 0)
 		frame = 0;
@@ -366,8 +366,8 @@ void Animation::drawFrameOnPicture(int32 frame, int32 xx, int32 yy) {
 	if (_frames[frame]._ref != -1)
 		frame = _frames[frame]._ref;
 
-	int32 rectX = _frames[frame]._x2 - _frames[frame]._x1;
-	int32 rectY = _frames[frame]._y2 - _frames[frame]._y1;
+	int16 rectX = _frames[frame]._x2 - _frames[frame]._x1;
+	int16 rectY = _frames[frame]._y2 - _frames[frame]._y1;
 
 	Picture *pic = _vm->getPicture();
 
@@ -389,9 +389,9 @@ void Animation::drawFrameOnPicture(int32 frame, int32 xx, int32 yy) {
 	int32 destPitch = pic->getWidth();
 	uint8 *c = _frames[frame]._data;
 	uint8 *curRow = (uint8 *)pic->getDataPtr() + (yy + _frames[frame]._y1 + _y1) * destPitch + (xx + _x1 + _frames[frame]._x1);
-	for (int32 y = 0; y < rectY; y++) {
+	for (int16 y = 0; y < rectY; y++) {
 		unsigned char *cur = curRow;
-		for (int32 x = 0; x < rectX; x++) {
+		for (int16 x = 0; x < rectX; x++) {
 			if (*c)
 				*cur = *c;
 			c++;
@@ -458,8 +458,8 @@ void AnimationInstance::render() {
 		if (frame >= _animation->_numFrames)
 			frame = _animation->_numFrames - 1;
 
-		int32 x = _x;
-		int32 y = _y;
+		int16 x = _x;
+		int16 y = _y;
 
 		if (_alignBottom) {
 			int32 offsetX = (_animation->_x2 - _animation->_x1) / 2 * (_scale - 1024);
@@ -513,7 +513,7 @@ void AnimationInstance::setAnimationRange(int32 rangeStart, int rangeEnd) {
 		_currentFrame = _rangeEnd;
 }
 
-void AnimationInstance::setPosition(int32 x, int32 y, int32 z, bool relative) {
+void AnimationInstance::setPosition(int16 x, int16 y, int32 z, bool relative) {
 	debugC(5, kDebugAnim, "setPosition(%d, %d, %d, %d)", x, y, z, (relative) ? 1 : 0);
 	if (relative || !_animation) {
 		_x = x;
@@ -526,7 +526,7 @@ void AnimationInstance::setPosition(int32 x, int32 y, int32 z, bool relative) {
 	}
 }
 
-void AnimationInstance::moveRelative(int32 dx, int32 dy, int32 dz) {
+void AnimationInstance::moveRelative(int16 dx, int16 dy, int32 dz) {
 	debugC(1, kDebugAnim, "moveRelative(%d, %d, %d)", dx, dy, dz);
 	_x += dx;
 	_y += dy;
@@ -571,13 +571,13 @@ void AnimationInstance::setUseMask(bool useMask) {
 	_useMask = useMask;
 }
 
-void AnimationInstance::getRect(int32 *x1, int32 *y1, int32 *x2, int32 *y2) const {
+void AnimationInstance::getRect(int16 *x1, int16 *y1, int16 *x2, int16 *y2) const {
 	debugC(5, kDebugAnim, "getRect(%d, %d, %d, %d)", *x1, *y1, *x2, *y2);
-	int32 rectX = _animation->_frames[_currentFrame]._x2 - _animation->_frames[_currentFrame]._x1;
-	int32 rectY = _animation->_frames[_currentFrame]._y2 - _animation->_frames[_currentFrame]._y1;
+	int16 rectX = _animation->_frames[_currentFrame]._x2 - _animation->_frames[_currentFrame]._x1;
+	int16 rectY = _animation->_frames[_currentFrame]._y2 - _animation->_frames[_currentFrame]._y1;
 
-	int32 finalWidth = rectX * _scale / 1024;
-	int32 finalHeight = rectY * _scale / 1024;
+	int16 finalWidth = rectX * _scale / 1024;
+	int16 finalHeight = rectY * _scale / 1024;
 
 	// compute final x1, y1, x2, y2
 	*x1 = _x + _animation->_x1 + _animation->_frames[_currentFrame]._x1 * _scale / 1024;
@@ -586,7 +586,7 @@ void AnimationInstance::getRect(int32 *x1, int32 *y1, int32 *x2, int32 *y2) cons
 	*y2 = *y1 + finalHeight;
 }
 
-void AnimationInstance::setX(int32 x, bool relative) {
+void AnimationInstance::setX(int16 x, bool relative) {
 	debugC(1, kDebugAnim, "setX(%d, %d)", x, (relative) ? 1 : 0);
 	if (relative || !_animation)
 		_x = x;
@@ -594,7 +594,7 @@ void AnimationInstance::setX(int32 x, bool relative) {
 		_x = x - _animation->_x1;
 }
 
-void AnimationInstance::setY(int32 y, bool relative) {
+void AnimationInstance::setY(int16 y, bool relative) {
 	debugC(1, kDebugAnim, "setY(%d, %d)", y, (relative) ? 1 : 0);
 	if (relative || !_animation)
 		_y = y;
@@ -617,11 +617,11 @@ int32 AnimationInstance::getLayerZ() const {
 	return _layerZ;
 }
 
-int32 AnimationInstance::getX2() const {
+int16 AnimationInstance::getX2() const {
 	return _x + _animation->_x1;
 }
 
-int32 AnimationInstance::getY2() const {
+int16 AnimationInstance::getY2() const {
 	return _y + _animation->_y1;
 }
 
@@ -650,6 +650,7 @@ void AnimationInstance::save(Common::WriteStream *stream) {
 	stream->writeSint32LE(_visible);
 	stream->writeSint32LE(_useMask);
 }
+
 void AnimationInstance::load(Common::ReadStream *stream) {
 	_currentFrame = stream->readSint32LE();
 	_currentTime = stream->readSint32LE();
@@ -698,14 +699,13 @@ void AnimationManager::updateInstance(AnimationInstance* instance) {
 }
 
 void AnimationManager::addInstance(AnimationInstance *instance) {
-
 	// if the instance already exists, we skip the add
 	for (uint32 i = 0; i < _instances.size(); i++) {
 		if (_instances[i] == instance)
 			return;
 	}
 
-	int found = -1;
+	int32 found = -1;
 
 	// here we now do an ordered insert (closer to the original game)
 	for (uint32 i = 0; i < _instances.size(); i++) {
@@ -715,11 +715,10 @@ void AnimationManager::addInstance(AnimationInstance *instance) {
 		}
 	}
 
-	if ( found == -1 ) {
+	if (found == -1)
 		_instances.push_back(instance);
-	} else {
+	else
 		_instances.insert_at(found, instance);
-	}
 }
 
 void AnimationManager::removeInstance(AnimationInstance *instance) {
diff --git a/engines/toon/anim.h b/engines/toon/anim.h
index eb8dcbd..cd550b2 100644
--- a/engines/toon/anim.h
+++ b/engines/toon/anim.h
@@ -36,10 +36,10 @@ class Picture;
 class ToonEngine;
 
 struct AnimationFrame {
-	int32 _x1;
-	int32 _y1;
-	int32 _x2;
-	int32 _y2;
+	int16 _x1;
+	int16 _y1;
+	int16 _x2;
+	int16 _y2;
 	int32 _ref;
 	uint8 *_data;
 };
@@ -49,10 +49,10 @@ public:
 	Animation(ToonEngine *vm);
 	~Animation();
 
-	int32 _x1;
-	int32 _y1;
-	int32 _x2;
-	int32 _y2;
+	int16 _x1;
+	int16 _y1;
+	int16 _x2;
+	int16 _y2;
 	int32 _numFrames;
 	int32 _fps;
 	AnimationFrame *_frames;
@@ -61,18 +61,18 @@ public:
 	char _name[32];
 
 	bool loadAnimation(const Common::String &file);
-	void drawFrame(Graphics::Surface &surface, int32 frame, int32 x, int32 y);
-	void drawFontFrame(Graphics::Surface &surface, int32 frame, int32 x, int32 y, byte *colorMap);
-	void drawFrameOnPicture(int32 frame, int32 x, int32 y);
-	void drawFrameWithMask(Graphics::Surface &surface, int32 frame, int32 xx, int32 yy, int32 zz, Picture *mask);
-	void drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 frame, int32 xx, int32 yy, int32 zz, Picture *mask, int32 scale);
+	void drawFrame(Graphics::Surface &surface, int32 frame, int16 x, int16 y);
+	void drawFontFrame(Graphics::Surface &surface, int32 frame, int16 x, int16 y, byte *colorMap);
+	void drawFrameOnPicture(int32 frame, int16 x, int16 y);
+	void drawFrameWithMask(Graphics::Surface &surface, int32 frame, int16 xx, int16 yy, int32 zz, Picture *mask);
+	void drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 frame, int16 xx, int16 yy, int32 zz, Picture *mask, int32 scale);
 	void drawStrip(int32 offset = 0);
 	void applyPalette(int32 offset, int32 srcOffset, int32 numEntries);
 	Common::Rect getFrameRect(int32 frame);
-	int32 getFrameWidth(int32 frame);
-	int32 getFrameHeight(int32 frame);
-	int32 getWidth() const;
-	int32 getHeight() const;
+	int16 getFrameWidth(int32 frame);
+	int16 getFrameHeight(int32 frame);
+	int16 getWidth() const;
+	int16 getHeight() const;
 	Common::Rect getRect();
 protected:
 	ToonEngine *_vm;
@@ -92,25 +92,25 @@ public:
 	void renderOnPicture();
 	void setAnimation(Animation *animation, bool setRange = true);
 	void playAnimation();
-	void setAnimationRange(int32 rangeStart, int rangeEnd);
+	void setAnimationRange(int32 rangeStart, int32 rangeEnd);
 	void setFps(int32 fps);
 	void setLooping(bool enable);
 	void stopAnimation();
 	void setFrame(int32 position);
 	void forceFrame(int32 position);
-	void setPosition(int32 x, int32 y, int32 z, bool relative = false);
+	void setPosition(int16 x, int16 y, int32 z, bool relative = false);
 	Animation *getAnimation() const { return _animation; }
 	void setScale(int32 scale, bool align = false);
 	void setVisible(bool visible);
 	bool getVisible() const { return _visible; }
 	void setUseMask(bool useMask);
-	void moveRelative(int32 dx, int32 dy, int32 dz);
-	void getRect(int32 *x1, int32 *y1, int32 *x2, int32 *y2) const;
-	int32 getX() const { return _x; }
-	int32 getY() const { return _y; }
+	void moveRelative(int16 dx, int16 dy, int32 dz);
+	void getRect(int16 *x1, int16 *y1, int16 *x2, int16 *y2) const;
+	int16 getX() const { return _x; }
+	int16 getY() const { return _y; }
 	int32 getZ() const { return _z; }
-	int32 getX2() const;
-	int32 getY2() const;
+	int16 getX2() const;
+	int16 getY2() const;
 	int32 getZ2() const;
 	int32 getFrame() const { return _currentFrame; }
 	void reset();
@@ -120,8 +120,8 @@ public:
 	void setId(int32 id) { _id = id; }
 	int32 getId() const { return _id; }
 
-	void setX(int32 x, bool relative = false);
-	void setY(int32 y, bool relative = false);
+	void setX(int16 x, bool relative = false);
+	void setY(int16 y, bool relative = false);
 	void setZ(int32 z, bool relative = false);
 	void setLayerZ(int32 layer);
 	int32 getLayerZ() const;
@@ -133,8 +133,8 @@ protected:
 	int32 _currentTime;
 	int32 _fps;
 	Animation *_animation;
-	int32 _x;
-	int32 _y;
+	int16 _x;
+	int16 _y;
 	int32 _z;
 	int32 _layerZ;
 	int32 _rangeStart;
diff --git a/engines/toon/character.cpp b/engines/toon/character.cpp
index 0973062..e19656f 100644
--- a/engines/toon/character.cpp
+++ b/engines/toon/character.cpp
@@ -534,35 +534,33 @@ int32 Character::getFacingFromDirection(int16 dx, int16 dy) {
 	dx = -dx;
 
 	int32 facingEntry = 0;
-	int32 ydiff = dy;
+	int16 ydiff = dy;
 	if (ydiff < 0) {
 		++facingEntry;
 		ydiff = -ydiff;
 	}
-	facingEntry <<= 1;
+	facingEntry *= 2;
 
-	int32 xdiff = dx;
+	int16 xdiff = dx;
 	if (xdiff < 0) {
 		++facingEntry;
 		xdiff = -xdiff;
 	}
 
-	facingEntry <<= 1;
+	facingEntry *= 2;
 
 	if (xdiff >= ydiff) {
-		int32 temp = ydiff;
+		// Swap xdiff and ydiff
+		int16 temp = ydiff;
 		ydiff = xdiff;
 		xdiff = temp;
-	} else {
-		facingEntry += 1;
-	}
-
-	facingEntry <<= 1;
+	} else
+		facingEntry++;
 
-	int32 temp = (ydiff + 1) >> 1;
+	facingEntry *= 2;
 
-	if (xdiff < temp)
-		facingEntry += 1;
+	if (xdiff < ((ydiff + 1) / 2))
+		facingEntry++;
 
 	return facingTable[facingEntry];
 }
diff --git a/engines/toon/font.cpp b/engines/toon/font.cpp
index d58663a..1e851ff 100644
--- a/engines/toon/font.cpp
+++ b/engines/toon/font.cpp
@@ -65,10 +65,10 @@ byte FontRenderer::textToFont(byte c) {
 	return map_textToFont[c - 0x80];
 }
 
-void FontRenderer::renderText(int32 x, int32 y, const Common::String &origText, int32 mode) {
+void FontRenderer::renderText(int16 x, int16 y, const Common::String &origText, int32 mode) {
 	debugC(5, kDebugFont, "renderText(%d, %d, %s, %d)", x, y, origText.c_str(), mode);
 
-	int32 xx, yy;
+	int16 xx, yy;
 	computeSize(origText, &xx, &yy);
 
 	if (mode & 2) {
@@ -83,8 +83,8 @@ void FontRenderer::renderText(int32 x, int32 y, const Common::String &origText,
 
 	_vm->addDirtyRect(x, y, x + xx, y + yy);
 
-	int32 curX = x;
-	int32 curY = y;
+	int16 curX = x;
+	int16 curY = y;
 	int32 height = 0;
 
 	const byte *text = (const byte *)origText.c_str();
@@ -98,20 +98,20 @@ void FontRenderer::renderText(int32 x, int32 y, const Common::String &origText,
 			curChar = textToFont(curChar);
 			_currentFont->drawFontFrame(_vm->getMainSurface(), curChar, curX, curY, _currentFontColor);
 			curX = curX + _currentFont->getFrameWidth(curChar) - 1;
-			height = MAX(height, _currentFont->getFrameHeight(curChar));
+			height = MAX<int32>(height, _currentFont->getFrameHeight(curChar));
 		}
 		text++;
 	}
 }
 
-void FontRenderer::computeSize(const Common::String &origText, int32 *retX, int32 *retY) {
+void FontRenderer::computeSize(const Common::String &origText, int16 *retX, int16 *retY) {
 	debugC(4, kDebugFont, "computeSize(%s, retX, retY)", origText.c_str());
 
-	int32 lineWidth = 0;
-	int32 lineHeight = 0;
-	int32 totalHeight = 0;
-	int32 totalWidth = 0;
-	int32 lastLineHeight = 0;
+	int16 lineWidth = 0;
+	int16 lineHeight = 0;
+	int16 totalHeight = 0;
+	int16 totalWidth = 0;
+	int16 lastLineHeight = 0;
 
 	const byte *text = (const byte *)origText.c_str();
 	while (*text) {
@@ -127,8 +127,8 @@ void FontRenderer::computeSize(const Common::String &origText, int32 *retX, int3
 			lastLineHeight = 0;
 		} else {
 			curChar = textToFont(curChar);
-			int32 charWidth = _currentFont->getFrameWidth(curChar) - 1;
-			int32 charHeight = _currentFont->getFrameHeight(curChar);
+			int16 charWidth = _currentFont->getFrameWidth(curChar) - 1;
+			int16 charHeight = _currentFont->getFrameHeight(curChar);
 			lineWidth += charWidth;
 			lineHeight = MAX(lineHeight, charHeight);
 
@@ -137,7 +137,7 @@ void FontRenderer::computeSize(const Common::String &origText, int32 *retX, int3
 			// assume we only need to take the lower bound into
 			// consideration.
 			Common::Rect charRect = _currentFont->getFrameRect(curChar);
-			lastLineHeight = MAX<int32>(lastLineHeight, charRect.bottom);
+			lastLineHeight = MAX(lastLineHeight, charRect.bottom);
 		}
 		text++;
 	}
@@ -189,7 +189,7 @@ void FontRenderer::setFontColor(int32 fontColor1, int32 fontColor2, int32 fontCo
 	_currentFontColor[3] = fontColor3;
 }
 
-void FontRenderer::renderMultiLineText(int32 x, int32 y, const Common::String &origText, int32 mode) {
+void FontRenderer::renderMultiLineText(int16 x, int16 y, const Common::String &origText, int32 mode) {
 	debugC(5, kDebugFont, "renderMultiLineText(%d, %d, %s, %d)", x, y, origText.c_str(), mode);
 
 	// divide the text in several lines
@@ -204,10 +204,10 @@ void FontRenderer::renderMultiLineText(int32 x, int32 y, const Common::String &o
 
 	byte *it = text;
 
-	int32 maxWidth = 0;
-	int32 curWidth = 0;
+	int16 maxWidth = 0;
+	int16 curWidth = 0;
 
-	while (1) {
+	while (true) {
 		byte *lastLine = it;
 		byte *lastSpace = it;
 		int32 lastSpaceX = 0;
@@ -223,7 +223,7 @@ void FontRenderer::renderMultiLineText(int32 x, int32 y, const Common::String &o
 				curChar = textToFont(curChar);
 
 			int width = _currentFont->getFrameWidth(curChar);
-			curWidth += MAX<int32>(width - 2, 0);
+			curWidth += MAX(width - 2, 0);
 			it++;
 			curLetterNr++;
 		}
@@ -260,8 +260,8 @@ void FontRenderer::renderMultiLineText(int32 x, int32 y, const Common::String &o
 	//numLines++;
 
 	// get font height (assumed to be constant)
-	int32 height = _currentFont->getHeight();
-	int textSize = (height - 2) * numLines;
+	int16 height = _currentFont->getHeight();
+	int32 textSize = (height - 2) * numLines;
 	y = y - textSize;
 	if (y < 30)
 		y = 30;
@@ -278,8 +278,8 @@ void FontRenderer::renderMultiLineText(int32 x, int32 y, const Common::String &o
 		x = TOON_SCREEN_WIDTH - (maxWidth / 2) - 30;
 
 	// we have good coordinates now, we can render the multi line
-	int32 curX = x;
-	int32 curY = y;
+	int16 curX = x;
+	int16 curY = y;
 
 	for (int32 i = 0; i < numLines; i++) {
 		const byte *line = lines[i];
diff --git a/engines/toon/font.h b/engines/toon/font.h
index 349d9d1..2a46ad3 100644
--- a/engines/toon/font.h
+++ b/engines/toon/font.h
@@ -33,9 +33,9 @@ public:
 	~FontRenderer();
 
 	void setFont(Animation *font);
-	void computeSize(const Common::String &origText, int32 *retX, int32 *retY);
-	void renderText(int32 x, int32 y, const Common::String &origText, int32 mode);
-	void renderMultiLineText(int32 x, int32 y, const Common::String &origText, int32 mode);
+	void computeSize(const Common::String &origText, int16 *retX, int16 *retY);
+	void renderText(int16 x, int16 y, const Common::String &origText, int32 mode);
+	void renderMultiLineText(int16 x, int16 y, const Common::String &origText, int32 mode);
 	void setFontColorByCharacter(int32 characterId);
 	void setFontColor(int32 fontColor1, int32 fontColor2, int32 fontColor3);
 protected:
diff --git a/engines/toon/hotspot.cpp b/engines/toon/hotspot.cpp
index ce2cdf1..8b8f0ab 100644
--- a/engines/toon/hotspot.cpp
+++ b/engines/toon/hotspot.cpp
@@ -57,7 +57,7 @@ void Hotspots::save(Common::WriteStream *Stream) {
 	}
 }
 
-int32 Hotspots::FindBasedOnCorner(int32 x, int32 y) {
+int32 Hotspots::FindBasedOnCorner(int16 x, int16 y) {
 	debugC(1, kDebugHotspot, "FindBasedOnCorner(%d, %d)", x, y);
 
 	for (int32 i = 0; i < _numItems; i++) {
@@ -73,7 +73,7 @@ int32 Hotspots::FindBasedOnCorner(int32 x, int32 y) {
 	return -1;
 }
 
-int32 Hotspots::Find(int32 x, int32 y) {
+int32 Hotspots::Find(int16 x, int16 y) {
 	debugC(6, kDebugHotspot, "Find(%d, %d)", x, y);
 
 	int32 priority = -1;
diff --git a/engines/toon/hotspot.h b/engines/toon/hotspot.h
index 70e8004..3852e2e 100644
--- a/engines/toon/hotspot.h
+++ b/engines/toon/hotspot.h
@@ -51,8 +51,8 @@ public:
 	~Hotspots();
 
 	bool LoadRif(const Common::String &rifName, const Common::String &additionalRifName);
-	int32 Find(int32 x, int32 y);
-	int32 FindBasedOnCorner(int32 x, int32 y);
+	int32 Find(int16 x, int16 y);
+	int32 FindBasedOnCorner(int16 x, int16 y);
 	HotspotData *Get(int32 id);
 	int32 getCount() const { return _numItems; }
 
diff --git a/engines/toon/picture.cpp b/engines/toon/picture.cpp
index ff136e5..204b0fe 100644
--- a/engines/toon/picture.cpp
+++ b/engines/toon/picture.cpp
@@ -150,7 +150,7 @@ void Picture::setupPalette() {
 		_vm->setPaletteEntries(_palette, 1, 128);
 }
 
-void Picture::drawMask(Graphics::Surface &surface, int32 x, int32 y, int32 dx, int32 dy) {
+void Picture::drawMask(Graphics::Surface &surface, int16 x, int16 y, int16 dx, int16 dy) {
 	debugC(1, kDebugPicture, "drawMask(surface, %d, %d, %d, %d)", x, y, dx, dy);
 
 	for (int32 i = 0; i < 128; i++) {
@@ -161,8 +161,8 @@ void Picture::drawMask(Graphics::Surface &surface, int32 x, int32 y, int32 dx, i
 		_vm->setPaletteEntries(color, i, 1);
 	}
 
-	int32 rx = MIN(_width, surface.w - x);
-	int32 ry = MIN(_height, surface.h - y);
+	int16 rx = MIN<int16>(_width, surface.w - x);
+	int16 ry = MIN<int16>(_height, surface.h - y);
 
 	if (rx < 0 || ry < 0)
 		return;
@@ -172,10 +172,10 @@ void Picture::drawMask(Graphics::Surface &surface, int32 x, int32 y, int32 dx, i
 	uint8 *c = _data + _width * dy + dx;
 	uint8 *curRow = (uint8 *)surface.pixels + y * destPitch + x;
 
-	for (int32 yy = 0; yy < ry; yy++) {
+	for (int16 yy = 0; yy < ry; yy++) {
 		uint8 *curSrc = c;
 		uint8 *cur = curRow;
-		for (int32 xx = 0; xx < rx; xx++) {
+		for (int16 xx = 0; xx < rx; xx++) {
 			//*cur = (*curSrc >> 5) * 8; // & 0x1f;
 			*cur = (*curSrc & 0x1f) ? 127 : 0;
 
@@ -187,10 +187,9 @@ void Picture::drawMask(Graphics::Surface &surface, int32 x, int32 y, int32 dx, i
 	}
 }
 
-void Picture::drawWithRectList(Graphics::Surface& surface, int32 x, int32 y, int32 dx, int32 dy, Common::Array<Common::Rect>& rectArray) {
-
-	int32 rx = MIN(_width, surface.w - x);
-	int32 ry = MIN(_height, surface.h - y);
+void Picture::drawWithRectList(Graphics::Surface& surface, int16 x, int16 y, int16 dx, int16 dy, Common::Array<Common::Rect>& rectArray) {
+	int16 rx = MIN<int16>(_width, surface.w - x);
+	int16 ry = MIN<int16>(_height, surface.h - y);
 
 	if (rx < 0 || ry < 0)
 		return;
@@ -202,16 +201,16 @@ void Picture::drawWithRectList(Graphics::Surface& surface, int32 x, int32 y, int
 
 		Common::Rect rect = rectArray[i];
 
-		int32 fillRx = MIN<int32>(rx, rect.right - rect.left);
-		int32 fillRy = MIN<int32>(ry, rect.bottom - rect.top);
+		int16 fillRx = MIN<int32>(rx, rect.right - rect.left);
+		int16 fillRy = MIN<int32>(ry, rect.bottom - rect.top);
 
 		uint8 *c = _data + _width * (dy + rect.top) + (dx + rect.left);
 		uint8 *curRow = (uint8 *)surface.pixels + (y + rect.top) * destPitch + (x + rect.left);
 
-		for (int32 yy = 0; yy < fillRy; yy++) {
+		for (int16 yy = 0; yy < fillRy; yy++) {
 			uint8 *curSrc = c;
 			uint8 *cur = curRow;
-			for (int32 xx = 0; xx < fillRx; xx++) {
+			for (int16 xx = 0; xx < fillRx; xx++) {
 				*cur = *curSrc;
 				curSrc++;
 				cur++;
@@ -222,11 +221,11 @@ void Picture::drawWithRectList(Graphics::Surface& surface, int32 x, int32 y, int
 	}
 }
 
-void Picture::draw(Graphics::Surface &surface, int32 x, int32 y, int32 dx, int32 dy) {
+void Picture::draw(Graphics::Surface &surface, int16 x, int16 y, int16 dx, int16 dy) {
 	debugC(6, kDebugPicture, "draw(surface, %d, %d, %d, %d)", x, y, dx, dy);
 
-	int32 rx = MIN(_width, surface.w - x);
-	int32 ry = MIN(_height, surface.h - y);
+	int16 rx = MIN<int16>(_width, surface.w - x);
+	int16 ry = MIN<int16>(_height, surface.h - y);
 
 	if (rx < 0 || ry < 0)
 		return;
@@ -236,10 +235,10 @@ void Picture::draw(Graphics::Surface &surface, int32 x, int32 y, int32 dx, int32
 	uint8 *c = _data + _width * dy + dx;
 	uint8 *curRow = (uint8 *)surface.pixels + y * destPitch + x;
 
-	for (int32 yy = 0; yy < ry; yy++) {
+	for (int16 yy = 0; yy < ry; yy++) {
 		uint8 *curSrc = c;
 		uint8 *cur = curRow;
-		for (int32 xx = 0; xx < rx; xx++) {
+		for (int16 xx = 0; xx < rx; xx++) {
 			*cur = *curSrc;
 			curSrc++;
 			cur++;
@@ -249,7 +248,7 @@ void Picture::draw(Graphics::Surface &surface, int32 x, int32 y, int32 dx, int32
 	}
 }
 
-uint8 Picture::getData(int32 x, int32 y) {
+uint8 Picture::getData(int16 x, int16 y) {
 	debugC(6, kDebugPicture, "getData(%d, %d)", x, y);
 
 	if (!_data)
@@ -259,7 +258,7 @@ uint8 Picture::getData(int32 x, int32 y) {
 }
 
 // use original work from johndoe
-void Picture::floodFillNotWalkableOnMask(int32 x, int32 y) {
+void Picture::floodFillNotWalkableOnMask(int16 x, int16 y) {
 	debugC(1, kDebugPicture, "floodFillNotWalkableOnMask(%d, %d)", x, y);
 	// Stack-based floodFill algorithm based on
 	// http://student.kuleuven.be/~m0216922/CG/files/floodfill.cpp
@@ -292,10 +291,10 @@ void Picture::floodFillNotWalkableOnMask(int32 x, int32 y) {
 	}
 }
 
-void Picture::drawLineOnMask(int32 x, int32 y, int32 x2, int32 y2, bool walkable) {
+void Picture::drawLineOnMask(int16 x, int16 y, int16 x2, int16 y2, bool walkable) {
 	debugC(1, kDebugPicture, "drawLineOnMask(%d, %d, %d, %d, %d)", x, y, x2, y2, (walkable) ? 1 : 0);
-	static int32 lastX = 0;
-	static int32 lastY = 0;
+	static int16 lastX = 0;
+	static int16 lastY = 0;
 
 	if (x == -1) {
 		x = lastX;
@@ -303,12 +302,12 @@ void Picture::drawLineOnMask(int32 x, int32 y, int32 x2, int32 y2, bool walkable
 	}
 
 	uint32 bx = x << 16;
-	int32 dx = x2 - x;
+	int16 dx = x2 - x;
 	uint32 by = y << 16;
-	int32 dy = y2 - y;
-	uint32 adx = abs(dx);
-	uint32 ady = abs(dy);
-	int32 t = 0;
+	int16 dy = y2 - y;
+	uint16 adx = abs(dx);
+	uint16 ady = abs(dy);
+	int16 t = 0;
 	if (adx <= ady)
 		t = ady;
 	else
@@ -317,9 +316,7 @@ void Picture::drawLineOnMask(int32 x, int32 y, int32 x2, int32 y2, bool walkable
 	int32 cdx = (dx << 16) / t;
 	int32 cdy = (dy << 16) / t;
 
-	int32 i = t;
-	while (i) {
-
+	for (int16 i = t; i > 0; i--) {
 		int32 rx = bx >> 16;
 		int32 ry = by >> 16;
 
@@ -337,7 +334,6 @@ void Picture::drawLineOnMask(int32 x, int32 y, int32 x2, int32 y2, bool walkable
 
 		bx += cdx;
 		by += cdy;
-		i--;
 	}
 }
 } // End of namespace Toon
diff --git a/engines/toon/picture.h b/engines/toon/picture.h
index 460c5b5..5e79612 100644
--- a/engines/toon/picture.h
+++ b/engines/toon/picture.h
@@ -33,25 +33,27 @@
 namespace Toon {
 
 class ToonEngine;
-class Picture {
 
+class Picture {
 public:
 	Picture(ToonEngine *vm);
 	~Picture();
+
 	bool loadPicture(const Common::String &file);
 	void setupPalette();
-	void draw(Graphics::Surface &surface, int32 x, int32 y, int32 dx, int32 dy);
-	void drawWithRectList(Graphics::Surface& surface, int32 x, int32 y, int32 dx, int32 dy, Common::Array<Common::Rect>& rectArray);
-	void drawMask(Graphics::Surface &surface, int32 x, int32 y, int32 dx, int32 dy);
-	void drawLineOnMask(int32 x, int32 y, int32 x2, int32 y2, bool walkable);
-	void floodFillNotWalkableOnMask(int32 x, int32 y);
-	uint8 getData(int32 x, int32 y);
+	void draw(Graphics::Surface &surface, int16 x, int16 y, int16 dx, int16 dy);
+	void drawWithRectList(Graphics::Surface& surface, int16 x, int16 y, int16 dx, int16 dy, Common::Array<Common::Rect>& rectArray);
+	void drawMask(Graphics::Surface &surface, int16 x, int16 y, int16 dx, int16 dy);
+	void drawLineOnMask(int16 x, int16 y, int16 x2, int16 y2, bool walkable);
+	void floodFillNotWalkableOnMask(int16 x, int16 y);
+	uint8 getData(int16 x, int16 y);
 	uint8 *getDataPtr() { return _data; }
-	int32 getWidth() const { return _width; }
-	int32 getHeight() const { return _height; }
+	int16 getWidth() const { return _width; }
+	int16 getHeight() const { return _height; }
+
 protected:
-	int32 _width;
-	int32 _height;
+	int16 _width;
+	int16 _height;
 	uint8 *_data;
 	uint8 *_palette; // need to be copied at 3-387
 	int32 _paletteEntries;
diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp
index 416daa1..0956b96 100644
--- a/engines/toon/toon.cpp
+++ b/engines/toon/toon.cpp
@@ -1588,12 +1588,12 @@ void ToonEngine::clickEvent() {
 }
 
 void ToonEngine::selectHotspot() {
-	int32 x1 = 0;
-	int32 x2 = 0;
-	int32 y1 = 0;
-	int32 y2 = 0;
+	int16 x1 = 0;
+	int16 x2 = 0;
+	int16 y1 = 0;
+	int16 y2 = 0;
 
-	int32 mouseX = _mouseX;
+	int16 mouseX = _mouseX;
 
 	if (_gameState->_inCutaway)
 		mouseX += TOON_BACKBUFFER_WIDTH;
@@ -1693,7 +1693,6 @@ void ToonEngine::selectHotspot() {
 }
 
 void ToonEngine::exitScene() {
-
 	fadeOut(5);
 
 	// disable all scene animation
@@ -2831,7 +2830,6 @@ void ToonEngine::playSoundWrong() {
 }
 
 void ToonEngine::getTextPosition(int32 characterId, int32 *retX, int32 *retY) {
-
 	if (characterId < 0)
 		characterId = 0;
 
@@ -2852,8 +2850,8 @@ void ToonEngine::getTextPosition(int32 characterId, int32 *retX, int32 *retY) {
 		}
 	} else if (characterId == 1) {
 		// flux
-		int32 x = _flux->getX();
-		int32 y = _flux->getY();
+		int16 x = _flux->getX();
+		int16 y = _flux->getY();
 		if (x >= _gameState->_currentScrollValue && x <= _gameState->_currentScrollValue + TOON_SCREEN_WIDTH) {
 			if (!_gameState->_inCutaway) {
 				*retX = x;
@@ -2885,7 +2883,7 @@ void ToonEngine::getTextPosition(int32 characterId, int32 *retX, int32 *retY) {
 		if (character && !_gameState->_inCutaway) {
 			if (character->getAnimationInstance()) {
 				if (character->getX() >= _gameState->_currentScrollValue && character->getX() <= _gameState->_currentScrollValue + TOON_SCREEN_WIDTH) {
-					int32 x1, y1, x2, y2;
+					int16 x1, y1, x2, y2;
 					character->getAnimationInstance()->getRect(&x1, &y1, &x2, &y2);
 					*retX = (x1 + x2) / 2;
 					*retY = y1;
@@ -2896,7 +2894,6 @@ void ToonEngine::getTextPosition(int32 characterId, int32 *retX, int32 *retY) {
 }
 
 Character *ToonEngine::getCharacterById(int32 charId) {
-
 	for (int32 i = 0; i < 8; i++) {
 		if (_characters[i] && _characters[i]->getId() == charId)
 			return _characters[i];






More information about the Scummvm-git-logs mailing list