[Scummvm-git-logs] scummvm master -> 864bc308add9598ded2d072068bb5354f137bcb1

sev- noreply at scummvm.org
Sat Apr 29 10:21:03 UTC 2023


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

Summary:
94a80395ef SCUMM: Inline ScummEngine::testGfxUsageBit()
0a1d1cb29b SCI: Inline Script::offsetIsObject()
d9d087ac3f SCI: Inline getSciVersion()
864bc308ad SCI: Inline reg_t::getOffset() & reg_t::setOffset()


Commit: 94a80395ef2acafbd04bcd0eb0e774ea238a1878
    https://github.com/scummvm/scummvm/commit/94a80395ef2acafbd04bcd0eb0e774ea238a1878
Author: Miro Kropacek (miro.kropacek at gmail.com)
Date: 2023-04-29T12:20:58+02:00

Commit Message:
SCUMM: Inline ScummEngine::testGfxUsageBit()

Changed paths:
    engines/scumm/scumm.h
    engines/scumm/usage_bits.cpp


diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 5ed7899d572..579175011a2 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -1441,7 +1441,15 @@ protected:
 	void upgradeGfxUsageBits();
 	void setGfxUsageBit(int strip, int bit);
 	void clearGfxUsageBit(int strip, int bit);
-	bool testGfxUsageBit(int strip, int bit);
+
+	// speed optimization: inline due to frequent calling
+	bool testGfxUsageBit(int strip, int bit) {
+		assert(strip >= 0 && strip < ARRAYSIZE(gfxUsageBits) / 3);
+		assert(1 <= bit && bit <= 96);
+		bit--;
+		return (gfxUsageBits[3 * strip + bit / 32] & (1 << (bit % 32))) != 0;
+	}
+
 	bool testGfxAnyUsageBits(int strip);
 	bool testGfxOtherUsageBits(int strip, int bit);
 
diff --git a/engines/scumm/usage_bits.cpp b/engines/scumm/usage_bits.cpp
index 83c24108cc6..fa17b693247 100644
--- a/engines/scumm/usage_bits.cpp
+++ b/engines/scumm/usage_bits.cpp
@@ -54,13 +54,6 @@ void ScummEngine::clearGfxUsageBit(int strip, int bit) {
 	gfxUsageBits[3 * strip + bit / 32] &= ~(1 << (bit % 32));
 }
 
-bool ScummEngine::testGfxUsageBit(int strip, int bit) {
-	assert(strip >= 0 && strip < ARRAYSIZE(gfxUsageBits) / 3);
-	assert(1 <= bit && bit <= 96);
-	bit--;
-	return (gfxUsageBits[3 * strip + bit / 32] & (1 << (bit % 32))) != 0;
-}
-
 bool ScummEngine::testGfxAnyUsageBits(int strip) {
 	// Exclude the DIRTY and RESTORED bits from the test
 	uint32 bitmask[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0x3FFFFFFF };


Commit: 0a1d1cb29b15f14cc3d1525b43f992f8aa6f4ab8
    https://github.com/scummvm/scummvm/commit/0a1d1cb29b15f14cc3d1525b43f992f8aa6f4ab8
Author: Miro Kropacek (miro.kropacek at gmail.com)
Date: 2023-04-29T12:20:58+02:00

Commit Message:
SCI: Inline Script::offsetIsObject()

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 c657c1f0958..a872d872ed6 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -1292,10 +1292,6 @@ Common::Array<reg_t> Script::listObjectReferences() const {
 	return tmp;
 }
 
-bool Script::offsetIsObject(uint32 offset) const {
-	return _buf->getUint16SEAt(offset + SCRIPT_OBJECT_MAGIC_OFFSET) == SCRIPT_OBJECT_MAGIC_NUMBER;
-}
-
 void Script::applySaidWorkarounds() {
 	// WORKAROUND: SQ3 version 1.018 has a messy vocab problem.
 	// Sierra added the vocab entry "scout" to this version at group id 0x953
diff --git a/engines/sci/engine/script.h b/engines/sci/engine/script.h
index 64c2255017e..ba9f5bc188e 100644
--- a/engines/sci/engine/script.h
+++ b/engines/sci/engine/script.h
@@ -125,7 +125,11 @@ public:
 	void syncLocalsBlock(SegManager *segMan);
 	ObjMap &getObjectMap() { return _objects; }
 	const ObjMap &getObjectMap() const { return _objects; }
-	bool offsetIsObject(uint32 offset) const;
+
+	// speed optimization: inline due to frequent calling
+	bool offsetIsObject(uint32 offset) const {
+		return _buf->getUint16SEAt(offset + SCRIPT_OBJECT_MAGIC_OFFSET) == SCRIPT_OBJECT_MAGIC_NUMBER;
+	}
 
 public:
 	Script();


Commit: d9d087ac3fa532faf55c1c50f9edb0ec1686f536
    https://github.com/scummvm/scummvm/commit/d9d087ac3fa532faf55c1c50f9edb0ec1686f536
Author: Miro Kropacek (miro.kropacek at gmail.com)
Date: 2023-04-29T12:20:58+02:00

Commit Message:
SCI: Inline getSciVersion()

Changed paths:
  A engines/sci/version.h
    engines/sci/console.cpp
    engines/sci/engine/object.h
    engines/sci/resource/resource.cpp
    engines/sci/resource/resource.h
    engines/sci/sci.h
    engines/sci/util.cpp


diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index b804c1c8dbc..94dbad064f7 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -27,6 +27,7 @@
 #include "sci/debug.h"
 #include "sci/event.h"
 #include "sci/resource/resource.h"
+#include "sci/version.h"
 #include "sci/engine/state.h"
 #include "sci/engine/kernel.h"
 #include "sci/engine/selector.h"
diff --git a/engines/sci/engine/object.h b/engines/sci/engine/object.h
index 3e43bb20d0d..1416a689a49 100644
--- a/engines/sci/engine/object.h
+++ b/engines/sci/engine/object.h
@@ -26,9 +26,9 @@
 #include "common/serializer.h"
 #include "common/textconsole.h"
 
-#include "sci/sci.h"			// for the SCI versions
 #include "sci/engine/vm_types.h"	// for reg_t
 #include "sci/util.h"
+#include "sci/version.h"
 
 namespace Sci {
 
diff --git a/engines/sci/resource/resource.cpp b/engines/sci/resource/resource.cpp
index 2afcd6b2d41..521adb097c5 100644
--- a/engines/sci/resource/resource.cpp
+++ b/engines/sci/resource/resource.cpp
@@ -56,16 +56,11 @@ struct resource_index_t {
 
 //////////////////////////////////////////////////////////////////////
 
-static SciVersion s_sciVersion = SCI_VERSION_NONE;	// FIXME: Move this inside a suitable class, e.g. SciEngine
-
-SciVersion getSciVersion() {
-	assert(s_sciVersion != SCI_VERSION_NONE);
-	return s_sciVersion;
-}
+SciVersion g_sciVersion = SCI_VERSION_NONE;	// FIXME: Move this inside a suitable class, e.g. SciEngine
 
 SciVersion getSciVersionForDetection() {
 	assert(!g_sci);
-	return s_sciVersion;
+	return g_sciVersion;
 }
 
 const char *getSciVersionDesc(SciVersion version) {
@@ -2635,7 +2630,7 @@ bool ResourceManager::checkResourceForSignatures(ResourceType resourceType, uint
 void ResourceManager::detectSciVersion() {
 	// We use the view compression to set a preliminary s_sciVersion for the sake of getResourceInfo
 	// Pretend we have a SCI0 game
-	s_sciVersion = SCI_VERSION_0_EARLY;
+	g_sciVersion = SCI_VERSION_0_EARLY;
 	bool oldDecompressors = true;
 
 	ResourceCompression viewCompression;
@@ -2654,7 +2649,7 @@ void ResourceManager::detectSciVersion() {
 		// If it's a different compression type from kCompLZW, the game is probably
 		// SCI_VERSION_1_EGA_ONLY or later. If the views are uncompressed, it is
 		// likely not an early disk game.
-		s_sciVersion = SCI_VERSION_1_EGA_ONLY;
+		g_sciVersion = SCI_VERSION_1_EGA_ONLY;
 		oldDecompressors = false;
 	}
 
@@ -2693,15 +2688,15 @@ void ResourceManager::detectSciVersion() {
 		// versions of SCI3 PC games. That is, the Mac scripts are compiled as
 		// separate script and hunk resources instead of the SCI3 script format.
 		if (res) {
-			s_sciVersion = SCI_VERSION_2_1_EARLY; // we check for SCI2.1 specifics a bit later
+			g_sciVersion = SCI_VERSION_2_1_EARLY; // we check for SCI2.1 specifics a bit later
 		} else {
-			s_sciVersion = SCI_VERSION_1_1;
+			g_sciVersion = SCI_VERSION_1_1;
 			return;
 		}
 	}
 
 	// Handle SCI32 versions here
-	if (s_sciVersion != SCI_VERSION_2_1_EARLY) {
+	if (g_sciVersion != SCI_VERSION_2_1_EARLY) {
 		if (_volVersion >= kResVersionSci2) {
 			Common::List<ResourceId> heaps = listResources(kResourceTypeHeap);
 			bool hasHeapResources = !heaps.empty();
@@ -2710,18 +2705,18 @@ void ResourceManager::detectSciVersion() {
 			// SCI1 Late resource maps have the resource types or'd with
 			// 0x80. We differentiate between SCI2 and SCI2.1/3 based on that.
 			if (_mapVersion == kResVersionSci1Late) {
-				s_sciVersion = SCI_VERSION_2;
+				g_sciVersion = SCI_VERSION_2;
 				return;
 			} else if (hasHeapResources) {
-				s_sciVersion = SCI_VERSION_2_1_EARLY; // exact SCI2.1 version is checked a bit later
+				g_sciVersion = SCI_VERSION_2_1_EARLY; // exact SCI2.1 version is checked a bit later
 			} else {
-				s_sciVersion = SCI_VERSION_3;
+				g_sciVersion = SCI_VERSION_3;
 				return;
 			}
 		}
 	}
 
-	if (s_sciVersion == SCI_VERSION_2_1_EARLY) {
+	if (g_sciVersion == SCI_VERSION_2_1_EARLY) {
 		// we only know that it's SCI2.1, not which exact version it is
 
 		// check, if selector "wordFail" inside vocab 997 exists, if it does it's SCI2.1 Early
@@ -2730,11 +2725,11 @@ void ResourceManager::detectSciVersion() {
 			return;
 		}
 
-		s_sciVersion = SCI_VERSION_2_1_MIDDLE;
+		g_sciVersion = SCI_VERSION_2_1_MIDDLE;
 		if (checkResourceForSignatures(kResourceTypeScript, 64918, detectSci21NewStringSignature, nullptr)) {
 			// new kString call detected, it's SCI2.1 late
 			// TODO: this call seems to be different on Mac
-			s_sciVersion = SCI_VERSION_2_1_LATE;
+			g_sciVersion = SCI_VERSION_2_1_LATE;
 			return;
 		}
 		return;
@@ -2744,7 +2739,7 @@ void ResourceManager::detectSciVersion() {
 	// If the game has any heap file (here we check for heap file 0), then
 	// it definitely uses a SCI1.1 kernel
 	if (testResource(ResourceId(kResourceTypeHeap, 0))) {
-		s_sciVersion = SCI_VERSION_1_1;
+		g_sciVersion = SCI_VERSION_1_1;
 		return;
 	}
 
@@ -2752,18 +2747,18 @@ void ResourceManager::detectSciVersion() {
 	case kResVersionSci0Sci1Early:
 		if (_viewType == kViewVga) {
 			// VGA
-			s_sciVersion = SCI_VERSION_1_EARLY;
+			g_sciVersion = SCI_VERSION_1_EARLY;
 			return;
 		}
 
 		// EGA
 		if (hasOldScriptHeader()) {
-			s_sciVersion = SCI_VERSION_0_EARLY;
+			g_sciVersion = SCI_VERSION_0_EARLY;
 			return;
 		}
 
 		if (hasSci0Voc999()) {
-			s_sciVersion = SCI_VERSION_0_LATE;
+			g_sciVersion = SCI_VERSION_0_LATE;
 			return;
 		}
 
@@ -2772,17 +2767,17 @@ void ResourceManager::detectSciVersion() {
 
 			// We first check for SCI1 vocab.999
 			if (testResource(ResourceId(kResourceTypeVocab, 999))) {
-				s_sciVersion = SCI_VERSION_01;
+				g_sciVersion = SCI_VERSION_01;
 				return;
 			}
 
 			// If vocab.999 is missing, we try vocab.900
 			if (testResource(ResourceId(kResourceTypeVocab, 900))) {
 				if (hasSci1Voc900()) {
-					s_sciVersion = SCI_VERSION_01;
+					g_sciVersion = SCI_VERSION_01;
 					return;
 				} else {
-					s_sciVersion = SCI_VERSION_0_LATE;
+					g_sciVersion = SCI_VERSION_0_LATE;
 					return;
 				}
 			}
@@ -2792,35 +2787,35 @@ void ResourceManager::detectSciVersion() {
 
 		// New decompressors. It's either SCI_VERSION_1_EGA_ONLY or SCI_VERSION_1_EARLY.
 		if (hasSci1Voc900()) {
-			s_sciVersion = SCI_VERSION_1_EGA_ONLY;
+			g_sciVersion = SCI_VERSION_1_EGA_ONLY;
 			return;
 		}
 
 		// SCI_VERSION_1_EARLY EGA versions lack the parser vocab
-		s_sciVersion = SCI_VERSION_1_EARLY;
+		g_sciVersion = SCI_VERSION_1_EARLY;
 		return;
 	case kResVersionSci1Middle:
 	case kResVersionKQ5FMT:
-		s_sciVersion = SCI_VERSION_1_MIDDLE;
+		g_sciVersion = SCI_VERSION_1_MIDDLE;
 		// Amiga SCI1 middle games are actually SCI1 late
 		if (_viewType == kViewAmiga || _viewType == kViewAmiga64)
-			s_sciVersion = SCI_VERSION_1_LATE;
+			g_sciVersion = SCI_VERSION_1_LATE;
 		// Same goes for Mac SCI1 middle games
 		if (g_sci && g_sci->getPlatform() == Common::kPlatformMacintosh)
-			s_sciVersion = SCI_VERSION_1_LATE;
+			g_sciVersion = SCI_VERSION_1_LATE;
 		return;
 	case kResVersionSci1Late:
 		if (_volVersion == kResVersionSci11) {
-			s_sciVersion = SCI_VERSION_1_1;
+			g_sciVersion = SCI_VERSION_1_1;
 			return;
 		}
-		s_sciVersion = SCI_VERSION_1_LATE;
+		g_sciVersion = SCI_VERSION_1_LATE;
 		return;
 	case kResVersionSci11:
-		s_sciVersion = SCI_VERSION_1_1;
+		g_sciVersion = SCI_VERSION_1_1;
 		return;
 	default:
-		s_sciVersion = SCI_VERSION_NONE;
+		g_sciVersion = SCI_VERSION_NONE;
 		error("detectSciVersion(): Unable to detect the game's SCI version");
 	}
 }
diff --git a/engines/sci/resource/resource.h b/engines/sci/resource/resource.h
index 5187cbd637f..855fe8bec42 100644
--- a/engines/sci/resource/resource.h
+++ b/engines/sci/resource/resource.h
@@ -30,6 +30,7 @@
 #include "sci/resource/decompressor.h"
 #include "sci/sci.h"
 #include "sci/util.h"
+#include "sci/version.h"
 
 namespace Common {
 class File;
@@ -142,6 +143,17 @@ enum ResVersion {
 	kResVersionSci3
 };
 
+/**
+ * Same as Sci::getSciVersion, but this version doesn't assert on unknown SCI
+ * versions. Only used by the fallback detector.
+ */
+SciVersion getSciVersionForDetection();
+
+/**
+ * Convenience function converting an SCI version into a human-readable string.
+ */
+const char *getSciVersionDesc(SciVersion version);
+
 class ResourceManager;
 class ResourceSource;
 class ResourcePatcher;
diff --git a/engines/sci/sci.h b/engines/sci/sci.h
index 08103db4a1c..c3155e0261d 100644
--- a/engines/sci/sci.h
+++ b/engines/sci/sci.h
@@ -398,22 +398,6 @@ private:
  */
 extern SciEngine *g_sci;
 
-/**
- * Convenience function to obtain the active SCI version.
- */
-SciVersion getSciVersion();
-
-/**
- * Same as above, but this version doesn't assert on unknown SCI versions.
- * Only used by the fallback detector
- */
-SciVersion getSciVersionForDetection();
-
-/**
- * Convenience function converting an SCI version into a human-readable string.
- */
-const char *getSciVersionDesc(SciVersion version);
-
 } // End of namespace Sci
 
 #endif // SCI_SCI_H
diff --git a/engines/sci/util.cpp b/engines/sci/util.cpp
index 3163494ffb3..d59fc679bab 100644
--- a/engines/sci/util.cpp
+++ b/engines/sci/util.cpp
@@ -21,6 +21,7 @@
 
 #include "sci/util.h"
 #include "sci/sci.h"
+#include "sci/version.h"
 
 namespace Sci {
 
diff --git a/engines/sci/version.h b/engines/sci/version.h
new file mode 100644
index 00000000000..5e14c8c74b8
--- /dev/null
+++ b/engines/sci/version.h
@@ -0,0 +1,43 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef SCI_VERSION_H
+#define SCI_VERSION_H
+
+#include "sci/detection.h"
+
+namespace Sci {
+
+/**
+ * Convenience function to obtain the active SCI version. Inline
+ * due to frequent calling.
+ */
+static inline SciVersion getSciVersion() {
+	// FIXME: declared in sci/resource/resource.cpp
+	extern SciVersion g_sciVersion;
+
+	assert(g_sciVersion != SCI_VERSION_NONE);
+	return g_sciVersion;
+}
+
+} // End of namespace Sci
+
+#endif // SCI_VERSION_H


Commit: 864bc308add9598ded2d072068bb5354f137bcb1
    https://github.com/scummvm/scummvm/commit/864bc308add9598ded2d072068bb5354f137bcb1
Author: Miro Kropacek (miro.kropacek at gmail.com)
Date: 2023-04-29T12:20:58+02:00

Commit Message:
SCI: Inline reg_t::getOffset() & reg_t::setOffset()

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


diff --git a/engines/sci/engine/vm_types.cpp b/engines/sci/engine/vm_types.cpp
index 517778b781b..52c628915b6 100644
--- a/engines/sci/engine/vm_types.cpp
+++ b/engines/sci/engine/vm_types.cpp
@@ -45,25 +45,6 @@ void reg_t::setSegment(SegmentId segment) {
 	}
 }
 
-uint32 reg_t::getOffset() const {
-	if (getSciVersion() < SCI_VERSION_3) {
-		return _offset;
-	} else {
-		// Return the lower 16 bits from the offset, and the 17th and 18th bits from the segment
-		return ((_segment & 0xC000) << 2) | _offset;
-	}
-}
-
-void reg_t::setOffset(uint32 offset) {
-	if (getSciVersion() < SCI_VERSION_3) {
-		_offset = offset;
-	} else {
-		// Store the lower 16 bits in the offset, and the 17th and 18th bits in the segment
-		_offset = offset & 0xFFFF;
-		_segment = ((offset & 0x30000) >> 2) | (_segment & 0x3FFF);
-	}
-}
-
 reg_t reg_t::lookForWorkaround(const reg_t right, const char *operation) const {
 	SciCallOrigin originReply;
 	SciWorkaroundSolution solution = trackOriginAndFindWorkaround(0, arithmeticWorkarounds, &originReply);
diff --git a/engines/sci/engine/vm_types.h b/engines/sci/engine/vm_types.h
index ebf3714cd8b..6c222f77dc1 100644
--- a/engines/sci/engine/vm_types.h
+++ b/engines/sci/engine/vm_types.h
@@ -23,6 +23,7 @@
 #define SCI_ENGINE_VM_TYPES_H
 
 #include "common/scummsys.h"
+#include "sci/version.h"
 
 namespace Sci {
 
@@ -42,8 +43,27 @@ struct reg_t {
 
 	SegmentId getSegment() const;
 	void setSegment(SegmentId segment);
-	uint32 getOffset() const;
-	void setOffset(uint32 offset);
+
+	// speed optimization: inline due to frequent calling
+	uint32 getOffset() const {
+		if (getSciVersion() < SCI_VERSION_3) {
+			return _offset;
+		} else {
+			// Return the lower 16 bits from the offset, and the 17th and 18th bits from the segment
+			return ((_segment & 0xC000) << 2) | _offset;
+		}
+	}
+
+	// speed optimization: inline due to frequent calling
+	void setOffset(uint32 offset) {
+		if (getSciVersion() < SCI_VERSION_3) {
+			_offset = offset;
+		} else {
+			// Store the lower 16 bits in the offset, and the 17th and 18th bits in the segment
+			_offset = offset & 0xFFFF;
+			_segment = ((offset & 0x30000) >> 2) | (_segment & 0x3FFF);
+		}
+	}
 
 	inline void incOffset(int32 offset) {
 		setOffset(getOffset() + offset);




More information about the Scummvm-git-logs mailing list