From 601e8c0de128899d78353a6b1ee49181c92f55f1 Mon Sep 17 00:00:00 2001 From: md5 Date: Mon, 21 Feb 2011 05:18:21 +0200 Subject: 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 --- engines/sci/engine/vm.cpp | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'engines/sci/engine/vm.cpp') 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 -- cgit v1.2.3