diff options
author | Filippos Karapetis | 2010-07-30 15:19:21 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-07-30 15:19:21 +0000 |
commit | cbbafc138b897387f702e541a0bf873348604179 (patch) | |
tree | da6596e790fe4852bb2dbfbd2e240a5d638c263c /engines | |
parent | 5b401215d9e0a31687c27b8b56ba3d651b89e000 (diff) | |
download | scummvm-rg350-cbbafc138b897387f702e541a0bf873348604179.tar.gz scummvm-rg350-cbbafc138b897387f702e541a0bf873348604179.tar.bz2 scummvm-rg350-cbbafc138b897387f702e541a0bf873348604179.zip |
SCI: Updated the op_mod changes and added a link to the original bug report
svn-id: r51509
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/vm.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
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; } |