SCI: adding workaround for camelot during ending

fixes bug #3044734
also fixing heap corruption during the ending

svn-id: r52077
This commit is contained in:
Martin Kiewitz 2010-08-14 06:05:54 +00:00
parent f252c0b67e
commit 512bf22af6
6 changed files with 20 additions and 1 deletions

View File

@ -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;

View File

@ -58,6 +58,12 @@ const SciWorkaroundEntry opcodeLeWorkarounds[] = {
SCI_WORKAROUNDENTRY_TERMINATOR
};
// 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

View File

@ -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[];

View File

@ -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);
}

View File

@ -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;

View File

@ -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);