aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb/runtime.h
diff options
context:
space:
mode:
Diffstat (limited to 'engines/dreamweb/runtime.h')
-rw-r--r--engines/dreamweb/runtime.h38
1 files changed, 24 insertions, 14 deletions
diff --git a/engines/dreamweb/runtime.h b/engines/dreamweb/runtime.h
index 8932e123a8..724d5e4053 100644
--- a/engines/dreamweb/runtime.h
+++ b/engines/dreamweb/runtime.h
@@ -97,16 +97,16 @@ public:
struct Segment {
Common::Array<uint8> data;
-
+
inline void assign(const uint8 *b, const uint8 *e) {
data.assign(b, e);
}
-
+
inline uint8 &byte(unsigned index) {
assert(index < data.size());
return data[index];
}
-
+
inline WordRef word(unsigned index) {
return WordRef(data, index);
}
@@ -163,7 +163,7 @@ public:
assert(_segment != 0);
_segment->assign(b, e);
}
-
+
inline uint8* ptr(unsigned index, unsigned size) {
assert(_segment != 0);
return _segment->ptr(index, size);
@@ -180,7 +180,7 @@ struct Flags {
inline bool l() const { return _o != _s; }
inline bool le() const { return _o != _s|| _z; }
-
+
inline void update_zs(uint8 v) {
_s = v & 0x80;
_z = v == 0;
@@ -228,7 +228,7 @@ public:
//data == fake segment register always pointing to data segment
Flags flags;
- inline Context(): engine(0), al(ax), ah(ax), bl(bx), bh(bx), cl(cx), ch(cx), dl(dx), dh(dx),
+ inline Context(): engine(0), al(ax), ah(ax), bl(bx), bh(bx), cl(cx), ch(cx), dl(dx), dh(dx),
cs(this), ds(this), es(this), data(this) {
_segments[kDefaultDataSegment] = SegmentPtr(new Segment());
cs.reset(kDefaultDataSegment);
@@ -462,12 +462,15 @@ public:
es.byte(di++) = ds.byte(si++);
}
- inline void _movsb(uint size) {
+ inline void _movsb(uint size, bool clear_cx = false) {
+ assert(size != 0xffff);
uint8 *dst = es.ptr(di, size);
uint8 *src = ds.ptr(si, size);
memcpy(dst, src, size);
di += size;
si += size;
+ if (clear_cx)
+ cx = 0;
}
inline void _movsw() {
@@ -475,18 +478,22 @@ public:
_movsb();
}
- inline void _movsw(uint size) {
- _movsb(size * 2);
+ inline void _movsw(uint size, bool clear_cx = false) {
+ assert(size != 0xffff);
+ _movsb(size * 2, clear_cx);
}
inline void _stosb() {
es.byte(di++) = al;
}
- inline void _stosb(uint size) {
+ inline void _stosb(uint size, bool clear_cx = false) {
+ assert(size != 0xffff);
uint8 *dst = es.ptr(di, size);
memset(dst, al, size);
di += size;
+ if (clear_cx)
+ cx = 0;
}
inline void _stosw() {
@@ -494,13 +501,16 @@ public:
es.byte(di++) = ah;
}
- inline void _stosw(uint size) {
- uint8 *dst = es.ptr(di, size);
+ inline void _stosw(uint size, bool clear_cx = false) {
+ assert(size != 0xffff);
+ uint8 *dst = es.ptr(di, size * 2);
di += 2 * size;
while(size--) {
*dst++ = al;
*dst++ = ah;
}
+ if (clear_cx)
+ cx = 0;
}
inline void _xchg(uint16 &a, uint16 &b) {
@@ -542,9 +552,9 @@ public:
};
#ifndef NDEBUG
-# define STACK_CHECK(context) StackChecker checker(context)
+# define STACK_CHECK StackChecker checker(*this)
#else
-# define STACK_CHECK(context) do {} while (0)
+# define STACK_CHECK do {} while (0)
#endif
}