[Scummvm-git-logs] scummvm master -> 6853b5101ff0528b30d056ee31fbd1d6dc22832e

sluicebox 22204938+sluicebox at users.noreply.github.com
Thu Mar 11 16:52:43 UTC 2021


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

Summary:
6853b5101f SCI: Convert PQ2 speed workaround to script patch


Commit: 6853b5101ff0528b30d056ee31fbd1d6dc22832e
    https://github.com/scummvm/scummvm/commit/6853b5101ff0528b30d056ee31fbd1d6dc22832e
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2021-03-11T08:50:46-08:00

Commit Message:
SCI: Convert PQ2 speed workaround to script patch

Cleans up kScriptID and speeds up startup

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


diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp
index 2b03e13cdb..3f1a51ff4b 100644
--- a/engines/sci/engine/kscripts.cpp
+++ b/engines/sci/engine/kscripts.cpp
@@ -287,17 +287,6 @@ reg_t kScriptID(EngineState *s, int argc, reg_t *argv) {
 		return NULL_REG;
 
 	const uint32 address = scr->validateExportFunc(index, true) + scr->getHeapOffset();
-
-	// WORKAROUND: Bugfix for the intro speed in PQ2 version 1.002.011.
-	// This is taken from the patch by NewRisingSun(NRS) / Belzorash. Global 3
-	// is used for timing during the intro, and in the problematic version it's
-	// initialized to 0, whereas it's 6 in other versions. Thus, we assign it
-	// to 6 here, fixing the speed of the introduction. Refer to bug #5496.
-	if (g_sci->getGameId() == GID_PQ2 && script == 200 &&
-		s->variables[VAR_GLOBAL][kGlobalVarSpeed].isNull()) {
-		s->variables[VAR_GLOBAL][kGlobalVarSpeed] = make_reg(0, 6);
-	}
-
 	return make_reg32(scriptSeg, address);
 }
 
diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp
index 90bdbe6a4a..dd81149367 100644
--- a/engines/sci/engine/script_patches.cpp
+++ b/engines/sci/engine/script_patches.cpp
@@ -10788,6 +10788,44 @@ static const SciScriptPatcherEntry pq1vgaSignatures[] = {
 	SCI_SIGNATUREENTRY_TERMINATOR
 };
 
+// ===========================================================================
+// Police Quest 2
+
+// Starting in PQ2 1.002.011, the introduction runs too fast. The speed test was
+//  changed to run before the introduction but this introduced a bug where the
+//  game speed wasn't restored from the temporary fast speed used for the test.
+//
+// We fix this by restoring the game speed to the correct default value. Since
+//  we're patching the speed test anyway, we also disable it so that it returns
+//  the maximum value without delaying game startup.
+//
+// Applies to: All versions, although the speed bug is in 1.002.011 and later
+// Responsible method: rm99:doit
+// Fixes bug: #5496
+static const uint16 pq2SignatureSpeedTest[] = {
+	SIG_MAGICDWORD,
+	0x8b, 0x00,                          // lsl 00
+	0x76,                                // push0
+	0x43, 0x46, 0x00,                    // callk GetTime 00
+	0x22,                                // lt?
+	0x30,                                // bnt [ skip exiting speed test ]
+	SIG_END
+};
+
+static const uint16 pq2PatchSpeedTest[] = {
+	0x34, PATCH_UINT16(0x7fff),          // ldi 7fff
+	0xa1, 0x6e,                          // sag 6e [ speed test result = $7fff ]
+	0x34, PATCH_UINT16(0x0006),          // ldi 0006
+	0xa1, 0x03,                          // sag 03 [ game speed = 6 ]
+	PATCH_END
+};
+
+//          script, description,                                 signature                     patch
+static const SciScriptPatcherEntry pq2Signatures[] = {
+	{  true,    99, "speed test / intro speed",               1, pq2SignatureSpeedTest,        pq2PatchSpeedTest },
+	SCI_SIGNATUREENTRY_TERMINATOR
+};
+
 // ===========================================================================
 // Police Quest 3
 
@@ -20973,6 +21011,9 @@ void ScriptPatcher::processScript(uint16 scriptNr, SciSpan<byte> scriptData) {
 	case GID_PQ1:
 		signatureTable = pq1vgaSignatures;
 		break;
+	case GID_PQ2:
+		signatureTable = pq2Signatures;
+		break;
 	case GID_PQ3:
 		signatureTable = pq3Signatures;
 		break;




More information about the Scummvm-git-logs mailing list