diff options
author | Walter van Niftrik | 2010-01-24 17:52:27 +0000 |
---|---|---|
committer | Walter van Niftrik | 2010-01-24 17:52:27 +0000 |
commit | 10da245619c520791430147ce0229824c53083cf (patch) | |
tree | 886a22cc258d0ef03c91468c5f8070146f058f04 /engines | |
parent | 414eadfb2aec530b21f0773ed6657017b650876f (diff) | |
download | scummvm-rg350-10da245619c520791430147ce0229824c53083cf.tar.gz scummvm-rg350-10da245619c520791430147ce0229824c53083cf.tar.bz2 scummvm-rg350-10da245619c520791430147ce0229824c53083cf.zip |
SCI: Cleanup
svn-id: r47506
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/segment.cpp | 23 | ||||
-rw-r--r-- | engines/sci/engine/segment.h | 2 |
2 files changed, 7 insertions, 18 deletions
diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp index 20d27b9ba2..6df4e1bac7 100644 --- a/engines/sci/engine/segment.cpp +++ b/engines/sci/engine/segment.cpp @@ -247,28 +247,17 @@ bool LocalVariables::isValidOffset(uint16 offset) const { } SegmentRef LocalVariables::dereference(reg_t pointer) { - // FIXME: The following doesn't seem to be endian safe. - // To fix this, we'd have to always treat the reg_t - // values stored here as in the little endian format. - // Anyway, generate a warning for now to see if this ever - // happens. - // One has to wonder whether we return the right value anyway. - // Here are three potential options: - // 1: ((byte *)&_locals[0]) + pointer.offset - // 2: ((byte *)&_locals[pointer.offset/2]) + (pointer.offset % 2) - // 3: ((byte *)&_locals[pointer.offset]) - // So which one is correct? :) if (pointer.offset & 1) warning("LocalVariables::dereference: Odd offset in pointer %04x:%04x", PRINT_REG(pointer)); SegmentRef ret; ret.isRaw = false; // reg_t based data! - ret.maxSize = (_locals.size() - pointer.offset/2) * 2; + ret.maxSize = (_locals.size() - pointer.offset / 2) * 2; if (ret.maxSize > 0) { - ret.raw = (byte *)&_locals[pointer.offset/2]; + ret.reg = &_locals[pointer.offset / 2]; } else { warning("LocalVariables::dereference: Offset at end or out of bounds %04x:%04x", PRINT_REG(pointer)); - ret.raw = 0; + ret.reg = 0; } return ret; } @@ -280,11 +269,11 @@ bool DataStack::isValidOffset(uint16 offset) const { SegmentRef DataStack::dereference(reg_t pointer) { SegmentRef ret; ret.isRaw = false; // reg_t based data! - ret.maxSize = (_capacity - pointer.offset/2) * 2; - // FIXME: Is this correct? See comment in LocalVariables::dereference + ret.maxSize = (_capacity - pointer.offset / 2) * 2; + if (pointer.offset & 1) warning("LocalVariables::dereference: Odd offset in pointer %04x:%04x", PRINT_REG(pointer)); - ret.raw = (byte *)&_entries[pointer.offset/2]; + ret.reg = &_entries[pointer.offset / 2]; return ret; } diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h index 9e65186c31..a1967f6bb8 100644 --- a/engines/sci/engine/segment.h +++ b/engines/sci/engine/segment.h @@ -47,7 +47,7 @@ struct SegmentRef { SegmentRef() : isRaw(true), raw(0), maxSize(0) {} - bool isValid() const { return raw != 0; } + bool isValid() const { return (isRaw ? raw != 0 : reg != 0); } }; |