[Scummvm-cvs-logs] scummvm master -> 27e4a1dee524fb4979a3ba2430b6c82d486be853

bluegr md5 at scummvm.org
Wed Apr 27 12:46:02 CEST 2011


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

Summary:
3ab0a133b3 SCUMM: Fixed compilation with MSVC
99e3028459 PNG: Improved code readability a bit
27e4a1dee5 PNG: Changed getPalette() to properly return a copy of the image palette


Commit: 3ab0a133b3fca2e9e28be9d9d6d6efd3a4c2cb88
    https://github.com/scummvm/scummvm/commit/3ab0a133b3fca2e9e28be9d9d6d6efd3a4c2cb88
Author: md5 (md5 at scummvm.org)
Date: 2011-04-27T03:29:51-07:00

Commit Message:
SCUMM: Fixed compilation with MSVC

Both double and float parameters were passed to atan2(), which didn't match
any variants of atan2()

Changed paths:
    engines/scumm/he/logic_he.cpp



diff --git a/engines/scumm/he/logic_he.cpp b/engines/scumm/he/logic_he.cpp
index 0f2d232..3364763 100644
--- a/engines/scumm/he/logic_he.cpp
+++ b/engines/scumm/he/logic_he.cpp
@@ -1020,7 +1020,7 @@ int LogicHEsoccer::op_1011(int32 a1, int32 a2, int32 a3, int32 a4, int32 a5) {
 	// This is called on each frame by startOfFrame() if activated by op_1012.
 	// This seems to do player placement!
 
-	float v28;
+	float v28 = 0.0;
 
 	for (int i = 0; i < 18; i++) {
 		// These seem to be some sort of percent? of angles?
@@ -1060,15 +1060,15 @@ int LogicHEsoccer::op_1011(int32 a1, int32 a2, int32 a3, int32 a4, int32 a5) {
 				putInArray(a5, 0, i, v24 + 11 * v21);
 		}
 
-		float v7 = atan2(_userDataD[524] - v28, v31);
+		float v7 = atan2(_userDataD[524] - v28, (double)v31);
 		int v8 = (int)(_userDataD[526] - (_userDataD[521] - v7) * _userDataD[522] + 300.0);
 
-		double v9 = atan2(_userDataD[523], v31);
+		double v9 = atan2(_userDataD[523], (double)v31);
 		// x/y position?
 		putInArray(a2, i, 0, (int32)(v29 * v9 + 640.0));
 		putInArray(a2, i, 1, v8);
 
-		double v10 = atan2(_userDataD[524], v31);
+		double v10 = atan2(_userDataD[524], (double)v31);
 		int v12 = (int)(_userDataD[526] - (_userDataD[521] - (float)v10) * _userDataD[522] + 300.0);
 		double v13 = _userDataD[523];
 


Commit: 99e30284593a58fb95edf35a74b5ba2374b485e3
    https://github.com/scummvm/scummvm/commit/99e30284593a58fb95edf35a74b5ba2374b485e3
Author: md5 (md5 at scummvm.org)
Date: 2011-04-27T03:43:03-07:00

Commit Message:
PNG: Improved code readability a bit

Changed paths:
    graphics/png.cpp



diff --git a/graphics/png.cpp b/graphics/png.cpp
index b256c87..ed1dd78 100644
--- a/graphics/png.cpp
+++ b/graphics/png.cpp
@@ -127,13 +127,14 @@ Graphics::Surface *PNG::getSurface(const PixelFormat &format) {
 
 		for (uint16 i = 0; i < output->h; i++) {
 			for (uint16 j = 0; j < output->w; j++) {
-				if (format.bytesPerPixel == 2) {
+				if (format.bytesPerPixel == 2) {	// 2bpp
+					uint16 *dest = ((uint16 *)output->getBasePtr(j, i));
 					if (_unfilteredSurface->bytesPerPixel == 1) {		// Grayscale
 						if (_transparentColorSpecified)
 							a = (src[0] == _transparentColor[0]) ? 0 : 0xFF;
-						*((uint16 *)output->getBasePtr(j, i)) = format.ARGBToColor(    a, src[0], src[0], src[0]);
+						*dest = format.ARGBToColor(    a, src[0], src[0], src[0]);
 					} else if (_unfilteredSurface->bytesPerPixel == 2) {	// Grayscale + alpha
-						*((uint16 *)output->getBasePtr(j, i)) = format.ARGBToColor(src[1], src[0], src[0], src[0]);
+						*dest = format.ARGBToColor(src[1], src[0], src[0], src[0]);
 					} else if (_unfilteredSurface->bytesPerPixel == 3) {	// RGB
 						if (_transparentColorSpecified) {
 							bool isTransparentColor = (src[0] == _transparentColor[0] &&
@@ -141,17 +142,18 @@ Graphics::Surface *PNG::getSurface(const PixelFormat &format) {
 													   src[2] == _transparentColor[2]);
 							a = isTransparentColor ? 0 : 0xFF;
 						}
-						*((uint16 *)output->getBasePtr(j, i)) = format.ARGBToColor(     a, src[0], src[1], src[2]);
+						*dest = format.ARGBToColor(     a, src[0], src[1], src[2]);
 					} else if (_unfilteredSurface->bytesPerPixel == 4) {	// RGBA
-						*((uint16 *)output->getBasePtr(j, i)) = format.ARGBToColor(src[3], src[0], src[1], src[2]);
+						*dest = format.ARGBToColor(src[3], src[0], src[1], src[2]);
 					}
-				} else {
+				} else {	// 4bpp
+					uint32 *dest = ((uint32 *)output->getBasePtr(j, i));
 					if (_unfilteredSurface->bytesPerPixel == 1) {		// Grayscale
 						if (_transparentColorSpecified)
 							a = (src[0] == _transparentColor[0]) ? 0 : 0xFF;
-						*((uint32 *)output->getBasePtr(j, i)) = format.ARGBToColor(     a, src[0], src[0], src[0]);
+						*dest = format.ARGBToColor(     a, src[0], src[0], src[0]);
 					} else if (_unfilteredSurface->bytesPerPixel == 2) {	// Grayscale + alpha
-						*((uint32 *)output->getBasePtr(j, i)) = format.ARGBToColor(src[1], src[0], src[0], src[0]);
+						*dest = format.ARGBToColor(src[1], src[0], src[0], src[0]);
 					} else if (_unfilteredSurface->bytesPerPixel == 3) {	// RGB
 						if (_transparentColorSpecified) {
 							bool isTransparentColor = (src[0] == _transparentColor[0] &&
@@ -159,9 +161,9 @@ Graphics::Surface *PNG::getSurface(const PixelFormat &format) {
 													   src[2] == _transparentColor[2]);
 							a = isTransparentColor ? 0 : 0xFF;
 						}
-						*((uint32 *)output->getBasePtr(j, i)) = format.ARGBToColor(     a, src[0], src[1], src[2]);
+						*dest = format.ARGBToColor(     a, src[0], src[1], src[2]);
 					} else if (_unfilteredSurface->bytesPerPixel == 4) {	// RGBA
-						*((uint32 *)output->getBasePtr(j, i)) = format.ARGBToColor(src[3], src[0], src[1], src[2]);
+						*dest = format.ARGBToColor(src[3], src[0], src[1], src[2]);
 					}
 				}
 


Commit: 27e4a1dee524fb4979a3ba2430b6c82d486be853
    https://github.com/scummvm/scummvm/commit/27e4a1dee524fb4979a3ba2430b6c82d486be853
Author: md5 (md5 at scummvm.org)
Date: 2011-04-27T03:44:19-07:00

Commit Message:
PNG: Changed getPalette() to properly return a copy of the image palette

Changed paths:
    graphics/png.h



diff --git a/graphics/png.h b/graphics/png.h
index 00c084d..af6630c 100644
--- a/graphics/png.h
+++ b/graphics/png.h
@@ -117,18 +117,18 @@ public:
 	}
 
 	/**
-	 * Returns the palette of the specified PNG8 image.
-	 *
-	 * Note that the palette's format is RGBA.
+	 * Returns the palette of the specified PNG8 image, given a pointer to
+	 * an RGBA palette array (4 x 256).
 	 */
-	void getPalette(byte *&palette, uint16 &entries) {
+	void getPalette(byte *palette, uint16 &entries) {
 		if (_header.colorType != kIndexed)
 			error("Palette requested for a non-indexed PNG");
-		// TODO: It might be that this should really return a copy of the
-		// palette, but since the implementation was like this I changed
-		// the palette pointer to be a reference instead of a value copy.
-		// Someone should check this code and verify this is as intended.
-		palette = _palette;
+		for (int i = 0; i < 256; i++) {
+			palette[0 + i * 4] = _palette[0 + i * 4];	// R
+			palette[1 + i * 4] = _palette[1 + i * 4];	// G
+			palette[2 + i * 4] = _palette[2 + i * 4];	// B
+			palette[3 + i * 4] = _palette[3 + i * 4];	// A
+		}
 		entries = _paletteEntries;
 	}
 






More information about the Scummvm-git-logs mailing list