22 #ifndef SCI_ENGINE_VM_TYPES_H 23 #define SCI_ENGINE_VM_TYPES_H 25 #include "common/scummsys.h" 26 #include "sci/version.h" 31 typedef uint16 SegmentId;
34 kUninitializedSegment = 0x1FFF,
35 kSegmentMask = 0x1FFF,
44 SegmentId getSegment()
const;
45 void setSegment(SegmentId segment);
48 uint32 getOffset()
const {
49 if (getSciVersion() < SCI_VERSION_3) {
53 return ((_segment & 0xC000) << 2) | _offset;
58 void setOffset(uint32 offset) {
59 if (getSciVersion() < SCI_VERSION_3) {
63 _offset = offset & 0xFFFF;
64 _segment = ((offset & 0x30000) >> 2) | (_segment & 0x3FFF);
68 inline void incOffset(int32 offset) {
69 setOffset(getOffset() + offset);
72 inline bool isNull()
const {
73 return (getOffset() | getSegment()) == 0;
76 inline uint16 toUint16()
const {
77 return (uint16)getOffset();
80 inline int16 toSint16()
const {
81 return (int16)getOffset();
84 bool isNumber()
const {
85 return getSegment() == 0;
88 bool isPointer()
const {
89 return getSegment() != 0 && getSegment() != kUninitializedSegment;
92 uint16 requireUint16()
const;
93 int16 requireSint16()
const;
95 inline bool isInitialized()
const {
96 return getSegment() != kUninitializedSegment;
100 bool operator==(
const reg_t &x)
const {
101 return (getOffset() == x.getOffset()) && (getSegment() == x.getSegment());
104 bool operator!=(
const reg_t &x)
const {
105 return (getOffset() != x.getOffset()) || (getSegment() != x.getSegment());
108 bool operator>(
const reg_t right)
const {
109 return cmp(right,
false) > 0;
112 bool operator>=(
const reg_t right)
const {
113 return cmp(right,
false) >= 0;
116 bool operator<(
const reg_t right)
const {
117 return cmp(right,
false) < 0;
120 bool operator<=(
const reg_t right)
const {
121 return cmp(right,
false) <= 0;
126 bool gtU(
const reg_t right)
const {
127 return cmp(right,
true) > 0;
130 bool geU(
const reg_t right)
const {
131 return cmp(right,
true) >= 0;
134 bool ltU(
const reg_t right)
const {
135 return cmp(right,
true) < 0;
138 bool leU(
const reg_t right)
const {
139 return cmp(right,
true) <= 0;
151 reg_t operator+(int16 right)
const;
152 reg_t operator-(int16 right)
const;
154 void operator+=(
const reg_t &right) { *
this = *
this + right; }
155 void operator-=(
const reg_t &right) { *
this = *
this - right; }
156 void operator+=(int16 right) { *
this = *
this + right; }
157 void operator-=(int16 right) { *
this = *
this - right; }
165 reg_t operator&(int16 right)
const;
166 reg_t operator|(int16 right)
const;
167 reg_t operator^(int16 right)
const;
169 void operator&=(
const reg_t &right) { *
this = *
this & right; }
170 void operator|=(
const reg_t &right) { *
this = *
this | right; }
171 void operator^=(
const reg_t &right) { *
this = *
this ^ right; }
172 void operator&=(int16 right) { *
this = *
this & right; }
173 void operator|=(int16 right) { *
this = *
this | right; }
174 void operator^=(int16 right) { *
this = *
this ^ right; }
185 int cmp(
const reg_t right,
bool treatAsUnsigned)
const;
186 reg_t lookForWorkaround(
const reg_t right,
const char *operation)
const;
187 bool pointerComparisonWithInteger(
const reg_t right)
const;
190 int sci32Comparison(
const reg_t right)
const;
194 static inline reg_t make_reg(SegmentId segment, uint16 offset) {
196 r.setSegment(segment);
201 static inline reg_t make_reg32(SegmentId segment, uint32 offset) {
203 r.setSegment(segment);
208 #define PRINT_REG(r) (kSegmentMask) & (unsigned) (r).getSegment(), (unsigned) (r).getOffset() 222 extern const reg_t NULL_REG;
223 extern const reg_t SIGNAL_REG;
224 extern const reg_t TRUE_REG;
227 typedef int Selector;
257 #endif // SCI_ENGINE_VM_TYPES_H Definition: vm_types.h:231
Definition: vm_types.h:219
Definition: vm_types.h:39