[Scummvm-cvs-logs] scummvm master -> 7d436622a8e10437488f6dfa930e3ff15e254a55

bluegr bluegr at gmail.com
Tue Aug 21 02:33:49 CEST 2012


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:
9568b78bab SCI: Use a simpler atan implementation for kGetAngle in SCI1 and newer games
1a61056b06 SCI: Extend a workaround for the dream sequence in QFG4
7d436622a8 SCI: More work on kRemapColors


Commit: 9568b78babdbdf350fd6c47b261c3f21902c31fc
    https://github.com/scummvm/scummvm/commit/9568b78babdbdf350fd6c47b261c3f21902c31fc
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2012-08-20T17:32:18-07:00

Commit Message:
SCI: Use a simpler atan implementation for kGetAngle in SCI1 and newer games

SCI1 games (QFG2 and newer) use a simpler and more accurate atan implementation
for kGetAngle. This properly fixes bug #3540976.

Changed paths:
    engines/sci/engine/kmath.cpp



diff --git a/engines/sci/engine/kmath.cpp b/engines/sci/engine/kmath.cpp
index a643fbe..4b8fadb 100644
--- a/engines/sci/engine/kmath.cpp
+++ b/engines/sci/engine/kmath.cpp
@@ -84,27 +84,10 @@ reg_t kSqrt(EngineState *s, int argc, reg_t *argv) {
  * accurate.
  */
 uint16 kGetAngleWorker(int16 x1, int16 y1, int16 x2, int16 y2) {
-	// TODO: This has been implemented based on behavior observed with a test
-	// program created with SCI Studio. However, the return values have subtle
-	// differences from the original, which uses custom implementation of atan().
-	// The differences in the return values are the cause of bug #3540976
-	// and perhaps bug #3037267 as well.
-	// The results of this function match the expected results of SCI0, but not
-	// SCI1 (hence the bug in Longbow). We need to find the point in history
-	// when this function was changed.
-
-	// HACK: Return the expected value for Longbow, scene 150 (bug #3540976).
-	// This is a temporary solution, till the function returns the expected
-	// results.
-	if (g_sci->getGameId() == GID_LONGBOW && g_sci->getEngineState()->currentRoomNumber() == 150) {
-		if (x1 == 207 && y1 == 88 && x2 == 107 && y2 == 184)
-			return 226;
-	}
-
-#if 0
-	// A simpler atan2-based implementation
-	return (int16)(360 - atan2((double)(x1 - x2), (double)(y1 - y2)) * 57.2958) % 360;
-#endif
+	// SCI1 games (QFG2 and newer) use a simple atan implementation. SCI0 games
+	// use a somewhat less accurate calculation (below).
+	if (getSciVersion() >= SCI_VERSION_1_EGA_ONLY)
+		return (int16)(360 - atan2((double)(x1 - x2), (double)(y1 - y2)) * 57.2958) % 360;
 
 	int16 xRel = x2 - x1;
 	int16 yRel = y1 - y2; // y-axis is mirrored.


Commit: 1a61056b06dc4ea5fe534f6ff13eb4e281bb9c03
    https://github.com/scummvm/scummvm/commit/1a61056b06dc4ea5fe534f6ff13eb4e281bb9c03
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2012-08-20T17:32:21-07:00

Commit Message:
SCI: Extend a workaround for the dream sequence in QFG4

Changed paths:
    engines/sci/engine/workarounds.cpp



diff --git a/engines/sci/engine/workarounds.cpp b/engines/sci/engine/workarounds.cpp
index a4c2355..9fa0368 100644
--- a/engines/sci/engine/workarounds.cpp
+++ b/engines/sci/engine/workarounds.cpp
@@ -399,7 +399,7 @@ const SciWorkaroundEntry kUnLoad_workarounds[] = {
 	{ GID_LSL6,          740,   740,  0,        "showCartoon", "changeState",    -1,    0, { WORKAROUND_IGNORE, 0 } }, // during ending, 4 additional parameters are passed by accident
 	{ GID_LSL6HIRES,     130,   130,  0,    "recruitLarryScr", "changeState",    -1,    0, { WORKAROUND_IGNORE, 0 } }, // during intro, a 3rd parameter is passed by accident
 	{ GID_SQ1,            43,   303,  0,            "slotGuy", "dispose",        -1,    0, { WORKAROUND_IGNORE, 0 } }, // when leaving ulence flats bar, parameter 1 is not passed - script error
-	{ GID_QFG4,          770,   110,  0,            "dreamer", "dispose",        -1,    0, { WORKAROUND_IGNORE, 0 } }, // during the dream sequence, a 3rd parameter is passed by accident
+	{ GID_QFG4,           -1,   110,  0,            "dreamer", "dispose",        -1,    0, { WORKAROUND_IGNORE, 0 } }, // during the dream sequence, a 3rd parameter is passed by accident
 	SCI_WORKAROUNDENTRY_TERMINATOR
 };
 


Commit: 7d436622a8e10437488f6dfa930e3ff15e254a55
    https://github.com/scummvm/scummvm/commit/7d436622a8e10437488f6dfa930e3ff15e254a55
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2012-08-20T17:32:23-07:00

Commit Message:
SCI: More work on kRemapColors

This implements some more color remap-based palette effects, found in QFG4

Changed paths:
    engines/sci/engine/kgraphics32.cpp
    engines/sci/graphics/palette.cpp
    engines/sci/graphics/palette.h



diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp
index 685b3c0..8b3afee 100644
--- a/engines/sci/engine/kgraphics32.cpp
+++ b/engines/sci/engine/kgraphics32.cpp
@@ -771,20 +771,23 @@ reg_t kRemapColors32(EngineState *s, int argc, reg_t *argv) {
 		}
 		break;
 	case 3:	{ // remap to gray
-		// Example call: QFG4 room 490 (Baba Yaga's hut) - params are color 253, 75% and 0
+		// Example call: QFG4 room 490 (Baba Yaga's hut) - params are color 253, 75% and 0.
+		// In this room, it's used for the cloud before Baba Yaga appears.
 		int16 color = argv[1].toSint16();
 		int16 percent = argv[2].toSint16(); // 0 - 100
-		uint16 unk3 = (argc >= 4) ? argv[3].toUint16() : 0;
-		warning("kRemapColors: RemapToGray color %d by %d percent (unk3 = %d)", color, percent, unk3);
-		// TODO
+		if (argc >= 4)
+			warning("RemapToGray called with 4 parameters, unknown parameter is %d", argv[3].toUint16());
+		g_sci->_gfxPalette->setRemappingPercentGray(color, percent);
 		}
 		break;
 	case 4:	{ // remap to percent gray
-		//int16 unk1 = argv[1].toSint16();
-		//uint16 unk2 = argv[2].toUint16();
-		//uint16 unk3 = argv[3].toUint16();
-		//uint16 unk4 = (argc >= 5) ? argv[4].toUint16() : 0;
-		kStub(s, argc, argv);
+		// Example call: QFG4 rooms 530/535 (swamp) - params are 253, 100%, 200
+		int16 color = argv[1].toSint16();
+		int16 percent = argv[2].toSint16(); // 0 - 100
+		// argv[3] is unknown (a number, e.g. 200) - start color, perhaps?
+		if (argc >= 5)
+			warning("RemapToGrayPercent called with 5 parameters, unknown parameter is %d", argv[4].toUint16());
+		g_sci->_gfxPalette->setRemappingPercentGray(color, percent);
 		}
 		break;
 	case 5:	{ // don't map to range
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp
index 68104b0..53d69cd 100644
--- a/engines/sci/graphics/palette.cpp
+++ b/engines/sci/graphics/palette.cpp
@@ -375,6 +375,27 @@ void GfxPalette::setRemappingPercent(byte color, byte percent) {
 	_remappingType[color] = kRemappingByPercent;
 }
 
+void GfxPalette::setRemappingPercentGray(byte color, byte percent) {
+	_remapOn = true;
+
+	// We need to defer the setup of the remapping table every time the screen
+	// palette is changed, so that kernelFindColor() can find the correct
+	// colors. Set it once here, in case the palette stays the same and update
+	// it on each palette change by copySysPaletteToScreen().
+	_remappingPercentToSet = percent;
+
+	// Note: This is not what the original does, but the results are the same visually
+	for (int i = 0; i < 256; i++) {
+		byte rComponent = _sysPalette.colors[i].r * _remappingPercentToSet * 0.30 / 100;
+		byte gComponent = _sysPalette.colors[i].g * _remappingPercentToSet * 0.59 / 100;
+		byte bComponent = _sysPalette.colors[i].b * _remappingPercentToSet * 0.11 / 100;
+		byte luminosity = rComponent + gComponent + bComponent;
+		_remappingByPercent[i] = kernelFindColor(luminosity, luminosity, luminosity);
+	}
+
+	_remappingType[color] = kRemappingByPercent;
+}
+
 void GfxPalette::setRemappingRange(byte color, byte from, byte to, byte base) {
 	_remapOn = true;
 
diff --git a/engines/sci/graphics/palette.h b/engines/sci/graphics/palette.h
index 9898315..e974781 100644
--- a/engines/sci/graphics/palette.h
+++ b/engines/sci/graphics/palette.h
@@ -61,6 +61,7 @@ public:
 
 	void resetRemapping();
 	void setRemappingPercent(byte color, byte percent);
+	void setRemappingPercentGray(byte color, byte percent);
 	void setRemappingRange(byte color, byte from, byte to, byte base);
 	bool isRemapped(byte color) const {
 		return _remapOn && (_remappingType[color] != kRemappingNone);






More information about the Scummvm-git-logs mailing list