From cbbafc138b897387f702e541a0bf873348604179 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 30 Jul 2010 15:19:21 +0000 Subject: SCI: Updated the op_mod changes and added a link to the original bug report svn-id: r51509 --- engines/sci/engine/vm.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 0ab66419c0..d849d3e008 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -1069,16 +1069,29 @@ void run_vm(EngineState *s) { case op_mod: { // 0x05 (05) r_temp = POP32(); - int16 modulo, value, result; - if (validate_signedInteger(s->r_acc, modulo) && validate_signedInteger(r_temp, value)) { - modulo = ABS(modulo); - result = (modulo != 0 ? value % modulo : 0); - // In SCI01, handling for negative numbers was added - if (getSciVersion() >= SCI_VERSION_01 && result < 0) - result += modulo; - s->r_acc = make_reg(0, result); + + if (getSciVersion() <= SCI_VERSION_0_LATE) { + uint16 modulo, value; + if (validate_unsignedInteger(s->r_acc, modulo) && validate_unsignedInteger(r_temp, value)) + s->r_acc = make_reg(0, (modulo != 0 ? value % modulo : 0)); + else + s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, s->r_acc, r_temp); } else { - s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, s->r_acc, r_temp); + // In Iceman (and perhaps from SCI0 0.000.685 onwards in general), + // handling for negative numbers was added. Since Iceman doesn't + // seem to have issues with the older code, we exclude it for now + // for simplicity's sake and use the new code for SCI01 and newer + // games. Fixes the battlecruiser mini game in SQ5 (room 850), + // bug #3035755 + int16 modulo, value, result; + if (validate_signedInteger(s->r_acc, modulo) && validate_signedInteger(r_temp, value)) { + modulo = ABS(modulo); + result = (modulo != 0 ? value % modulo : 0); + if (result < 0) + result += modulo; + s->r_acc = make_reg(0, result); + } else + s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, s->r_acc, r_temp); } break; } -- cgit v1.2.3