[Scummvm-git-logs] scummvm master -> 37425b269d128659e8508d39ffd57308226a3372

AndywinXp noreply at scummvm.org
Thu Oct 23 13:02:57 UTC 2025


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

Summary:
aee471199b SCUMM: Activate debug mode only when gdebugLevel > 0
37425b269d SCUMM: HE: Fix #13864


Commit: aee471199bf6c12cbd17df7a91e8422bf7d190fd
    https://github.com/scummvm/scummvm/commit/aee471199bf6c12cbd17df7a91e8422bf7d190fd
Author: AndywinXp (andywinxp at gmail.com)
Date: 2025-10-23T15:00:48+02:00

Commit Message:
SCUMM: Activate debug mode only when gdebugLevel > 0

I'm sick of having games malfunctioning in their own debug mode
just because I want basic debug messages! :P

Changed paths:
    engines/scumm/scumm.cpp


diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index eac13db791e..42adf014649 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -260,7 +260,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
 	g_scumm = this;
 
 	// Read settings from the detector & config manager
-	_debugMode = (gDebugLevel >= 0);
+	_debugMode = (gDebugLevel > 0);
 	_dumpScripts = ConfMan.getBool("dump_scripts");
 	_bootParam = ConfMan.getInt("boot_param");
 	// Boot params often need debugging switched on to work


Commit: 37425b269d128659e8508d39ffd57308226a3372
    https://github.com/scummvm/scummvm/commit/37425b269d128659e8508d39ffd57308226a3372
Author: AndywinXp (andywinxp at gmail.com)
Date: 2025-10-23T15:00:48+02:00

Commit Message:
SCUMM: HE: Fix #13864

This fixes #13864:
"SCUMM/HE: Blue's Treasure Hunt - Missing Backgrounds during some animations"

Changed paths:
    engines/scumm/he/gfx_primitives_he.cpp
    engines/scumm/he/palette_he.cpp
    engines/scumm/he/wiz_he.h
    engines/scumm/resource.cpp


diff --git a/engines/scumm/he/gfx_primitives_he.cpp b/engines/scumm/he/gfx_primitives_he.cpp
index a9087e7312c..d66d8a76967 100644
--- a/engines/scumm/he/gfx_primitives_he.cpp
+++ b/engines/scumm/he/gfx_primitives_he.cpp
@@ -954,40 +954,42 @@ void Wiz::pgTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRec
 
 	// Left or right?
 	if (sourceRect->left <= sourceRect->right) {
-		soff = sw - cw;
-		doff = dw - cw;
-
-		while (--ch >= 0) {
-			if (!_uses16BitColor) {
-				for (int x = cw; --x >= 0;) {
-					value = *s8++;
+		if (!_uses16BitColor && _vm->_game.heversion >= 98 && ((sw >= 0) && ((cw % 4) == 0))) {
+			pgArbitraryTransparentBlitPrim(d8, dw, s8, sw, cw, ch, transparentColor);
+		} else {
+			soff = sw - cw;
+			doff = dw - cw;
 
-					if (value != tColor) {
-						*d8++ = (WizRawPixel8)value;
-					} else {
-						d8++;
+			while (--ch >= 0) {
+				if (!_uses16BitColor) {
+					for (int x = cw; --x >= 0;) {
+						value = *s8++;
+
+						if (value != tColor) {
+							*d8++ = (WizRawPixel8)value;
+						} else {
+							d8++;
+						}
 					}
-				}
-
-				s8 += soff;
-				d8 += doff;
-			} else {
-				for (int x = cw; --x >= 0;) {
-					value = FROM_LE_16(*s16++);
 
-					if (value != tColor) {
-						*d16++ = (WizRawPixel16)value;
-					} else {
-						d16++;
+					s8 += soff;
+					d8 += doff;
+				} else {
+					for (int x = cw; --x >= 0;) {
+						value = FROM_LE_16(*s16++);
+
+						if (value != tColor) {
+							*d16++ = (WizRawPixel16)value;
+						} else {
+							d16++;
+						}
 					}
-				}
 
-				s16 += soff;
-				d16 += doff;
+					s16 += soff;
+					d16 += doff;
+				}
 			}
-
 		}
-
 	} else {
 		soff = sw + cw;
 		doff = dw - cw;
@@ -1024,6 +1026,91 @@ void Wiz::pgTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRec
 	}
 }
 
+void Wiz::pgArbitraryTransparentBlitPrim(WizRawPixel8 *dstPtr, int dstStride, WizRawPixel8 *srcPtr, int srcStride, int copyWidth, int copyHeight, int transparentColor) {
+	// Originally from ASM code...
+
+	// Fix the stride for this copy amount...
+	dstStride -= copyWidth;
+	srcStride -= copyWidth;
+
+	// Check to see if there is an odd amount...
+	if ((copyWidth & 3) == 0) {
+		// Width count / 4
+		int groupsOf4 = copyWidth >> 2;
+		if (groupsOf4 == 0)
+			return; // No actual data to transfer...
+
+		for (int y = 0; y < copyHeight; y++) {
+			// Cross off a group of 4 pixels...
+			for (int x = 0; x < groupsOf4; x++) {
+				WizRawPixel8 p0 = srcPtr[0];
+				if (p0 != transparentColor)
+					dstPtr[0] = p0;
+
+				WizRawPixel8 p1 = srcPtr[1];
+				if (p1 != transparentColor)
+					dstPtr[1] = p1;
+
+				WizRawPixel8 p2 = srcPtr[2];
+				if (p2 != transparentColor)
+					dstPtr[2] = p2;
+
+				WizRawPixel8 p3 = srcPtr[3];
+				if (p3 != transparentColor)
+					dstPtr[3] = p3;
+
+				dstPtr += 4;
+				srcPtr += 4;
+			}
+
+			dstPtr += dstStride;
+			srcPtr += srcStride;
+		}
+	} else {
+		// Adjust the counter for the odd copy amount...
+		int oddPixels = copyWidth & 3;
+		int groupsOf4 = copyWidth >> 2;
+
+		if (groupsOf4 == 0)
+			return; // No actual data to transfer...
+
+		for (int y = 0; y < copyHeight; y++) {
+			// Cross off a group of 4 pixels...
+			for (int x = 0; x < groupsOf4; x++) {
+				WizRawPixel8 p0 = srcPtr[0];
+				if (p0 != transparentColor)
+					dstPtr[0] = p0;
+
+				WizRawPixel8 p1 = srcPtr[1];
+				if (p1 != transparentColor)
+					dstPtr[1] = p1;
+
+				WizRawPixel8 p2 = srcPtr[2];
+				if (p2 != transparentColor)
+					dstPtr[2] = p2;
+
+				WizRawPixel8 p3 = srcPtr[3];
+				if (p3 != transparentColor)
+					dstPtr[3] = p3;
+
+				dstPtr += 4;
+				srcPtr += 4;
+			}
+
+			// Get leftover count...
+			for (int x = 0; x < oddPixels; x++) {
+				WizRawPixel8 p = *srcPtr++;
+				if (p != transparentColor)
+					*dstPtr = p;
+				dstPtr++;
+			}
+
+			dstPtr += dstStride;
+			srcPtr += srcStride;
+		}
+	}
+}
+
 void Wiz::pgDrawWarpDrawLetter(WizRawPixel *bitmapBuffer, int bitmapWidth, int bitmapHeight, const byte *charData, int x1, int y1, int width, int height, byte *colorLookupTable) {
 	WizRawPixel *remapTable = (_vm->_game.heversion <= 90) ? nullptr : (WizRawPixel *)_vm->getHEPaletteSlot(1);
 
diff --git a/engines/scumm/he/palette_he.cpp b/engines/scumm/he/palette_he.cpp
index 5cf7f592019..5ca49e6fae0 100644
--- a/engines/scumm/he/palette_he.cpp
+++ b/engines/scumm/he/palette_he.cpp
@@ -261,7 +261,7 @@ void ScummEngine_v99he::setPaletteFromPtr(const byte *ptr, int numcolor) {
 		g = *ptr++;
 		b = *ptr++;
 
-		if (i == 15 || r < 252 || g < 252 || b < 252) {
+		if (i == 15 || !(i > 10 && i < 246) || r < 252 || g < 252 || b < 252) {
 			*dest++ = r;
 			*dest++ = g;
 			*dest++ = b;
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index cf40b1ac6ad..9efa8b9bf44 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -847,6 +847,7 @@ public:
 	void pgSimpleBlitMixColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, const byte *mixColorTable);
 	void pgSimpleBlitTransparentMixColors(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, WizRawPixel transparentColor, const byte *mixColorTable);
 	void pgTransparentSimpleBlit(WizSimpleBitmap *destBM, Common::Rect *destRect, WizSimpleBitmap *sourceBM, Common::Rect *sourceRect, WizRawPixel transparentColor);
+	void pgArbitraryTransparentBlitPrim(WizRawPixel8 *dstPtr, int dstStride, WizRawPixel8 *srcPtr, int srcStride, int copyWidth, int copyHeight, int transparentColor);
 
 	void pgDrawWarpDrawLetter(WizRawPixel *bitmapBuffer, int bitmapWidth, int bitmapHeight, const byte *charData, int x1, int y1, int width, int height, byte *colorLookupTable);
 	void pgDraw8BppFormatImage(WizRawPixel *bufferPtr, const byte *rawData, int bufferWidth, int bufferHeight, int x, int y, int width, int height, Common::Rect *clipRectPtr, int32 wizFlags, const byte *extraTable, int transparentColor, const WizRawPixel *conversionTable);
diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp
index e0a72312985..72d6980b8cf 100644
--- a/engines/scumm/resource.cpp
+++ b/engines/scumm/resource.cpp
@@ -858,16 +858,36 @@ byte *ResourceManager::createResource(ResType type, ResId idx, uint32 size) {
 		// cases. For instance, Zak tries to reload the intro music
 		// while it's playing. See bug #2115.
 
-		if (_types[type][idx]._address && (type == rtSound || type == rtScript || type == rtCostume))
+		if (_types[type][idx]._address && (type == rtSound || type == rtScript || type == rtCostume)) {
+			_vm->_insideCreateResource--;
 			return _types[type][idx]._address;
+		}
 	}
 
-	nukeResource(type, idx);
+	// HE70+ reuses the resource without deallocating it if it has the same size.
+	// 
+	// Not replicating this behavior this can creare very rare gfx corruption issues, e.g.
+	// #13864 ("SCUMM/HE: Blue's Treasure Hunt - Missing Backgrounds during some animations"),
+	// in which a WIZ transparent (color 5) image is prepared for it to serve as a canvas for
+	// some Smacker videos, only for the former to be nuked and replaced with an all 0 (black)
+	// empty image.
+	// 
+	// This is just one of the many differences of our system versus the HE resource allocation system...
+	// The whole thing should probably be rewritten at some point to match the source code. ;-)
+	if (_vm->_game.heversion >= 70 && _types[type][idx]._address && _types[type][idx]._size == size) {
+		increaseResourceCounters();
+		setResourceCounter(type, idx, 1);
+		_vm->_insideCreateResource--;
+		return _types[type][idx]._address;
+	} else {
+		nukeResource(type, idx);
+	}
 
 	expireResources(size);
 
 	byte *ptr = new byte[size + SAFETY_AREA]();
 	if (ptr == nullptr) {
+		_vm->_insideCreateResource--;
 		error("createResource(%s,%d): Out of memory while allocating %d", nameOfResType(type), idx, size);
 	}
 




More information about the Scummvm-git-logs mailing list