mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-09 03:10:22 +00:00
SCI: Convert PQ2 speed workaround to script patch
Cleans up kScriptID and speeds up startup
This commit is contained in:
parent
a40c216236
commit
6853b5101f
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user