diff options
author | Willem Jan Palenstijn | 2009-09-27 11:14:01 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2009-09-27 11:14:01 +0000 |
commit | 56e2e32268859e98263097e669abe2ab104774e9 (patch) | |
tree | f2de0dd99e60f761d35e3de9f9b18cb3faf87418 | |
parent | 0f564aad8138366d7606875b623e573cbb6141d4 (diff) | |
download | scummvm-rg350-56e2e32268859e98263097e669abe2ab104774e9.tar.gz scummvm-rg350-56e2e32268859e98263097e669abe2ab104774e9.tar.bz2 scummvm-rg350-56e2e32268859e98263097e669abe2ab104774e9.zip |
SCI: clean up kStrAt
svn-id: r44394
-rw-r--r-- | engines/sci/engine/kstring.cpp | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp index 84ac720a05..961b28485f 100644 --- a/engines/sci/engine/kstring.cpp +++ b/engines/sci/engine/kstring.cpp @@ -305,24 +305,34 @@ reg_t kStrAt(EngineState *s, int, int argc, reg_t *argv) { return NULL_REG; } - byte* dest; + byte value; + byte newvalue = 0; + unsigned int offset = argv[1].toUint16(); + if (argc > 2) + newvalue = argv[2].toSint16(); if (dest_r.isRaw) { - dest = (byte*)dest_r.raw + argv[1].toUint16(); + value = dest_r.raw[offset]; + if (argc > 2) /* Request to modify this char */ + dest_r.raw[offset] = newvalue; } else { -#ifndef SCUMM_BIG_ENDIAN - int odd = argv[1].toUint16() & 1; -#else - int odd = !(argv[1].toUint16() & 1); -#endif - reg_t *tmp = dest_r.reg + (argv[1].toUint16() / 2); - dest = ((byte *)(&tmp->offset)) + odd; + reg_t &tmp = dest_r.reg[offset / 2]; + if (!(offset & 1)) { + value = tmp.offset & 0x00ff; + if (argc > 2) { /* Request to modify this char */ + tmp.offset &= 0xff00; + tmp.offset |= newvalue; + } + } else { + value = tmp.offset >> 8; + if (argc > 2) { /* Request to modify this char */ + tmp.offset &= 0x00ff; + tmp.offset |= newvalue << 8; + } + } } - s->r_acc = make_reg(0, *dest); - - if (argc > 2) - *dest = argv[2].toSint16(); /* Request to modify this char */ + s->r_acc = make_reg(0, value); return s->r_acc; } |