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

csnover csnover at users.noreply.github.com
Fri Jul 14 05:36:16 CEST 2017


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:
3e45309b83 SCI32: Add workaround for Phant1
8047f3fa77 SCI32: Stop optimising palette merges
7543bd444d SCI32: Move priority comparison of ScreenItems into its own function
bbad7ada1b SCI32: Ignore chest view palette in Phantasmagoria
b1b18c54f3 SCI32: Patch out bad rat view init code in Phantasmagoria


Commit: 3e45309b8343fb7c9056c39650905d8464a276db
    https://github.com/scummvm/scummvm/commit/3e45309b8343fb7c9056c39650905d8464a276db
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-07-13T17:19:50-05:00

Commit Message:
SCI32: Add workaround for Phant1

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


diff --git a/engines/sci/engine/workarounds.cpp b/engines/sci/engine/workarounds.cpp
index ac02769..a43df75 100644
--- a/engines/sci/engine/workarounds.cpp
+++ b/engines/sci/engine/workarounds.cpp
@@ -359,6 +359,7 @@ const SciWorkaroundEntry uninitializedReadWorkarounds[] = {
 	{ GID_MOTHERGOOSEHIRES,-1,64950, -1,               "View", "handleEvent",                     NULL,     0, { WORKAROUND_FAKE,   0 } }, // see above
 	{ GID_PEPPER,         -1,   894,  0,            "Package", "doVerb",                          NULL,     3, { WORKAROUND_FAKE,   0 } }, // using the hand on the book in the inventory - bug #5154
 	{ GID_PEPPER,        150,   928,  0,           "Narrator", "startText",                       NULL,     0, { WORKAROUND_FAKE,   0 } }, // happens during the non-interactive demo of Pepper
+	{ GID_PHANTASMAGORIA, -1, 64921, -1,              "Print", "addEdit",                         NULL,     1, { WORKAROUND_FAKE,   0 } }, // When trying to use the game debugger's flag setting command
 	{ GID_PQ4,            -1,    25,  0,         "iconToggle", "select",                          NULL,     1, { WORKAROUND_FAKE,   0 } }, // when toggling the icon bar to auto-hide or not
 	{ GID_PQ4,           170,   170, -1,        "hideAndSeek", "handleEvent",                     NULL,     1, { WORKAROUND_FAKE,   0 } }, // when clicking to move right while still moving left during the Emo shootout - bug #9847
 	{ GID_PQ4,           275, 64964, -1,              "DPath", "init",                            NULL,     1, { WORKAROUND_FAKE,   0 } }, // when Sherry walks out of the morgue on day 3


Commit: 8047f3fa77c6fa2f6bb417366d4c9cbed29b82eb
    https://github.com/scummvm/scummvm/commit/8047f3fa77c6fa2f6bb417366d4c9cbed29b82eb
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-07-13T17:19:50-05:00

Commit Message:
SCI32: Stop optimising palette merges

While this optimisation helped to reduce unnecessary palette
updates in KQ7, it broke Phant1, which relies on changes to index
255 in the source palette causing palette invalidation.

Refs Trac#9788.

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


diff --git a/engines/sci/graphics/palette32.cpp b/engines/sci/graphics/palette32.cpp
index d7f6710..fded8f0 100644
--- a/engines/sci/graphics/palette32.cpp
+++ b/engines/sci/graphics/palette32.cpp
@@ -566,11 +566,12 @@ Palette GfxPalette32::getPaletteFromResource(const GuiResourceId resourceId) con
 }
 
 void GfxPalette32::mergePalette(Palette &to, const Palette &from) {
-	// The last color is always white in SCI, so it is not copied. (Some
-	// palettes, particularly in KQ7, try to set the last color, which causes
-	// unnecessary palette updates since the last color is forced by SSCI to a
-	// specific value)
-	for (int i = 0; i < ARRAYSIZE(to.colors) - 1; ++i) {
+	// All colors MUST be copied, even index 255, despite the fact that games
+	// cannot actually change index 255 (it is forced to white when generating
+	// the hardware palette in updateHardware). While this causes some
+	// additional unnecessary source palette invalidations, not doing it breaks
+	// some badly programmed rooms, like room 6400 in Phant1 (see Trac#9788)
+	for (int i = 0; i < ARRAYSIZE(to.colors); ++i) {
 		if (from.colors[i].used) {
 			to.colors[i] = from.colors[i];
 		}


Commit: 7543bd444d46b2a8d4a2c79967c0a8d45a0874d1
    https://github.com/scummvm/scummvm/commit/7543bd444d46b2a8d4a2c79967c0a8d45a0874d1
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-07-13T21:31:07-05:00

Commit Message:
SCI32: Move priority comparison of ScreenItems into its own function

Rendering bugs in ScummVM are often caused by buggy game scripts
relying on the last ditch sort, which is not the same in ScummVM
as in SSCI (since the SSCI last ditch sort relies on a different
memory architecture and is super buggy). However, these bugs do
not show up very frequently these days, so it is easy to forget
all the places that need to be checked when debugging a rendering
problem that appears to be caused by sorting failure.

This commit breaks out the last ditch comparison formerly in
Plane::calcLists to hopefully make it more visible to future
programmers.

Refs Trac#9957.

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


diff --git a/engines/sci/graphics/plane32.cpp b/engines/sci/graphics/plane32.cpp
index 47d41bc..50a3465 100644
--- a/engines/sci/graphics/plane32.cpp
+++ b/engines/sci/graphics/plane32.cpp
@@ -518,8 +518,7 @@ void Plane::calcLists(Plane &visiblePlane, const PlaneList &planeList, DrawList
 				) {
 					const ScreenItem *drawnItem = drawListEntry->screenItem;
 
-					if (
-						(newItem->_priority > drawnItem->_priority || (newItem->_priority == drawnItem->_priority && newItem->_creationId > drawnItem->_creationId)) &&
+					if (newItem->hasPriorityAbove(*drawnItem) &&
 						drawListEntry->rect.intersects(newItem->_screenRect)
 					) {
 						mergeToDrawList(j, drawListEntry->rect.findIntersectingRect(newItem->_screenRect), drawList);
diff --git a/engines/sci/graphics/screen_item32.h b/engines/sci/graphics/screen_item32.h
index c2c4e43..ef29609 100644
--- a/engines/sci/graphics/screen_item32.h
+++ b/engines/sci/graphics/screen_item32.h
@@ -275,6 +275,8 @@ public:
 				// these insertion IDs instead. They are more stable and cause
 				// objects with identical priority and z-index to be rendered in
 				// the order that they were created.
+				//
+				// This also applies to ScreenItem::hasPriorityAbove.
 				return _creationId < other._creationId;
 			}
 		}
@@ -302,6 +304,20 @@ public:
 		return false;
 	}
 
+	inline bool hasPriorityAbove(const ScreenItem &other) const {
+		if (_priority > other._priority) {
+			return true;
+		}
+
+		if (_priority == other._priority) {
+			// This is different than SSCI; see ScreenItem::operator< for an
+			// explanation
+			return _creationId > other._creationId;
+		}
+
+		return false;
+	}
+
 	/**
 	 * Calculates the dimensions and scaling parameters for
 	 * the screen item, using the given plane as the parent


Commit: bbad7ada1b88c18f89590119bccc0ae1bd70b04b
    https://github.com/scummvm/scummvm/commit/bbad7ada1b88c18f89590119bccc0ae1bd70b04b
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-07-13T21:31:21-05:00

Commit Message:
SCI32: Ignore chest view palette in Phantasmagoria

This fixes the 3-frame glitch that was also present in the
original game when moving in the chapel from room 6500 to 6400 in
chapter 7.

Fixes Trac#9788.

Changed paths:
    engines/sci/graphics/celobj32.cpp
    engines/sci/graphics/palette32.cpp


diff --git a/engines/sci/graphics/celobj32.cpp b/engines/sci/graphics/celobj32.cpp
index df55ec9..49b3b00 100644
--- a/engines/sci/graphics/celobj32.cpp
+++ b/engines/sci/graphics/celobj32.cpp
@@ -982,7 +982,19 @@ CelObjView::CelObjView(const GuiResourceId viewId, const int16 loopNo, const int
 		error("Cel is less than 0 on loop 0");
 	}
 
-	_hunkPaletteOffset = data.getUint32SEAt(8);
+	// HACK: Phantasmagoria view 64001 contains a bad palette that overwrites
+	// parts of the palette used by the background picture in room 6400, causing
+	// the black shadows to become tan, and many of the other background colors
+	// to end up a little bit off. View 64001 renders fine using the existing
+	// palette created by the background image, so here we just ignore the
+	// embedded palette entirely.
+	if (g_sci->getGameId() == GID_PHANTASMAGORIA &&
+		_info.type == kCelTypeView && _info.resourceId == 64001) {
+
+		_hunkPaletteOffset = 0;
+	} else {
+		_hunkPaletteOffset = data.getUint32SEAt(8);
+	}
 	_celHeaderOffset = loopHeader.getUint32SEAt(12) + (data[13] * _info.celNo);
 
 	const SciSpan<const byte> celHeader = data.subspan(_celHeaderOffset);
diff --git a/engines/sci/graphics/palette32.cpp b/engines/sci/graphics/palette32.cpp
index fded8f0..0ea64d6 100644
--- a/engines/sci/graphics/palette32.cpp
+++ b/engines/sci/graphics/palette32.cpp
@@ -570,7 +570,9 @@ void GfxPalette32::mergePalette(Palette &to, const Palette &from) {
 	// cannot actually change index 255 (it is forced to white when generating
 	// the hardware palette in updateHardware). While this causes some
 	// additional unnecessary source palette invalidations, not doing it breaks
-	// some badly programmed rooms, like room 6400 in Phant1 (see Trac#9788)
+	// some badly programmed rooms, like room 6400 in Phant1 (see Trac#9788).
+	// (Note, however, that that specific glitch is fully fixed by ignoring a
+	// bad palette in the CelObjView constructor)
 	for (int i = 0; i < ARRAYSIZE(to.colors); ++i) {
 		if (from.colors[i].used) {
 			to.colors[i] = from.colors[i];


Commit: b1b18c54f3fca42fb47295886b76d0fa948ad519
    https://github.com/scummvm/scummvm/commit/b1b18c54f3fca42fb47295886b76d0fa948ad519
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-07-13T22:33:12-05:00

Commit Message:
SCI32: Patch out bad rat view init code in Phantasmagoria

Fixes Trac#9957.

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


diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp
index 0168ef1..04aecba 100644
--- a/engines/sci/engine/script_patches.cpp
+++ b/engines/sci/engine/script_patches.cpp
@@ -3514,9 +3514,40 @@ static const uint16 phant1PatchSavedVolume[] = {
 	PATCH_END
 };
 
+// Phantasmagoria performs an incomplete initialisation of a rat view when
+// exiting the alcove in the basement any time after chapter 3 when flag 26 is
+// not set. This causes the rat view to be rendered with the same origin and
+// priority as the background picture for the game plane, triggering last ditch
+// sorting of the screen items in the renderer. This happens to work OK most of
+// the time in SSCI because the last ditch sort uses memory handle indexes, and
+// the index of the rat seems to usually end up below the index for the
+// background pic, so the rat's screen item is submitted before the background,
+// ensuring that the background palette overrides the rat view's palette. In
+// ScummVM, last ditch sorting operates using the creation order of screen
+// items, so the rat ends up always sorting above the background, which causes
+// the background palette to get replaced by the rat palette, which corrupts the
+// background. This patch stops the game script from initialising the bad rat
+// view entirely.
+// Applies to at least: English CD, French CD
+static const uint16 phant1RatSignature[] = {
+	SIG_MAGICDWORD,
+	0x78,                         // push1
+	0x39, 0x1a,                   // pushi $1a
+	0x45, 0x03, SIG_UINT16(0x02), // callb 03, 0002
+	0x18,                         // not
+	0x31, 0x18,                   // bnt $18
+	SIG_END
+};
+
+static const uint16 phant1RatPatch[] = {
+	0x33, 0x20, // jmp [past rat condition + call]
+	PATCH_END
+};
+
 //          script, description,                                      signature                        patch
 static const SciScriptPatcherEntry phantasmagoriaSignatures[] = {
 	{  true,   901, "invalid array construction",                  1, sci21IntArraySignature,          sci21IntArrayPatch },
+	{  true, 20200, "fix broken rat init in sEnterFromAlcove",     1, phant1RatSignature,              phant1RatPatch },
 	{  true,  1111, "ignore audio settings from save game",        1, phant1SignatureSavedVolume,      phant1PatchSavedVolume },
 	{  true, 64908, "disable video benchmarking",                  1, sci2BenchmarkSignature,          sci2BenchmarkPatch },
 	SCI_SIGNATUREENTRY_TERMINATOR





More information about the Scummvm-git-logs mailing list