From b24be4f52620d01fd2928d8afddd9fe884b392ed Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 27 Jan 2010 12:13:39 +0000 Subject: Added support of the subtraction of two pointers, when they got the same segment. This operation will yield a number, like in C, and it's used by script 385 in Castle of Dr. Brain (the hangman script). Fixes exiting room 360 (the puzzle room) in Castle of Dr. Brain svn-id: r47595 --- engines/sci/engine/vm.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'engines/sci/engine') diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index e921d0f8fc..3d320d485c 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -763,7 +763,7 @@ void run_vm(EngineState *s, int restoring) { case 0x02: // sub r_temp = POP32(); - if (r_temp.segment || s->r_acc.segment) { + if (r_temp.segment != s->r_acc.segment) { reg_t r_ptr = NULL_REG; int offset; // Pointer arithmetics! @@ -783,8 +783,11 @@ void run_vm(EngineState *s, int restoring) { s->r_acc = pointer_add(s, r_ptr, -offset); - } else + } else { + // We can subtract numbers, or pointers with the same segment, + // an operation which will yield a number like in C s->r_acc = make_reg(0, r_temp.offset - s->r_acc.offset); + } break; case 0x03: // mul -- cgit v1.2.3