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

bluegr noreply at scummvm.org
Sat Mar 21 22:24:05 UTC 2026


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:
52c33a47c5 TINSEL: Fix DW1 PSX palette mapping
a663f323f3 TINSEL: Fix DW1 PSX/Saturn image clipping


Commit: 52c33a47c57187ddb129ff9e381ce8198ef415ff
    https://github.com/scummvm/scummvm/commit/52c33a47c57187ddb129ff9e381ce8198ef415ff
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2026-03-22T00:23:59+02:00

Commit Message:
TINSEL: Fix DW1 PSX palette mapping

Fixes certain colors, usually black, not being drawn in certain images
that were encoded as 4 bits per pixel with a RGB555 CLUT.

Fixes bug #6395

Changed paths:
    engines/tinsel/graphics.cpp
    engines/tinsel/palette.cpp


diff --git a/engines/tinsel/graphics.cpp b/engines/tinsel/graphics.cpp
index c3858033bb2..9dd8737e7c0 100644
--- a/engines/tinsel/graphics.cpp
+++ b/engines/tinsel/graphics.cpp
@@ -380,9 +380,10 @@ static void psxSaturnDrawTiles(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP, bool
 				} else {
 					for (int xp = boxBounds.left; xp <= boxBounds.right; ++xp) {
 						// Extract pixel value from byte
-						byte pixValue =  (*(p + (xp / 2)) & ((xp % 2) ? 0xf0 : 0x0f)) >> ((xp % 2) ? 4 : 0);
-						if (pixValue || !transparency)
-							*(tempDest + SCREEN_WIDTH * (yp - boxBounds.top) + (xp - boxBounds.left)) = psxMapperTable[pixValue];
+						byte psxIndexValue =  (*(p + (xp / 2)) & ((xp % 2) ? 0xf0 : 0x0f)) >> ((xp % 2) ? 4 : 0);
+						byte pixelValue = psxMapperTable[psxIndexValue];
+						if (pixelValue || !transparency)
+							*(tempDest + SCREEN_WIDTH * (yp - boxBounds.top) + (xp - boxBounds.left)) = pixelValue;
 					}
 				}
 			}
diff --git a/engines/tinsel/palette.cpp b/engines/tinsel/palette.cpp
index fc3e98ec20a..453cc353a05 100644
--- a/engines/tinsel/palette.cpp
+++ b/engines/tinsel/palette.cpp
@@ -99,42 +99,63 @@ void ResetVarsPalette() {
 }
 
 /**
- * Map PSX palettes to original palette from resource file
+ * Map PSX palettes to original palette from resource file.
+ * PSX CLUTs contain 16 colors as 16-bit LE entries in RGB555 format.
+ * A color value of zero indicates transparency.
  */
 void psxPaletteMapper(PALQ *originalPal, uint8 *psxClut, byte *mapperTable) {
 	PALETTE *pal = _vm->_handle->GetPalette(originalPal->hPal);
-	bool colorFound = false;
-	uint16 clutEntry = 0;
 
-	// Empty the table with color correspondences
+	// Initialize the table to empty (transparent) entries
 	memset(mapperTable, 0, 16);
 
-	for (int j = 1; j < 16; j++) {
-		clutEntry = READ_16(psxClut + (sizeof(uint16) * j));
-		if (clutEntry) {
-			if (clutEntry == 0x7EC0) { // This is an already known value, used by the in-game text
-				mapperTable[j] = 232;
+	for (int j = 0; j < 16; j++) {
+		uint16 clutEntry = READ_16(psxClut + (sizeof(uint16) * j));
+		if (clutEntry == 0) {
+			// RGB555(0,0,0) indicates transparency.
+			// optimization: assume all subsequent entries
+			// are also zero, unless this is the first entry.
+			if (j == 0) {
 				continue;
+			} else {
+				break;
 			}
+		}
+
+		if (clutEntry == 0x7EC0) { // This is an already known value, used by the in-game text
+			mapperTable[j] = 232;
+			continue;
+		}
 
-			// Check for correspondent color
-			for (int32 i = 0; (i < pal->numColors) && !colorFound; i++) {
-				// get R G B values in the same way as psx format converters
-				uint16 psxEquivalent = TINSEL_PSX_RGB(
-					pal->palette[i * 3] >> 3,
-					pal->palette[i * 3 + 1] >> 3,
-					pal->palette[i * 3 + 2] >> 3
-				);
-
-				if (psxEquivalent == clutEntry) {
-					mapperTable[j] = i + 1; // Add entry in the table for the found color
-					colorFound = true;
+		// Check for the matching RGB888 color in the original palette resource.
+		// We use the first color whose upper 5 bits of each component match.
+		// If no color matches, assume black. An RGB555 color value of zero
+		// represents transparency, but this makes it impossible to represent black.
+		// Instead, the developers used almost-black colors such as RGB555(0,0,1),
+		// but that workaround means we won't always find a matching original color.
+		for (int32 i = 0; (i < pal->numColors); i++) {
+			// get R G B values in the same way as psx format converters
+			uint16 psxEquivalent = TINSEL_PSX_RGB(
+				pal->palette[i * 3 + 0] >> 3,
+				pal->palette[i * 3 + 1] >> 3,
+				pal->palette[i * 3 + 2] >> 3
+			);
+
+			if (psxEquivalent == clutEntry) {
+				mapperTable[j] = i + 1; // Add entry in the table for the found color
+				break;
+			}
+		}
+		// If no color was found then use black
+		if (!mapperTable[j]) {
+			for (int32 i = 0; (i < pal->numColors); i++) {
+				if (pal->palette[i * 3 + 0] == 0 &&
+					pal->palette[i * 3 + 1] == 0 &&
+					pal->palette[i * 3 + 2] == 0) {
+					mapperTable[j] = i + 1;
+					break;
 				}
 			}
-			colorFound = false;
-		} else { // The rest of the entries are zeroes
-			delete pal;
-			return;
 		}
 	}
 


Commit: a663f323f33723b4e20e51e726bf08324d570298
    https://github.com/scummvm/scummvm/commit/a663f323f33723b4e20e51e726bf08324d570298
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2026-03-22T00:23:59+02:00

Commit Message:
TINSEL: Fix DW1 PSX/Saturn image clipping

Fixes drawing rows beyond the image height. The Act 3 city guard
odds-calculation dialog was drawing an extra yellow line underneath
the book button. This behavior was exposed by fixing the PSX palette
mapping bug in the previous commit.

This behavior is also in the DW1 DOS renderer, but I will wait until
after the upcoming to release to change it, as it is not worth risking
a regression. Overdrawing probably has no visible effect in DOS, or it
would have been noticed by now. Presumably all the extra pixels in the
DOS 4x4 image tiles are zero (transparent).

Changed paths:
    engines/tinsel/graphics.cpp


diff --git a/engines/tinsel/graphics.cpp b/engines/tinsel/graphics.cpp
index 9dd8737e7c0..4991106979d 100644
--- a/engines/tinsel/graphics.cpp
+++ b/engines/tinsel/graphics.cpp
@@ -325,7 +325,7 @@ static void psxSaturnDrawTiles(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP, bool
 		if (!applyClipping) {
 			// No clipping, so so set box bounding area for drawing full 4x4 pixel blocks
 			boxBounds.top = 0;
-			boxBounds.bottom = 3;
+			boxBounds.bottom = MIN(pObj->height - 1, 3);
 			boxBounds.left = 0;
 		} else {
 			// Handle any possible clipping at the top of the char block.




More information about the Scummvm-git-logs mailing list