From 148a9b70583168be0ea52549868bd79f7a23b58d Mon Sep 17 00:00:00 2001 From: sluicebox Date: Thu, 27 Jun 2019 17:33:48 -0700 Subject: SCI32: Fix kShakeScreen32 parameter count check --- engines/sci/engine/kgraphics32.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'engines/sci/engine') diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp index f9c1edee42..c28f0cd380 100644 --- a/engines/sci/engine/kgraphics32.cpp +++ b/engines/sci/engine/kgraphics32.cpp @@ -155,7 +155,17 @@ reg_t kSetCursor32(EngineState *s, int argc, reg_t *argv) { } reg_t kShakeScreen32(EngineState *s, int argc, reg_t *argv) { - g_sci->_gfxFrameout->shakeScreen(argv[0].toSint16(), (ShakeDirection)argv[1].toSint16()); + int16 shakeCount = argv[0].toSint16(); + + // SSCI didn't check the parameter count and assumed a direction parameter + // was always passed. This parameter was optional in SCI16 and at least GK1 + // and QFG4 scripts continued to not pass it. This would shake in a random + // direction depending on whatever happened to be in memory, or not at all. + // We treat direction as optional with a a vertical default as in SCI16 as + // that's what the scripts expect. + ShakeDirection directions = (argc > 1) ? (ShakeDirection)argv[1].toSint16() : kShakeVertical; + + g_sci->_gfxFrameout->shakeScreen(shakeCount, directions); return s->r_acc; } -- cgit v1.2.3