diff options
author | Vladimir Menshakov | 2011-06-10 01:30:07 +0400 |
---|---|---|
committer | Alyssa Milburn | 2011-06-15 17:33:51 +0200 |
commit | 07ad2efd80075c50be51d9120a5a93f6cf69cef7 (patch) | |
tree | bf88f273f852522bb4940cdf463bcfae53880882 | |
parent | 9717b220f10186d816c4a897157c4810ae615490 (diff) | |
download | scummvm-rg350-07ad2efd80075c50be51d9120a5a93f6cf69cef7.tar.gz scummvm-rg350-07ad2efd80075c50be51d9120a5a93f6cf69cef7.tar.bz2 scummvm-rg350-07ad2efd80075c50be51d9120a5a93f6cf69cef7.zip |
DREAMWEB: fixed invalid register parts update
-rw-r--r-- | engines/dreamweb/runtime.h | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/engines/dreamweb/runtime.h b/engines/dreamweb/runtime.h index 1def57a50d..45882a266d 100644 --- a/engines/dreamweb/runtime.h +++ b/engines/dreamweb/runtime.h @@ -13,7 +13,10 @@ namespace dreamgen { #undef random struct Register { - uint16 _value; + union { + uint16 _value; + uint8 _part[2]; + }; inline Register(): _value() {} inline Register& operator=(uint16 v) { _value = v; return *this; } inline operator uint16&() { return _value; } @@ -21,35 +24,38 @@ struct Register { if (_value & 0x80) _value |= 0xff00; else - _value &= 0xff; + _value &= 0x7f; } }; -template<int Mask, int Shift> +template<int kIndex> //from low to high struct RegisterPart { - Register &_reg; - uint8 _value; + uint8 &_value; - explicit inline RegisterPart(Register ®) : _reg(reg), _value(reg._value >> Shift) {} + explicit inline RegisterPart(Register ®) : _value(reg._part[kIndex]) {} inline operator uint8&() { return _value; } + inline RegisterPart& operator=(const RegisterPart& o) { _value = o._value; return *this; } + inline RegisterPart& operator=(uint8 v) { _value = v; return *this; } - inline ~RegisterPart() { - _reg._value = (_reg._value & ~Mask) | (_value << Shift); - } }; -typedef RegisterPart<0xff, 0> LowPartOfRegister; -typedef RegisterPart<0xff00, 8> HighPartOfRegister; +#ifdef SCUMM_LITTLE_ENDIAN + typedef RegisterPart<0> LowPartOfRegister; + typedef RegisterPart<1> HighPartOfRegister; +#else + typedef RegisterPart<1> LowPartOfRegister; + typedef RegisterPart<0> HighPartOfRegister; +#endif class WordRef { uint8 *_data; |