[Scummvm-git-logs] scummvm master -> c9ad2062db80fc9b6339bebdcd70f58269e38bf6

csnover csnover at users.noreply.github.com
Thu Oct 20 18:33:39 CEST 2016


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

Summary:
55222ec06c SCI32: Fix zero-offset exports
34bd1bcaa9 SCI32: Split out detection of features that cross SSCI versions
45f7aef8cb SCI32: Fix typo
bd4b0dbbfd SCI32: Fix QFG4 version comments
c9ad2062db SCI32: Fix wrong value passed to updateInfoFlagViewVisible


Commit: 55222ec06c030a03d288b7ad476c5dbf1444a48b
    https://github.com/scummvm/scummvm/commit/55222ec06c030a03d288b7ad476c5dbf1444a48b
Author: Colin Snover (github.com at zetafleet.com)
Date: 2016-10-20T11:33:08-05:00

Commit Message:
SCI32: Fix zero-offset exports

Exports with a zero offset are supposed to point to the start of
the code block in the script hunk, but they were being ignored.

This may also apply to SCI1.1 games, but until that can be
verified, this fixes the zero-offset in only SCI32 games for now.

Changed paths:
    engines/sci/engine/script.cpp
    engines/sci/engine/script.h



diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index aef9cb1..098c2e5 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -72,6 +72,11 @@ void Script::freeScript() {
 	_offsetLookupSaidCount = 0;
 }
 
+enum {
+	kSci11NumExportsOffset = 6,
+	kSci11ExportTableOffset = 8
+};
+
 void Script::load(int script_nr, ResourceManager *resMan, ScriptPatcher *scriptPatcher) {
 	freeScript();
 
@@ -172,10 +177,11 @@ void Script::load(int script_nr, ResourceManager *resMan, ScriptPatcher *scriptP
 			_localsCount = (READ_LE_UINT16(_buf + _localsOffset - 2) - 4) >> 1;	// half block size
 		}
 	} else if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1_LATE) {
-		if (READ_LE_UINT16(_buf + 1 + 5) > 0) {	// does the script have an export table?
-			_exportTable = (const uint16 *)(_buf + 1 + 5 + 2);
-			_numExports = READ_SCI11ENDIAN_UINT16(_exportTable - 1);
+		_numExports = READ_SCI11ENDIAN_UINT16(_buf + kSci11NumExportsOffset);
+		if (_numExports) {
+			_exportTable = (const uint16 *)(_buf + kSci11ExportTableOffset);
 		}
+
 		_localsOffset = _scriptSize + 4;
 		_localsCount = READ_SCI11ENDIAN_UINT16(_buf + _localsOffset - 2);
 	} else if (getSciVersion() == SCI_VERSION_3) {
@@ -234,6 +240,7 @@ void Script::identifyOffsets() {
 	_offsetLookupObjectCount = 0;
 	_offsetLookupStringCount = 0;
 	_offsetLookupSaidCount = 0;
+	_codeOffset = 0;
 
 	if (getSciVersion() < SCI_VERSION_1_1) {
 		// SCI0 + SCI1
@@ -392,6 +399,16 @@ void Script::identifyOffsets() {
 		scriptDataPtr = _heapStart;
 		scriptDataLeft = _heapSize;
 
+		enum {
+			kExportSize = 2,
+			kPropertySize = 2,
+			kNumMethodsSize = 2,
+			kPropDictEntrySize = 2,
+			kMethDictEntrySize = 4
+		};
+
+		const byte *hunkPtr = _buf + kSci11ExportTableOffset + _numExports * kExportSize;
+
 		if (scriptDataLeft < 4)
 			error("Script::identifyOffsets(): unexpected end of script in script %d", _nr);
 
@@ -431,11 +448,22 @@ void Script::identifyOffsets() {
 			if (scriptDataLeft < 2)
 				error("Script::identifyOffsets(): unexpected end of script in script %d", _nr);
 
-			blockSize = READ_SCI11ENDIAN_UINT16(scriptDataPtr) * 2;
+			const uint16 numProperties = READ_SCI11ENDIAN_UINT16(scriptDataPtr);
+			blockSize = numProperties * kPropertySize;
 			if (blockSize < 4)
 				error("Script::identifyOffsets(): invalid block size in script %d", _nr);
 			scriptDataPtr  += 2;
 			scriptDataLeft -= 2;
+
+			const uint16 scriptNum = READ_SCI11ENDIAN_UINT16(scriptDataPtr + 6);
+
+			if (scriptNum != 0xFFFF) {
+				hunkPtr += numProperties * kPropDictEntrySize;
+			}
+
+			const uint16 numMethods = READ_SCI11ENDIAN_UINT16(hunkPtr);
+			hunkPtr += kNumMethodsSize + numMethods * kMethDictEntrySize;
+
 			blockSize -= 4; // blocksize contains UINT16 type and UINT16 size
 			if (scriptDataLeft < blockSize)
 				error("Script::identifyOffsets(): invalid block size in script %d", _nr);
@@ -444,6 +472,8 @@ void Script::identifyOffsets() {
 			scriptDataLeft -= blockSize;
 		} while (1);
 
+		_codeOffset = hunkPtr - _buf;
+
 		// now scriptDataPtr points to right at the start of the strings
 		if (scriptDataPtr > endOfStringPtr)
 			error("Script::identifyOffsets(): string block / end-of-string block mismatch in script %d", _nr);
@@ -820,9 +850,10 @@ uint32 Script::validateExportFunc(int pubfunct, bool relocSci3) {
 		}
 	}
 
-	// Note that it's perfectly normal to return a zero offset, especially in
-	// SCI1.1 and newer games. Examples include script 64036 in Torin's Passage,
-	// script 64908 in the demo of RAMA and script 1013 in KQ6 floppy.
+	// TODO: Check if this should be done for SCI1.1 games as well
+	if (getSciVersion() >= SCI_VERSION_2 && offset == 0) {
+		offset = _codeOffset;
+	}
 
 	if (offset >= _bufSize)
 		error("Invalid export function pointer");
diff --git a/engines/sci/engine/script.h b/engines/sci/engine/script.h
index 755e2f3..31f0a9e 100644
--- a/engines/sci/engine/script.h
+++ b/engines/sci/engine/script.h
@@ -81,6 +81,8 @@ private:
 	const byte *_synonyms; /**< Synonyms block or 0 if not present */
 	uint16 _numSynonyms; /**< Number of entries in the synonyms block */
 
+	int _codeOffset; /**< The absolute offset of the VM code block */
+
 	int _localsOffset;
 	uint16 _localsCount;
 


Commit: 34bd1bcaa9246d6599819ff3ed1ab4c35812136d
    https://github.com/scummvm/scummvm/commit/34bd1bcaa9246d6599819ff3ed1ab4c35812136d
Author: Colin Snover (github.com at zetafleet.com)
Date: 2016-10-20T11:33:29-05:00

Commit Message:
SCI32: Split out detection of features that cross SSCI versions

Changed paths:
    engines/sci/engine/features.h
    engines/sci/engine/kgraphics32.cpp
    engines/sci/graphics/palette32.cpp
    engines/sci/graphics/plane32.cpp
    engines/sci/graphics/remap32.cpp
    engines/sci/sound/audio32.cpp



diff --git a/engines/sci/engine/features.h b/engines/sci/engine/features.h
index b2d40f4..15c80a7 100644
--- a/engines/sci/engine/features.h
+++ b/engines/sci/engine/features.h
@@ -82,6 +82,41 @@ public:
 	 * @return Graphics functions type, SCI_VERSION_2 / SCI_VERSION_2_1
 	 */
 	SciVersion detectSci21KernelType();
+
+	inline bool usesModifiedAudioAttenuation() const {
+		switch (g_sci->getGameId()) {
+		// Assuming MGDX uses modified attenuation since SQ6 does and it was
+		// released earlier, but not verified (Phar Lap Windows-only release)
+		case GID_MOTHERGOOSEHIRES:
+		case GID_PQ4:
+		case GID_SQ6:
+			return true;
+		case GID_KQ7:
+		case GID_QFG4:
+			// (1) KQ7 1.51 (SCI2.1early) uses the non-standard attenuation, but
+			// 2.00b (SCI2.1mid) does not
+			// (2) QFG4 CD is SCI2.1early; QFG4 floppy is SCI2 and does not use
+			// the SCI2.1 audio system
+			return getSciVersion() == SCI_VERSION_2_1_EARLY;
+		default:
+			return false;
+		}
+	}
+
+	inline bool hasTransparentPicturePlanes() const {
+		const SciGameId &gid = g_sci->getGameId();
+
+		// NOTE: MGDX is assumed to not have transparent picture planes since it
+		// was released before SQ6, but this has not been verified since it
+		// cannot be disassembled at the moment (Phar Lap Windows-only release)
+		return getSciVersion() >= SCI_VERSION_2_1_MIDDLE &&
+			gid != GID_SQ6 &&
+			gid != GID_MOTHERGOOSEHIRES;
+	}
+
+	inline bool hasNewPaletteCode() const {
+		return getSciVersion() >= SCI_VERSION_2_1_MIDDLE || g_sci->getGameId() == GID_KQ7;
+	}
 #endif
 
 	/**
diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp
index 039373c..d437741 100644
--- a/engines/sci/engine/kgraphics32.cpp
+++ b/engines/sci/engine/kgraphics32.cpp
@@ -972,9 +972,7 @@ reg_t kPalVarySetVary(EngineState *s, int argc, reg_t *argv) {
 	int16 fromColor;
 	int16 toColor;
 
-	if ((getSciVersion() >= SCI_VERSION_2_1_MIDDLE || g_sci->getGameId() == GID_KQ7)
-		&& argc > 4) {
-
+	if (g_sci->_features->hasNewPaletteCode() && argc > 4) {
 		fromColor = argv[3].toSint16();
 		toColor = argv[4].toSint16();
 	} else {
diff --git a/engines/sci/graphics/palette32.cpp b/engines/sci/graphics/palette32.cpp
index ec3d912..56e1940 100644
--- a/engines/sci/graphics/palette32.cpp
+++ b/engines/sci/graphics/palette32.cpp
@@ -28,6 +28,7 @@
 #include "sci/event.h"
 #include "sci/resource.h"
 #include "sci/util.h"
+#include "sci/engine/features.h"
 #include "sci/graphics/palette32.h"
 #include "sci/graphics/remap32.h"
 #include "sci/graphics/screen.h"
@@ -557,7 +558,7 @@ void GfxPalette32::setCycle(const uint8 fromColor, const uint8 toColor, const in
 	}
 
 	uint16 numColorsToCycle = toColor - fromColor;
-	if (getSciVersion() >= SCI_VERSION_2_1_MIDDLE || g_sci->getGameId() == GID_KQ7) {
+	if (g_sci->_features->hasNewPaletteCode()) {
 		numColorsToCycle += 1;
 	}
 	cycler->fromColor = fromColor;
diff --git a/engines/sci/graphics/plane32.cpp b/engines/sci/graphics/plane32.cpp
index 7dfaed4..086a4a7 100644
--- a/engines/sci/graphics/plane32.cpp
+++ b/engines/sci/graphics/plane32.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "sci/console.h"
+#include "sci/engine/features.h"
 #include "sci/engine/kernel.h"
 #include "sci/engine/selector.h"
 #include "sci/engine/state.h"
@@ -191,7 +192,7 @@ void Plane::addPicInternal(const GuiResourceId pictureId, const Common::Point *p
 		delete screenItem->_celObj;
 		screenItem->_celObj = celObj;
 	}
-	_type = (getSciVersion() == SCI_VERSION_3 && transparent) ? kPlaneTypeTransparentPicture : kPlaneTypePicture;
+	_type = (g_sci->_features->hasTransparentPicturePlanes() && transparent) ? kPlaneTypeTransparentPicture : kPlaneTypePicture;
 }
 
 GuiResourceId Plane::addPic(const GuiResourceId pictureId, const Common::Point &position, const bool mirrorX, const bool deleteDuplicate) {
@@ -751,14 +752,13 @@ void Plane::setType() {
 		_type = kPlaneTypeOpaque;
 		break;
 	case kPlanePicTransparentPicture:
-		if (getSciVersion() == SCI_VERSION_3) {
-			warning("TODO: Using transparent picture plane. Rendering may be incomplete");
+		if (g_sci->_features->hasTransparentPicturePlanes()) {
 			_type = kPlaneTypeTransparentPicture;
 			break;
 		}
-		// fall through for sci2/2.1
+		// fall through for games without transparent picture planes
 	default:
-		if (_type != kPlaneTypeTransparentPicture) {
+		if (!g_sci->_features->hasTransparentPicturePlanes() || _type != kPlaneTypeTransparentPicture) {
 			_type = kPlaneTypePicture;
 		}
 		break;
diff --git a/engines/sci/graphics/remap32.cpp b/engines/sci/graphics/remap32.cpp
index d5a2362..768594f 100644
--- a/engines/sci/graphics/remap32.cpp
+++ b/engines/sci/graphics/remap32.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "sci/sci.h"
+#include "sci/engine/features.h"
 #include "sci/graphics/palette32.h"
 #include "sci/graphics/remap32.h"
 
@@ -300,7 +301,7 @@ GfxRemap32::GfxRemap32() :
 	// match the highest possible value of `_remapStartColor`
 	assert(_remapStartColor == 236);
 
-	if (getSciVersion() >= SCI_VERSION_2_1_MIDDLE || g_sci->getGameId() == GID_KQ7) {
+	if (g_sci->_features->hasNewPaletteCode()) {
 		_remaps.resize(9);
 	} else {
 		_remaps.resize(19);
diff --git a/engines/sci/sound/audio32.cpp b/engines/sci/sound/audio32.cpp
index 659a526..d5a7ae1 100644
--- a/engines/sci/sound/audio32.cpp
+++ b/engines/sci/sound/audio32.cpp
@@ -35,6 +35,7 @@
 #include "common/textconsole.h"     // for warning
 #include "common/types.h"           // for Flag::NO
 #include "engine.h"                 // for Engine, g_engine
+#include "sci/engine/features.h"    // for GameFeatures
 #include "sci/engine/vm_types.h"    // for reg_t, make_reg, NULL_REG
 #include "sci/resource.h"           // for ResourceId, ResourceType::kResour...
 #include "sci/sci.h"                // for SciEngine, g_sci, getSciVersion
@@ -135,23 +136,7 @@ Audio32::Audio32(ResourceManager *resMan) :
 		_channels.resize(8);
 	}
 
-	_useModifiedAttenuation = false;
-	if (getSciVersion() == SCI_VERSION_2_1_MIDDLE) {
-		switch (g_sci->getGameId()) {
-		case GID_MOTHERGOOSEHIRES:
-		case GID_PQ4:
-		case GID_QFG4:
-		case GID_SQ6:
-			_useModifiedAttenuation = true;
-		default:
-			break;
-		}
-	} else if (getSciVersion() == SCI_VERSION_2_1_EARLY && g_sci->getGameId() == GID_KQ7) {
-		// KQ7 1.51 uses the non-standard attenuation, but 2.00b
-		// does not, which is strange.
-		_useModifiedAttenuation = true;
-	}
-
+	_useModifiedAttenuation = g_sci->_features->usesModifiedAudioAttenuation();
 	_mixer->playStream(Audio::Mixer::kSFXSoundType, &_handle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
 }
 


Commit: 45f7aef8cb063ebddbef7226a395ee8a8b6efa9a
    https://github.com/scummvm/scummvm/commit/45f7aef8cb063ebddbef7226a395ee8a8b6efa9a
Author: Colin Snover (github.com at zetafleet.com)
Date: 2016-10-20T11:33:29-05:00

Commit Message:
SCI32: Fix typo

Changed paths:
    engines/sci/graphics/plane32.cpp



diff --git a/engines/sci/graphics/plane32.cpp b/engines/sci/graphics/plane32.cpp
index 086a4a7..f56df4d 100644
--- a/engines/sci/graphics/plane32.cpp
+++ b/engines/sci/graphics/plane32.cpp
@@ -50,7 +50,7 @@ _pictureId(pictureId),
 _mirrored(false),
 _type(kPlaneTypeColored),
 _back(0),
-_priorityChanged(0),
+_priorityChanged(false),
 _object(make_reg(0, _nextObjectId++)),
 _redrawAllCount(g_sci->_gfxFrameout->getScreenCount()),
 _created(g_sci->_gfxFrameout->getScreenCount()),


Commit: bd4b0dbbfdddf0426f451ae0a68cc7d4bdc45262
    https://github.com/scummvm/scummvm/commit/bd4b0dbbfdddf0426f451ae0a68cc7d4bdc45262
Author: Colin Snover (github.com at zetafleet.com)
Date: 2016-10-20T11:33:30-05:00

Commit Message:
SCI32: Fix QFG4 version comments

Changed paths:
    engines/sci/sci.h



diff --git a/engines/sci/sci.h b/engines/sci/sci.h
index b46207b..61dccb4 100644
--- a/engines/sci/sci.h
+++ b/engines/sci/sci.h
@@ -225,8 +225,8 @@ enum SciVersion {
 	SCI_VERSION_1_LATE, // Dr. Brain 1, EcoQuest 1, Longbow, PQ3, SQ1, LSL5, KQ5 CD
 	SCI_VERSION_1_1, // Dr. Brain 2, EcoQuest 1 CD, EcoQuest 2, KQ6, QFG3, SQ4CD, XMAS 1992 and many more
 	SCI_VERSION_2, // GK1, PQ4 floppy, QFG4 floppy
-	SCI_VERSION_2_1_EARLY, // GK2 demo, KQ7 1.4/1.51, LSL6 hires, PQ4CD, QFG4 floppy
-	SCI_VERSION_2_1_MIDDLE, // GK2, KQ7 2.00b, MUMG Deluxe, Phantasmagoria 1, PQ:SWAT, QFG4CD, Shivers 1, SQ6, Torin
+	SCI_VERSION_2_1_EARLY, // GK2 demo, KQ7 1.4/1.51, LSL6 hires, PQ4CD, QFG4CD
+	SCI_VERSION_2_1_MIDDLE, // GK2, KQ7 2.00b, MUMG Deluxe, Phantasmagoria 1, PQ:SWAT, Shivers 1, SQ6, Torin
 	SCI_VERSION_2_1_LATE, // demos of LSL7, Lighthouse, RAMA
 	SCI_VERSION_3 // LSL7, Lighthouse, RAMA, Phantasmagoria 2
 };


Commit: c9ad2062db80fc9b6339bebdcd70f58269e38bf6
    https://github.com/scummvm/scummvm/commit/c9ad2062db80fc9b6339bebdcd70f58269e38bf6
Author: Colin Snover (github.com at zetafleet.com)
Date: 2016-10-20T11:33:30-05:00

Commit Message:
SCI32: Fix wrong value passed to updateInfoFlagViewVisible

updateInfoFlagViewVisible accepts a property index, not a selector
ID.

Fixes Trac#9583.

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



diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp
index 3ae9022..585b0ef 100644
--- a/engines/sci/engine/selector.cpp
+++ b/engines/sci/engine/selector.cpp
@@ -233,12 +233,12 @@ void writeSelector(SegManager *segMan, reg_t object, Selector selectorId, reg_t
 	if (lookupSelector(segMan, object, selectorId, &address, NULL) != kSelectorVariable) {
 		const SciCallOrigin origin = g_sci->getEngineState()->getCurrentCallOrigin();
 		error("Selector '%s' of object could not be written to. Address %04x:%04x, %s", g_sci->getKernel()->getSelectorName(selectorId).c_str(), PRINT_REG(object), origin.toString().c_str());
-	} else {
-		*address.getPointer(segMan) = value;
+	}
+
+	*address.getPointer(segMan) = value;
 #ifdef ENABLE_SCI32
-		updateInfoFlagViewVisible(segMan->getObject(object), selectorId);
+	updateInfoFlagViewVisible(segMan->getObject(object), address.varindex);
 #endif
-	}
 }
 
 void invokeSelector(EngineState *s, reg_t object, int selectorId,





More information about the Scummvm-git-logs mailing list