diff options
author | Filippos Karapetis | 2010-07-30 14:56:38 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-07-30 14:56:38 +0000 |
commit | 5b401215d9e0a31687c27b8b56ba3d651b89e000 (patch) | |
tree | b8f8bb21ffe90192d0a7c72bb9ec51fc064ee7a0 | |
parent | c665b9e9a7c7e860119cdd2b4fae76d39d276a81 (diff) | |
download | scummvm-rg350-5b401215d9e0a31687c27b8b56ba3d651b89e000.tar.gz scummvm-rg350-5b401215d9e0a31687c27b8b56ba3d651b89e000.tar.bz2 scummvm-rg350-5b401215d9e0a31687c27b8b56ba3d651b89e000.zip |
SCI: Added handling of negative numbers to
op_mod for SCI01 and newer games. Fixes the
battlecruiser mini-game in SQ5. Many thanks
to lskovlun, wjp and m_kiewitz for their
joined effort on this issue
svn-id: r51508
-rw-r--r-- | engines/sci/engine/vm.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index b7f6896a48..0ab66419c0 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -1069,11 +1069,17 @@ void run_vm(EngineState *s) { case op_mod: { // 0x05 (05) r_temp = POP32(); - int16 modulo, value; - if (validate_signedInteger(s->r_acc, modulo) && validate_signedInteger(r_temp, value)) - s->r_acc = make_reg(0, (modulo != 0 ? value % modulo : 0)); - else + 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); + } else { s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, s->r_acc, r_temp); + } break; } |