aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorMartin Kiewitz2010-07-18 18:26:00 +0000
committerMartin Kiewitz2010-07-18 18:26:00 +0000
commitd06603f151f1d66410aaa3f533ff7308c3b60d3a (patch)
tree2da947ce4c66147c0d963e4fcf8ed40035a99f23 /engines/sci/engine
parentd14635d6b26972f4a0cb7d66ce25090b6157a5cc (diff)
downloadscummvm-rg350-d06603f151f1d66410aaa3f533ff7308c3b60d3a.tar.gz
scummvm-rg350-d06603f151f1d66410aaa3f533ff7308c3b60d3a.tar.bz2
scummvm-rg350-d06603f151f1d66410aaa3f533ff7308c3b60d3a.zip
SCI: make bnot/mod/mul more verbose
...and add abitility to easily add workarounds svn-id: r51003
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/vm.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index c77e12443f..09eb720f0b 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -1130,7 +1130,11 @@ void run_vm(EngineState *s, bool restoring) {
case op_bnot: // 0x00 (00)
// Binary not
- s->r_acc = ACC_ARITHMETIC_L(0xffff ^ /*acc*/);
+ int16 value;
+ if (validate_signedInteger(s->r_acc, value))
+ s->r_acc = make_reg(0, 0xffff ^ value);
+ else
+ s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, s->r_acc, NULL_REG);
break;
case op_add: // 0x01 (01)
@@ -1197,13 +1201,17 @@ void run_vm(EngineState *s, bool restoring) {
break;
case op_mul: // 0x03 (03)
- s->r_acc = ACC_ARITHMETIC_L(((int16)POP()) * (int16)/*acc*/);
+ r_temp = POP32();
+ int16 value1, value2;
+ if (validate_signedInteger(s->r_acc, value1) && validate_signedInteger(r_temp, value2))
+ s->r_acc = make_reg(0, value1 * value2);
+ else
+ s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, s->r_acc, r_temp);
break;
case op_div: { // 0x04 (04)
r_temp = POP32();
- int16 divisor;
- int16 dividend;
+ int16 divisor, dividend;
if (validate_signedInteger(s->r_acc, divisor) && validate_signedInteger(r_temp, dividend))
s->r_acc = make_reg(0, (divisor != 0 ? dividend / divisor : 0));
else
@@ -1211,8 +1219,12 @@ void run_vm(EngineState *s, bool restoring) {
break;
}
case op_mod: { // 0x05 (05)
- int16 modulo = signed_validate_arithmetic(s->r_acc);
- s->r_acc = make_reg(0, (modulo != 0 ? ((int16)POP()) % modulo : 0));
+ 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
+ s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, s->r_acc, r_temp);
break;
}
case op_shr: // 0x06 (06)