aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2010-11-19 10:28:43 +0000
committerFilippos Karapetis2010-11-19 10:28:43 +0000
commitc19e8377f9cc947f0110247af8ce5fb21c40e64e (patch)
tree77227e6d663610c951dc2d25d9d11c459921e7c9
parent6ec8ec416bfdd4241d451de7ba501873fbae38b2 (diff)
downloadscummvm-rg350-c19e8377f9cc947f0110247af8ce5fb21c40e64e.tar.gz
scummvm-rg350-c19e8377f9cc947f0110247af8ce5fb21c40e64e.tar.bz2
scummvm-rg350-c19e8377f9cc947f0110247af8ce5fb21c40e64e.zip
SCI: Added pointer arithmetic support for SCI2 strings
svn-id: r54365
-rw-r--r--engines/sci/engine/vm.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index 94fa016790..80500f74d1 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -641,6 +641,30 @@ static reg_t pointer_add(EngineState *s, reg_t base, int offset) {
base.offset += offset;
return base;
+ case SEG_TYPE_STRING: {
+ // We need to copy over the string into a new one
+ // Make sure that the offset is positive
+ if (offset < 0)
+ error("pointer_add: Attempt to reference a previous offset of a SCI string");
+
+ // Get the source string...
+ SciString *str = s->_segMan->lookupString(base);
+ Common::String rawStr = str->toString();
+
+ // ...and copy it to a new one
+ reg_t newStringAddr;
+ SciString *newStr = s->_segMan->allocateString(&newStringAddr);
+ newStr->setSize(str->getSize() - offset);
+
+ // Cut off characters till we reach the desired location
+ for (int i = 0; i < offset; i++)
+ rawStr.deleteChar(0);
+
+ newStr->fromString(rawStr);
+
+ return newStringAddr;
+ }
+
default:
// FIXME: Changed this to warning, because iceman does this during dancing with girl.
// Investigate why that is so and either fix the underlying issue or implement a more