diff options
-rw-r--r-- | engines/sci/engine/vm.cpp | 5 | ||||
-rw-r--r-- | engines/sci/engine/workarounds.cpp | 6 | ||||
-rw-r--r-- | engines/sci/engine/workarounds.h | 1 | ||||
-rw-r--r-- | engines/sci/graphics/paint16.cpp | 1 | ||||
-rw-r--r-- | engines/sci/graphics/ports.cpp | 7 | ||||
-rw-r--r-- | engines/sci/graphics/ports.h | 1 |
6 files changed, 20 insertions, 1 deletions
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 7c989e43f4..af4d4eb880 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -1800,7 +1800,10 @@ void run_vm(EngineState *s) { // Load global, local, temp or param variable into the accumulator, // using the accumulator as an additional index var_type = opcode & 0x3; // Gets the variable type: g, l, t or p - var_number = opparams[0] + signed_validate_arithmetic(s->r_acc); + int16 value; + if (!validate_signedInteger(s->r_acc, value)) + value = arithmetic_lookForWorkaround(opcode, opcodeLaiWorkarounds, s->r_acc, NULL_REG).offset; + var_number = opparams[0] + value; s->r_acc = READ_VAR(var_type, var_number); break; diff --git a/engines/sci/engine/workarounds.cpp b/engines/sci/engine/workarounds.cpp index fe269df563..ca47472ded 100644 --- a/engines/sci/engine/workarounds.cpp +++ b/engines/sci/engine/workarounds.cpp @@ -59,6 +59,12 @@ const SciWorkaroundEntry opcodeLeWorkarounds[] = { }; // gameID, room,script,lvl, object-name, method-name, call,index, workaround +const SciWorkaroundEntry opcodeLaiWorkarounds[] = { + { GID_CAMELOT, 92, 92, 0, "endingCartoon2", "changeState", 0x20d, 0, { WORKAROUND_FAKE, 0 } }, // during the ending, sub gets called with no parameters, uses parameter 1 which is theGrail in this case - bug #3044734 + SCI_WORKAROUNDENTRY_TERMINATOR +}; + +// gameID, room,script,lvl, object-name, method-name, call,index, workaround const SciWorkaroundEntry opcodeLsiWorkarounds[] = { { GID_QFG2, 200, 200, 0, "astro", "messages", -1, 0, { WORKAROUND_FAKE, 0 } }, // when getting asked for your name by the astrologer bug #3039879 SCI_WORKAROUNDENTRY_TERMINATOR diff --git a/engines/sci/engine/workarounds.h b/engines/sci/engine/workarounds.h index 220ffd7fda..55a4b8f885 100644 --- a/engines/sci/engine/workarounds.h +++ b/engines/sci/engine/workarounds.h @@ -72,6 +72,7 @@ extern const SciWorkaroundEntry opcodeDivWorkarounds[]; extern const SciWorkaroundEntry opcodeDptoaWorkarounds[]; extern const SciWorkaroundEntry opcodeGeWorkarounds[]; extern const SciWorkaroundEntry opcodeLeWorkarounds[]; +extern const SciWorkaroundEntry opcodeLaiWorkarounds[]; extern const SciWorkaroundEntry opcodeLsiWorkarounds[]; extern const SciWorkaroundEntry opcodeMulWorkarounds[]; extern const SciWorkaroundEntry opcodeAndWorkarounds[]; diff --git a/engines/sci/graphics/paint16.cpp b/engines/sci/graphics/paint16.cpp index 6e7da7c4dd..dbc738e2f7 100644 --- a/engines/sci/graphics/paint16.cpp +++ b/engines/sci/graphics/paint16.cpp @@ -417,6 +417,7 @@ void GfxPaint16::kernelGraphFrameBox(const Common::Rect &rect, int16 color) { } void GfxPaint16::kernelGraphDrawLine(Common::Point startPoint, Common::Point endPoint, int16 color, int16 priority, int16 control) { + _ports->clipLine(startPoint, endPoint); _ports->offsetLine(startPoint, endPoint); _screen->drawLine(startPoint.x, startPoint.y, endPoint.x, endPoint.y, color, priority, control); } diff --git a/engines/sci/graphics/ports.cpp b/engines/sci/graphics/ports.cpp index 32a9db5ae3..2d8bfde37d 100644 --- a/engines/sci/graphics/ports.cpp +++ b/engines/sci/graphics/ports.cpp @@ -566,6 +566,13 @@ void GfxPorts::offsetLine(Common::Point &start, Common::Point &end) { end.y += _curPort->top; } +void GfxPorts::clipLine(Common::Point &start, Common::Point &end) { + start.y = CLIP<int16>(start.y, _curPort->rect.top, _curPort->rect.bottom - 1); + start.x = CLIP<int16>(start.x, _curPort->rect.left, _curPort->rect.right - 1); + end.y = CLIP<int16>(end.y, _curPort->rect.top, _curPort->rect.bottom - 1); + end.x = CLIP<int16>(end.x, _curPort->rect.left, _curPort->rect.right - 1); +} + void GfxPorts::priorityBandsInit(int16 bandCount, int16 top, int16 bottom) { int16 y; int32 bandSize; diff --git a/engines/sci/graphics/ports.h b/engines/sci/graphics/ports.h index 42a0a5d4b4..453cb50986 100644 --- a/engines/sci/graphics/ports.h +++ b/engines/sci/graphics/ports.h @@ -83,6 +83,7 @@ public: void offsetRect(Common::Rect &r); void offsetLine(Common::Point &start, Common::Point &end); + void clipLine(Common::Point &start, Common::Point &end); void priorityBandsInit(int16 bandCount, int16 top, int16 bottom); void priorityBandsInit(byte *data); |