aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine/vm.cpp
diff options
context:
space:
mode:
authormd52011-02-21 05:18:21 +0200
committermd52011-02-21 05:18:21 +0200
commit601e8c0de128899d78353a6b1ee49181c92f55f1 (patch)
treed6dcc813c4998cb5673b3d63d306525890e2017f /engines/sci/engine/vm.cpp
parent9afc89e67c287c3253e20a0a724774e84fa244f3 (diff)
downloadscummvm-rg350-601e8c0de128899d78353a6b1ee49181c92f55f1.tar.gz
scummvm-rg350-601e8c0de128899d78353a6b1ee49181c92f55f1.tar.bz2
scummvm-rg350-601e8c0de128899d78353a6b1ee49181c92f55f1.zip
SCI: Added a custom modulo reg_t operator
This version only handles signed integers. The modulo operator was changed in SCI0 late (Iceman, and perhaps all SCI0 0.000.685 and later) so that it handles negative numbers as well. We need to see if there really is a need to keep two different modulo operators (which will only be necessary if any SCI0 game asks for the modulo of a negative number by mistake, or a number larger than 32767). Thus, error out in such a case for SCI0, so that this can be investigated properly
Diffstat (limited to 'engines/sci/engine/vm.cpp')
-rw-r--r--engines/sci/engine/vm.cpp24
1 files changed, 3 insertions, 21 deletions
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index a6677ee633..69d046da7d 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -961,28 +961,10 @@ void run_vm(EngineState *s) {
s->r_acc = POP32() / s->r_acc;
break;
- case op_mod: { // 0x05 (05)
- if (getSciVersion() <= SCI_VERSION_0_LATE) {
- uint16 modulo = s->r_acc.requireUint16();
- uint16 value = POP32().requireUint16();
- uint16 result = (modulo != 0 ? value % modulo : 0);
- s->r_acc = make_reg(0, result);
- } else {
- // 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 = ABS(s->r_acc.requireSint16());
- int16 value = POP32().requireSint16();
- int16 result = (modulo != 0 ? value % modulo : 0);
- if (result < 0)
- result += modulo;
- s->r_acc = make_reg(0, result);
- }
+ case op_mod: // 0x05 (05)
+ // we check for division by 0 inside the custom reg_t modulo operator
+ s->r_acc = POP32() % s->r_acc;
break;
- }
case op_shr: // 0x06 (06)
// Shift right logical