Skip to content

Commit

Permalink
SCI: Apply SQ4 timing workaround to non-VGA versions
Browse files Browse the repository at this point in the history
Fixes bug #6193 by applying the SQ4 floppy kPaletteAnimation timing
workaround from 99de89c to versions
with less than 256 colors. This includes DOS EGA, PC-98, and Amiga.

This also patches out the intro script's workaround that uses different
timing in EGA mode, as this is incompatible with ours and makes the
intro screen last over 3 minutes instead of 5 seconds.
  • Loading branch information
sluicebox authored and bluegr committed Mar 19, 2019
1 parent a4f92ce commit a398d36
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
27 changes: 14 additions & 13 deletions engines/sci/engine/kgraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,18 +646,17 @@ reg_t kPaletteAnimate(EngineState *s, int argc, reg_t *argv) {
bool paletteChanged = false;

// Palette animation in non-VGA SCI1 games has been removed
if (g_sci->_gfxPalette16->getTotalColorCount() < 256)
return s->r_acc;

for (argNr = 0; argNr < argc; argNr += 3) {
uint16 fromColor = argv[argNr].toUint16();
uint16 toColor = argv[argNr + 1].toUint16();
int16 speed = argv[argNr + 2].toSint16();
if (g_sci->_gfxPalette16->kernelAnimate(fromColor, toColor, speed))
paletteChanged = true;
if (g_sci->_gfxPalette16->getTotalColorCount() == 256) {
for (argNr = 0; argNr < argc; argNr += 3) {
uint16 fromColor = argv[argNr].toUint16();
uint16 toColor = argv[argNr + 1].toUint16();
int16 speed = argv[argNr + 2].toSint16();
if (g_sci->_gfxPalette16->kernelAnimate(fromColor, toColor, speed))
paletteChanged = true;
}
if (paletteChanged)
g_sci->_gfxPalette16->kernelAnimateSet();
}
if (paletteChanged)
g_sci->_gfxPalette16->kernelAnimateSet();

// WORKAROUND: The game scripts in SQ4 floppy count the number of elapsed
// cycles in the intro from the number of successive kAnimate calls during
Expand All @@ -668,8 +667,10 @@ reg_t kPaletteAnimate(EngineState *s, int argc, reg_t *argv) {
// speed throttler gets called) between the different palette animation calls.
// Thus, we add a small delay between each animate call to make the whole
// palette animation effect slower and visible, and not have the logo screen
// get skipped because the scripts don't wait between animation steps. Fixes
// bug #3537232.
// get skipped because the scripts don't wait between animation steps. This
// workaround is applied to non-VGA versions as well because even though they
// don't use palette animation they still call this function and use it for
// timing. Fixes bugs #6057, #6193.
// The original workaround was for the intro SQ4 logo (room#1).
// This problem also happens in the time pod (room#531).
// This problem also happens in the ending cutscene time rip (room#21).
Expand Down
25 changes: 25 additions & 0 deletions engines/sci/engine/script_patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11092,6 +11092,30 @@ static const uint16 sq4CdPatchGettingShotWhileGettingRope[] = {
PATCH_END
};

// During the SQ4 introduction logo, EGA versions increase the number of calls
// to kPaletteAnimate by 40x. This was probably to achieve the same delay as
// VGA even though no palette animation occurred. This adjustment interferes
// with our kPaletteAnimate speed throttling for SQ4 scripts such as this, bug
// #6057. We remove the EGA delay, making all versions consistent, otherwise
// the logo is displayed for over 3 minutes instead of 5 seconds.
//
// Applies to: English PC EGA Floppy, Japanese PC-98
// Responsible method: rmScript:changeState
// Fixes bug #6193
static const uint16 sq4SignatureEgaIntroDelay[] = {
SIG_MAGICDWORD,
0x89, 0x69, // lsg 69 [ system colors ]
0x35, 0x10, // ldi 10
0x1e, // gt? [ system colors > 16 ]
0x30, // bnt [ use EGA delay ]
SIG_END
};

static const uint16 sq4PatchEgaIntroDelay[] = {
0x33, 0x06, // jmp 06 [ don't use EGA delay ]
PATCH_END
};

// Talking in room 520 results in a missing message due to passing the wrong
// modNum to the narrator.
//
Expand Down Expand Up @@ -11351,6 +11375,7 @@ static const uint16 sq4CdPatchTextOptions[] = {

// script, description, signature patch
static const SciScriptPatcherEntry sq4Signatures[] = {
{ true, 1, "Floppy: EGA intro delay fix", 2, sq4SignatureEgaIntroDelay, sq4PatchEgaIntroDelay },
{ true, 298, "Floppy: endless flight", 1, sq4FloppySignatureEndlessFlight, sq4FloppyPatchEndlessFlight },
{ true, 700, "Floppy: throw stuff at sequel police bug", 1, sq4FloppySignatureThrowStuffAtSequelPoliceBug, sq4FloppyPatchThrowStuffAtSequelPoliceBug },
{ true, 35, "CD: sidewalk smell message fix", 1, sq4CdSignatureSidewalkSmellMessage, sq4CdPatchSidewalkSmellMessage },
Expand Down

0 comments on commit a398d36

Please sign in to comment.