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 void init(SegmentId segment, uint32 offset);
46 SegmentId getSegment()
const;
47 void setSegment(SegmentId segment);
50 uint32 getOffset()
const {
51 if (getSciVersion() < SCI_VERSION_3) {
55 return ((_segment & 0xC000) << 2) | _offset;
60 void setOffset(uint32 offset) {
61 if (getSciVersion() < SCI_VERSION_3) {
65 _offset = offset & 0xFFFF;
66 _segment = ((offset & 0x30000) >> 2) | (_segment & 0x3FFF);
70 inline void incOffset(int32 offset) {
71 setOffset(getOffset() + offset);
74 inline bool isNull()
const {
75 return (getOffset() | getSegment()) == 0;
78 inline uint16 toUint16()
const {
79 return (uint16)getOffset();
82 inline int16 toSint16()
const {
83 return (int16)getOffset();
86 bool isNumber()
const {
87 return getSegment() == 0;
90 bool isPointer()
const {
91 return getSegment() != 0 && getSegment() != kUninitializedSegment;
94 uint16 requireUint16()
const;
95 int16 requireSint16()
const;
97 inline bool isInitialized()
const {
98 return getSegment() != kUninitializedSegment;
102 bool operator==(
const reg_t &x)
const {
103 return (getOffset() == x.getOffset()) && (getSegment() == x.getSegment());
106 bool operator!=(
const reg_t &x)
const {
107 return (getOffset() != x.getOffset()) || (getSegment() != x.getSegment());
110 bool operator>(
const reg_t right)
const {
111 return cmp(right,
false) > 0;
114 bool operator>=(
const reg_t right)
const {
115 return cmp(right,
false) >= 0;
118 bool operator<(
const reg_t right)
const {
119 return cmp(right,
false) < 0;
122 bool operator<=(
const reg_t right)
const {
123 return cmp(right,
false) <= 0;
128 bool gtU(
const reg_t right)
const {
129 return cmp(right,
true) > 0;
132 bool geU(
const reg_t right)
const {
133 return cmp(right,
true) >= 0;
136 bool ltU(
const reg_t right)
const {
137 return cmp(right,
true) < 0;
140 bool leU(
const reg_t right)
const {
141 return cmp(right,
true) <= 0;
153 reg_t operator+(int16 right)
const;
154 reg_t operator-(int16 right)
const;
156 void operator+=(
const reg_t &right) { *
this = *
this + right; }
157 void operator-=(
const reg_t &right) { *
this = *
this - right; }
158 void operator+=(int16 right) { *
this = *
this + right; }
159 void operator-=(int16 right) { *
this = *
this - right; }
167 reg_t operator&(int16 right)
const;
168 reg_t operator|(int16 right)
const;
169 reg_t operator^(int16 right)
const;
171 void operator&=(
const reg_t &right) { *
this = *
this & right; }
172 void operator|=(
const reg_t &right) { *
this = *
this | right; }
173 void operator^=(
const reg_t &right) { *
this = *
this ^ right; }
174 void operator&=(int16 right) { *
this = *
this & right; }
175 void operator|=(int16 right) { *
this = *
this | right; }
176 void operator^=(int16 right) { *
this = *
this ^ right; }
187 int cmp(
const reg_t right,
bool treatAsUnsigned)
const;
188 reg_t lookForWorkaround(
const reg_t right,
const char *operation)
const;
189 bool pointerComparisonWithInteger(
const reg_t right)
const;
192 int sci32Comparison(
const reg_t right)
const;
196 static inline reg_t make_reg(SegmentId segment, uint16 offset) {
198 r.init(segment, offset);
202 static inline reg_t make_reg32(SegmentId segment, uint32 offset) {
204 r.init(segment, offset);
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:219
Definition: vm_types.h:231
Definition: vm_types.h:39