mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-11 21:55:27 +00:00
DREAMWEB: get rid of data, added simple segment management
This commit is contained in:
parent
781d06709f
commit
1ee6b0af69
@ -63,7 +63,7 @@ namespace %s {
|
||||
if size == 0:
|
||||
raise Exception("invalid var '%s' size %u" %(name, size))
|
||||
if self.indirection == 0:
|
||||
value = "context.data.%s(%d)" %("byte" if size == 1 else "word", g.offset)
|
||||
value = "context.ds.%s(%d)" %("byte" if size == 1 else "word", g.offset)
|
||||
elif self.indirection == -1:
|
||||
value = "%s" %g.offset
|
||||
self.indirection = 0
|
||||
@ -161,9 +161,9 @@ namespace %s {
|
||||
|
||||
if indirection == 1:
|
||||
if size == 1:
|
||||
expr = "context.data.byte(%s)" %expr
|
||||
expr = "context.ds.byte(%s)" %expr
|
||||
elif size == 2:
|
||||
expr = "context.data.word(%s)" %expr
|
||||
expr = "context.ds.word(%s)" %expr
|
||||
else:
|
||||
expr = "@invalid size 0"
|
||||
elif indirection == 0:
|
||||
@ -505,7 +505,7 @@ namespace %s {
|
||||
n += 1
|
||||
if (n & 0xf) == 0:
|
||||
data_impl += "\n\t\t"
|
||||
data_impl += "};\n\tcontext.data.assign(src, src + sizeof(src))"
|
||||
data_impl += "};\n\tcontext.ds.assign(src, src + sizeof(src))"
|
||||
hid = "TASMRECOVER_%s_STUBS_H__" %self.namespace.upper()
|
||||
self.hd.write("""#ifndef %s
|
||||
#define %s
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -114,12 +114,10 @@ class SegmentRef {
|
||||
Segment *_segment;
|
||||
|
||||
public:
|
||||
SegmentRef(Context *ctx): _context(ctx), _value(), _segment() {
|
||||
SegmentRef(Context *ctx, uint16 value = 0, Segment *segment = 0): _context(ctx), _value(value), _segment(segment) {
|
||||
}
|
||||
|
||||
inline void reset(uint16 value) {
|
||||
|
||||
}
|
||||
inline void reset(uint16 value);
|
||||
|
||||
inline SegmentRef& operator=(const uint16 id) {
|
||||
return *this;
|
||||
@ -143,6 +141,11 @@ public:
|
||||
assert(_segment != 0);
|
||||
return _segment->word(index);
|
||||
}
|
||||
|
||||
inline void assign(const uint8 *b, const uint8 *e) {
|
||||
assert(_segment != 0);
|
||||
_segment->assign(b, e);
|
||||
}
|
||||
};
|
||||
|
||||
struct Flags {
|
||||
@ -174,9 +177,12 @@ struct Flags {
|
||||
};
|
||||
|
||||
class Context {
|
||||
Common::HashMap<uint16, Segment> _segments;
|
||||
typedef Common::HashMap<uint16, Segment> SegmentMap;
|
||||
SegmentMap _segments;
|
||||
|
||||
public:
|
||||
enum { kDefaultDataSegment };
|
||||
|
||||
Register ax, dx, bx, cx, si, di;
|
||||
RegisterPart<kLowPartOfRegister> al;
|
||||
RegisterPart<kHighPartOfRegister> ah;
|
||||
@ -191,9 +197,18 @@ public:
|
||||
Flags flags;
|
||||
|
||||
inline Context(): al(ax), ah(ax), bl(bx), bh(bx), cl(cx), ch(cx), dl(dx), dh(dx), cs(this), ds(this), es(this) {
|
||||
|
||||
_segments[kDefaultDataSegment] = Segment();
|
||||
cs.reset(1);
|
||||
ds.reset(1);
|
||||
es.reset(1);
|
||||
}
|
||||
|
||||
|
||||
SegmentRef getSegment(uint16 value) {
|
||||
SegmentMap::iterator i = _segments.find(value);
|
||||
assert(i != _segments.end());
|
||||
return SegmentRef(this, value, &i->_value);
|
||||
}
|
||||
|
||||
inline void _cmp(uint8 a, uint8 b) {
|
||||
uint8 x = a;
|
||||
_sub(x, b);
|
||||
@ -342,10 +357,12 @@ public:
|
||||
stack.pop_back();
|
||||
return v;
|
||||
}
|
||||
|
||||
Segment data;
|
||||
};
|
||||
|
||||
inline void SegmentRef::reset(uint16 value) {
|
||||
*this = _context->getSegment(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user